2023.2 release (#1091)

This commit is contained in:
Yann Cébron 2023-07-26 14:44:10 +02:00 committed by GitHub
parent 8aa8712db7
commit d7dd55a7e0
48 changed files with 292 additions and 223 deletions

View File

@ -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.*")
}
}

View File

@ -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.

View File

@ -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());
}
/**

View File

@ -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.*")
}
}

View File

@ -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);
}
}

View File

@ -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.*")
}
}

View File

@ -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();

View File

@ -35,7 +35,7 @@
<extensions defaultExtensionNs="com.intellij">
<intentionAction>
<!-- add "<language>JAVA</language>" when targeting 2022.3 and later only -->
<language>JAVA</language> <!-- available in 2022.3 and later -->
<className>org.intellij.sdk.intention.ConditionalOperatorConverter</className>
<category>SDK intentions</category>
</intentionAction>

View File

@ -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.*")
}
}

View File

@ -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");
}

View File

@ -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.
*

View File

@ -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();

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}

View File

@ -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 {

View File

@ -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.*")
}
}

View File

@ -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

View File

@ -34,7 +34,8 @@
<extensions defaultExtensionNs="com.intellij">
<defaultLiveTemplates file="/liveTemplates/Markdown.xml"/>
<liveTemplateContext implementation="org.intellij.sdk.liveTemplates.MarkdownContext"/>
<liveTemplateContext implementation="org.intellij.sdk.liveTemplates.MarkdownContext"
contextId="MARKDOWN"/>
<liveTemplateMacro implementation="org.intellij.sdk.liveTemplates.TitleCaseMacro"/>
</extensions>

View File

@ -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` |
|----------|-------------------------------------------------------|--------------------------|
| 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

View File

@ -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.*")
}
}

View File

@ -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();
}
}

View File

@ -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;
}

View File

@ -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 = "<br>The number of open projects exceeds the SDK plugin max_opened_projects limit.<br><br>" +
"This is not an error<br><br>";
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();
}
}

View File

@ -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 = "<br>The number of open projects exceeds the SDK plugin max_opened_projects limit.<br><br>";
ApplicationManager.getApplication().invokeLater(() ->
Messages.showMessageDialog(project, message, title, Messages.getInformationIcon())
);
}
}
}

View File

@ -36,8 +36,11 @@
<vendor url="https://plugins.jetbrains.com">IntelliJ Platform SDK</vendor>
<applicationListeners>
<listener class="org.intellij.sdk.maxOpenProjects.ProjectOpenCloseListener"
<listener class="org.intellij.sdk.maxOpenProjects.ProjectCloseListener"
topic="com.intellij.openapi.project.ProjectManagerListener"/>
</applicationListeners>
<extensions defaultExtensionNs="com.intellij">
<postStartupActivity implementation="org.intellij.sdk.maxOpenProjects.ProjectOpenStartupActivity"/>
</extensions>
</idea-plugin>

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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" +

View File

@ -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();

View File

@ -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();

View File

@ -9,8 +9,8 @@ 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` |
|--------------------------------|-----------------------------------------------------|---------------------------|
| `com.intellij.projectViewPane` | [ImagesProjectViewPane][file:ImagesProjectViewPane] | `AbstractProjectViewPane` |
*Reference: [Plugin Extension Points in IntelliJ SDK Docs][docs:ep]*

View File

@ -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.*")
}
}

View File

@ -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");
}
}

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}

View File

@ -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,9 +10,15 @@ 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);
@ -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");
}

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}

View File

@ -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 {

View File

@ -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);
}
};

View File

@ -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);
});
}

View File

@ -13,7 +13,7 @@
<version>0.1</version>
<!-- Compatible with the following versions of IntelliJ Platform: version 2022.1 and newer. -->
<idea-version since-build="2022.1"/>
<idea-version since-build="221"/>
<!-- Indicate this plugin can be loaded in all IntelliJ Platform-based products. -->
<depends>com.intellij.modules.platform</depends>

View File

@ -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.*")
}
}

View File

@ -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.*")
}
}