From 4dcc88eb48ea26c9b788b7f78a73cbfcd8729e75 Mon Sep 17 00:00:00 2001 From: Alexandr Trushev Date: Tue, 11 Jun 2024 19:55:05 +0200 Subject: [PATCH] IJPL-797 `intellij.platform.editor` review internal API GitOrigin-RevId: 008ab023d706e3aa8dfe71ac1d5205f04fb8e71d --- .../typeMigration/ui/MigrationPanel.java | 2 +- .../ide/hierarchy/JavaHierarchyUtil.java | 2 +- .../projectView/FileNameComparatorTest.java | 6 ++-- .../editor-ui-api/api-dump-unreviewed.txt | 31 +++---------------- .../editor-ui-api/exposed-third-party-api.txt | 1 - .../src/com/intellij/ide/DataManager.java | 4 +++ .../ide/lightEdit/LightEditFilePatterns.java | 2 ++ .../LightEditTabAttributesProvider.java | 2 ++ .../projectView/TreeStructureProvider.java | 3 ++ .../structureView/StructureViewBuilder.java | 3 ++ .../structureView/StructureViewFactory.java | 5 +++ .../ide/ui/FontSubpixelResolution.java | 2 ++ .../intellij/ide/ui/NotRoamableUiSettings.kt | 4 +-- .../ide/util/treeView/AlphaComparator.java | 11 ++++++- .../ide/util/treeView/FileNameComparator.java | 9 ++++++ .../ide/util/treeView/IndexComparator.java | 9 ++++++ .../ide/util/treeView/NodeDescriptor.java | 14 +++++++-- .../ide/util/treeView/TreeAnchorizer.java | 5 +++ ...ltNewRunConfigurationTreePopupFactory.java | 10 +++--- .../impl/NewRunConfigurationPopup.java | 2 +- .../NewRunConfigurationTreePopupFactory.java | 4 +-- .../impl/GroupByTypeComparator.java | 2 +- .../util/AbstractTreeClassChooserDialog.java | 2 +- .../ide/util/TreeFileChooserDialog.java | 2 +- .../com/intellij/slicer/SliceTreeBuilder.java | 2 +- .../sm/runner/ui/SMTestRunnerResultsForm.java | 2 +- .../TestFrameworkRunningModel.java | 2 +- .../HierarchicalFilePathComparator.java | 2 +- .../vcs/changes/ui/ChangesBrowserNode.java | 2 +- .../vcs/changes/ui/ChangesComparator.java | 2 +- .../ide/commander/AbstractListBuilder.java | 2 +- .../com/intellij/ide/commander/Commander.java | 2 +- .../coverage/view/ElementColumnInfo.java | 2 +- .../src/PsiViewerDialog.java | 2 +- .../psiViewer/debug/PsiViewerDebugPanel.kt | 2 +- .../python/hierarchy/PyHierarchyUtils.java | 2 +- 36 files changed, 100 insertions(+), 61 deletions(-) delete mode 100644 platform/editor-ui-api/exposed-third-party-api.txt diff --git a/java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java b/java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java index 51ae2aa1dcce..12b6eb706819 100644 --- a/java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java +++ b/java/java-impl-refactorings/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java @@ -81,7 +81,7 @@ public final class MigrationPanel extends JPanel implements Disposable { myRootsTree = new MyTree(); TypeMigrationTreeStructure structure = new TypeMigrationTreeStructure(project); structure.setRoots(currentRoot); - StructureTreeModel model = new StructureTreeModel<>(structure, AlphaComparator.INSTANCE, this); + StructureTreeModel model = new StructureTreeModel<>(structure, AlphaComparator.getInstance(), this); myRootsTree.setModel(new AsyncTreeModel(model, this)); initTree(myRootsTree); diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/JavaHierarchyUtil.java b/java/java-impl/src/com/intellij/ide/hierarchy/JavaHierarchyUtil.java index 949625040093..cd5497b86a02 100644 --- a/java/java-impl/src/com/intellij/ide/hierarchy/JavaHierarchyUtil.java +++ b/java/java-impl/src/com/intellij/ide/hierarchy/JavaHierarchyUtil.java @@ -23,6 +23,6 @@ public final class JavaHierarchyUtil { public static @NotNull Comparator> getComparator(@NotNull Project project) { HierarchyBrowserManager.State state = HierarchyBrowserManager.getInstance(project).getState(); - return state != null && state.SORT_ALPHABETICALLY ? AlphaComparator.INSTANCE : SourceComparator.INSTANCE; + return state != null && state.SORT_ALPHABETICALLY ? AlphaComparator.getInstance() : SourceComparator.INSTANCE; } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/projectView/FileNameComparatorTest.java b/java/java-tests/testSrc/com/intellij/projectView/FileNameComparatorTest.java index aa045e6ab3e3..8e665bec4d8a 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/FileNameComparatorTest.java +++ b/java/java-tests/testSrc/com/intellij/projectView/FileNameComparatorTest.java @@ -164,13 +164,13 @@ public class FileNameComparatorTest extends TestCase { public void testOrder() { ArrayList shuffled = new ArrayList<>(PATHS); Collections.shuffle(shuffled); - List sortedPaths = ContainerUtil.sorted(shuffled, FileNameComparator.INSTANCE); + List sortedPaths = ContainerUtil.sorted(shuffled, FileNameComparator.getInstance()); UsefulTestCase.assertOrderedEquals(sortedPaths, PATHS); } public void testTransitive1() { PlatformTestUtil.assertComparisonContractNotViolated(PATHS, - FileNameComparator.INSTANCE, + FileNameComparator.getInstance(), (path1, path2) -> path1.equals(path2)); } @@ -194,7 +194,7 @@ public class FileNameComparatorTest extends TestCase { //System.out.println("Pairs to check: " + names.size() * names.size() * names.size()); PlatformTestUtil.assertComparisonContractNotViolated(names, - FileNameComparator.INSTANCE, + FileNameComparator.getInstance(), (path1, path2) -> path1.equals(path2)); } } diff --git a/platform/editor-ui-api/api-dump-unreviewed.txt b/platform/editor-ui-api/api-dump-unreviewed.txt index 26704f47875d..eacfba17a87e 100644 --- a/platform/editor-ui-api/api-dump-unreviewed.txt +++ b/platform/editor-ui-api/api-dump-unreviewed.txt @@ -25,7 +25,6 @@ com.intellij.codeInsight.daemon.GutterMark com.intellij.codeInsight.daemon.NonHideableIconGutterMark - com.intellij.codeInsight.daemon.GutterMark a:com.intellij.ide.DataManager -- ():V - a:getDataContext():com.intellij.openapi.actionSystem.DataContext - a:getDataContext(java.awt.Component):com.intellij.openapi.actionSystem.DataContext - a:getDataContext(java.awt.Component,I,I):com.intellij.openapi.actionSystem.DataContext @@ -48,17 +47,6 @@ f:com.intellij.ide.highlighter.HighlighterFactory - s:createHighlighter(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.editor.colors.EditorColorsScheme,com.intellij.openapi.project.Project):com.intellij.openapi.editor.highlighter.EditorHighlighter f:com.intellij.ide.lightEdit.LightEdit - s:owns(com.intellij.openapi.project.Project):Z -c:com.intellij.ide.lightEdit.LightEditFilePatterns -- sf:DEFAULT_PATTERNS:java.lang.String[] -- sf:PATTERN_SEPARATOR:java.lang.String -- ():V -- equals(java.lang.Object):Z -- getPatterns():java.util.List -- hashCode():I -- match(com.intellij.openapi.vfs.VirtualFile):Z -- s:parse(java.lang.String):com.intellij.ide.lightEdit.LightEditFilePatterns -- setPatterns(java.util.List):V -- toSeparatedString():java.lang.String *:com.intellij.ide.lightEdit.LightEditService - sf:WINDOW_NAME:java.lang.String - a:closeEditorWindow():Z @@ -86,7 +74,6 @@ c:com.intellij.ide.lightEdit.LightEditFilePatterns - lightEditWindowClosed(com.intellij.openapi.project.Project):V - lightEditWindowOpened(com.intellij.openapi.project.Project):V *:com.intellij.ide.lightEdit.LightEditTabAttributesProvider -- sf:EP_NAME:com.intellij.openapi.extensions.ExtensionPointName - a:calcAttributes(com.intellij.ide.lightEdit.LightEditorInfo):com.intellij.openapi.editor.markup.TextAttributes *:com.intellij.ide.lightEdit.LightEditorInfo - a:getFile():com.intellij.openapi.vfs.VirtualFile @@ -163,7 +150,6 @@ com.intellij.ide.projectView.SettingsProvider - a:getSettings():com.intellij.ide.projectView.ViewSettings com.intellij.ide.projectView.TreeStructureProvider - com.intellij.openapi.project.PossiblyDumbAware -- sf:EP:com.intellij.openapi.extensions.ProjectExtensionPointName - getData(java.util.Collection,java.lang.String):java.lang.Object - a:modify(com.intellij.ide.util.treeView.AbstractTreeNode,java.util.Collection,com.intellij.ide.projectView.ViewSettings):java.util.Collection com.intellij.ide.projectView.ViewSettings @@ -206,13 +192,11 @@ com.intellij.ide.structureView.StructureView - a:restoreState():V - a:storeState():V com.intellij.ide.structureView.StructureViewBuilder -- sf:EP_NAME:com.intellij.openapi.extensions.ExtensionPointName - sf:PROVIDER:com.intellij.ide.structureView.StructureViewBuilderProvider - a:createStructureView(com.intellij.openapi.fileEditor.FileEditor,com.intellij.openapi.project.Project):com.intellij.ide.structureView.StructureView com.intellij.ide.structureView.StructureViewBuilderProvider - a:getStructureViewBuilder(com.intellij.openapi.fileTypes.FileType,com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.project.Project):com.intellij.ide.structureView.StructureViewBuilder a:com.intellij.ide.structureView.StructureViewFactory -- ():V - a:createStructureView(com.intellij.openapi.fileEditor.FileEditor,com.intellij.ide.structureView.StructureViewModel,com.intellij.openapi.project.Project):com.intellij.ide.structureView.StructureView - a:createStructureView(com.intellij.openapi.fileEditor.FileEditor,com.intellij.ide.structureView.StructureViewModel,com.intellij.openapi.project.Project,Z):com.intellij.ide.structureView.StructureView - s:getInstance(com.intellij.openapi.project.Project):com.intellij.ide.structureView.StructureViewFactory @@ -310,10 +294,6 @@ c:com.intellij.ide.ui.ColorBlindnessSupport - ():V - s:get(com.intellij.ide.ui.ColorBlindness):com.intellij.ide.ui.ColorBlindnessSupport - getFilter():java.awt.image.ImageFilter -f:com.intellij.ide.ui.FontSubpixelResolution -- sf:ENABLED:Z -- sf:RESOLUTION:java.awt.Dimension -- ():V e:com.intellij.ide.ui.NavBarLocation - java.lang.Enum - sf:BOTTOM:com.intellij.ide.ui.NavBarLocation @@ -333,8 +313,6 @@ f:com.intellij.ide.ui.NotRoamableUiOptions - f:overrideLafFontsWasMigrated:Z - f:presentationModeIdeScale:F - ():V -- (com.intellij.ide.ui.AntialiasingType,com.intellij.ide.ui.AntialiasingType,java.lang.String,F,F,F,F,Z,Z,Z):V -- b:(com.intellij.ide.ui.AntialiasingType,com.intellij.ide.ui.AntialiasingType,java.lang.String,F,F,F,F,Z,Z,Z,I,kotlin.jvm.internal.DefaultConstructorMarker):V - f:component1():com.intellij.ide.ui.AntialiasingType - f:component10():Z - f:component2():com.intellij.ide.ui.AntialiasingType @@ -351,7 +329,6 @@ f:com.intellij.ide.ui.NotRoamableUiOptions - hashCode():I f:com.intellij.ide.ui.NotRoamableUiSettings - com.intellij.openapi.components.SerializablePersistentStateComponent -- sf:COMPONENT_NAME:java.lang.String - sf:Companion:com.intellij.ide.ui.NotRoamableUiSettings$Companion - ():V - f:getEditorAAType():com.intellij.ide.ui.AntialiasingType @@ -872,20 +849,21 @@ f:com.intellij.ide.util.treeView.AlphaComparator - java.util.Comparator - sf:INSTANCE:com.intellij.ide.util.treeView.AlphaComparator - compare(com.intellij.ide.util.treeView.NodeDescriptor,com.intellij.ide.util.treeView.NodeDescriptor):I +- s:getInstance():com.intellij.ide.util.treeView.AlphaComparator c:com.intellij.ide.util.treeView.FileNameComparator - java.util.Comparator - sf:INSTANCE:java.util.Comparator - ():V - compare(java.lang.String,java.lang.String):I +- s:getInstance():java.util.Comparator f:com.intellij.ide.util.treeView.IndexComparator - java.util.Comparator - sf:INSTANCE:com.intellij.ide.util.treeView.IndexComparator - compare(com.intellij.ide.util.treeView.NodeDescriptor,com.intellij.ide.util.treeView.NodeDescriptor):I +- s:getInstance():com.intellij.ide.util.treeView.IndexComparator com.intellij.ide.util.treeView.InplaceCommentAppender - a:append(java.lang.String,com.intellij.ui.SimpleTextAttributes):V a:com.intellij.ide.util.treeView.NodeDescriptor -- sf:DEFAULT_WEIGHT:I -- sf:EMPTY_ARRAY:com.intellij.ide.util.treeView.NodeDescriptor[] - p:myClosedIcon:javax.swing.Icon - p:myColor:java.awt.Color - p:myName:java.lang.String @@ -895,7 +873,9 @@ a:com.intellij.ide.util.treeView.NodeDescriptor - expandOnDoubleClick():Z - f:getChildrenSortingStamp():J - f:getColor():java.awt.Color +- s:getDefaultWeight():I - a:getElement():java.lang.Object +- s:getEmptyArray():com.intellij.ide.util.treeView.NodeDescriptor[] - f:getIcon():javax.swing.Icon - getIndex():I - getParentDescriptor():com.intellij.ide.util.treeView.NodeDescriptor @@ -976,7 +956,6 @@ c:com.intellij.ide.util.treeView.PresentableNodeDescriptor$ColoredFragment - getToolTip():java.lang.String - hashCode():I c:com.intellij.ide.util.treeView.TreeAnchorizer -- ():V - s:anchorizeList(java.util.Collection):java.util.List - createAnchor(java.lang.Object):java.lang.Object - freeAnchor(java.lang.Object):V diff --git a/platform/editor-ui-api/exposed-third-party-api.txt b/platform/editor-ui-api/exposed-third-party-api.txt deleted file mode 100644 index 1ff3abdfef32..000000000000 --- a/platform/editor-ui-api/exposed-third-party-api.txt +++ /dev/null @@ -1 +0,0 @@ -kotlin/jvm/internal/DefaultConstructorMarker diff --git a/platform/editor-ui-api/src/com/intellij/ide/DataManager.java b/platform/editor-ui-api/src/com/intellij/ide/DataManager.java index 3855cd5916c9..b354f3172297 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/DataManager.java +++ b/platform/editor-ui-api/src/com/intellij/ide/DataManager.java @@ -32,6 +32,10 @@ public abstract class DataManager { private static final String CLIENT_PROPERTY_DATA_PROVIDER = "DataProvider"; + @ApiStatus.Internal + protected DataManager() { + } + /** * @return {@link DataContext} constructed by the currently focused component * @deprecated use either {@link #getDataContext(Component)} or {@link #getDataContextFromFocus()} diff --git a/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java b/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java index 7103fa4d1819..48bd69fee098 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java +++ b/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java @@ -6,12 +6,14 @@ import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.fileTypes.FileNameMatcherFactory; import java.util.*; import java.util.stream.Collectors; +@ApiStatus.Internal public class LightEditFilePatterns { public static final String[] DEFAULT_PATTERNS = { "*.txt", "*.log", "*.md", "*.json", "*.xml", "*.sh", "*.ini", "*.yml", "*.conf"}; diff --git a/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditTabAttributesProvider.java b/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditTabAttributesProvider.java index ec09c932d8ef..b53ba92794f7 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditTabAttributesProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditTabAttributesProvider.java @@ -9,6 +9,8 @@ import org.jetbrains.annotations.Nullable; @ApiStatus.Experimental public interface LightEditTabAttributesProvider { + + @ApiStatus.Internal ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.lightEditTabAttributesProvider"); diff --git a/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java b/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java index 7d6bc01419c6..1078d4fe71c3 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java @@ -4,6 +4,7 @@ package com.intellij.ide.projectView; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.openapi.extensions.ProjectExtensionPointName; import com.intellij.openapi.project.PossiblyDumbAware; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,6 +18,8 @@ import java.util.Collection; * @see ProjectViewNodeDecorator */ public interface TreeStructureProvider extends PossiblyDumbAware { + + @ApiStatus.Internal ProjectExtensionPointName EP = new ProjectExtensionPointName<>("com.intellij.treeStructureProvider"); /** diff --git a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewBuilder.java b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewBuilder.java index 486f785e8244..6435f4783054 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewBuilder.java +++ b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewBuilder.java @@ -6,6 +6,7 @@ import com.intellij.openapi.extensions.KeyedFactoryEPBean; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileTypes.FileTypeExtensionFactory; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,6 +23,8 @@ import org.jetbrains.annotations.Nullable; */ public interface StructureViewBuilder { + + @ApiStatus.Internal ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.structureViewBuilder"); StructureViewBuilderProvider PROVIDER = diff --git a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java index 8d353a2d91bc..01708cef41b4 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java +++ b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java @@ -3,6 +3,7 @@ package com.intellij.ide.structureView; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -38,4 +39,8 @@ public abstract class StructureViewFactory { public static StructureViewFactory getInstance(Project project) { return project.getService(StructureViewFactory.class); } + + @ApiStatus.Internal + protected StructureViewFactory() { + } } diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/FontSubpixelResolution.java b/platform/editor-ui-api/src/com/intellij/ide/ui/FontSubpixelResolution.java index 7a60af5985a3..5e6ac6c72502 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/FontSubpixelResolution.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/FontSubpixelResolution.java @@ -2,10 +2,12 @@ package com.intellij.ide.ui; import com.intellij.openapi.diagnostic.Logger; +import org.jetbrains.annotations.ApiStatus; import java.awt.*; import java.lang.reflect.Field; +@ApiStatus.Internal public final class FontSubpixelResolution { private static final Logger LOG = Logger.getInstance(FontSubpixelResolution.class); diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt index e3e327af18de..37b72c67b1a7 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt @@ -18,7 +18,7 @@ class NotRoamableUiSettings : SerializablePersistentStateComponent() - const val COMPONENT_NAME: String = "NotRoamableUiSettings" + internal const val COMPONENT_NAME: String = "NotRoamableUiSettings" } var ideScale: Float @@ -130,7 +130,7 @@ class NotRoamableUiSettings : SerializablePersistentStateComponent> { + + /** + * @deprecated use {@link #getInstance()} instead + */ + @Deprecated public static final AlphaComparator INSTANCE = new AlphaComparator(); + public static AlphaComparator getInstance() { + return INSTANCE; + } + private AlphaComparator() { } @@ -21,6 +30,6 @@ public final class AlphaComparator implements Comparator> { if (s1 == null) return s2 == null ? 0 : -1; if (s2 == null) return +1; - return FileNameComparator.INSTANCE.compare(s1, s2); + return FileNameComparator.getInstance().compare(s1, s2); } } diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/FileNameComparator.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/FileNameComparator.java index c6ea6ccad479..b64cb33335de 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/FileNameComparator.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/FileNameComparator.java @@ -6,8 +6,17 @@ import com.intellij.openapi.util.text.NaturalComparator; import java.util.Comparator; public class FileNameComparator implements Comparator { + + /** + * @deprecated use {@link #getInstance()} instead + */ + @Deprecated public static final Comparator INSTANCE = new FileNameComparator(); + public static Comparator getInstance() { + return INSTANCE; + } + @Override public int compare(String s1, String s2) { return NaturalComparator.naturalCompare(s1, s2, s1.length(), s2.length(), true, true); diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/IndexComparator.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/IndexComparator.java index 85eac77ade51..3ed6b3d61077 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/IndexComparator.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/IndexComparator.java @@ -5,8 +5,17 @@ package com.intellij.ide.util.treeView; import java.util.Comparator; public final class IndexComparator implements Comparator> { + + /** + * @deprecated use {@link #getInstance()} instead + */ + @Deprecated public static final IndexComparator INSTANCE = new IndexComparator(); + public static IndexComparator getInstance() { + return INSTANCE; + } + private IndexComparator() {} @Override diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java index d462ae624965..8b877fcb9667 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java @@ -11,8 +11,16 @@ import java.awt.*; import java.util.Comparator; public abstract class NodeDescriptor { - public static final NodeDescriptor[] EMPTY_ARRAY = new NodeDescriptor[0]; - public static final int DEFAULT_WEIGHT = 30; + private static final NodeDescriptor[] EMPTY_ARRAY = new NodeDescriptor[0]; + private static final int DEFAULT_WEIGHT = 30; + + public static NodeDescriptor[] getEmptyArray() { + return EMPTY_ARRAY; + } + + public static int getDefaultWeight() { + return DEFAULT_WEIGHT; + } protected final Project myProject; private final NodeDescriptor myParentDescriptor; @@ -84,7 +92,7 @@ public abstract class NodeDescriptor { if (element instanceof WeighedItem) { return ((WeighedItem) element).getWeight(); } - return DEFAULT_WEIGHT; + return getDefaultWeight(); } public final long getChildrenSortingStamp() { diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java index c91a223c9223..7c6bf32fd809 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java @@ -3,6 +3,7 @@ package com.intellij.ide.util.treeView; import com.intellij.openapi.application.ApplicationManager; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,6 +27,10 @@ public class TreeAnchorizer { return result; } + @ApiStatus.Internal + protected TreeAnchorizer() { + } + public @NotNull Object createAnchor(@NotNull Object element) { return element; } diff --git a/platform/execution-impl/src/com/intellij/execution/impl/DefaultNewRunConfigurationTreePopupFactory.java b/platform/execution-impl/src/com/intellij/execution/impl/DefaultNewRunConfigurationTreePopupFactory.java index 164358ba7b54..0631e39a1c34 100644 --- a/platform/execution-impl/src/com/intellij/execution/impl/DefaultNewRunConfigurationTreePopupFactory.java +++ b/platform/execution-impl/src/com/intellij/execution/impl/DefaultNewRunConfigurationTreePopupFactory.java @@ -41,7 +41,7 @@ public class DefaultNewRunConfigurationTreePopupFactory extends NewRunConfigurat public void initStructure(@NotNull Project project) { root = createDescriptor(project, "", null); other = createDescriptor(project, ExecutionBundle.message("add.new.run.configuration.other.types.node.text"), root, - NodeDescriptor.DEFAULT_WEIGHT + 1); + NodeDescriptor.getDefaultWeight() + 1); myTypesToShow = new ArrayList<>( RunConfigurable.Companion.configurationTypeSorted(project, true, ConfigurationType.CONFIGURATION_TYPE_EP.getExtensionList(), true)); @@ -95,14 +95,14 @@ public class DefaultNewRunConfigurationTreePopupFactory extends NewRunConfigurat if (!myOtherTypes.isEmpty()) { list.add(other); } - return list.toArray(NodeDescriptor.EMPTY_ARRAY); + return list.toArray(NodeDescriptor.getEmptyArray()); } else if (nodeDescriptor instanceof GroupDescriptor) { ArrayList list = new ArrayList<>(); for (ConfigurationType type : ((GroupDescriptor)nodeDescriptor).myTypes) { list.add(createDescriptor(project, type, nodeDescriptor)); } - return list.toArray(NodeDescriptor.EMPTY_ARRAY); + return list.toArray(NodeDescriptor.getEmptyArray()); } else if (other.equals(nodeDescriptor)) { return convertToDescriptors(project, nodeDescriptor, myOtherTypes.toArray()); @@ -113,7 +113,7 @@ public class DefaultNewRunConfigurationTreePopupFactory extends NewRunConfigurat return convertToDescriptors(project, nodeDescriptor, factories); } } - return NodeDescriptor.EMPTY_ARRAY; + return NodeDescriptor.getEmptyArray(); } @@ -143,7 +143,7 @@ public class DefaultNewRunConfigurationTreePopupFactory extends NewRunConfigurat @Override public int getWeight() { - return DEFAULT_WEIGHT - 1; + return getDefaultWeight() - 1; } } } diff --git a/platform/execution-impl/src/com/intellij/execution/impl/NewRunConfigurationPopup.java b/platform/execution-impl/src/com/intellij/execution/impl/NewRunConfigurationPopup.java index 2163ebb5eca1..cb27ddd85cd2 100644 --- a/platform/execution-impl/src/com/intellij/execution/impl/NewRunConfigurationPopup.java +++ b/platform/execution-impl/src/com/intellij/execution/impl/NewRunConfigurationPopup.java @@ -199,7 +199,7 @@ public final class NewRunConfigurationPopup { @Override public @NotNull NodeDescriptor createDescriptor(@NotNull Object element, @Nullable NodeDescriptor parentDescriptor) { - return treePopupFactory.createDescriptor(project, element, parentDescriptor, NodeDescriptor.DEFAULT_WEIGHT); + return treePopupFactory.createDescriptor(project, element, parentDescriptor, NodeDescriptor.getDefaultWeight()); } @Override diff --git a/platform/lang-api/src/com/intellij/execution/impl/NewRunConfigurationTreePopupFactory.java b/platform/lang-api/src/com/intellij/execution/impl/NewRunConfigurationTreePopupFactory.java index e0e88e421003..609aca44fa01 100644 --- a/platform/lang-api/src/com/intellij/execution/impl/NewRunConfigurationTreePopupFactory.java +++ b/platform/lang-api/src/com/intellij/execution/impl/NewRunConfigurationTreePopupFactory.java @@ -30,7 +30,7 @@ public abstract class NewRunConfigurationTreePopupFactory { for (Object element : elements) { descriptors.add(createDescriptor(project, element, parent)); } - return descriptors.toArray(NodeDescriptor.EMPTY_ARRAY); + return descriptors.toArray(NodeDescriptor.getEmptyArray()); } //This method is supposed to be called just once for each node, the result goes to cache @@ -51,7 +51,7 @@ public abstract class NewRunConfigurationTreePopupFactory { public final @NotNull NodeDescriptor createDescriptor(@NotNull Project project, @NotNull Object element, @Nullable NodeDescriptor parentDescriptor) { - return createDescriptor(project, element, parentDescriptor, NodeDescriptor.DEFAULT_WEIGHT); + return createDescriptor(project, element, parentDescriptor, NodeDescriptor.getDefaultWeight()); } public @NotNull NodeDescriptor createDescriptor(@NotNull Project project, diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java index 40f8ab9ff104..0dc749f8b37f 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java @@ -99,7 +99,7 @@ public class GroupByTypeComparator implements Comparator> { } if (descriptor1 == null) return -1; if (descriptor2 == null) return 1; - return AlphaComparator.INSTANCE.compare(descriptor1, descriptor2); + return AlphaComparator.getInstance().compare(descriptor1, descriptor2); } private NodeDescriptor getUpdatedDescriptor(NodeDescriptor descriptor) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java b/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java index 063eed0423fa..7c9ef8626e6c 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java @@ -111,7 +111,7 @@ public abstract class AbstractTreeClassChooserDialog myScope = scope; myElementClass = elementClass; myClassFilter = classFilter == null ? allFilter() : classFilter; - myComparator = comparator == null ? AlphaComparator.INSTANCE : comparator; + myComparator = comparator == null ? AlphaComparator.getInstance() : comparator; myBaseClass = baseClass; myInitialClass = initialClass; myIsShowMembers = isShowMembers; diff --git a/platform/lang-impl/src/com/intellij/ide/util/TreeFileChooserDialog.java b/platform/lang-impl/src/com/intellij/ide/util/TreeFileChooserDialog.java index 94dc6cb01ac9..4d837550ba52 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/TreeFileChooserDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/util/TreeFileChooserDialog.java @@ -95,7 +95,7 @@ public final class TreeFileChooserDialog extends DialogWrapper implements TreeFi myInitialFile = initialFile; myFilter = filter; myFileType = fileType; - myComparator = comparator == null ? AlphaComparator.INSTANCE : comparator; + myComparator = comparator == null ? AlphaComparator.getInstance() : comparator; myDisableStructureProviders = disableStructureProviders; myShowLibraryContents = showLibraryContents; setTitle(title); diff --git a/platform/lang-impl/src/com/intellij/slicer/SliceTreeBuilder.java b/platform/lang-impl/src/com/intellij/slicer/SliceTreeBuilder.java index aaef6e57ee91..740580a008ce 100644 --- a/platform/lang-impl/src/com/intellij/slicer/SliceTreeBuilder.java +++ b/platform/lang-impl/src/com/intellij/slicer/SliceTreeBuilder.java @@ -19,7 +19,7 @@ public final class SliceTreeBuilder { public static final Comparator> SLICE_NODE_COMPARATOR = (o1, o2) -> { if (!(o1 instanceof SliceNode node1) || !(o2 instanceof SliceNode node2)) { - return AlphaComparator.INSTANCE.compare(o1, o2); + return AlphaComparator.getInstance().compare(o1, o2); } SliceUsage usage1 = node1.getValue(); SliceUsage usage2 = node2.getValue(); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java index 9c0af600aef3..774e3ed7fff9 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java @@ -165,7 +165,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel myTreeView.setTestResultsViewer(this); final SMTRunnerTreeStructure structure = new SMTRunnerTreeStructure(myProject, myTestsRootNode); myTreeBuilder = new SMTRunnerTreeBuilder(myTreeView, structure); - StructureTreeModel structureTreeModel = new StructureTreeModel<>(structure, IndexComparator.INSTANCE, myProject); + StructureTreeModel structureTreeModel = new StructureTreeModel<>(structure, IndexComparator.getInstance(), myProject); AsyncTreeModel asyncTreeModel = new AsyncTreeModel(structureTreeModel, true, myProject); myTreeView.setModel(asyncTreeModel); myTreeBuilder.setModel(structureTreeModel); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestFrameworkRunningModel.java b/platform/testRunner/src/com/intellij/execution/testframework/TestFrameworkRunningModel.java index 31215c8512ae..3afe260c7aab 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestFrameworkRunningModel.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestFrameworkRunningModel.java @@ -47,7 +47,7 @@ public interface TestFrameworkRunningModel extends Disposable { }; } else { - comparator = TestConsoleProperties.SORT_ALPHABETICALLY.value(properties) ? AlphaComparator.INSTANCE : null; + comparator = TestConsoleProperties.SORT_ALPHABETICALLY.value(properties) ? AlphaComparator.getInstance() : null; } return comparator; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/HierarchicalFilePathComparator.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/HierarchicalFilePathComparator.java index c14768084dd4..300f188a0da4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/HierarchicalFilePathComparator.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/HierarchicalFilePathComparator.java @@ -37,7 +37,7 @@ public class HierarchicalFilePathComparator implements Comparator { public static final HierarchicalFilePathComparator NATURAL = new HierarchicalFilePathComparator(true) { @Override protected int compareFileNames(@NotNull CharSequence name1, @NotNull CharSequence name2) { - return FileNameComparator.INSTANCE.compare(name1.toString(), name2.toString()); + return FileNameComparator.getInstance().compare(name1.toString(), name2.toString()); } }; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java index adc370c67c0f..441cbe08b011 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java @@ -350,7 +350,7 @@ public abstract class ChangesBrowserNode extends DefaultMutableTreeNode imple } protected static int compareFileNames(@NotNull String name1, @NotNull String name2) { - return FileNameComparator.INSTANCE.compare(name1, name2); + return FileNameComparator.getInstance().compare(name1, name2); } public static int compareFilePaths(@NotNull FilePath path1, @NotNull FilePath path2) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesComparator.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesComparator.java index ba6cd22ec163..797beadda2fa 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesComparator.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesComparator.java @@ -38,7 +38,7 @@ public final class ChangesComparator { private static int comparePaths(@NotNull FilePath filePath1, @NotNull FilePath filePath2, boolean flattened) { if (flattened) { - int delta = FileNameComparator.INSTANCE.compare(filePath1.getName(), filePath2.getName()); + int delta = FileNameComparator.getInstance().compare(filePath1.getName(), filePath2.getName()); if (delta != 0) return delta; } return HierarchicalFilePathComparator.NATURAL.compare(filePath1, filePath2); diff --git a/plugins/commander/src/com/intellij/ide/commander/AbstractListBuilder.java b/plugins/commander/src/com/intellij/ide/commander/AbstractListBuilder.java index 5022d4875229..6a0ab807eeeb 100644 --- a/plugins/commander/src/com/intellij/ide/commander/AbstractListBuilder.java +++ b/plugins/commander/src/com/intellij/ide/commander/AbstractListBuilder.java @@ -365,7 +365,7 @@ public abstract class AbstractListBuilder implements Disposable { resultDescriptors.sort(myComparator); } else { - resultDescriptors.sort(IndexComparator.INSTANCE); + resultDescriptors.sort(IndexComparator.getInstance()); } if (shouldAddTopElement()) { diff --git a/plugins/commander/src/com/intellij/ide/commander/Commander.java b/plugins/commander/src/com/intellij/ide/commander/Commander.java index 26b3029228fb..2150e093287f 100644 --- a/plugins/commander/src/com/intellij/ide/commander/Commander.java +++ b/plugins/commander/src/com/intellij/ide/commander/Commander.java @@ -310,7 +310,7 @@ public class Commander extends JPanel implements PersistentStateComponent, Strin @Override public Comparator> getComparator() { - return AlphaComparator.INSTANCE; + return AlphaComparator.getInstance(); } @Override diff --git a/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java b/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java index 0f89eb7e4208..ef52856d7d51 100644 --- a/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java +++ b/plugins/dev/intellij.dev.psiViewer/src/PsiViewerDialog.java @@ -197,7 +197,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { }); myTreeStructure = new ViewerTreeStructure(myProject); - myStructureTreeModel = new StructureTreeModel<>(myTreeStructure, IndexComparator.INSTANCE, getDisposable()); + myStructureTreeModel = new StructureTreeModel<>(myTreeStructure, IndexComparator.getInstance(), getDisposable()); AsyncTreeModel asyncTreeModel = new AsyncTreeModel(myStructureTreeModel, getDisposable()); myPsiTree.setModel(asyncTreeModel); diff --git a/plugins/dev/intellij.java.dev/src/psiViewer/debug/PsiViewerDebugPanel.kt b/plugins/dev/intellij.java.dev/src/psiViewer/debug/PsiViewerDebugPanel.kt index 7ac36206bc0d..b050b48a46c2 100644 --- a/plugins/dev/intellij.java.dev/src/psiViewer/debug/PsiViewerDebugPanel.kt +++ b/plugins/dev/intellij.java.dev/src/psiViewer/debug/PsiViewerDebugPanel.kt @@ -80,7 +80,7 @@ class PsiViewerDebugPanel( setShowTreeNodes(settings.showTreeNodes) } - private val structureTreeModel = StructureTreeModel(treeStructure, IndexComparator.INSTANCE, this) + private val structureTreeModel = StructureTreeModel(treeStructure, IndexComparator.getInstance(), this) private val psiTree = Tree() diff --git a/python/src/com/jetbrains/python/hierarchy/PyHierarchyUtils.java b/python/src/com/jetbrains/python/hierarchy/PyHierarchyUtils.java index fcca9f0b80f2..27d310b76441 100644 --- a/python/src/com/jetbrains/python/hierarchy/PyHierarchyUtils.java +++ b/python/src/com/jetbrains/python/hierarchy/PyHierarchyUtils.java @@ -17,7 +17,7 @@ public final class PyHierarchyUtils { public static @NotNull Comparator> getComparator(final Project project) { if (HierarchyBrowserManager.getInstance(project).getState().SORT_ALPHABETICALLY) { - return AlphaComparator.INSTANCE; + return AlphaComparator.getInstance(); } else { return NODE_DESCRIPTOR_COMPARATOR;