diff --git a/extract/gson-impl/pom.xml b/extract/gson-impl/pom.xml index 57c061fde6..8a70543f27 100644 --- a/extract/gson-impl/pom.xml +++ b/extract/gson-impl/pom.xml @@ -23,7 +23,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -40,7 +40,7 @@ consulo.plugin consulo.java-gson.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/extract/guava-impl/pom.xml b/extract/guava-impl/pom.xml index 37c4ddf0c1..4a969dbe7e 100644 --- a/extract/guava-impl/pom.xml +++ b/extract/guava-impl/pom.xml @@ -17,37 +17,37 @@ --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - consulo - arch.ide-api-provided - 3-SNAPSHOT - - + + consulo + arch.ide-api-provided + 4-SNAPSHOT + + - - - consulo - https://maven.consulo.dev/repository/snapshots/ - - true - interval:60 - - - + + + consulo + https://maven.consulo.dev/repository/snapshots/ + + true + interval:60 + + + - consulo.plugin - consulo.java-guava.impl - 3-SNAPSHOT - jar + consulo.plugin + consulo.java-guava.impl + 4-SNAPSHOT + jar - - - ${project.groupId} - consulo.java-java.language.impl - ${project.version} - - + + + ${project.groupId} + consulo.java-java.language.impl + ${project.version} + + \ No newline at end of file diff --git a/jam-api/pom.xml b/jam-api/pom.xml index 712737967f..bf3fae7a20 100644 --- a/jam-api/pom.xml +++ b/jam-api/pom.xml @@ -15,50 +15,50 @@ - limitations under the License. --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - consulo - arch.ide-api-provided - 3-SNAPSHOT - - + + consulo + arch.ide-api-provided + 4-SNAPSHOT + + - - - consulo - https://maven.consulo.dev/repository/snapshots/ - - true - interval:60 - - - + + + consulo + https://maven.consulo.dev/repository/snapshots/ + + true + interval:60 + + + - consulo.plugin - consulo.java-jam.api - 3-SNAPSHOT - jar + consulo.plugin + consulo.java-jam.api + 4-SNAPSHOT + jar - - - ${project.groupId} - consulo.java-java.language.api - ${project.version} - + + + ${project.groupId} + consulo.java-java.language.api + ${project.version} + - - ${project.groupId} - consulo.java-java.indexing.api - ${project.version} - + + ${project.groupId} + consulo.java-java.indexing.api + ${project.version} + - - ${project.groupId} - com.intellij.xml - ${project.version} - provided - - + + ${project.groupId} + com.intellij.xml + ${project.version} + provided + + \ No newline at end of file diff --git a/jam-impl/pom.xml b/jam-impl/pom.xml index e5e55991f6..b0cc1c07ad 100644 --- a/jam-impl/pom.xml +++ b/jam-impl/pom.xml @@ -16,56 +16,56 @@ - limitations under the License. --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - consulo - arch.ide-api-provided - 3-SNAPSHOT - - + + consulo + arch.ide-api-provided + 4-SNAPSHOT + + - - - consulo - https://maven.consulo.dev/repository/snapshots/ - - true - interval:60 - - - + + + consulo + https://maven.consulo.dev/repository/snapshots/ + + true + interval:60 + + + - consulo.plugin - consulo.java-jam.impl - 3-SNAPSHOT - jar + consulo.plugin + consulo.java-jam.impl + 4-SNAPSHOT + jar - - - consulo - consulo-proxy - ${project.version} - + + + consulo + consulo-proxy + ${project.version} + - - ${project.groupId} - consulo.java-jam.api - ${project.version} - + + ${project.groupId} + consulo.java-jam.api + ${project.version} + - - ${project.groupId} - consulo.java-java.language.impl - ${project.version} - + + ${project.groupId} + consulo.java-java.language.impl + ${project.version} + - - ${project.groupId} - com.intellij.xml - ${project.version} - provided - - + + ${project.groupId} + com.intellij.xml + ${project.version} + provided + + \ No newline at end of file diff --git a/java-analysis-api/pom.xml b/java-analysis-api/pom.xml index 934d0702ae..afb3a0f2e8 100644 --- a/java-analysis-api/pom.xml +++ b/java-analysis-api/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.analysis.api - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-analysis-impl/pom.xml b/java-analysis-impl/pom.xml index b6aeff0d61..24b6592096 100644 --- a/java-analysis-impl/pom.xml +++ b/java-analysis-impl/pom.xml @@ -15,84 +15,84 @@ - limitations under the License. --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - consulo - arch.ide-api-provided - 3-SNAPSHOT - - + + consulo + arch.ide-api-provided + 4-SNAPSHOT + + - - - consulo - https://maven.consulo.dev/repository/snapshots/ - - true - interval:60 - - - + + + consulo + https://maven.consulo.dev/repository/snapshots/ + + true + interval:60 + + + - consulo.plugin - consulo.java-java.analysis.impl - 3-SNAPSHOT - jar + consulo.plugin + consulo.java-java.analysis.impl + 4-SNAPSHOT + jar - - - - consulo.maven - maven-consulo-plugin - true - - - generate-sources - - generate-localize - - - - - - + + + + consulo.maven + maven-consulo-plugin + true + + + generate-sources + + generate-localize + + + + + + - - - ${project.groupId} - consulo.java-java.indexing.impl - ${project.version} - - - ${project.groupId} - consulo.java-java.analysis.api - ${project.version} - - - ${project.groupId} - consulo.java-java.language.impl - ${project.version} - - - one.util - streamex - 0.7.1 - + + + ${project.groupId} + consulo.java-java.indexing.impl + ${project.version} + + + ${project.groupId} + consulo.java-java.analysis.api + ${project.version} + + + ${project.groupId} + consulo.java-java.language.impl + ${project.version} + + + one.util + streamex + 0.7.1 + - - consulo - consulo-language-editor-impl - ${project.version} - provided - + + consulo + consulo-language-editor-impl + ${project.version} + provided + - - ${project.groupId} - com.intellij.xml - ${project.version} - provided - - + + ${project.groupId} + com.intellij.xml + ${project.version} + provided + + \ No newline at end of file diff --git a/java-compiler-api/pom.xml b/java-compiler-api/pom.xml index f36266945d..29aab3d498 100644 --- a/java-compiler-api/pom.xml +++ b/java-compiler-api/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,6 +38,6 @@ consulo.plugin consulo.java-java.compiler.api - 3-SNAPSHOT + 4-SNAPSHOT jar \ No newline at end of file diff --git a/java-compiler-artifact-impl/pom.xml b/java-compiler-artifact-impl/pom.xml index d866e25c2c..b963aaa24e 100644 --- a/java-compiler-artifact-impl/pom.xml +++ b/java-compiler-artifact-impl/pom.xml @@ -22,7 +22,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -39,7 +39,7 @@ consulo.plugin consulo.java-java.compiler.artifact.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-compiler-impl/pom.xml b/java-compiler-impl/pom.xml index e91d6d0be0..930140521f 100644 --- a/java-compiler-impl/pom.xml +++ b/java-compiler-impl/pom.xml @@ -22,7 +22,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -39,7 +39,7 @@ consulo.plugin consulo.java-java.compiler.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-coverage-impl/coverage_rt/pom.xml b/java-coverage-impl/coverage_rt/pom.xml index e1ff0cb190..899848d55e 100644 --- a/java-coverage-impl/coverage_rt/pom.xml +++ b/java-coverage-impl/coverage_rt/pom.xml @@ -33,7 +33,7 @@ consulo.plugin consulo.java-java.coverage.rt - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-coverage-impl/pom.xml b/java-coverage-impl/pom.xml index 81d190f729..157f5cba6f 100644 --- a/java-coverage-impl/pom.xml +++ b/java-coverage-impl/pom.xml @@ -22,7 +22,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -39,7 +39,7 @@ consulo.plugin consulo.java-java.coverage.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-debugger-api/pom.xml b/java-debugger-api/pom.xml index 7b1df0da79..209720955c 100644 --- a/java-debugger-api/pom.xml +++ b/java-debugger-api/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -56,7 +56,7 @@ consulo.plugin consulo.java-java.debugger.api - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-debugger-image-impl/pom.xml b/java-debugger-image-impl/pom.xml index 880940367b..77b9442a7a 100644 --- a/java-debugger-image-impl/pom.xml +++ b/java-debugger-image-impl/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.debugger.image.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-debugger-impl/pom.xml b/java-debugger-impl/pom.xml index d7b1491d6d..4f39dc37ed 100644 --- a/java-debugger-impl/pom.xml +++ b/java-debugger-impl/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.debugger.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-debugger-impl/src/main/java/com/intellij/java/debugger/impl/GenericDebuggerRunner.java b/java-debugger-impl/src/main/java/com/intellij/java/debugger/impl/GenericDebuggerRunner.java index 1ea48c2a45..c870e516ef 100644 --- a/java-debugger-impl/src/main/java/com/intellij/java/debugger/impl/GenericDebuggerRunner.java +++ b/java-debugger-impl/src/main/java/com/intellij/java/debugger/impl/GenericDebuggerRunner.java @@ -25,7 +25,6 @@ import com.intellij.java.execution.runners.JavaPatchableProgramRunner; import consulo.annotation.component.ExtensionImpl; import consulo.application.Application; -import consulo.document.FileDocumentManager; import consulo.execution.DefaultExecutionResult; import consulo.execution.ExecutionResult; import consulo.execution.configuration.*; @@ -55,12 +54,6 @@ public String getRunnerId() { return DebuggingRunnerData.DEBUGGER_RUNNER_ID; } - @Override - protected RunContentDescriptor doExecute(@Nonnull RunProfileState state, @Nonnull ExecutionEnvironment env) throws ExecutionException { - FileDocumentManager.getInstance().saveAllDocuments(); - return createContentDescriptor(state, env); - } - @Nullable protected RunContentDescriptor createContentDescriptor( @Nonnull RunProfileState state, diff --git a/java-execution-api/pom.xml b/java-execution-api/pom.xml index c4b7a30228..8caae9f00c 100644 --- a/java-execution-api/pom.xml +++ b/java-execution-api/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -56,7 +56,7 @@ consulo.plugin consulo.java-java.execution.api - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-execution-impl/pom.xml b/java-execution-impl/pom.xml index 0a38b8714a..625beae673 100644 --- a/java-execution-impl/pom.xml +++ b/java-execution-impl/pom.xml @@ -22,7 +22,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -39,7 +39,7 @@ consulo.plugin consulo.java-java.execution.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-execution-impl/src/main/java/com/intellij/java/execution/impl/DefaultJavaProgramRunner.java b/java-execution-impl/src/main/java/com/intellij/java/execution/impl/DefaultJavaProgramRunner.java index 39c83e3167..3eaf03a21d 100644 --- a/java-execution-impl/src/main/java/com/intellij/java/execution/impl/DefaultJavaProgramRunner.java +++ b/java-execution-impl/src/main/java/com/intellij/java/execution/impl/DefaultJavaProgramRunner.java @@ -82,9 +82,8 @@ public void patch(OwnJavaParameters javaParameters, RunnerSettings settings, Run runCustomPatchers(javaParameters, DefaultRunExecutor.getRunExecutorInstance(), runProfile); } + @Override protected RunContentDescriptor doExecute(@Nonnull RunProfileState state, @Nonnull ExecutionEnvironment env) throws ExecutionException { - FileDocumentManager.getInstance().saveAllDocuments(); - ExecutionResult executionResult; boolean shouldAddDefaultActions = true; if (state instanceof JavaCommandLine javaCommandLine) { @@ -97,7 +96,7 @@ protected RunContentDescriptor doExecute(@Nonnull RunProfileState state, @Nonnul ProcessHandler handler = executionResult != null ? executionResult.getProcessHandler() : null; if (handler != null) { proxy.attach(handler); - handler.addProcessListener(new ProcessAdapter() { + handler.addProcessListener(new ProcessListener() { @Override public void processTerminated(@Nonnull ProcessEvent event) { proxy.destroy(); diff --git a/java-execution-impl/src/main/java/com/intellij/java/execution/impl/filters/ExceptionExFilterFactory.java b/java-execution-impl/src/main/java/com/intellij/java/execution/impl/filters/ExceptionExFilterFactory.java index 653c347101..78fbfe8fa0 100644 --- a/java-execution-impl/src/main/java/com/intellij/java/execution/impl/filters/ExceptionExFilterFactory.java +++ b/java-execution-impl/src/main/java/com/intellij/java/execution/impl/filters/ExceptionExFilterFactory.java @@ -22,8 +22,7 @@ import com.intellij.java.language.psi.PsiCodeBlock; import com.intellij.java.language.psi.PsiTryStatement; import consulo.annotation.component.ExtensionImpl; -import consulo.application.AccessToken; -import consulo.application.ApplicationManager; +import consulo.application.ReadAction; import consulo.colorScheme.EffectType; import consulo.colorScheme.TextAttributes; import consulo.document.Document; @@ -42,9 +41,9 @@ import consulo.ui.ex.awt.UIUtil; import consulo.ui.ex.awtUnsafe.TargetAWT; import consulo.util.lang.Trinity; - import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; + import java.awt.*; import java.util.HashMap; import java.util.Map; @@ -55,104 +54,106 @@ */ @ExtensionImpl public class ExceptionExFilterFactory implements ExceptionFilterFactory { - @Nonnull - @Override - public Filter create(@Nonnull GlobalSearchScope searchScope) { - return new MyFilter(searchScope); - } - - private static class MyFilter implements Filter, FilterMixin { - private final ExceptionInfoCache myCache; - - public MyFilter(@Nonnull final GlobalSearchScope scope) { - myCache = new ExceptionInfoCache(scope); - } - + @Nonnull @Override - public Result applyFilter(final String line, final int textEndOffset) { - return null; + public Filter create(@Nonnull GlobalSearchScope searchScope) { + return new MyFilter(searchScope); } - @Override - public boolean shouldRunHeavy() { - return true; - } + private static class MyFilter implements Filter, FilterMixin { + private final ExceptionInfoCache myCache; - @Override - public void applyHeavyFilter(@Nonnull final Document copiedFragment, final int startOffset, int startLineNumber, @Nonnull final Consumer consumer) { - Map> visited = new HashMap>(); - final Trinity emptyInfo = Trinity.create(null, null, null); - - final ExceptionWorker worker = new ExceptionWorker(myCache); - for (int i = 0; i < copiedFragment.getLineCount(); i++) { - final int lineStartOffset = copiedFragment.getLineStartOffset(i); - final int lineEndOffset = copiedFragment.getLineEndOffset(i); - - String text = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset)); - if (!text.contains(".java:")) { - continue; + public MyFilter(@Nonnull final GlobalSearchScope scope) { + myCache = new ExceptionInfoCache(scope); } - Trinity info = visited.get(text); - if (info == emptyInfo) { - continue; + + @Override + public Result applyFilter(final String line, final int textEndOffset) { + return null; } - if (info == null) { - info = emptyInfo; - AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); - try { - worker.execute(text, lineEndOffset); - Result result = worker.getResult(); - if (result == null) { - continue; - } - HyperlinkInfo hyperlinkInfo = result.getHyperlinkInfo(); - if (!(hyperlinkInfo instanceof FileHyperlinkInfo)) { - continue; - } + @Override + public boolean shouldRunHeavy() { + return true; + } - OpenFileDescriptor descriptor = ((FileHyperlinkInfo) hyperlinkInfo).getDescriptor(); - if (descriptor == null) { - continue; - } + @Override + public void applyHeavyFilter(@Nonnull final Document copiedFragment, final int startOffset, int startLineNumber, @Nonnull final Consumer consumer) { + Map> visited = new HashMap>(); + final Trinity emptyInfo = Trinity.create(null, null, null); - PsiFile psiFile = worker.getFile(); - if (psiFile == null || psiFile instanceof PsiCompiledFile) { - continue; - } - int offset = descriptor.getOffset(); - if (offset <= 0) { - continue; - } + final ExceptionWorker worker = new ExceptionWorker(myCache); + for (int i = 0; i < copiedFragment.getLineCount(); i++) { + final int lineStartOffset = copiedFragment.getLineStartOffset(i); + final int lineEndOffset = copiedFragment.getLineEndOffset(i); + + String text = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset)); + if (!text.contains(".java:")) { + continue; + } + Trinity info = visited.get(text); + if (info == emptyInfo) { + continue; + } + + if (info == null) { + info = ReadAction.compute(() -> { + worker.execute(text, lineEndOffset); + Result result = worker.getResult(); + if (result == null) { + return null; + } + HyperlinkInfo hyperlinkInfo = result.getHyperlinkInfo(); + if (!(hyperlinkInfo instanceof FileHyperlinkInfo)) { + return null; + } + + OpenFileDescriptor descriptor = ((FileHyperlinkInfo) hyperlinkInfo).getDescriptor(); + if (descriptor == null) { + return null; + } - PsiElement element = psiFile.findElementAt(offset); - PsiTryStatement parent = PsiTreeUtil.getParentOfType(element, PsiTryStatement.class, true, PsiClass.class); - PsiCodeBlock tryBlock = parent != null ? parent.getTryBlock() : null; - if (tryBlock == null || !tryBlock.getTextRange().contains(offset)) { - continue; + PsiFile psiFile = worker.getFile(); + if (psiFile == null || psiFile instanceof PsiCompiledFile) { + return null; + } + int offset = descriptor.getOffset(); + if (offset <= 0) { + return null; + } + + PsiElement element = psiFile.findElementAt(offset); + PsiTryStatement parent = PsiTreeUtil.getParentOfType(element, PsiTryStatement.class, true, PsiClass.class); + PsiCodeBlock tryBlock = parent != null ? parent.getTryBlock() : null; + if (tryBlock == null || !tryBlock.getTextRange().contains(offset)) { + return null; + } + return worker.getInfo(); + }); + + if (info != null) { + visited.put(text, info); + } + else { + continue; + } + } + int off = startOffset + lineStartOffset; + final ColorValue color = TargetAWT.from(UIUtil.getInactiveTextColor()); + consumer.accept(new AdditionalHighlight(off + info.first.getStartOffset(), off + info.second.getEndOffset()) { + @Nonnull + @Override + public TextAttributes getTextAttributes(@Nullable TextAttributes source) { + return new TextAttributes(null, null, color, EffectType.BOLD_DOTTED_LINE, Font.PLAIN); + } + }); } - info = worker.getInfo(); - } finally { - token.finish(); - visited.put(text, info); - } } - int off = startOffset + lineStartOffset; - final ColorValue color = TargetAWT.from(UIUtil.getInactiveTextColor()); - consumer.accept(new AdditionalHighlight(off + info.first.getStartOffset(), off + info.second.getEndOffset()) { - @Nonnull - @Override - public TextAttributes getTextAttributes(@Nullable TextAttributes source) { - return new TextAttributes(null, null, color, EffectType.BOLD_DOTTED_LINE, Font.PLAIN); - } - }); - } - } - @Nonnull - @Override - public String getUpdateMessage() { - return "Highlighting try blocks..."; + @Nonnull + @Override + public String getUpdateMessage() { + return "Highlighting try blocks..."; + } } - } } diff --git a/java-impl-testing/pom.xml b/java-impl-testing/pom.xml index caff394952..80b1ed8208 100644 --- a/java-impl-testing/pom.xml +++ b/java-impl-testing/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.impl.testing - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-indexing-api/pom.xml b/java-indexing-api/pom.xml index eb74249429..c6c99b342c 100644 --- a/java-indexing-api/pom.xml +++ b/java-indexing-api/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.indexing.api - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-indexing-impl/pom.xml b/java-indexing-impl/pom.xml index ac9617239b..03b9939cc9 100644 --- a/java-indexing-impl/pom.xml +++ b/java-indexing-impl/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.indexing.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-intellilang/pom.xml b/java-intellilang/pom.xml index 0890935b2c..dff27066c6 100644 --- a/java-intellilang/pom.xml +++ b/java-intellilang/pom.xml @@ -23,7 +23,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -40,7 +40,7 @@ consulo.plugin consulo.java-java.intelliLang - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-intellilang/src/main/java/consulo/java/impl/intelliLang/config/ui/MethodParameterPanel.java b/java-intellilang/src/main/java/consulo/java/impl/intelliLang/config/ui/MethodParameterPanel.java index 6144af9e1d..815ff313b2 100644 --- a/java-intellilang/src/main/java/consulo/java/impl/intelliLang/config/ui/MethodParameterPanel.java +++ b/java-intellilang/src/main/java/consulo/java/impl/intelliLang/config/ui/MethodParameterPanel.java @@ -23,7 +23,7 @@ import consulo.application.Application; import consulo.application.util.function.Computable; import consulo.dataContext.DataSink; -import consulo.dataContext.TypeSafeDataProvider; +import consulo.dataContext.UiDataProvider; import consulo.document.Document; import consulo.document.event.DocumentAdapter; import consulo.document.event.DocumentEvent; @@ -53,7 +53,6 @@ import consulo.ui.ex.awt.tree.table.ListTreeTableModelOnColumns; import consulo.ui.ex.awt.tree.table.TreeColumnInfo; import consulo.util.collection.ContainerUtil; -import consulo.util.dataholder.Key; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -69,346 +68,375 @@ public class MethodParameterPanel extends AbstractInjectionPanel { - LanguagePanel myLanguagePanel; // read by reflection - AdvancedPanel myAdvancedPanel; + LanguagePanel myLanguagePanel; // read by reflection + AdvancedPanel myAdvancedPanel; + + private JPanel myRoot; + private JPanel myClassPanel; + + private TreeTableView myParamsTable; + + private final ReferenceEditorWithBrowseButton myClassField; + private DefaultMutableTreeNode myRootNode; + + private final Map myData = new HashMap<>(); + + @RequiredUIAccess + public MethodParameterPanel(MethodParameterInjection injection, final Project project) { + super(injection, project); + + myClassField = new ReferenceEditorWithBrowseButton( + new BrowseClassListener(project), + project, + s -> { + final Document document = PsiUtilEx.createDocument(s, project); + document.addDocumentListener(new DocumentAdapter() { + @Override + public void documentChanged(final DocumentEvent e) { + updateParamTree(); + updateTree(); + } + }); + return document; + }, + "" + ); + myClassPanel.add(myClassField, BorderLayout.CENTER); + myParamsTable.getTree().setShowsRootHandles(true); + myParamsTable.getTree().setCellRenderer(new ColoredTreeCellRenderer() { + + @Override + public void customizeCellRenderer( + @Nonnull final JTree tree, + final Object value, + final boolean selected, + final boolean expanded, + final boolean leaf, + final int row, + final boolean hasFocus + ) { + final Object o = ((DefaultMutableTreeNode) value).getUserObject(); + setIcon(o instanceof PsiMethod ? AllIcons.Nodes.Method : o instanceof PsiParameter ? AllIcons.Nodes.Parameter : null); + final String name; + if (o instanceof PsiMethod method) { + name = PsiFormatUtil.formatMethod( + method, + PsiSubstitutor.EMPTY, + PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, + PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE + ); + } + else if (o instanceof PsiParameter parameter) { + name = PsiFormatUtil.formatVariable(parameter, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE, PsiSubstitutor.EMPTY); + } + else { + name = null; + } + final boolean missing = o instanceof PsiElement element && !element.isPhysical(); + if (name != null) { + append(name, missing ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); + } + } - private JPanel myRoot; - private JPanel myClassPanel; - - private TreeTableView myParamsTable; - - private final ReferenceEditorWithBrowseButton myClassField; - private DefaultMutableTreeNode myRootNode; - - private final Map myData = new HashMap<>(); + }); + init(injection.copy()); + new TreeTableSpeedSearch(myParamsTable, o -> { + final Object userObject = ((DefaultMutableTreeNode) o.getLastPathComponent()).getUserObject(); + return userObject instanceof PsiNamedElement namedElement ? namedElement.getName() : null; + }); + new AnAction("Toggle") { + @Override + @RequiredUIAccess + public void actionPerformed(@Nonnull final AnActionEvent e) { + performToggleAction(); + } + }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), myParamsTable); + } - @RequiredUIAccess - public MethodParameterPanel(MethodParameterInjection injection, final Project project) { - super(injection, project); + private void performToggleAction() { + final Collection selectedInjections = myParamsTable.getSelection(); + boolean enabledExists = false; + boolean disabledExists = false; + for (DefaultMutableTreeNode node : selectedInjections) { + final Boolean nodeSelected = isNodeSelected(node); + if (Boolean.TRUE == nodeSelected) { + enabledExists = true; + } + else if (Boolean.FALSE == nodeSelected) { + disabledExists = true; + } + if (enabledExists && disabledExists) { + break; + } + } + boolean allEnabled = !enabledExists && disabledExists; + for (DefaultMutableTreeNode node : selectedInjections) { + setNodeSelected(node, allEnabled); + } + myParamsTable.updateUI(); + } - myClassField = new ReferenceEditorWithBrowseButton( - new BrowseClassListener(project), - project, - s -> { - final Document document = PsiUtilEx.createDocument(s, project); - document.addDocumentListener(new DocumentAdapter() { - @Override - public void documentChanged(final DocumentEvent e) { - updateParamTree(); - updateTree(); - } - }); - return document; - }, - "" - ); - myClassPanel.add(myClassField, BorderLayout.CENTER); - myParamsTable.getTree().setShowsRootHandles(true); - myParamsTable.getTree().setCellRenderer(new ColoredTreeCellRenderer() { - - public void customizeCellRenderer( - @Nonnull final JTree tree, - final Object value, - final boolean selected, - final boolean expanded, - final boolean leaf, - final int row, - final boolean hasFocus - ) { - final Object o = ((DefaultMutableTreeNode)value).getUserObject(); - setIcon(o instanceof PsiMethod ? AllIcons.Nodes.Method : o instanceof PsiParameter ? AllIcons.Nodes.Parameter : null); - final String name; - if (o instanceof PsiMethod method) { - name = PsiFormatUtil.formatMethod( - method, - PsiSubstitutor.EMPTY, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE - ); + @Nullable + private PsiType getClassType() { + final Document document = myClassField.getEditorTextField().getDocument(); + final PsiDocumentManager dm = PsiDocumentManager.getInstance(getProject()); + dm.commitDocument(document); + final PsiFile psiFile = dm.getPsiFile(document); + if (psiFile == null) { + return null; } - else if (o instanceof PsiParameter parameter) { - name = PsiFormatUtil.formatVariable(parameter, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE, PsiSubstitutor.EMPTY); + try { + return ((PsiTypeCodeFragment) psiFile).getType(); } - else name = null; - final boolean missing = o instanceof PsiElement element && !element.isPhysical(); - if (name != null) { - append(name, missing ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); + catch (PsiTypeCodeFragment.TypeSyntaxException e1) { + return null; + } + catch (PsiTypeCodeFragment.NoTypeException e1) { + return null; } - } - - }); - init(injection.copy()); - new TreeTableSpeedSearch(myParamsTable, o -> { - final Object userObject = ((DefaultMutableTreeNode)o.getLastPathComponent()).getUserObject(); - return userObject instanceof PsiNamedElement namedElement ? namedElement.getName() : null; - }); - new AnAction("Toggle") { - @Override - @RequiredUIAccess - public void actionPerformed(@Nonnull final AnActionEvent e) { - performToggleAction(); - } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), myParamsTable); - } - - private void performToggleAction() { - final Collection selectedInjections = myParamsTable.getSelection(); - boolean enabledExists = false; - boolean disabledExists = false; - for (DefaultMutableTreeNode node : selectedInjections) { - final Boolean nodeSelected = isNodeSelected(node); - if (Boolean.TRUE == nodeSelected) enabledExists = true; - else if (Boolean.FALSE == nodeSelected) disabledExists = true; - if (enabledExists && disabledExists) break; - } - boolean allEnabled = !enabledExists && disabledExists; - for (DefaultMutableTreeNode node : selectedInjections) { - setNodeSelected(node, allEnabled); } - myParamsTable.updateUI(); - } - - @Nullable - private PsiType getClassType() { - final Document document = myClassField.getEditorTextField().getDocument(); - final PsiDocumentManager dm = PsiDocumentManager.getInstance(getProject()); - dm.commitDocument(document); - final PsiFile psiFile = dm.getPsiFile(document); - if (psiFile == null) return null; - try { - return ((PsiTypeCodeFragment)psiFile).getType(); + + private void setPsiClass(String name) { + myClassField.setText(name); } - catch (PsiTypeCodeFragment.TypeSyntaxException e1) { - return null; + + private void updateParamTree() { + rebuildTreeModel(); + refreshTreeStructure(); } - catch (PsiTypeCodeFragment.NoTypeException e1) { - return null; + + private void rebuildTreeModel() { + myData.clear(); + Application.get().runReadAction(() -> { + final PsiType classType = getClassType(); + final PsiClass[] classes = classType instanceof PsiClassType ? JavaPsiFacade.getInstance(getProject()). + findClasses(classType.getCanonicalText(), GlobalSearchScope.allScope(getProject())) : PsiClass.EMPTY_ARRAY; + if (classes.length == 0) { + return; + } + final Set visitedSignatures = new HashSet<>(); + for (PsiClass psiClass : classes) { + for (PsiMethod method : psiClass.getMethods()) { + final PsiModifierList modifiers = method.getModifierList(); + if (modifiers.hasModifierProperty(PsiModifier.PRIVATE) || modifiers.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) { + continue; + } + if (MethodParameterInjection.isInjectable( + method.getReturnType(), + method.getProject()) || ContainerUtil.find(method.getParameterList().getParameters(), + p -> MethodParameterInjection.isInjectable(p.getType(), p.getProject()) + ) != null) { + final MethodParameterInjection.MethodInfo info = MethodParameterInjection.createMethodInfo(method); + if (!visitedSignatures.add(info.getMethodSignature())) { + continue; + } + myData.put(method, info); + } + } + } + }); } - } - - private void setPsiClass(String name) { - myClassField.setText(name); - } - - private void updateParamTree() { - rebuildTreeModel(); - refreshTreeStructure(); - } - - private void rebuildTreeModel() { - myData.clear(); - Application.get().runReadAction(() -> { - final PsiType classType = getClassType(); - final PsiClass[] classes = classType instanceof PsiClassType ? JavaPsiFacade.getInstance(getProject()). - findClasses(classType.getCanonicalText(), GlobalSearchScope.allScope(getProject())) : PsiClass.EMPTY_ARRAY; - if (classes.length == 0) return; - final Set visitedSignatures = new HashSet<>(); - for (PsiClass psiClass : classes) { - for (PsiMethod method : psiClass.getMethods()) { - final PsiModifierList modifiers = method.getModifierList(); - if (modifiers.hasModifierProperty(PsiModifier.PRIVATE) || modifiers.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) continue; - if (MethodParameterInjection.isInjectable( - method.getReturnType(), - method.getProject()) || ContainerUtil.find(method.getParameterList().getParameters(), - p -> MethodParameterInjection.isInjectable(p.getType(), p.getProject()) - ) != null) { - final MethodParameterInjection.MethodInfo info = MethodParameterInjection.createMethodInfo(method); - if (!visitedSignatures.add(info.getMethodSignature())) continue; - myData.put(method, info); - } + + private void refreshTreeStructure() { + myRootNode.removeAllChildren(); + final ArrayList methods = new ArrayList<>(myData.keySet()); + Collections.sort(methods, (o1, o2) -> { + final int names = o1.getName().compareTo(o2.getName()); + if (names != 0) { + return names; + } + return o1.getParameterList().getParametersCount() - o2.getParameterList().getParametersCount(); + }); + for (PsiMethod method : methods) { + final PsiParameter[] params = method.getParameterList().getParameters(); + final DefaultMutableTreeNode methodNode = new DefaultMutableTreeNode(method, true); + myRootNode.add(methodNode); + for (final PsiParameter parameter : params) { + methodNode.add(new DefaultMutableTreeNode(parameter, false)); + } } - } - }); - } - - private void refreshTreeStructure() { - myRootNode.removeAllChildren(); - final ArrayList methods = new ArrayList<>(myData.keySet()); - Collections.sort(methods, (o1, o2) -> { - final int names = o1.getName().compareTo(o2.getName()); - if (names != 0) return names; - return o1.getParameterList().getParametersCount() - o2.getParameterList().getParametersCount(); - }); - for (PsiMethod method : methods) { - final PsiParameter[] params = method.getParameterList().getParameters(); - final DefaultMutableTreeNode methodNode = new DefaultMutableTreeNode(method, true); - myRootNode.add(methodNode); - for (final PsiParameter parameter : params) { - methodNode.add(new DefaultMutableTreeNode(parameter, false)); - } + final ListTreeTableModelOnColumns tableModel = (ListTreeTableModelOnColumns) myParamsTable.getTableModel(); + tableModel.reload(); + TreeUtil.expandAll(myParamsTable.getTree()); + myParamsTable.revalidate(); } - final ListTreeTableModelOnColumns tableModel = (ListTreeTableModelOnColumns)myParamsTable.getTableModel(); - tableModel.reload(); - TreeUtil.expandAll(myParamsTable.getTree()); - myParamsTable.revalidate(); - } - - private String getClassName() { - final PsiType type = getClassType(); - if (type == null) { - return myClassField.getText(); + + private String getClassName() { + final PsiType type = getClassType(); + if (type == null) { + return myClassField.getText(); + } + return type.getCanonicalText(); } - return type.getCanonicalText(); - } - protected void apply(final MethodParameterInjection other) { - final boolean applyMethods = Application.get().runReadAction((Computable)() -> { - other.setClassName(getClassName()); - return getClassType() != null; - }); - if (applyMethods) { - other.setMethodInfos(ContainerUtil.findAll(myData.values(), MethodParameterInjection.MethodInfo::isEnabled)); + @Override + protected void apply(final MethodParameterInjection other) { + final boolean applyMethods = Application.get().runReadAction((Computable) () -> { + other.setClassName(getClassName()); + return getClassType() != null; + }); + if (applyMethods) { + other.setMethodInfos(ContainerUtil.findAll(myData.values(), MethodParameterInjection.MethodInfo::isEnabled)); + } } - } - protected void resetImpl() { - setPsiClass(getOrigInjection().getClassName()); + @Override + protected void resetImpl() { + setPsiClass(getOrigInjection().getClassName()); - rebuildTreeModel(); - final Map map = new HashMap<>(); - for (PsiMethod method : myData.keySet()) { - final MethodParameterInjection.MethodInfo methodInfo = myData.get(method); - map.put(methodInfo.getMethodSignature(), methodInfo); - } - for (MethodParameterInjection.MethodInfo info : getOrigInjection().getMethodInfos()) { - final MethodParameterInjection.MethodInfo curInfo = map.get(info.getMethodSignature()); - if (curInfo != null) { - System.arraycopy(info.getParamFlags(), 0, curInfo.getParamFlags(), 0, Math.min(info.getParamFlags().length, curInfo.getParamFlags().length)); - curInfo.setReturnFlag(info.isReturnFlag()); - } - else { - final PsiMethod missingMethod = MethodParameterInjection.makeMethod(getProject(), info.getMethodSignature()); - myData.put(missingMethod, info.copy()); - } - } - refreshTreeStructure(); - final Enumeration enumeration = myRootNode.children(); - while (enumeration.hasMoreElements()) { - PsiMethod method = (PsiMethod)((DefaultMutableTreeNode)enumeration.nextElement()).getUserObject(); - assert myData.containsKey(method); - } - } - - public JPanel getComponent() { - return myRoot; - } - - private void createUIComponents() { - myLanguagePanel = new LanguagePanel(getProject(), getOrigInjection()); - myRootNode = new DefaultMutableTreeNode(null, true); - myParamsTable = new MyView(new ListTreeTableModelOnColumns(myRootNode, createColumnInfos())); - myAdvancedPanel = new AdvancedPanel(getProject(), getOrigInjection()); - } - - @Nullable - private Boolean isNodeSelected(final DefaultMutableTreeNode o) { - final Object userObject = o.getUserObject(); - if (userObject instanceof PsiMethod method) { - return MethodParameterInjection.isInjectable(method.getReturnType(), method.getProject()) ? myData.get(method).isReturnFlag() : null; - } - else if (userObject instanceof PsiParameter parameter) { - final PsiMethod method = getMethodByNode(o); - final int index = method.getParameterList().getParameterIndex(parameter); - return MethodParameterInjection.isInjectable(parameter.getType(), method.getProject()) - ? myData.get(method).getParamFlags()[index] : null; + rebuildTreeModel(); + final Map map = new HashMap<>(); + for (PsiMethod method : myData.keySet()) { + final MethodParameterInjection.MethodInfo methodInfo = myData.get(method); + map.put(methodInfo.getMethodSignature(), methodInfo); + } + for (MethodParameterInjection.MethodInfo info : getOrigInjection().getMethodInfos()) { + final MethodParameterInjection.MethodInfo curInfo = map.get(info.getMethodSignature()); + if (curInfo != null) { + System.arraycopy(info.getParamFlags(), 0, curInfo.getParamFlags(), 0, Math.min(info.getParamFlags().length, curInfo.getParamFlags().length)); + curInfo.setReturnFlag(info.isReturnFlag()); + } + else { + final PsiMethod missingMethod = MethodParameterInjection.makeMethod(getProject(), info.getMethodSignature()); + myData.put(missingMethod, info.copy()); + } + } + refreshTreeStructure(); + final Enumeration enumeration = myRootNode.children(); + while (enumeration.hasMoreElements()) { + PsiMethod method = (PsiMethod) ((DefaultMutableTreeNode) enumeration.nextElement()).getUserObject(); + assert myData.containsKey(method); + } } - return null; - } - private void setNodeSelected(final DefaultMutableTreeNode o, final boolean value) { - final Object userObject = o.getUserObject(); - if (userObject instanceof PsiMethod method) { - myData.get(method).setReturnFlag(value); - } - else if (userObject instanceof PsiParameter parameter) { - final PsiMethod method = getMethodByNode(o); - final int index = method.getParameterList().getParameterIndex(parameter); - myData.get(method).getParamFlags()[index] = value; + @Override + public JPanel getComponent() { + return myRoot; } - } - private static PsiMethod getMethodByNode(final DefaultMutableTreeNode o) { - final Object userObject = o.getUserObject(); - if (userObject instanceof PsiMethod method) { - return method; + private void createUIComponents() { + myLanguagePanel = new LanguagePanel(getProject(), getOrigInjection()); + myRootNode = new DefaultMutableTreeNode(null, true); + myParamsTable = new MyView(new ListTreeTableModelOnColumns(myRootNode, createColumnInfos())); + myAdvancedPanel = new AdvancedPanel(getProject(), getOrigInjection()); } - return (PsiMethod)((DefaultMutableTreeNode)o.getParent()).getUserObject(); - } - - private ColumnInfo[] createColumnInfos() { - return new ColumnInfo[]{ - new ColumnInfo(" ") { // "" for the first column's name isn't a good idea - final BooleanTableCellRenderer myRenderer = new BooleanTableCellRenderer(); - public Boolean valueOf(DefaultMutableTreeNode o) { - return isNodeSelected(o); - } - - public int getWidth(JTable table) { - return myRenderer.getPreferredSize().width; - } - - public TableCellEditor getEditor(DefaultMutableTreeNode o) { - return new DefaultCellEditor(new JCheckBox()); - } - - public TableCellRenderer getRenderer(DefaultMutableTreeNode o) { - myRenderer.setEnabled(isCellEditable(o)); - return myRenderer; - } - - public void setValue(DefaultMutableTreeNode o, Boolean value) { - setNodeSelected(o, Boolean.TRUE.equals(value)); - } + @Nullable + private Boolean isNodeSelected(final DefaultMutableTreeNode o) { + final Object userObject = o.getUserObject(); + if (userObject instanceof PsiMethod method) { + return MethodParameterInjection.isInjectable(method.getReturnType(), method.getProject()) ? myData.get(method).isReturnFlag() : null; + } + else if (userObject instanceof PsiParameter parameter) { + final PsiMethod method = getMethodByNode(o); + final int index = method.getParameterList().getParameterIndex(parameter); + return MethodParameterInjection.isInjectable(parameter.getType(), method.getProject()) + ? myData.get(method).getParamFlags()[index] : null; + } + return null; + } - public Class getColumnClass() { - return Boolean.class; - } + private void setNodeSelected(final DefaultMutableTreeNode o, final boolean value) { + final Object userObject = o.getUserObject(); + if (userObject instanceof PsiMethod method) { + myData.get(method).setReturnFlag(value); + } + else if (userObject instanceof PsiParameter parameter) { + final PsiMethod method = getMethodByNode(o); + final int index = method.getParameterList().getParameterIndex(parameter); + myData.get(method).getParamFlags()[index] = value; + } + } - public boolean isCellEditable(DefaultMutableTreeNode o) { - return valueOf(o) != null; - } + private static PsiMethod getMethodByNode(final DefaultMutableTreeNode o) { + final Object userObject = o.getUserObject(); + if (userObject instanceof PsiMethod method) { + return method; + } + return (PsiMethod) ((DefaultMutableTreeNode) o.getParent()).getUserObject(); + } - }, new TreeColumnInfo("Method/Parameters") - }; - } + private ColumnInfo[] createColumnInfos() { + return new ColumnInfo[]{ + new ColumnInfo(" ") { // "" for the first column's name isn't a good idea + final BooleanTableCellRenderer myRenderer = new BooleanTableCellRenderer(); + + @Override + public Boolean valueOf(DefaultMutableTreeNode o) { + return isNodeSelected(o); + } + + @Override + public int getWidth(JTable table) { + return myRenderer.getPreferredSize().width; + } + + @Override + public TableCellEditor getEditor(DefaultMutableTreeNode o) { + return new DefaultCellEditor(new JCheckBox()); + } + + @Override + public TableCellRenderer getRenderer(DefaultMutableTreeNode o) { + myRenderer.setEnabled(isCellEditable(o)); + return myRenderer; + } + + @Override + public void setValue(DefaultMutableTreeNode o, Boolean value) { + setNodeSelected(o, Boolean.TRUE.equals(value)); + } + + @Override + public Class getColumnClass() { + return Boolean.class; + } + + @Override + public boolean isCellEditable(DefaultMutableTreeNode o) { + return valueOf(o) != null; + } + + }, new TreeColumnInfo("Method/Parameters") + }; + } - private class BrowseClassListener implements ActionListener { - private final Project myProject; + private class BrowseClassListener implements ActionListener { + private final Project myProject; - public BrowseClassListener(Project project) { - myProject = project; - } + public BrowseClassListener(Project project) { + myProject = project; + } - public void actionPerformed(ActionEvent e) { - final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myProject); - final TreeClassChooser chooser = factory.createAllProjectScopeChooser("Select Class"); - chooser.showDialog(); - final PsiClass psiClass = chooser.getSelected(); - if (psiClass != null) { - setPsiClass(psiClass.getQualifiedName()); - updateParamTree(); - updateTree(); - } + @Override + public void actionPerformed(ActionEvent e) { + final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myProject); + final TreeClassChooser chooser = factory.createAllProjectScopeChooser("Select Class"); + chooser.showDialog(); + final PsiClass psiClass = chooser.getSelected(); + if (psiClass != null) { + setPsiClass(psiClass.getQualifiedName()); + updateParamTree(); + updateTree(); + } + } } - } - private class MyView extends TreeTableView implements TypeSafeDataProvider { - public MyView(ListTreeTableModelOnColumns treeTableModel) { - super(treeTableModel); - } + private class MyView extends TreeTableView implements UiDataProvider { + public MyView(ListTreeTableModelOnColumns treeTableModel) { + super(treeTableModel); + } - public void calcData(final Key key, final DataSink sink) { - if (PsiElement.KEY == key) { - final Collection selection = getSelection(); - if (!selection.isEmpty()) { - final Object o = ((DefaultMutableTreeNode)selection.iterator().next()).getUserObject(); - if (o instanceof PsiElement element) { - sink.put(PsiElement.KEY, element); - } + @Override + public void uiDataSnapshot(@Nonnull DataSink dataSink) { + final Collection selection = getSelection(); + if (!selection.isEmpty()) { + final Object o = ((DefaultMutableTreeNode) selection.iterator().next()).getUserObject(); + if (o instanceof PsiElement element) { + dataSink.set(PsiElement.KEY, element); + } + } } - } } - } } diff --git a/java-language-api/pom.xml b/java-language-api/pom.xml index 9739106977..abffa0a9f8 100644 --- a/java-language-api/pom.xml +++ b/java-language-api/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -57,7 +57,7 @@ consulo.plugin consulo.java-java.language.api - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-language-impl/pom.xml b/java-language-impl/pom.xml index 1c2a8f14ea..ff6d3cc4c7 100644 --- a/java-language-impl/pom.xml +++ b/java-language-impl/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -58,7 +58,7 @@ consulo.plugin consulo.java-java.language.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-manifest/pom.xml b/java-manifest/pom.xml index 1c04c3d98f..986d35aadd 100644 --- a/java-manifest/pom.xml +++ b/java-manifest/pom.xml @@ -22,7 +22,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -39,7 +39,7 @@ consulo.plugin consulo.java-java.manifest - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-properties-impl/pom.xml b/java-properties-impl/pom.xml index 3269bcd067..014589c59c 100644 --- a/java-properties-impl/pom.xml +++ b/java-properties-impl/pom.xml @@ -21,7 +21,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java-java.properties.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-regexp-impl/pom.xml b/java-regexp-impl/pom.xml index 5684d64de1..51f116fe45 100644 --- a/java-regexp-impl/pom.xml +++ b/java-regexp-impl/pom.xml @@ -23,7 +23,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -40,7 +40,7 @@ consulo.plugin consulo.java-java.regexp.impl - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/java-rt-common/pom.xml b/java-rt-common/pom.xml index bccc6f2450..c1ca3a2959 100644 --- a/java-rt-common/pom.xml +++ b/java-rt-common/pom.xml @@ -22,7 +22,7 @@ consulo.plugin consulo.java-java.rt.common - 3-SNAPSHOT + 4-SNAPSHOT diff --git a/java-rt-shaded/pom.xml b/java-rt-shaded/pom.xml index 34bfc9cc80..78c84c3ca5 100644 --- a/java-rt-shaded/pom.xml +++ b/java-rt-shaded/pom.xml @@ -6,7 +6,7 @@ consulo.plugin consulo.java-java.rt.shaded - 3-SNAPSHOT + 4-SNAPSHOT diff --git a/java-rt/pom.xml b/java-rt/pom.xml index 8c76b2e5ba..3b85e78c3a 100644 --- a/java-rt/pom.xml +++ b/java-rt/pom.xml @@ -6,7 +6,7 @@ consulo.plugin consulo.java-java.rt - 3-SNAPSHOT + 4-SNAPSHOT diff --git a/java-spellchecker/pom.xml b/java-spellchecker/pom.xml index 9a3c3a54a3..a6c4482b57 100644 --- a/java-spellchecker/pom.xml +++ b/java-spellchecker/pom.xml @@ -23,7 +23,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -40,7 +40,7 @@ consulo.plugin consulo.java-java.spellchecker - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/jdk-annotations/pom.xml b/jdk-annotations/pom.xml index 7fad856a6b..412ab6d783 100644 --- a/jdk-annotations/pom.xml +++ b/jdk-annotations/pom.xml @@ -22,7 +22,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -39,6 +39,6 @@ consulo.plugin consulo.java-jdk.annotations - 3-SNAPSHOT + 4-SNAPSHOT jar \ No newline at end of file diff --git a/jvm-bytecode-viewer/pom.xml b/jvm-bytecode-viewer/pom.xml index a034e5dcfc..5af0bc01db 100644 --- a/jvm-bytecode-viewer/pom.xml +++ b/jvm-bytecode-viewer/pom.xml @@ -23,7 +23,7 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT @@ -40,7 +40,7 @@ consulo.plugin consulo.java-jvm.bytecode.viewer - 3-SNAPSHOT + 4-SNAPSHOT jar diff --git a/plugin/pom.xml b/plugin/pom.xml index e8ab3db85e..38a5dd205d 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -20,13 +20,13 @@ consulo arch.ide-api-provided - 3-SNAPSHOT + 4-SNAPSHOT consulo.plugin consulo.java - 3-SNAPSHOT + 4-SNAPSHOT consulo-plugin diff --git a/pom.xml b/pom.xml index 21c93c0dbd..aa7ac4d958 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ consulo arch.managment - 3-SNAPSHOT + 4-SNAPSHOT @@ -38,7 +38,7 @@ consulo.plugin consulo.java.parent - 3-SNAPSHOT + 4-SNAPSHOT pom