mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Cleanup code_samples JavaDocs
This commit is contained in:
parent
09c3ed4620
commit
5942892ddb
@ -14,8 +14,8 @@ import icons.SdkIcons;
|
|||||||
public class CustomDefaultActionGroup extends DefaultActionGroup {
|
public class CustomDefaultActionGroup extends DefaultActionGroup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given CustomDefaultActionGroup is derived from ActionGroup, in this context
|
* Given {@link CustomDefaultActionGroup} is derived from {@link com.intellij.openapi.actionSystem.ActionGroup},
|
||||||
* update() determines whether the action group itself should be enabled or disabled.
|
* in this context {@code update()} determines whether the action group itself should be enabled or disabled.
|
||||||
* Requires an editor to be active in order to enable the group functionality.
|
* Requires an editor to be active in order to enable the group functionality.
|
||||||
*
|
*
|
||||||
* @param event Event received when the associated group-id menu is chosen.
|
* @param event Event received when the associated group-id menu is chosen.
|
||||||
|
@ -9,11 +9,10 @@ import icons.SdkIcons;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Demonstrates adding an action group to a menu statically in plugin.xml, and then creating a menu item
|
* Demonstrates adding an action group to a menu statically in plugin.xml, and then creating a menu item within
|
||||||
* within the group at runtime. See plugin.xml for the declaration of DynamicActionGroup,
|
* the group at runtime. See plugin.xml for the declaration of {@link DynamicActionGroup}, and note the group
|
||||||
* and note the group declaration does not contain an action.
|
* declaration does not contain an action. {@link DynamicActionGroup} is based on {@link ActionGroup} because menu
|
||||||
* DynamicActionGroup is based on ActionGroup because menu children are determined
|
* children are determined on rules other than just positional constraints.
|
||||||
* on rules other than just positional constraints.
|
|
||||||
*
|
*
|
||||||
* @see ActionGroup
|
* @see ActionGroup
|
||||||
*/
|
*/
|
||||||
@ -23,8 +22,8 @@ public class DynamicActionGroup extends ActionGroup {
|
|||||||
* Returns an array of menu actions for the group.
|
* Returns an array of menu actions for the group.
|
||||||
*
|
*
|
||||||
* @param e Event received when the associated group-id menu is chosen.
|
* @param e Event received when the associated group-id menu is chosen.
|
||||||
* @return AnAction[] An instance of AnAction, in this case containing a single instance of the
|
* @return AnAction[] An instance of {@link AnAction}, in this case containing a single instance of the
|
||||||
* PopupDialogAction class.
|
* {@link PopupDialogAction} class.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,9 +22,8 @@ import javax.swing.*;
|
|||||||
public class PopupDialogAction extends AnAction {
|
public class PopupDialogAction extends AnAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This default constructor is used by the IntelliJ Platform framework to
|
* This default constructor is used by the IntelliJ Platform framework to instantiate this class based on plugin.xml
|
||||||
* instantiate this class based on plugin.xml declarations. Only needed in PopupDialogAction
|
* declarations. Only needed in {@link PopupDialogAction} class because a second constructor is overridden.
|
||||||
* class because a second constructor is overridden.
|
|
||||||
*
|
*
|
||||||
* @see AnAction#AnAction()
|
* @see AnAction#AnAction()
|
||||||
*/
|
*/
|
||||||
@ -48,7 +47,7 @@ public class PopupDialogAction extends AnAction {
|
|||||||
/**
|
/**
|
||||||
* Gives the user feedback when the dynamic action menu is chosen.
|
* Gives the user feedback when the dynamic action menu is chosen.
|
||||||
* Pops a simple message dialog. See the psi_demo plugin for an
|
* Pops a simple message dialog. See the psi_demo plugin for an
|
||||||
* example of how to use AnActionEvent to access data.
|
* example of how to use {@link AnActionEvent} to access data.
|
||||||
*
|
*
|
||||||
* @param event Event received when the associated menu item is chosen.
|
* @param event Event received when the associated menu item is chosen.
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,7 @@ import java.util.StringTokenizer;
|
|||||||
import static com.siyeh.ig.psiutils.ExpressionUtils.isNullLiteral;
|
import static com.siyeh.ig.psiutils.ExpressionUtils.isNullLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements an inspection to detect when object references are compared using 'a==b' or 'a!=b'
|
* Implements an inspection to detect when object references are compared using 'a==b' or 'a!=b'.
|
||||||
* The quick fix converts these comparisons to 'a.equals(b) or '!a.equals(b)' respectively.
|
* The quick fix converts these comparisons to 'a.equals(b) or '!a.equals(b)' respectively.
|
||||||
*/
|
*/
|
||||||
public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspectionTool {
|
public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||||
@ -38,8 +38,7 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
/**
|
/**
|
||||||
* This method is called to get the panel describing the inspection.
|
* This method is called to get the panel describing the inspection.
|
||||||
* It is called every time the user selects the inspection in preferences.
|
* It is called every time the user selects the inspection in preferences.
|
||||||
* The user has the option to edit the list of CHECKED_CLASSES.
|
* The user has the option to edit the list of {@link #CHECKED_CLASSES}.
|
||||||
* Adds a document listener to see if
|
|
||||||
*
|
*
|
||||||
* @return panel to display inspection information.
|
* @return panel to display inspection information.
|
||||||
*/
|
*/
|
||||||
@ -57,8 +56,8 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is overridden to provide a custom visitor
|
* This method is overridden to provide a custom visitor.
|
||||||
* that inspects expressions with relational operators '==' and '!='
|
* that inspects expressions with relational operators '==' and '!='.
|
||||||
* The visitor must not be recursive and must be thread-safe.
|
* The visitor must not be recursive and must be thread-safe.
|
||||||
*
|
*
|
||||||
* @param holder object for visitor to register problems found.
|
* @param holder object for visitor to register problems found.
|
||||||
@ -72,8 +71,8 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
return new JavaElementVisitor() {
|
return new JavaElementVisitor() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This string defines the short message shown to a user signaling the inspection
|
* This string defines the short message shown to a user signaling the inspection found a problem.
|
||||||
* found a problem. It reuses a string from the inspections bundle.
|
* It reuses a string from the inspections bundle.
|
||||||
*/
|
*/
|
||||||
@NonNls
|
@NonNls
|
||||||
private final String DESCRIPTION_TEMPLATE = "SDK " +
|
private final String DESCRIPTION_TEMPLATE = "SDK " +
|
||||||
@ -89,12 +88,9 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluate binary psi expressions to see if they contain
|
* Evaluate binary psi expressions to see if they contain relational operators '==' and '!=', AND they contain
|
||||||
* relational operators '==' and '!=', AND they contain
|
* classes contained in CHECKED_CLASSES. The evaluation ignores expressions comparing an object to null.
|
||||||
* classes contained in CHECKED_CLASSES. The evaluation
|
* IF this criteria is met, add the expression to the problems list.
|
||||||
* ignores expressions comparing an object to null.
|
|
||||||
* IF this criteria is met, add the expression to the
|
|
||||||
* problems list.
|
|
||||||
*
|
*
|
||||||
* @param expression The binary expression to be evaluated.
|
* @param expression The binary expression to be evaluated.
|
||||||
*/
|
*/
|
||||||
@ -124,8 +120,8 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
* Verifies the input is the correct {@code PsiType} for this inspection.
|
* Verifies the input is the correct {@code PsiType} for this inspection.
|
||||||
*
|
*
|
||||||
* @param type The {@code PsiType} to be examined for a match
|
* @param type The {@code PsiType} to be examined for a match
|
||||||
* @return {@code true} if input is {@code PsiClassType} and matches
|
* @return {@code true} if input is {@code PsiClassType} and matches one of the classes
|
||||||
* one of the classes in the CHECKED_CLASSES list.
|
* in the {@link ComparingReferencesInspection#CHECKED_CLASSES} list.
|
||||||
*/
|
*/
|
||||||
private boolean isCheckedType(PsiType type) {
|
private boolean isCheckedType(PsiType type) {
|
||||||
if (!(type instanceof PsiClassType)) {
|
if (!(type instanceof PsiClassType)) {
|
||||||
@ -145,8 +141,8 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a solution to inspection problem expressions by manipulating
|
* This class provides a solution to inspection problem expressions by manipulating the PSI tree to use 'a.equals(b)'
|
||||||
* the PSI tree to use a.equals(b) instead of '==' or '!='
|
* instead of '==' or '!='.
|
||||||
*/
|
*/
|
||||||
private static class CriQuickFix implements LocalQuickFix {
|
private static class CriQuickFix implements LocalQuickFix {
|
||||||
|
|
||||||
@ -163,8 +159,7 @@ public class ComparingReferencesInspection extends AbstractBaseJavaLocalInspecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method manipulates the PSI tree to replace 'a==b' with 'a.equals(b)
|
* This method manipulates the PSI tree to replace 'a==b' with 'a.equals(b)' or 'a!=b' with '!a.equals(b)'.
|
||||||
* or 'a!=b' with '!a.equals(b)'
|
|
||||||
*
|
*
|
||||||
* @param project The project that contains the file being edited.
|
* @param project The project that contains the file being edited.
|
||||||
* @param descriptor A problem found by this inspection.
|
* @param descriptor A problem found by this inspection.
|
||||||
|
@ -11,13 +11,13 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for testing ComparingReferencesInspection.
|
* Class for testing ComparingReferencesInspection.
|
||||||
* Requires idea.home.path to be set in build.gradle
|
* Requires {@code idea.home.path} to be set in build.gradle.
|
||||||
* doTest() does the work for individual test cases.
|
* doTest() does the work for individual test cases.
|
||||||
*/
|
*/
|
||||||
public class ComparingReferencesInspectionTest extends LightJavaCodeInsightFixtureTestCase {
|
public class ComparingReferencesInspectionTest extends LightJavaCodeInsightFixtureTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines path to files used for running tests
|
* Defines path to files used for running tests.
|
||||||
*
|
*
|
||||||
* @return The path from this module's root directory ($MODULE_WORKING_DIR$) to the
|
* @return The path from this module's root directory ($MODULE_WORKING_DIR$) to the
|
||||||
* directory containing files for these tests.
|
* directory containing files for these tests.
|
||||||
@ -50,14 +50,14 @@ public class ComparingReferencesInspectionTest extends LightJavaCodeInsightFixtu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the "==" case
|
* Test the '==' case.
|
||||||
*/
|
*/
|
||||||
public void testRelationalEq() {
|
public void testRelationalEq() {
|
||||||
doTest("Eq");
|
doTest("Eq");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the "!=" case
|
* Test the '!=' case.
|
||||||
*/
|
*/
|
||||||
public void testRelationalNeq() {
|
public void testRelationalNeq() {
|
||||||
doTest("Neq");
|
doTest("Neq");
|
||||||
|
@ -15,14 +15,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements an intention action to replace a ternary statement with if-then-else
|
* Implements an intention action to replace a ternary statement with if-then-else.
|
||||||
*/
|
*/
|
||||||
@NonNls
|
@NonNls
|
||||||
public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction implements IntentionAction {
|
public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction implements IntentionAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this action is applicable, returns the text to be shown in the list of
|
* If this action is applicable, returns the text to be shown in the list of intention actions available.
|
||||||
* intention actions available.
|
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getText() {
|
public String getText() {
|
||||||
@ -30,8 +29,8 @@ public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns text for name of this family of intentions. It is used to externalize
|
* Returns text for name of this family of intentions.
|
||||||
* "auto-show" state of intentions.
|
* It is used to externalize "auto-show" state of intentions.
|
||||||
* It is also the directory name for the descriptions.
|
* It is also the directory name for the descriptions.
|
||||||
*
|
*
|
||||||
* @return the intention family name.
|
* @return the intention family name.
|
||||||
@ -42,20 +41,17 @@ public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this intention is available at the caret offset in file - the caret
|
* Checks whether this intention is available at the caret offset in file - the caret must sit just before a "?"
|
||||||
* must sit just before a "?" character in a ternary statement. If this condition is met,
|
* character in a ternary statement. If this condition is met, this intention's entry is shown in the available
|
||||||
* this intention's entry is shown in the available intentions list.
|
* intentions list.
|
||||||
* <p>
|
*
|
||||||
* Note: this method must do its checks quickly and return.
|
* <p>Note: this method must do its checks quickly and return.</p>
|
||||||
*
|
*
|
||||||
* @param project a reference to the Project object being edited.
|
* @param project a reference to the Project object being edited.
|
||||||
* @param editor a reference to the object editing the project source
|
* @param editor a reference to the object editing the project source
|
||||||
* @param element a reference to the PSI element currently under the caret
|
* @param element a reference to the PSI element currently under the caret
|
||||||
* @return <ul>
|
* @return {@code true} if the caret is in a literal string element, so this functionality should be added to the
|
||||||
* <li> true if the caret is in a literal string element, so this functionality
|
* intention menu or {@code false} for all other types of caret positions
|
||||||
* should be added to the intention menu.</li>
|
|
||||||
* <li> false for all other types of caret positions</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public boolean isAvailable(@NotNull Project project, Editor editor, @Nullable PsiElement element) {
|
public boolean isAvailable(@NotNull Project project, Editor editor, @Nullable PsiElement element) {
|
||||||
// Quick sanity check
|
// Quick sanity check
|
||||||
@ -82,9 +78,8 @@ public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the Psi to change a ternary expression to an if-then-else statement.
|
* Modifies the Psi to change a ternary expression to an if-then-else statement.
|
||||||
* If the ternary is part of a declaration, the declaration is separated and
|
* If the ternary is part of a declaration, the declaration is separated and moved above the if-then-else statement.
|
||||||
* moved above the if-then-else statement. Called when user selects this intention action
|
* Called when user selects this intention action from the available intentions list.
|
||||||
* from the available intentions list.
|
|
||||||
*
|
*
|
||||||
* @param project a reference to the Project object being edited.
|
* @param project a reference to the Project object being edited.
|
||||||
* @param editor a reference to the object editing the project source
|
* @param editor a reference to the object editing the project source
|
||||||
@ -195,13 +190,10 @@ public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates this intention action expects the Psi framework to provide the write action
|
* Indicates this intention action expects the Psi framework to provide the write action context for any changes.
|
||||||
* context for any changes.
|
|
||||||
*
|
*
|
||||||
* @return <ul>
|
* @return {@code true} if the intention requires a write action context to be provided or {@code false} if this
|
||||||
* <li> true if the intention requires a write action context to be provided</li>
|
* intention action will start a write action
|
||||||
* <li> false if this intention action will start a write action</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public boolean startInWriteAction() {
|
public boolean startInWriteAction() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,9 +8,9 @@ import org.junit.Assert;
|
|||||||
public class ConditionalOperatorConverterTest extends LightJavaCodeInsightFixtureTestCase {
|
public class ConditionalOperatorConverterTest extends LightJavaCodeInsightFixtureTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines path to files used for running tests
|
* Defines path to files used for running tests.
|
||||||
*
|
*
|
||||||
* @return The path from this module's root directory ($MODULE_WORKING_DIR$) to the
|
* @return The path from this module's root directory ({@code $MODULE_WORKING_DIR$}) to the
|
||||||
* directory containing files for these tests.
|
* directory containing files for these tests.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,10 +11,9 @@ import com.intellij.openapi.ui.Messages;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If conditions support it, makes a menu visible to display information
|
* If conditions support it, makes a menu visible to display information about the caret.
|
||||||
* about the caret.
|
|
||||||
*
|
*
|
||||||
* @see com.intellij.openapi.actionSystem.AnAction
|
* @see AnAction
|
||||||
*/
|
*/
|
||||||
public class EditorAreaIllustration extends AnAction {
|
public class EditorAreaIllustration extends AnAction {
|
||||||
|
|
||||||
@ -42,8 +41,10 @@ public class EditorAreaIllustration extends AnAction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets visibility and enables this action menu item if:
|
* Sets visibility and enables this action menu item if:
|
||||||
* A project is open,
|
* <ul>
|
||||||
* An editor is active,
|
* <li>a project is open</li>
|
||||||
|
* <li>an editor is active</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param e Event related to this action
|
* @param e Event related to this action
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* Menu action to clone a new caret based on an existing one.
|
* Menu action to clone a new caret based on an existing one.
|
||||||
*
|
*
|
||||||
* @see com.intellij.openapi.actionSystem.AnAction
|
* @see AnAction
|
||||||
*/
|
*/
|
||||||
public class EditorHandlerIllustration extends AnAction {
|
public class EditorHandlerIllustration extends AnAction {
|
||||||
|
|
||||||
@ -39,9 +39,11 @@ public class EditorHandlerIllustration extends AnAction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables and sets visibility of this action menu item if:
|
* Enables and sets visibility of this action menu item if:
|
||||||
* A project is open,
|
* <ul>
|
||||||
* An editor is active,
|
* <li>a project is open</li>
|
||||||
* At least one caret exists
|
* <li>an editor is active</li>
|
||||||
|
* <li>at least one caret exists</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param e Event related to this action
|
* @param e Event related to this action
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* Menu action to replace a selection of characters with a fixed string.
|
* Menu action to replace a selection of characters with a fixed string.
|
||||||
*
|
*
|
||||||
* @see com.intellij.openapi.actionSystem.AnAction
|
* @see AnAction
|
||||||
*/
|
*/
|
||||||
public class EditorIllustrationAction extends AnAction {
|
public class EditorIllustrationAction extends AnAction {
|
||||||
|
|
||||||
@ -46,9 +46,11 @@ public class EditorIllustrationAction extends AnAction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets visibility and enables this action menu item if:
|
* Sets visibility and enables this action menu item if:
|
||||||
* A project is open,
|
* <ul>
|
||||||
* An editor is active,
|
* <li>a project is open</li>
|
||||||
* Some characters are selected
|
* <li>an editor is active</li>
|
||||||
|
* <li>some characters are selected</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param e Event related to this action
|
* @param e Event related to this action
|
||||||
*/
|
*/
|
||||||
|
@ -11,8 +11,7 @@ import com.intellij.psi.PsiFile;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a custom TypedHandlerDelegate that handles actions activated
|
* This is a custom {@link TypedHandlerDelegate} that handles actions activated keystrokes in the editor.
|
||||||
* keystrokes in the editor.
|
|
||||||
* The execute method inserts a fixed string at Offset 0 of the document.
|
* The execute method inserts a fixed string at Offset 0 of the document.
|
||||||
* Document changes are made in the context of a write action.
|
* Document changes are made in the context of a write action.
|
||||||
*/
|
*/
|
||||||
|
@ -34,8 +34,7 @@ public class DemoFacetConfiguration implements FacetConfiguration, PersistentSta
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the IntelliJ Platform when this facet's state is loaded.
|
* Called by the IntelliJ Platform when this facet's state is loaded.
|
||||||
* The method can and will be called several times, if
|
* The method can and will be called several times, if config files were externally changed while IDEA running.
|
||||||
* config files were externally changed while IDEA running.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadState(@NotNull DemoFacetState state) {
|
public void loadState(@NotNull DemoFacetState state) {
|
||||||
@ -47,7 +46,7 @@ public class DemoFacetConfiguration implements FacetConfiguration, PersistentSta
|
|||||||
*
|
*
|
||||||
* @param context The context in which a facet is being added/deleted, or modified.
|
* @param context The context in which a facet is being added/deleted, or modified.
|
||||||
* @param manager The manager which can be used to access custom validators.
|
* @param manager The manager which can be used to access custom validators.
|
||||||
* @return Array of DemoFacetEditorTabs. In this case size is always 1.
|
* @return Array of {@link DemoFacetEditorTab}. In this case size is always 1.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FacetEditorTab[] createEditorTabs(FacetEditorContext context, FacetValidatorsManager manager) {
|
public FacetEditorTab[] createEditorTabs(FacetEditorContext context, FacetValidatorsManager manager) {
|
||||||
|
@ -24,13 +24,11 @@ public class DemoFacetEditorTab extends FacetEditorTab {
|
|||||||
private final JTextField myPath;
|
private final JTextField myPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only org.intellij.sdk.facet.DemoFacetState is captured so it can be updated per user changes
|
* Only org.intellij.sdk.facet.DemoFacetState is captured so it can be updated per user changes in the EditorTab.
|
||||||
* in the EditorTab.
|
|
||||||
*
|
*
|
||||||
* @param state org.intellij.sdk.facet.DemoFacetState object persisting org.intellij.sdk.facet.DemoFacet state.
|
* @param state {@link DemoFacetState} object persisting {@link DemoFacet} state.
|
||||||
* @param context Facet editor context, can be used to get e.g. the current project module.
|
* @param context Facet editor context, can be used to get e.g. the current project module.
|
||||||
* @param validator Facet validator manager, can be used to get and apply a custom validator for
|
* @param validator Facet validator manager, can be used to get and apply a custom validator for this facet.
|
||||||
* this facet.
|
|
||||||
*/
|
*/
|
||||||
public DemoFacetEditorTab(@NotNull DemoFacetState state, @NotNull FacetEditorContext context,
|
public DemoFacetEditorTab(@NotNull DemoFacetState state, @NotNull FacetEditorContext context,
|
||||||
@NotNull FacetValidatorsManager validator) {
|
@NotNull FacetValidatorsManager validator) {
|
||||||
@ -39,9 +37,9 @@ public class DemoFacetEditorTab extends FacetEditorTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the JPanel displayed in the Preferences | Facet UI
|
* Provides the {@link JPanel} displayed in the Preferences | Facet UI
|
||||||
*
|
*
|
||||||
* @return JPanel to be displayed in the org.intellij.sdk.facet.DemoFacetEditorTab.
|
* @return {@link JPanel} to be displayed in the {@link DemoFacetEditorTab}.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@ -54,7 +52,6 @@ public class DemoFacetEditorTab extends FacetEditorTab {
|
|||||||
return facetPanel;
|
return facetPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name of this facet for display in this editor tab.
|
* @return the name of this facet for display in this editor tab.
|
||||||
*/
|
*/
|
||||||
@ -65,12 +62,10 @@ public class DemoFacetEditorTab extends FacetEditorTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the facet state entered in the UI differs
|
* Determines if the facet state entered in the UI differs from the currently stored state.
|
||||||
* from the currently stored state.
|
* Called when user changes text in {@link #myPath}.
|
||||||
* Called when user changes text in myPath.
|
|
||||||
*
|
*
|
||||||
* @return {@code true} if the state returned from the panel's UI
|
* @return {@code true} if the state returned from the panel's UI differs from the stored facet state.
|
||||||
* differs from the stored facet state.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
@ -80,6 +75,7 @@ public class DemoFacetEditorTab extends FacetEditorTab {
|
|||||||
/**
|
/**
|
||||||
* Stores new facet state (text) entered by the user.
|
* Stores new facet state (text) entered by the user.
|
||||||
* Called when {@link #isModified()} returns true.
|
* Called when {@link #isModified()} returns true.
|
||||||
|
*
|
||||||
* @throws ConfigurationException if anything generates an exception.
|
* @throws ConfigurationException if anything generates an exception.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -94,7 +90,7 @@ public class DemoFacetEditorTab extends FacetEditorTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies current org.intellij.sdk.facet.DemoFacetState into the myPath UI element.
|
* Copies current {@link DemoFacetState} into the {@link #myPath} UI element.
|
||||||
* This method is called each time this editor tab is needed for display.
|
* This method is called each time this editor tab is needed for display.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,5 +27,4 @@ public class DemoFacetState {
|
|||||||
myPathToSdk = newPath;
|
myPathToSdk = newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the type, id, and name of the {@link DemoFacet}. Provides creation of DemoFacet
|
* Defines the type, id, and name of the {@link DemoFacet}.
|
||||||
* and associated Configuration.
|
* Provides creation of {@link DemoFacet} and associated Configuration.
|
||||||
* Allows application of this facet to all ModuleTypes.
|
* Allows application of this facet to all {@link ModuleType} instances.
|
||||||
*/
|
*/
|
||||||
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
|
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class DemoCodeInspection extends LocalInspectionTool {
|
public class DemoCodeInspection extends LocalInspectionTool {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is overridden to provide a custom visitor
|
* This method is overridden to provide a custom visitor.
|
||||||
* The visitor must not be recursive and must be thread-safe.
|
* The visitor must not be recursive and must be thread-safe.
|
||||||
*
|
*
|
||||||
* @param holder object for visitor to register problems found.
|
* @param holder object for visitor to register problems found.
|
||||||
* @param isOnTheFly true if inspection was run in non-batch mode
|
* @param isOnTheFly true if inspection was run in non-batch mode
|
||||||
* @return DemoInspectionVisitor.
|
* @return {@link DemoInspectionVisitor} instance
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,14 +3,18 @@
|
|||||||
package org.intellij.sdk.maxOpenProjects;
|
package org.intellij.sdk.maxOpenProjects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application service implementation to keep a running count of
|
* Application service implementation to keep a running count of how many projects are open at a given time.
|
||||||
* how many projects are open at a given time.
|
|
||||||
*/
|
*/
|
||||||
public class ProjectCountingService {
|
public class ProjectCountingService {
|
||||||
|
|
||||||
// Sets the maximum allowed number of opened projects.
|
/**
|
||||||
|
* Sets the maximum allowed number of opened projects.
|
||||||
|
*/
|
||||||
private final static int MAX_OPEN_PRJ_LIMIT = 3;
|
private final static int MAX_OPEN_PRJ_LIMIT = 3;
|
||||||
// The count of open projects must always be >= 0
|
|
||||||
|
/**
|
||||||
|
* The count of open projects must always be >= 0.
|
||||||
|
*/
|
||||||
private int myOpenProjectCount = 0;
|
private int myOpenProjectCount = 0;
|
||||||
|
|
||||||
public void incrProjectCount() {
|
public void incrProjectCount() {
|
||||||
|
@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener to detect project open and close.
|
* Listener to detect project open and close.
|
||||||
* Depends on org.intellij.sdk.maxOpenProjects.ProjectCountingService
|
* Depends on {@link ProjectCountingService}
|
||||||
*/
|
*/
|
||||||
public class ProjectOpenCloseListener implements ProjectManagerListener {
|
public class ProjectOpenCloseListener implements ProjectManagerListener {
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ public class PopupDialogAction extends AnAction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the user feedback when the dynamic action menu is chosen.
|
* Gives the user feedback when the dynamic action menu is chosen.
|
||||||
* Pops a simple message dialog. See the psi_demo plugin for an
|
* Pops a simple message dialog. See the psi_demo plugin for an example of how to use AnActionEvent to access data.
|
||||||
* example of how to use AnActionEvent to access data.
|
|
||||||
*
|
*
|
||||||
* @param event Event received when the associated menu item is chosen.
|
* @param event Event received when the associated menu item is chosen.
|
||||||
*/
|
*/
|
||||||
|
@ -120,7 +120,6 @@ public class ImagesProjectNode extends AbstractTreeNode<VirtualFile> {
|
|||||||
data.setPresentableText(getValue().getName());
|
data.setPresentableText(getValue().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canNavigate() {
|
public boolean canNavigate() {
|
||||||
return !getValue().isDirectory();
|
return !getValue().isDirectory();
|
||||||
|
@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class DemoConfigurationFactory extends ConfigurationFactory {
|
public class DemoConfigurationFactory extends ConfigurationFactory {
|
||||||
|
|
||||||
private static final String FACTORY_NAME = "Demo configuration factory";
|
private static final String FACTORY_NAME = "Demo configuration factory";
|
||||||
|
|
||||||
protected DemoConfigurationFactory(ConfigurationType type) {
|
protected DemoConfigurationFactory(ConfigurationType type) {
|
||||||
@ -32,4 +33,5 @@ public class DemoConfigurationFactory extends ConfigurationFactory {
|
|||||||
public Class<? extends BaseState> getOptionsClass() {
|
public Class<? extends BaseState> getOptionsClass() {
|
||||||
return DemoRunConfigurationOptions.class;
|
return DemoRunConfigurationOptions.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class DemoRunConfiguration extends RunConfigurationBase<DemoRunConfigurationOptions> {
|
public class DemoRunConfiguration extends RunConfigurationBase<DemoRunConfigurationOptions> {
|
||||||
|
|
||||||
protected DemoRunConfiguration(Project project, ConfigurationFactory factory, String name) {
|
protected DemoRunConfiguration(Project project, ConfigurationFactory factory, String name) {
|
||||||
super(project, factory, name);
|
super(project, factory, name);
|
||||||
}
|
}
|
||||||
@ -58,4 +59,5 @@ public class DemoRunConfiguration extends RunConfigurationBase<DemoRunConfigurat
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.intellij.execution.configurations.RunConfigurationOptions;
|
|||||||
import com.intellij.openapi.components.StoredProperty;
|
import com.intellij.openapi.components.StoredProperty;
|
||||||
|
|
||||||
public class DemoRunConfigurationOptions extends RunConfigurationOptions {
|
public class DemoRunConfigurationOptions extends RunConfigurationOptions {
|
||||||
|
|
||||||
private final StoredProperty<String> myScriptName = string("").provideDelegate(this, "scriptName");
|
private final StoredProperty<String> myScriptName = string("").provideDelegate(this, "scriptName");
|
||||||
|
|
||||||
public String getScriptName() {
|
public String getScriptName() {
|
||||||
@ -15,4 +16,5 @@ public class DemoRunConfigurationOptions extends RunConfigurationOptions {
|
|||||||
public void setScriptName(String scriptName) {
|
public void setScriptName(String scriptName) {
|
||||||
myScriptName.setValue(this, scriptName);
|
myScriptName.setValue(this, scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class DemoRunConfigurationType implements ConfigurationType {
|
public class DemoRunConfigurationType implements ConfigurationType {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
@ -36,4 +37,5 @@ public class DemoRunConfigurationType implements ConfigurationType {
|
|||||||
public ConfigurationFactory[] getConfigurationFactories() {
|
public ConfigurationFactory[] getConfigurationFactories() {
|
||||||
return new ConfigurationFactory[]{new DemoConfigurationFactory(this)};
|
return new ConfigurationFactory[]{new DemoConfigurationFactory(this)};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class DemoSettingsEditor extends SettingsEditor<DemoRunConfiguration> {
|
public class DemoSettingsEditor extends SettingsEditor<DemoRunConfiguration> {
|
||||||
|
|
||||||
private JPanel myPanel;
|
private JPanel myPanel;
|
||||||
private LabeledComponent<TextFieldWithBrowseButton> myScriptName;
|
private LabeledComponent<TextFieldWithBrowseButton> myScriptName;
|
||||||
|
|
||||||
@ -33,4 +34,5 @@ public class DemoSettingsEditor extends SettingsEditor<DemoRunConfiguration> {
|
|||||||
myScriptName = new LabeledComponent<>();
|
myScriptName = new LabeledComponent<>();
|
||||||
myScriptName.setComponent(new TextFieldWithBrowseButton());
|
myScriptName.setComponent(new TextFieldWithBrowseButton());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports creating and managing a JPanel for the Settings Dialog.
|
* Supports creating and managing a {@link JPanel} for the Settings Dialog.
|
||||||
*/
|
*/
|
||||||
public class AppSettingsComponent {
|
public class AppSettingsComponent {
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports storing the application settings in a persistent way.
|
* Supports storing the application settings in a persistent way.
|
||||||
* The State and Storage annotations define the name of the data and the file name where
|
* The {@link State} and {@link Storage} annotations define the name of the data and the file name where
|
||||||
* these persistent application settings are stored.
|
* these persistent application settings are stored.
|
||||||
*/
|
*/
|
||||||
@State(
|
@State(
|
||||||
|
@ -25,7 +25,6 @@ public class SimpleCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
|
|||||||
return "Simple";
|
return "Simple";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings settings, @NotNull CodeStyleSettings modelSettings) {
|
public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings settings, @NotNull CodeStyleSettings modelSettings) {
|
||||||
return new CodeStyleAbstractConfigurable(settings, modelSettings, this.getConfigurableDisplayName()) {
|
return new CodeStyleAbstractConfigurable(settings, modelSettings, this.getConfigurableDisplayName()) {
|
||||||
|
@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: This class is only used with the fileTypeFactory extension point
|
* Note: This class is only used with the fileTypeFactory extension point
|
||||||
* for versions of the IntelliJ Platform prior to v2019.2
|
* for versions of the IntelliJ Platform prior to v2019.2.
|
||||||
*/
|
*/
|
||||||
public class SimpleFileTypeFactory extends FileTypeFactory {
|
public class SimpleFileTypeFactory extends FileTypeFactory {
|
||||||
|
|
||||||
|
@ -18,7 +18,13 @@ import java.util.List;
|
|||||||
|
|
||||||
public class SimpleUtil {
|
public class SimpleUtil {
|
||||||
|
|
||||||
// Searches the entire project for Simple language files with instances of the Simple property with the given key
|
/**
|
||||||
|
* Searches the entire project for Simple language files with instances of the Simple property with the given key.
|
||||||
|
*
|
||||||
|
* @param project current project
|
||||||
|
* @param key to check
|
||||||
|
* @return matching properties
|
||||||
|
*/
|
||||||
public static List<SimpleProperty> findProperties(Project project, String key) {
|
public static List<SimpleProperty> findProperties(Project project, String key) {
|
||||||
List<SimpleProperty> result = new ArrayList<>();
|
List<SimpleProperty> result = new ArrayList<>();
|
||||||
Collection<VirtualFile> virtualFiles =
|
Collection<VirtualFile> virtualFiles =
|
||||||
|
@ -20,7 +20,6 @@ import java.util.List;
|
|||||||
public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
|
public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return path to test data file directory relative to working directory in the run configuration for this test.
|
* @return path to test data file directory relative to working directory in the run configuration for this test.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -84,4 +83,5 @@ public class SimpleCodeInsightTest extends LightJavaCodeInsightFixtureTestCase {
|
|||||||
PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
|
PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
|
||||||
assertEquals("https://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue());
|
assertEquals("https://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ package org.intellij.sdk.language;
|
|||||||
import com.intellij.testFramework.ParsingTestCase;
|
import com.intellij.testFramework.ParsingTestCase;
|
||||||
|
|
||||||
public class SimpleParsingTest extends ParsingTestCase {
|
public class SimpleParsingTest extends ParsingTestCase {
|
||||||
|
|
||||||
public SimpleParsingTest() {
|
public SimpleParsingTest() {
|
||||||
super("", "simple", new SimpleParserDefinition());
|
super("", "simple", new SimpleParserDefinition());
|
||||||
}
|
}
|
||||||
@ -14,7 +15,6 @@ public class SimpleParsingTest extends ParsingTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return path to test data file directory relative to root of this module.
|
* @return path to test data file directory relative to root of this module.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -31,4 +31,5 @@ public class SimpleParsingTest extends ParsingTestCase {
|
|||||||
protected boolean includeRanges() {
|
protected boolean includeRanges() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class MyToolWindowFactory implements ToolWindowFactory {
|
public class MyToolWindowFactory implements ToolWindowFactory {
|
||||||
|
|
||||||
// Create the tool window content.
|
/**
|
||||||
|
* Create the tool window content.
|
||||||
|
*
|
||||||
|
* @param project current project
|
||||||
|
* @param toolWindow current tool window
|
||||||
|
*/
|
||||||
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
|
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
|
||||||
MyToolWindow myToolWindow = new MyToolWindow(toolWindow);
|
MyToolWindow myToolWindow = new MyToolWindow(toolWindow);
|
||||||
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
|
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user