diff --git a/action_basics/build.gradle.kts b/action_basics/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/action_basics/build.gradle.kts +++ b/action_basics/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/action_basics/src/main/java/org/intellij/sdk/action/CustomDefaultActionGroup.java b/action_basics/src/main/java/org/intellij/sdk/action/CustomDefaultActionGroup.java index 68fb86ef6..126275e72 100644 --- a/action_basics/src/main/java/org/intellij/sdk/action/CustomDefaultActionGroup.java +++ b/action_basics/src/main/java/org/intellij/sdk/action/CustomDefaultActionGroup.java @@ -1,18 +1,25 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.action; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.editor.Editor; import icons.SdkIcons; +import org.jetbrains.annotations.NotNull; /** * Creates an action group to contain menu actions. See plugin.xml declarations. */ public class CustomDefaultActionGroup extends DefaultActionGroup { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + /** * Given {@link CustomDefaultActionGroup} is derived from {@link com.intellij.openapi.actionSystem.ActionGroup}, * in this context {@code update()} determines whether the action group itself should be enabled or disabled. diff --git a/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java b/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java index 173ff31d0..683809318 100644 --- a/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java +++ b/action_basics/src/main/java/org/intellij/sdk/action/PopupDialogAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.action; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -21,6 +22,11 @@ import javax.swing.*; */ public class PopupDialogAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + /** * This default constructor is used by the IntelliJ Platform framework to instantiate this class based on plugin.xml * declarations. Only needed in {@link PopupDialogAction} class because a second constructor is overridden. @@ -56,13 +62,13 @@ public class PopupDialogAction extends AnAction { // Using the event, create and show a dialog Project currentProject = event.getProject(); StringBuilder dlgMsg = new StringBuilder(event.getPresentation().getText() + " Selected!"); - String dlgTitle = event.getPresentation().getDescription(); + String dialogTitle = event.getPresentation().getDescription(); // If an element is selected in the editor, add info about it. - Navigatable nav = event.getData(CommonDataKeys.NAVIGATABLE); - if (nav != null) { - dlgMsg.append(String.format("\nSelected Element: %s", nav.toString())); + Navigatable navigatable = event.getData(CommonDataKeys.NAVIGATABLE); + if (navigatable != null) { + dlgMsg.append(String.format("\nSelected Element: %s", navigatable)); } - Messages.showMessageDialog(currentProject, dlgMsg.toString(), dlgTitle, Messages.getInformationIcon()); + Messages.showMessageDialog(currentProject, dlgMsg.toString(), dialogTitle, Messages.getInformationIcon()); } /** diff --git a/comparing_string_references_inspection/build.gradle.kts b/comparing_string_references_inspection/build.gradle.kts index 0e741e83a..32c66f008 100644 --- a/comparing_string_references_inspection/build.gradle.kts +++ b/comparing_string_references_inspection/build.gradle.kts @@ -22,7 +22,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") plugins.set(listOf("com.intellij.java")) } @@ -33,7 +33,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/comparing_string_references_inspection/src/main/java/org/intellij/sdk/codeInspection/ComparingStringReferencesInspection.java b/comparing_string_references_inspection/src/main/java/org/intellij/sdk/codeInspection/ComparingStringReferencesInspection.java index 3edddf62f..ca6b88439 100644 --- a/comparing_string_references_inspection/src/main/java/org/intellij/sdk/codeInspection/ComparingStringReferencesInspection.java +++ b/comparing_string_references_inspection/src/main/java/org/intellij/sdk/codeInspection/ComparingStringReferencesInspection.java @@ -9,6 +9,7 @@ import com.intellij.codeInspection.ProblemsHolder; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.PsiTypesUtil; import org.jetbrains.annotations.NotNull; /** @@ -35,7 +36,7 @@ public class ComparingStringReferencesInspection extends AbstractBaseJavaLocalIn return new JavaElementVisitor() { /** - * Evaluate binary psi expressions to see if they contain relational operators '==' and '!=', + * Evaluate binary PSI expressions to see if they contain relational operators '==' and '!=', * AND they are of String type. * The evaluation ignores expressions comparing an object to null. * IF these criteria are met, register the problem in the ProblemsHolder. @@ -43,7 +44,7 @@ public class ComparingStringReferencesInspection extends AbstractBaseJavaLocalIn * @param expression The binary expression to be evaluated. */ @Override - public void visitBinaryExpression(PsiBinaryExpression expression) { + public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) { super.visitBinaryExpression(expression); IElementType opSign = expression.getOperationTokenType(); if (opSign == JavaTokenType.EQEQ || opSign == JavaTokenType.NE) { @@ -64,15 +65,12 @@ public class ComparingStringReferencesInspection extends AbstractBaseJavaLocalIn } private boolean isStringType(PsiExpression operand) { - PsiType type = operand.getType(); - if (!(type instanceof PsiClassType)) { + PsiClass psiClass = PsiTypesUtil.getPsiClass(operand.getType()); + if (psiClass == null) { return false; } - PsiClass resolvedType = ((PsiClassType) type).resolve(); - if (resolvedType == null) { - return false; - } - return "java.lang.String".equals(resolvedType.getQualifiedName()); + + return "java.lang.String".equals(psiClass.getQualifiedName()); } private static boolean isNullLiteral(PsiExpression expression) { @@ -119,14 +117,18 @@ public class ComparingStringReferencesInspection extends AbstractBaseJavaLocalIn PsiMethodCallExpression equalsCall = (PsiMethodCallExpression) factory.createExpressionFromText("a.equals(b)", null); - equalsCall.getMethodExpression().getQualifierExpression().replace(lExpr); + PsiExpression qualifierExpression = equalsCall.getMethodExpression().getQualifierExpression(); + assert qualifierExpression != null; + qualifierExpression.replace(lExpr); equalsCall.getArgumentList().getExpressions()[0].replace(rExpr); PsiExpression result = (PsiExpression) binaryExpression.replace(equalsCall); if (opSign == JavaTokenType.NE) { PsiPrefixExpression negation = (PsiPrefixExpression) factory.createExpressionFromText("!a", null); - negation.getOperand().replace(result); + PsiExpression operand = negation.getOperand(); + assert operand != null; + operand.replace(result); result.replace(negation); } } diff --git a/conditional_operator_intention/build.gradle.kts b/conditional_operator_intention/build.gradle.kts index 0e741e83a..32c66f008 100644 --- a/conditional_operator_intention/build.gradle.kts +++ b/conditional_operator_intention/build.gradle.kts @@ -22,7 +22,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") plugins.set(listOf("com.intellij.java")) } @@ -33,7 +33,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/conditional_operator_intention/src/main/java/org/intellij/sdk/intention/ConditionalOperatorConverter.java b/conditional_operator_intention/src/main/java/org/intellij/sdk/intention/ConditionalOperatorConverter.java index 9edce5756..347036fbd 100644 --- a/conditional_operator_intention/src/main/java/org/intellij/sdk/intention/ConditionalOperatorConverter.java +++ b/conditional_operator_intention/src/main/java/org/intellij/sdk/intention/ConditionalOperatorConverter.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.intention; @@ -60,14 +60,12 @@ public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction } // Is this a token of type representing a "?" character? - if (element instanceof PsiJavaToken) { - final PsiJavaToken token = (PsiJavaToken) element; + if (element instanceof PsiJavaToken token) { if (token.getTokenType() != JavaTokenType.QUEST) { return false; } // Is this token part of a fully formed conditional, i.e. a ternary? - if (token.getParent() instanceof PsiConditionalExpression) { - final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression) token.getParent(); + if (token.getParent() instanceof PsiConditionalExpression conditionalExpression) { // Satisfies all criteria; call back invoke method return conditionalExpression.getThenExpression() != null && conditionalExpression.getElseExpression() != null; } @@ -116,8 +114,7 @@ public class ConditionalOperatorConverter extends PsiElementBaseIntentionAction // If the original statement is a declaration based on a ternary operator, // split the declaration and assignment - if (originalStatement instanceof PsiDeclarationStatement) { - final PsiDeclarationStatement declaration = (PsiDeclarationStatement) originalStatement; + if (originalStatement instanceof PsiDeclarationStatement declaration) { // Find the local variable within the declaration statement final PsiElement[] declaredElements = declaration.getDeclaredElements(); diff --git a/conditional_operator_intention/src/main/resources/META-INF/plugin.xml b/conditional_operator_intention/src/main/resources/META-INF/plugin.xml index cbf93deb5..f016faf69 100644 --- a/conditional_operator_intention/src/main/resources/META-INF/plugin.xml +++ b/conditional_operator_intention/src/main/resources/META-INF/plugin.xml @@ -35,7 +35,7 @@ - + JAVA org.intellij.sdk.intention.ConditionalOperatorConverter SDK intentions diff --git a/editor_basics/build.gradle.kts b/editor_basics/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/editor_basics/build.gradle.kts +++ b/editor_basics/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/editor_basics/src/main/java/org/intellij/sdk/editor/EditorAreaIllustration.java b/editor_basics/src/main/java/org/intellij/sdk/editor/EditorAreaIllustration.java index 5cfa1c5fd..ef935df9e 100644 --- a/editor_basics/src/main/java/org/intellij/sdk/editor/EditorAreaIllustration.java +++ b/editor_basics/src/main/java/org/intellij/sdk/editor/EditorAreaIllustration.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.editor; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -17,6 +18,11 @@ import org.jetbrains.annotations.NotNull; */ public class EditorAreaIllustration extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + /** * Displays a message with information about the current caret. * @@ -34,7 +40,7 @@ public class EditorAreaIllustration extends AnAction { VisualPosition visualPos = primaryCaret.getVisualPosition(); int caretOffset = primaryCaret.getOffset(); // Build and display the caret report. - String report = logicalPos.toString() + "\n" + visualPos.toString() + "\n" + + String report = logicalPos + "\n" + visualPos + "\n" + "Offset: " + caretOffset; Messages.showInfoMessage(report, "Caret Parameters Inside The Editor"); } @@ -53,7 +59,7 @@ public class EditorAreaIllustration extends AnAction { // Get required data keys final Project project = e.getProject(); final Editor editor = e.getData(CommonDataKeys.EDITOR); - //Set visibility only in case of existing project and editor + // Set visibility only in case of existing project and editor e.getPresentation().setEnabledAndVisible(project != null && editor != null); } diff --git a/editor_basics/src/main/java/org/intellij/sdk/editor/EditorHandlerIllustration.java b/editor_basics/src/main/java/org/intellij/sdk/editor/EditorHandlerIllustration.java index 89353aa34..e658612fc 100644 --- a/editor_basics/src/main/java/org/intellij/sdk/editor/EditorHandlerIllustration.java +++ b/editor_basics/src/main/java/org/intellij/sdk/editor/EditorHandlerIllustration.java @@ -1,11 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.editor; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.actionSystem.EditorActionManager; @@ -19,6 +16,11 @@ import org.jetbrains.annotations.NotNull; */ public class EditorHandlerIllustration extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + /** * Clones a new caret at a higher Logical Position line number. * diff --git a/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java b/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java index 1664cd02e..1d497ded6 100644 --- a/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java +++ b/editor_basics/src/main/java/org/intellij/sdk/editor/EditorIllustrationAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.editor; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -19,6 +20,11 @@ import org.jetbrains.annotations.NotNull; */ public class EditorIllustrationAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + /** * Replaces the run of text selected by the primary caret with a fixed string. * @@ -38,7 +44,7 @@ public class EditorIllustrationAction extends AnAction { // Replace the selection with a fixed string. // Must do this document change in a write action context. WriteCommandAction.runWriteCommandAction(project, () -> - document.replaceString(start, end, "editor_basics") + document.replaceString(start, end, "Replacement") ); // De-select the text range that was just replaced primaryCaret.removeSelection(); diff --git a/facet_basics/build.gradle.kts b/facet_basics/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/facet_basics/build.gradle.kts +++ b/facet_basics/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/framework_basics/build.gradle.kts b/framework_basics/build.gradle.kts index 27a9a80d5..b263e26cf 100644 --- a/framework_basics/build.gradle.kts +++ b/framework_basics/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") plugins.set(listOf("com.intellij.java")) } @@ -29,7 +29,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/kotlin_demo/build.gradle.kts b/kotlin_demo/build.gradle.kts index 5a7c0d4c1..990b5e021 100644 --- a/kotlin_demo/build.gradle.kts +++ b/kotlin_demo/build.gradle.kts @@ -19,7 +19,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -29,8 +29,8 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } compileKotlin { diff --git a/live_templates/build.gradle.kts b/live_templates/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/live_templates/build.gradle.kts +++ b/live_templates/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/live_templates/src/main/java/org/intellij/sdk/liveTemplates/MarkdownContext.java b/live_templates/src/main/java/org/intellij/sdk/liveTemplates/MarkdownContext.java index 4bf91cb3d..762207b4a 100644 --- a/live_templates/src/main/java/org/intellij/sdk/liveTemplates/MarkdownContext.java +++ b/live_templates/src/main/java/org/intellij/sdk/liveTemplates/MarkdownContext.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.liveTemplates; @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; public class MarkdownContext extends TemplateContextType { protected MarkdownContext() { - super("MARKDOWN", "Markdown"); + super("Markdown"); } @Override diff --git a/live_templates/src/main/resources/META-INF/plugin.xml b/live_templates/src/main/resources/META-INF/plugin.xml index 340bd2a60..33828fc62 100644 --- a/live_templates/src/main/resources/META-INF/plugin.xml +++ b/live_templates/src/main/resources/META-INF/plugin.xml @@ -34,7 +34,8 @@ - + diff --git a/max_opened_projects/README.md b/max_opened_projects/README.md index 14643f701..80f647d81 100644 --- a/max_opened_projects/README.md +++ b/max_opened_projects/README.md @@ -3,16 +3,23 @@ ## Quickstart -Maximum Open Projects Sample implements a `ProjectManagerListener` with two methods applied to check if the current projects have been opened or closed. -Each method refers to the `ProjectCountingService` [light service][docs:plugin_services:light_services]. -It provides methods to increase and decrease the global counter of the currently opened projects in the IDE. -After opening each one, a message dialog is presented to the user with the current number. +Maximum Open Projects Sample implements a `StartupActivity` extension point to run on project open as well as a +`ProjectManagerListener` for tracking projects being closed. +Both use `ProjectCountingService` application-level [light service][docs:plugin_services:light_services]. +It provides methods to increase and decrease the counter of currently opened projects in the IDE. +When opening more projects than the maximum allowed (3), a message dialog is shown. + +### Extension Points + +| Name | Implementation | Extension Point Class | +|------------------------------------|---------------------------------------------------------------|-----------------------| +| `com.intellij.postStartupActivity` | [ProjectOpenStartupActivity][file:ProjectOpenStartupActivity] | `StartupActivity` | ### Application Listeners -| Name | Implementation | Listener Class | -|----------|-----------------------------------------------------------|--------------------------| -| listener | [ProjectOpenCloseListener][file:ProjectOpenCloseListener] | `ProjectManagerListener` | +| Name | Implementation | Listener Class | +|----------|-------------------------------------------------------|--------------------------| +| listener | [ProjectOpenCloseListener][file:ProjectCloseListener] | `ProjectManagerListener` | *Reference: [Plugin Listeners in IntelliJ SDK Docs][docs:listeners]* @@ -21,5 +28,6 @@ After opening each one, a message dialog is presented to the user with the curre [docs:plugin_services:light_services]: https://plugins.jetbrains.com/docs/intellij/plugin-services.html#light-services [docs:listeners]: https://plugins.jetbrains.com/docs/intellij/plugin-listeners.html +[file:ProjectOpenStartupActivity]: ./src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenStartupActivity.java [file:ProjectCountingService]: ./src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCountingService.java -[file:ProjectOpenCloseListener]: ./src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenCloseListener.java +[file:ProjectCloseListener]: ./src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCloseListener.java diff --git a/max_opened_projects/build.gradle.kts b/max_opened_projects/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/max_opened_projects/build.gradle.kts +++ b/max_opened_projects/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCloseListener.java b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCloseListener.java new file mode 100644 index 000000000..8aef3961f --- /dev/null +++ b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCloseListener.java @@ -0,0 +1,29 @@ +// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + +package org.intellij.sdk.maxOpenProjects; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManagerListener; +import org.jetbrains.annotations.NotNull; + +/** + * Listener to detect project close. + */ +public class ProjectCloseListener implements ProjectManagerListener { + + @Override + public void projectClosed(@NotNull Project project) { + // Ensure this isn't part of testing + if (ApplicationManager.getApplication().isUnitTestMode()) { + return; + } + + // Get the counting service + ProjectCountingService projectCountingService = + ApplicationManager.getApplication().getService(ProjectCountingService.class); + // Decrement the count because a project just closed + projectCountingService.decreaseOpenProjectCount(); + } + +} diff --git a/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCountingService.java b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCountingService.java index 0568b2e60..d1dc238bd 100644 --- a/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCountingService.java +++ b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectCountingService.java @@ -14,17 +14,17 @@ public final class ProjectCountingService { private int myOpenProjectCount = 0; - public void incrProjectCount() { + public void increaseOpenProjectCount() { myOpenProjectCount++; } - public void decrProjectCount() { + public void decreaseOpenProjectCount() { if (myOpenProjectCount > 0) { myOpenProjectCount--; } } - public boolean projectLimitExceeded() { + public boolean isOpenProjectsLimitExceeded() { return myOpenProjectCount > MAX_OPEN_PROJECTS_LIMIT; } diff --git a/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenCloseListener.java b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenCloseListener.java deleted file mode 100644 index f77d29019..000000000 --- a/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenCloseListener.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - -package org.intellij.sdk.maxOpenProjects; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManagerListener; -import com.intellij.openapi.ui.Messages; -import org.jetbrains.annotations.NotNull; - -/** - * Listener to detect project open and close. - * Depends on {@link ProjectCountingService} - */ -public class ProjectOpenCloseListener implements ProjectManagerListener { - - /** - * Invoked on project open. - * - * @param project opening project - */ - @Override - public void projectOpened(@NotNull Project project) { - // Ensure this isn't part of testing - if (ApplicationManager.getApplication().isUnitTestMode()) { - return; - } - // Get the counting service - ProjectCountingService projectCountingService = - ApplicationManager.getApplication().getService(ProjectCountingService.class); - // Increment the project count - projectCountingService.incrProjectCount(); - // See if the total # of projects violates the limit. - if (projectCountingService.projectLimitExceeded()) { - // Transitioned to outside the limit - String title = String.format("Opening Project \"%s\"", project.getName()); - String message = "
The number of open projects exceeds the SDK plugin max_opened_projects limit.

" + - "This is not an error

"; - Messages.showMessageDialog(project, message, title, Messages.getInformationIcon()); - } - } - - /** - * Invoked on project close. - * - * @param project closing project - */ - @Override - public void projectClosed(@NotNull Project project) { - // Ensure this isn't part of testing - if (ApplicationManager.getApplication().isUnitTestMode()) { - return; - } - // Get the counting service - ProjectCountingService projectCountingService = - ApplicationManager.getApplication().getService(ProjectCountingService.class); - // Decrement the count because a project just closed - projectCountingService.decrProjectCount(); - } - -} diff --git a/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenStartupActivity.java b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenStartupActivity.java new file mode 100644 index 000000000..fa057c062 --- /dev/null +++ b/max_opened_projects/src/main/java/org/intellij/sdk/maxOpenProjects/ProjectOpenStartupActivity.java @@ -0,0 +1,41 @@ +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. + +package org.intellij.sdk.maxOpenProjects; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.startup.StartupActivity; +import com.intellij.openapi.ui.Messages; +import org.jetbrains.annotations.NotNull; + +/** + * Invoked on opening a project. + */ +public class ProjectOpenStartupActivity implements StartupActivity.DumbAware { + + @Override + public void runActivity(@NotNull Project project) { + // Ensure this isn't part of testing + if (ApplicationManager.getApplication().isUnitTestMode()) { + return; + } + + // Get the counting service + ProjectCountingService projectCountingService = + ApplicationManager.getApplication().getService(ProjectCountingService.class); + // Increment the project count + projectCountingService.increaseOpenProjectCount(); + + // See if the total # of projects violates the limit. + if (projectCountingService.isOpenProjectsLimitExceeded()) { + // Transitioned to outside the limit + String title = String.format("Opening Project \"%s\"", project.getName()); + String message = "
The number of open projects exceeds the SDK plugin max_opened_projects limit.

"; + + ApplicationManager.getApplication().invokeLater(() -> + Messages.showMessageDialog(project, message, title, Messages.getInformationIcon()) + ); + } + } + +} diff --git a/max_opened_projects/src/main/resources/META-INF/plugin.xml b/max_opened_projects/src/main/resources/META-INF/plugin.xml index 2a75befeb..7ef8d3a7d 100644 --- a/max_opened_projects/src/main/resources/META-INF/plugin.xml +++ b/max_opened_projects/src/main/resources/META-INF/plugin.xml @@ -36,8 +36,11 @@ IntelliJ Platform SDK - + + + diff --git a/module/build.gradle.kts b/module/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/module/build.gradle.kts +++ b/module/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/product_specific/pycharm_basics/build.gradle.kts b/product_specific/pycharm_basics/build.gradle.kts index e518dd7e9..5a0adf60d 100644 --- a/product_specific/pycharm_basics/build.gradle.kts +++ b/product_specific/pycharm_basics/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") type.set("PY") plugins.set(listOf("Pythonid")) downloadSources.set(false) @@ -31,7 +31,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/project_model/build.gradle.kts b/project_model/build.gradle.kts index 27a9a80d5..b263e26cf 100644 --- a/project_model/build.gradle.kts +++ b/project_model/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") plugins.set(listOf("com.intellij.java")) } @@ -29,7 +29,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/project_model/src/main/java/org/intellij/sdk/project/model/LibrariesAction.java b/project_model/src/main/java/org/intellij/sdk/project/model/LibrariesAction.java index 4d2d4cc9b..8397848ce 100644 --- a/project_model/src/main/java/org/intellij/sdk/project/model/LibrariesAction.java +++ b/project_model/src/main/java/org/intellij/sdk/project/model/LibrariesAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.project.model; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -17,6 +18,11 @@ import org.jetbrains.annotations.NotNull; public class LibrariesAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + @Override public void update(@NotNull final AnActionEvent event) { Project project = event.getProject(); diff --git a/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java b/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java index 5c494dcd5..484ff526f 100644 --- a/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java +++ b/project_model/src/main/java/org/intellij/sdk/project/model/ModificationAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.project.model; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -19,6 +20,11 @@ import org.jetbrains.annotations.NotNull; public class ModificationAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + @Override public void actionPerformed(@NotNull final AnActionEvent event) { Project project = event.getProject(); diff --git a/project_model/src/main/java/org/intellij/sdk/project/model/ProjectFileIndexSampleAction.java b/project_model/src/main/java/org/intellij/sdk/project/model/ProjectFileIndexSampleAction.java index 69b921684..7cd424d49 100644 --- a/project_model/src/main/java/org/intellij/sdk/project/model/ProjectFileIndexSampleAction.java +++ b/project_model/src/main/java/org/intellij/sdk/project/model/ProjectFileIndexSampleAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.project.model; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -18,6 +19,11 @@ import org.jetbrains.annotations.NotNull; public class ProjectFileIndexSampleAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + @Override public void update(@NotNull final AnActionEvent event) { Project project = event.getProject(); @@ -33,6 +39,7 @@ public class ProjectFileIndexSampleAction extends AnAction { if (project == null || editor == null) { return; } + Document document = editor.getDocument(); FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance(); VirtualFile virtualFile = fileDocumentManager.getFile(document); @@ -43,7 +50,7 @@ public class ProjectFileIndexSampleAction extends AnAction { moduleName = module != null ? module.getName() : "No module defined for file"; VirtualFile moduleContentRoot = projectFileIndex.getContentRootForFile(virtualFile); - boolean isLibraryFile = projectFileIndex.isLibraryClassFile(virtualFile); + boolean isLibraryFile = projectFileIndex.isInLibrary(virtualFile); boolean isInLibraryClasses = projectFileIndex.isInLibraryClasses(virtualFile); boolean isInLibrarySource = projectFileIndex.isInLibrarySource(virtualFile); Messages.showInfoMessage("Module: " + moduleName + "\n" + diff --git a/project_model/src/main/java/org/intellij/sdk/project/model/ProjectSdkAction.java b/project_model/src/main/java/org/intellij/sdk/project/model/ProjectSdkAction.java index cfeba2e0c..a18e478a1 100644 --- a/project_model/src/main/java/org/intellij/sdk/project/model/ProjectSdkAction.java +++ b/project_model/src/main/java/org/intellij/sdk/project/model/ProjectSdkAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.project.model; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; @@ -12,6 +13,11 @@ import org.jetbrains.annotations.NotNull; public class ProjectSdkAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + @Override public void actionPerformed(@NotNull final AnActionEvent event) { Project project = event.getProject(); diff --git a/project_model/src/main/java/org/intellij/sdk/project/model/ShowSourceRootsActions.java b/project_model/src/main/java/org/intellij/sdk/project/model/ShowSourceRootsActions.java index e29eaf73c..d2f2c096b 100644 --- a/project_model/src/main/java/org/intellij/sdk/project/model/ShowSourceRootsActions.java +++ b/project_model/src/main/java/org/intellij/sdk/project/model/ShowSourceRootsActions.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.project.model; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; @@ -12,12 +13,18 @@ import org.jetbrains.annotations.NotNull; public class ShowSourceRootsActions extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + @Override public void actionPerformed(@NotNull final AnActionEvent event) { Project project = event.getProject(); if (project == null) { return; } + String projectName = project.getName(); StringBuilder sourceRootsList = new StringBuilder(); VirtualFile[] vFiles = ProjectRootManager.getInstance(project).getContentSourceRoots(); diff --git a/project_view_pane/README.md b/project_view_pane/README.md index 8a1b8e35d..3adabb10a 100644 --- a/project_view_pane/README.md +++ b/project_view_pane/README.md @@ -8,9 +8,9 @@ The current demo describes an implementation of the `com.intellij.projectViewPan ### Extension Points -| Name | Implementation | Extension Point Class | -|--------------------------------|-----------------------------------------------------|------------------------------| -| `com.intellij.projectViewPane` | [ImagesProjectViewPane][file:ImagesProjectViewPane] | `AbstractProjectViewPSIPane` | +| Name | Implementation | Extension Point Class | +|--------------------------------|-----------------------------------------------------|---------------------------| +| `com.intellij.projectViewPane` | [ImagesProjectViewPane][file:ImagesProjectViewPane] | `AbstractProjectViewPane` | *Reference: [Plugin Extension Points in IntelliJ SDK Docs][docs:ep]* diff --git a/project_view_pane/build.gradle.kts b/project_view_pane/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/project_view_pane/build.gradle.kts +++ b/project_view_pane/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/project_view_pane/src/main/java/org/intellij/sdk/view/pane/ImagesProjectViewPane.java b/project_view_pane/src/main/java/org/intellij/sdk/view/pane/ImagesProjectViewPane.java index 20dd8d948..0407e0340 100644 --- a/project_view_pane/src/main/java/org/intellij/sdk/view/pane/ImagesProjectViewPane.java +++ b/project_view_pane/src/main/java/org/intellij/sdk/view/pane/ImagesProjectViewPane.java @@ -1,24 +1,17 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.intellij.sdk.view.pane; import com.intellij.icons.AllIcons; import com.intellij.ide.SelectInTarget; import com.intellij.ide.impl.ProjectViewSelectInTarget; -import com.intellij.ide.projectView.BaseProjectTreeBuilder; import com.intellij.ide.projectView.ViewSettings; -import com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane; -import com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase; -import com.intellij.ide.projectView.impl.ProjectTreeStructure; -import com.intellij.ide.projectView.impl.ProjectViewTree; -import com.intellij.ide.util.treeView.AbstractTreeBuilder; -import com.intellij.ide.util.treeView.AbstractTreeUpdater; +import com.intellij.ide.projectView.impl.*; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import javax.swing.tree.DefaultTreeModel; -public class ImagesProjectViewPane extends AbstractProjectViewPSIPane { +public class ImagesProjectViewPane extends AbstractProjectViewPaneWithAsyncSupport { public static final String ID = "IMAGES"; @@ -29,7 +22,7 @@ public class ImagesProjectViewPane extends AbstractProjectViewPSIPane { @NotNull @Override public String getTitle() { - return "SDK-Images"; + return "SDK Images"; } @NotNull @@ -99,17 +92,4 @@ public class ImagesProjectViewPane extends AbstractProjectViewPSIPane { }; } - // Legacy code, awaiting refactoring of AbstractProjectViewPSIPane#createBuilder - @Override - protected BaseProjectTreeBuilder createBuilder(@NotNull DefaultTreeModel treeModel) { - return null; - } - - // Legacy code, awaiting refactoring of AbstractProjectViewPSIPane#createTreeUpdater - @NotNull - @Override - protected AbstractTreeUpdater createTreeUpdater(@NotNull AbstractTreeBuilder builder) { - throw new IllegalStateException("ImagesProjectViewPane tree is async now"); - } - } diff --git a/project_wizard/build.gradle.kts b/project_wizard/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/project_wizard/build.gradle.kts +++ b/project_wizard/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/psi_demo/build.gradle.kts b/psi_demo/build.gradle.kts index 27a9a80d5..b263e26cf 100644 --- a/psi_demo/build.gradle.kts +++ b/psi_demo/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") plugins.set(listOf("com.intellij.java")) } @@ -29,7 +29,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/psi_demo/src/main/java/org/intellij/sdk/psi/PsiNavigationDemoAction.java b/psi_demo/src/main/java/org/intellij/sdk/psi/PsiNavigationDemoAction.java index f6e9cc4bc..f27c0e419 100644 --- a/psi_demo/src/main/java/org/intellij/sdk/psi/PsiNavigationDemoAction.java +++ b/psi_demo/src/main/java/org/intellij/sdk/psi/PsiNavigationDemoAction.java @@ -1,7 +1,8 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.psi; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -9,16 +10,22 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.ui.Messages; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; public class PsiNavigationDemoAction extends AnAction { + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + @Override public void actionPerformed(AnActionEvent anActionEvent) { Editor editor = anActionEvent.getData(CommonDataKeys.EDITOR); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); - if (editor == null || psiFile == null) { - return; - } + if (editor == null || psiFile == null) { + return; + } int offset = editor.getCaretModel().getOffset(); final StringBuilder infoBuilder = new StringBuilder(); @@ -40,7 +47,7 @@ public class PsiNavigationDemoAction extends AnAction { infoBuilder.append("Local variables:\n"); containingMethod.accept(new JavaRecursiveElementVisitor() { @Override - public void visitLocalVariable(PsiLocalVariable variable) { + public void visitLocalVariable(@NotNull PsiLocalVariable variable) { super.visitLocalVariable(variable); infoBuilder.append(variable.getName()).append("\n"); } diff --git a/run_configuration/build.gradle.kts b/run_configuration/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/run_configuration/build.gradle.kts +++ b/run_configuration/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/settings/build.gradle.kts b/settings/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/settings/build.gradle.kts +++ b/settings/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/simple_language_plugin/build.gradle.kts b/simple_language_plugin/build.gradle.kts index 1d38747f4..70665357b 100644 --- a/simple_language_plugin/build.gradle.kts +++ b/simple_language_plugin/build.gradle.kts @@ -31,7 +31,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") plugins.set(listOf("com.intellij.java")) } @@ -42,7 +42,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java b/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java index 144318888..bda4e4485 100644 --- a/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java +++ b/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleAnnotator.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.language; @@ -23,15 +23,14 @@ public class SimpleAnnotator implements Annotator { @Override public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) { - // Ensure the Psi Element is an expression - if (!(element instanceof PsiLiteralExpression)) { + // Ensure the PSI Element is an expression + if (!(element instanceof PsiLiteralExpression literalExpression)) { return; } // Ensure the Psi element contains a string that starts with the prefix and separator - PsiLiteralExpression literalExpression = (PsiLiteralExpression) element; String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null; - if ((value == null) || !value.startsWith(SIMPLE_PREFIX_STR + SIMPLE_SEPARATOR_STR)) { + if (value == null || !value.startsWith(SIMPLE_PREFIX_STR + SIMPLE_SEPARATOR_STR)) { return; } @@ -56,7 +55,7 @@ public class SimpleAnnotator implements Annotator { holder.newAnnotation(HighlightSeverity.ERROR, "Unresolved property") .range(keyRange) .highlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL) - // ** Tutorial step 18.3 - Add a quick fix for the string containing possible properties + // ** Tutorial step 19. - Add a quick fix for the string containing possible properties .withFix(new SimpleCreatePropertyQuickFix(key)) .create(); } else { diff --git a/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCodeStyleSettingsProvider.java b/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCodeStyleSettingsProvider.java index b0a62b40f..c00a90fb3 100644 --- a/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCodeStyleSettingsProvider.java +++ b/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCodeStyleSettingsProvider.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.language; @@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable; public class SimpleCodeStyleSettingsProvider extends CodeStyleSettingsProvider { @Override - public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) { + public CustomCodeStyleSettings createCustomSettings(@NotNull CodeStyleSettings settings) { return new SimpleCodeStyleSettings(settings); } @@ -26,10 +26,11 @@ public class SimpleCodeStyleSettingsProvider extends CodeStyleSettingsProvider { } @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()) { @Override - protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) { + protected @NotNull CodeStyleAbstractPanel createPanel(@NotNull CodeStyleSettings settings) { return new SimpleCodeStyleMainPanel(getCurrentSettings(), settings); } }; diff --git a/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCreatePropertyQuickFix.java b/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCreatePropertyQuickFix.java index ce1a0c9a0..d09143b57 100644 --- a/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCreatePropertyQuickFix.java +++ b/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCreatePropertyQuickFix.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.sdk.language; @@ -75,6 +75,7 @@ class SimpleCreatePropertyQuickFix extends BaseIntentionAction { private void createProperty(final Project project, final VirtualFile file) { WriteCommandAction.writeCommandAction(project).run(() -> { SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(file); + assert simpleFile != null; ASTNode lastChildNode = simpleFile.getNode().getLastChildNode(); // TODO: Add another check for CRLF if (lastChildNode != null/* && !lastChildNode.getElementType().equals(SimpleTypes.CRLF)*/) { @@ -84,7 +85,9 @@ class SimpleCreatePropertyQuickFix extends BaseIntentionAction { SimpleProperty property = SimpleElementFactory.createProperty(project, key.replaceAll(" ", "\\\\ "), ""); simpleFile.getNode().addChild(property.getNode()); ((Navigatable) property.getLastChild().getNavigationElement()).navigate(true); - FileEditorManager.getInstance(project).getSelectedTextEditor().getCaretModel().moveCaretRelatively(2, 0, false, false, false); + Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); + assert editor != null; + editor.getCaretModel().moveCaretRelatively(2, 0, false, false, false); }); } diff --git a/theme_basics/resources/META-INF/plugin.xml b/theme_basics/resources/META-INF/plugin.xml index 10bbefb63..aae8a39d7 100644 --- a/theme_basics/resources/META-INF/plugin.xml +++ b/theme_basics/resources/META-INF/plugin.xml @@ -13,7 +13,7 @@ 0.1 - + com.intellij.modules.platform diff --git a/tool_window/build.gradle.kts b/tool_window/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/tool_window/build.gradle.kts +++ b/tool_window/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } } diff --git a/tree_structure_provider/build.gradle.kts b/tree_structure_provider/build.gradle.kts index 88f5302c8..63131d48f 100644 --- a/tree_structure_provider/build.gradle.kts +++ b/tree_structure_provider/build.gradle.kts @@ -18,7 +18,7 @@ java { // See https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2022.3.3") } tasks { @@ -28,7 +28,7 @@ tasks { patchPluginXml { version.set("${project.version}") - sinceBuild.set("222") - untilBuild.set("231.*") + sinceBuild.set("223") + untilBuild.set("232.*") } }