From c0f11e5298a11715e1beb5b5151a9468b1113dde Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Fri, 9 Aug 2024 10:50:25 +0200 Subject: [PATCH] HighlightDisplayKey: introduce proper getShortName instead of toString GitOrigin-RevId: 7c6fb37449dbebb6308c3d76f4cbb48bb3cc1392 --- .../impl/analysis/UnusedImportsVisitor.java | 4 ++-- .../OfflineInspectionResultViewTest.java | 6 ++--- platform/analysis-api/api-dump-unreviewed.txt | 1 + .../daemon/HighlightDisplayKey.java | 9 +++++++ .../daemon/impl/HighlightInfo.java | 11 +++++---- .../ex/InspectionProfileImpl.java | 24 ++++++++++--------- .../daemon/impl/LocalInspectionsPass.java | 11 +++++---- .../actions/RunInspectionIntention.java | 4 ++-- .../ex/DisableInspectionToolAction.java | 4 ++-- .../ex/EditInspectionToolsSettingsAction.java | 4 ++-- .../codeInspection/ex/VisibleTreeState.kt | 5 ++-- .../ui/SingleInspectionProfilePanel.java | 24 +++++++++---------- .../InspectionsConfigTreeTable.java | 10 ++++---- .../ui/table/ScopesAndSeveritiesTable.java | 4 ++-- .../KotlinUnusedHighlightingVisitor.kt | 4 ++-- .../ui/SpellCheckingEditorCustomization.java | 2 +- 16 files changed, 72 insertions(+), 55 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/UnusedImportsVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/UnusedImportsVisitor.java index 017ef6375602..aa5eb865a7a4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/UnusedImportsVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/UnusedImportsVisitor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.daemon.HighlightDisplayKey; @@ -171,7 +171,7 @@ class UnusedImportsVisitor extends JavaElementVisitor { String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") : JavaAnalysisBundle.message("text.unused.import.in.template"); InspectionProfile profile = getCurrentProfile(myFile); - TextAttributesKey key = ObjectUtils.notNull(profile.getEditorAttributes(unusedImportKey.toString(), myFile), + TextAttributesKey key = ObjectUtils.notNull(profile.getEditorAttributes(unusedImportKey.getShortName(), myFile), JavaHighlightInfoTypes.UNUSED_IMPORT.getAttributesKey()); HighlightInfoType.HighlightInfoTypeImpl configHighlightType = new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(unusedImportKey, myFile).getSeverity(), key); diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/OfflineInspectionResultViewTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/OfflineInspectionResultViewTest.java index ac09eb49fde4..3e6a96f3a7ed 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/OfflineInspectionResultViewTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/OfflineInspectionResultViewTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.java.codeInspection; import com.intellij.codeInsight.daemon.HighlightDisplayKey; @@ -43,7 +43,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase { final InspectionProfileImpl profile = new InspectionProfileImpl("test") { @Override public boolean isToolEnabled(final @Nullable HighlightDisplayKey key, PsiElement element) { - return key != null && Comparing.strEqual(key.toString(), UnusedDeclarationInspectionBase.SHORT_NAME); + return key != null && Comparing.strEqual(key.getShortName(), UnusedDeclarationInspectionBase.SHORT_NAME); } @Override @@ -61,7 +61,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase { @Override public boolean isToolEnabled(@Nullable HighlightDisplayKey key, PsiElement element) { - return key != null && Comparing.strEqual(key.toString(), UnusedDeclarationInspectionBase.SHORT_NAME); + return key != null && Comparing.strEqual(key.getShortName(), UnusedDeclarationInspectionBase.SHORT_NAME); } }; } diff --git a/platform/analysis-api/api-dump-unreviewed.txt b/platform/analysis-api/api-dump-unreviewed.txt index daf1824893ff..4ca0a23c3cec 100644 --- a/platform/analysis-api/api-dump-unreviewed.txt +++ b/platform/analysis-api/api-dump-unreviewed.txt @@ -469,6 +469,7 @@ f:com.intellij.codeInsight.daemon.HighlightDisplayKey - s:getAlternativeID(com.intellij.codeInsight.daemon.HighlightDisplayKey):java.lang.String - s:getDisplayNameByKey(com.intellij.codeInsight.daemon.HighlightDisplayKey):java.lang.String - getID():java.lang.String +- getShortName():java.lang.String - s:register(java.lang.String,com.intellij.openapi.util.Computable,java.lang.String):com.intellij.codeInsight.daemon.HighlightDisplayKey - s:register(java.lang.String,com.intellij.openapi.util.Computable,java.lang.String,java.lang.String):com.intellij.codeInsight.daemon.HighlightDisplayKey - s:register(java.lang.String,java.lang.String,java.lang.String):com.intellij.codeInsight.daemon.HighlightDisplayKey diff --git a/platform/analysis-api/src/com/intellij/codeInsight/daemon/HighlightDisplayKey.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/HighlightDisplayKey.java index 02cbe5d3355f..edcf917ed0a2 100644 --- a/platform/analysis-api/src/com/intellij/codeInsight/daemon/HighlightDisplayKey.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/HighlightDisplayKey.java @@ -158,6 +158,15 @@ public final class HighlightDisplayKey { return myShortName; } + /** + * @see LocalInspectionTool#getShortName() + * + * @return short name of inspection tool + */ + public String getShortName() { + return myShortName; + } + /** * @see LocalInspectionTool#getID() * diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java index d41a49aaeeb0..6785078edce1 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.Pass; @@ -13,7 +13,10 @@ import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.injected.editor.DocumentWindow; import com.intellij.lang.ASTNode; -import com.intellij.lang.annotation.*; +import com.intellij.lang.annotation.Annotation; +import com.intellij.lang.annotation.ExternalAnnotator; +import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.lang.annotation.ProblemGroup; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.modcommand.ModCommandAction; import com.intellij.openapi.diagnostic.Logger; @@ -766,7 +769,7 @@ public class HighlightInfo implements Segment { myCanCleanup = false; } else { - InspectionToolWrapper toolWrapper = profile.getInspectionTool(myKey.toString(), element); + InspectionToolWrapper toolWrapper = profile.getInspectionTool(myKey.getShortName(), element); myCanCleanup = toolWrapper != null && toolWrapper.isCleanupTool(); } } @@ -806,7 +809,7 @@ public class HighlightInfo implements Segment { IntentionManager intentionManager = IntentionManager.getInstance(); List newOptions = intentionManager.getStandardIntentionOptions(key, element); InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getCurrentProfile(); - InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.toString(), element); + InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.getShortName(), element); if (toolWrapper != null) { myCanCleanup = toolWrapper.isCleanupTool(); diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index cbef0f9a1227..a62bb4ae8fc1 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.ex; import com.intellij.codeHighlighting.HighlightDisplayLevel; @@ -185,11 +185,13 @@ public class InspectionProfileImpl extends NewInspectionProfile { @Override public @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element) { Project project = element == null ? null : element.getProject(); - ToolsImpl tools = getToolsOrNull(inspectionToolKey.toString(), project); + ToolsImpl tools = getToolsOrNull(inspectionToolKey.getShortName(), project); HighlightDisplayLevel level = tools != null ? tools.getLevel(element) : HighlightDisplayLevel.WARNING; if (!myProfileManager.getSeverityRegistrar().isSeverityValid(level.getSeverity().getName())) { level = HighlightDisplayLevel.WARNING; - setErrorLevel(inspectionToolKey, level, project); + if (tools != null) { + setErrorLevel(inspectionToolKey, level, project); + } } return level; } @@ -708,7 +710,7 @@ public class InspectionProfileImpl extends NewInspectionProfile { } private @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, @Nullable Project project) { - return getTools(key.toString(), project).getLevel(); + return getTools(key.getShortName(), project).getLevel(); } @TestOnly @@ -757,7 +759,7 @@ public class InspectionProfileImpl extends NewInspectionProfile { } public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, Project project) { - getTools(key.toString(), project).setLevel(level); + getTools(key.getShortName(), project).setLevel(level); mySchemeState = SchemeState.POSSIBLY_CHANGED; } @@ -766,7 +768,7 @@ public class InspectionProfileImpl extends NewInspectionProfile { if (key == null) { return false; } - Tools toolState = getToolsOrNull(key.toString(), element == null ? null : element.getProject()); + Tools toolState = getToolsOrNull(key.getShortName(), element == null ? null : element.getProject()); return toolState != null && toolState.isEnabled(element); } @@ -902,7 +904,7 @@ public class InspectionProfileImpl extends NewInspectionProfile { } public boolean isToolEnabled(@NotNull HighlightDisplayKey key, @Nullable NamedScope namedScope, @NotNull Project project) { - return getTools(key.toString(), project).isEnabled(namedScope,project); + return getTools(key.getShortName(), project).isEnabled(namedScope,project); } public void removeScope(@NotNull String toolShortName, @NotNull String scopeName, @NotNull Project project) { @@ -951,13 +953,13 @@ public class InspectionProfileImpl extends NewInspectionProfile { @Transient public @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, @Nullable NamedScope scope, @NotNull Project project) { - ToolsImpl tools = getToolsOrNull(key.toString(), project); + ToolsImpl tools = getToolsOrNull(key.getShortName(), project); return tools != null ? tools.getLevel(scope, project) : HighlightDisplayLevel.WARNING; } @Transient public @Nullable TextAttributesKey getEditorAttributesKey(@NotNull HighlightDisplayKey key, @Nullable NamedScope scope, @NotNull Project project) { - ToolsImpl tools = getToolsOrNull(key.toString(), project); + ToolsImpl tools = getToolsOrNull(key.getShortName(), project); return tools != null ? tools.getEditorAttributesKey(scope, project) : null; } @@ -970,7 +972,7 @@ public class InspectionProfileImpl extends NewInspectionProfile { } public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, @Nullable String scopeName, @NotNull Project project) { - getTools(key.toString(), project).setLevel(level, scopeName, project); + getTools(key.getShortName(), project).setLevel(level, scopeName, project); mySchemeState = SchemeState.POSSIBLY_CHANGED; } @@ -982,7 +984,7 @@ public class InspectionProfileImpl extends NewInspectionProfile { public void setEditorAttributesKey(@NotNull List keys, @Nullable TextAttributesKey attributesKey, @Nullable String scopeName, @NotNull Project project) { for (HighlightDisplayKey key : keys) { - setEditorAttributesKey(key.toString(), attributesKey == null ? null : attributesKey.getExternalName(), scopeName, project); + setEditorAttributesKey(key.getShortName(), attributesKey == null ? null : attributesKey.getExternalName(), scopeName, project); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 3e7da10fa78c..900a1dc5de9b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.HighlightDisplayLevel; @@ -28,7 +28,10 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectTypeService; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.NlsContexts; +import com.intellij.openapi.util.NlsSafe; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; @@ -183,7 +186,7 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass HighlightSeverity severity = highlightInfoType.getSeverity(psiElement); TextAttributesKey attributesKey = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes(); if (problemDescriptor.getHighlightType() == ProblemHighlightType.GENERIC_ERROR_OR_WARNING && attributesKey == null) { - attributesKey = myProfileWrapper.getInspectionProfile().getEditorAttributes(key.toString(), getFile()); + attributesKey = myProfileWrapper.getInspectionProfile().getEditorAttributes(key.getShortName(), getFile()); } TextAttributes attributes = attributesKey == null || editorColorsScheme == null || severity.getName().equals(attributesKey.getExternalName()) ? severityRegistrar.getTextAttributesBySeverity(severity) @@ -406,7 +409,7 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass if (((ProblemDescriptorBase)descriptor).getEnforcedTextAttributes() != null) { needEmptyAction = false; } - if (needEmptyAction && emptyActionRegistered.add(Pair.create(((ProblemDescriptorBase)descriptor).getTextRange(), key.toString()))) { + if (needEmptyAction && emptyActionRegistered.add(Pair.create(((ProblemDescriptorBase)descriptor).getTextRange(), key.getShortName()))) { String displayNameByKey = HighlightDisplayKey.getDisplayNameByKey(key); LOG.assertTrue(displayNameByKey != null, key.toString()); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java index 114f0f3123e6..7001741edc3e 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.actions; import com.intellij.analysis.AnalysisScope; @@ -40,7 +40,7 @@ public final class RunInspectionIntention implements IntentionAction, HighPriori private final String myShortName; public RunInspectionIntention(@NotNull HighlightDisplayKey key) { - myShortName = key.toString(); + myShortName = key.getShortName(); } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java index c23586db2608..76735d6359d7 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.ex; import com.intellij.codeInsight.daemon.HighlightDisplayKey; @@ -26,7 +26,7 @@ public class DisableInspectionToolAction extends IntentionAndQuickFixAction impl } public DisableInspectionToolAction(final HighlightDisplayKey key) { - myToolId = key.toString(); + myToolId = key.getShortName(); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java index 9fd3ea25e781..29aa548b2629 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.ex; @@ -26,7 +26,7 @@ public final class EditInspectionToolsSettingsAction implements IntentionAction, private final String myShortName; public EditInspectionToolsSettingsAction(@NotNull HighlightDisplayKey key) { - myShortName = key.toString(); + myShortName = key.getShortName(); } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/VisibleTreeState.kt b/platform/lang-impl/src/com/intellij/codeInspection/ex/VisibleTreeState.kt index bb4fb966dda5..4fd5090285d5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/VisibleTreeState.kt +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/VisibleTreeState.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.ex import com.intellij.openapi.components.BaseState @@ -8,7 +8,6 @@ import com.intellij.ui.treeStructure.Tree import com.intellij.util.ui.tree.TreeUtil import com.intellij.util.xmlb.annotations.Tag import com.intellij.util.xmlb.annotations.XCollection -import java.util.* import javax.swing.tree.DefaultMutableTreeNode import javax.swing.tree.TreePath @@ -71,7 +70,7 @@ internal class VisibleTreeState : BaseState() { var node = _node val expandedNode: State if (node is InspectionConfigTreeNode.Tool) { - expandedNode = State(node.key.toString()) + expandedNode = State(node.key.shortName) } else { val buf = StringBuilder() diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 010b3e125d81..0cd9e6fd93ba 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.profile.codeInspection.ui; import com.intellij.analysis.AnalysisBundle; @@ -192,7 +192,7 @@ public class SingleInspectionProfilePanel extends JPanel { for (int i = 0; i < root.getChildCount(); i++) { final InspectionConfigTreeNode child = (InspectionConfigTreeNode)root.getChildAt(i); if (child instanceof InspectionConfigTreeNode.Tool) { - if (((InspectionConfigTreeNode.Tool)child).getKey().toString().equals(name)) { + if (((InspectionConfigTreeNode.Tool)child).getKey().getShortName().equals(name)) { return child; } } @@ -238,7 +238,7 @@ public class SingleInspectionProfilePanel extends JPanel { } else if (forceInclude) return false; } for (Set keySet : keySetList) { - if (keySet.contains(descriptor.getKey().toString())) { + if (keySet.contains(descriptor.getKey().getShortName())) { if (!forceInclude) { return true; } @@ -376,7 +376,7 @@ public class SingleInspectionProfilePanel extends JPanel { private void loadDescriptorsConfigs(boolean onlyModified) { myInitialToolDescriptors.values().stream().flatMap(ToolDescriptors::getDescriptors).forEach(d -> { - if (!onlyModified || myProfile.isProperSetting(d.getKey().toString())) { + if (!onlyModified || myProfile.isProperSetting(d.getKey().getShortName())) { d.loadConfig(); } }); @@ -405,7 +405,7 @@ public class SingleInspectionProfilePanel extends JPanel { if (selectionPath != null) { InspectionConfigTreeNode node = (InspectionConfigTreeNode)selectionPath.getLastPathComponent(); if (node instanceof InspectionConfigTreeNode.Tool) { - final boolean properSetting = myProfile.isProperSetting(((InspectionConfigTreeNode.Tool)node).getKey().toString()); + final boolean properSetting = myProfile.isProperSetting(((InspectionConfigTreeNode.Tool)node).getKey().getShortName()); if (node.isProperSetting() != properSetting) { myAlarm.cancelAllRequests(); myAlarm.addRequest(() -> myTreeTable.repaint(), 300); @@ -706,7 +706,7 @@ public class SingleInspectionProfilePanel extends JPanel { private boolean includeDoNotShow(Collection nodes) { final Project project = getProject(); return !ContainerUtil.exists(nodes, node -> { - final InspectionToolWrapper tool = myProfile.getToolDefaultState(node.getKey().toString(), project).getTool(); + final InspectionToolWrapper tool = myProfile.getToolDefaultState(node.getKey().getShortName(), project).getTool(); return tool instanceof GlobalInspectionToolWrapper && ((GlobalInspectionToolWrapper)tool).getSharedLocalInspectionToolWrapper() == null; }); @@ -761,7 +761,7 @@ public class SingleInspectionProfilePanel extends JPanel { final Project project = getProject(); final InspectionConfigTreeNode.Tool singleNode = myTreeTable.getStrictlySelectedToolNode(); final ScopeToolState toolState = singleNode != null ? - myProfile.getToolDefaultState(singleNode.getDefaultDescriptor().getKey().toString(), project) : null; + myProfile.getToolDefaultState(singleNode.getDefaultDescriptor().getKey().getShortName(), project) : null; boolean showDefaultConfigurationOptions = toolState == null || toolState.getTool().getTool().showDefaultConfigurationOptions(); if (singleNode != null) { // Inspection tool node selected @@ -803,7 +803,7 @@ public class SingleInspectionProfilePanel extends JPanel { final Set scopesNames = new HashSet<>(); for (final InspectionConfigTreeNode.Tool node : nodes) { - final List nonDefaultTools = myProfile.getNonDefaultTools(node.getDefaultDescriptor().getKey().toString(), project); + final List nonDefaultTools = myProfile.getNonDefaultTools(node.getDefaultDescriptor().getKey().getShortName(), project); for (final ScopeToolState tool : nonDefaultTools) { scopesNames.add(tool.getScopeName()); } @@ -845,7 +845,7 @@ public class SingleInspectionProfilePanel extends JPanel { final NamedScope scope = node.getDefaultDescriptor().getScope(); final boolean doUpdate = myProfile.getEditorAttributesKey(node.getKey(), scope, project) != key; if (doUpdate) { - myProfile.setEditorAttributesKey(node.getKey().toString(), key.getExternalName(), null, project); + myProfile.setEditorAttributesKey(node.getKey().getShortName(), key.getExternalName(), null, project); toUpdate.add(node); } } @@ -873,7 +873,7 @@ public class SingleInspectionProfilePanel extends JPanel { || myProfile.getEditorAttributesKey(key, scope, project) != null; if (doUpdate) { myProfile.setErrorLevel(key, level, null, project); - myProfile.setEditorAttributesKey(node.getKey().toString(), null, null, project); + myProfile.setEditorAttributesKey(node.getKey().getShortName(), null, null, project); updateHighlightingChooser(nodes, project, highlightingChooser); toUpdate.add(node); } @@ -1046,7 +1046,7 @@ public class SingleInspectionProfilePanel extends JPanel { private boolean isThoughOneNodeEnabled(Collection nodes) { final Project project = getProject(); for (final InspectionConfigTreeNode.Tool node : nodes) { - final String toolId = node.getKey().toString(); + final String toolId = node.getKey().getShortName(); if (myProfile.getTools(toolId, project).isEnabled()) { return true; } @@ -1310,7 +1310,7 @@ public class SingleInspectionProfilePanel extends JPanel { } } - final List tools = profile.getNonDefaultTools(desc.getKey().toString(), project); + final List tools = profile.getNonDefaultTools(desc.getKey().getShortName(), project); if (tools.size() != descriptors.size()) { return true; } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java index 47eb21f1333b..2a1719fbfcdd 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.profile.codeInspection.ui.inspectionsTree; import com.intellij.analysis.AnalysisBundle; @@ -252,7 +252,7 @@ public final class InspectionsConfigTreeTable extends TreeTable { else { final MultiColoredHighlightSeverityIconSink sink = new MultiColoredHighlightSeverityIconSink(); for (final HighlightDisplayKey selectedInspectionsNode : inspectionsKeys) { - final String toolId = selectedInspectionsNode.toString(); + final String toolId = selectedInspectionsNode.getShortName(); if (mySettings.getInspectionProfile().getTools(toolId, mySettings.getProject()).isEnabled()) { sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()), mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject())); @@ -271,7 +271,7 @@ public final class InspectionsConfigTreeTable extends TreeTable { private Boolean isEnabled(@NotNull List selectedInspectionsNodes) { return selectedInspectionsNodes .stream() - .map(key -> mySettings.getInspectionProfile().getTools(key.toString(), mySettings.getProject())) + .map(key -> mySettings.getInspectionProfile().getTools(key.getShortName(), mySettings.getProject())) .flatMap(tools -> tools.isEnabled() ? tools.getTools().stream().map(ScopeToolState::isEnabled) : Stream.of(false)) .distinct() .collect(MoreCollectors.onlyOne()).orElse(null); @@ -292,7 +292,7 @@ public final class InspectionsConfigTreeTable extends TreeTable { final InspectionProfileImpl profile = mySettings.getInspectionProfile(); for (final InspectionConfigTreeNode.Tool aNode : InspectionsAggregationUtil.getInspectionsNodes((InspectionConfigTreeNode)node)) { - InspectionProfileImpl.setToolEnabled(doEnable, profile, aNode.getKey().toString(), mySettings.getProject()); + InspectionProfileImpl.setToolEnabled(doEnable, profile, aNode.getKey().getShortName(), mySettings.getProject()); mySettings.onChanged(aNode); } updateRightPanel(); @@ -327,7 +327,7 @@ public final class InspectionsConfigTreeTable extends TreeTable { final InspectionProfileImpl profile = mySettings.getInspectionProfile(); for (HighlightDisplayKey tool : tools) { - InspectionProfileImpl.setToolEnabled(newState, profile, tool.toString(), mySettings.getProject()); + InspectionProfileImpl.setToolEnabled(newState, profile, tool.getShortName(), mySettings.getProject()); } for (InspectionConfigTreeNode node : nodes) { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java index 2d14ae81aabb..fbbb739657bc 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.profile.codeInspection.ui.table; import com.intellij.application.options.colors.ColorAndFontOptions; @@ -182,7 +182,7 @@ public final class ScopesAndSeveritiesTable extends JBTable { for(final InspectionConfigTreeNode.Tool node : nodes) { final HighlightDisplayKey key = node.getKey(); myKeys.add(key); - myKeyNames.add(key.toString()); + myKeyNames.add(key.getShortName()); } myInspectionProfile = inspectionProfile; diff --git a/plugins/kotlin/highlighting/highlighting-k2/src/org/jetbrains/kotlin/idea/highlighting/KotlinUnusedHighlightingVisitor.kt b/plugins/kotlin/highlighting/highlighting-k2/src/org/jetbrains/kotlin/idea/highlighting/KotlinUnusedHighlightingVisitor.kt index 39ba91284ce0..d0b9a303b76b 100644 --- a/plugins/kotlin/highlighting/highlighting-k2/src/org/jetbrains/kotlin/idea/highlighting/KotlinUnusedHighlightingVisitor.kt +++ b/plugins/kotlin/highlighting/highlighting-k2/src/org/jetbrains/kotlin/idea/highlighting/KotlinUnusedHighlightingVisitor.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.highlighting import com.intellij.codeInsight.daemon.HighlightDisplayKey @@ -53,7 +53,7 @@ class KotlinUnusedHighlightingVisitor(private val ktFile: KtFile) { deadCodeInfoType = if (deadCodeKey == null) null else HighlightInfoType.HighlightInfoTypeImpl( profile.getErrorLevel(deadCodeKey, ktFile).severity, - ((profile.getEditorAttributes(deadCodeKey.toString(), ktFile)) ?: HighlightInfoType.UNUSED_SYMBOL.getAttributesKey()) + ((profile.getEditorAttributes(deadCodeKey.shortName, ktFile)) ?: HighlightInfoType.UNUSED_SYMBOL.getAttributesKey()) ) enabled = deadCodeInspection != null && deadCodeInfoType != null diff --git a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java index 46648979dec6..2910eb9da1d5 100644 --- a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java +++ b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java @@ -141,7 +141,7 @@ public class SpellCheckingEditorCustomization extends SimpleEditorCustomization @Override public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) { - return (key != null && SPELL_CHECK_TOOLS.containsKey(key.toString()) ? myUseSpellCheck : super.isToolEnabled(key, element)); + return (key != null && SPELL_CHECK_TOOLS.containsKey(key.getShortName()) ? myUseSpellCheck : super.isToolEnabled(key, element)); } } }