HighlightDisplayKey: introduce proper getShortName instead of toString

GitOrigin-RevId: 7c6fb37449dbebb6308c3d76f4cbb48bb3cc1392
This commit is contained in:
Max Medvedev
2024-08-09 10:50:25 +02:00
committed by intellij-monorepo-bot
parent 57b9c44e8f
commit c0f11e5298
16 changed files with 72 additions and 55 deletions

View File

@@ -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; package com.intellij.codeInsight.daemon.impl.analysis;
import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.HighlightDisplayKey;
@@ -171,7 +171,7 @@ class UnusedImportsVisitor extends JavaElementVisitor {
String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") : String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") :
JavaAnalysisBundle.message("text.unused.import.in.template"); JavaAnalysisBundle.message("text.unused.import.in.template");
InspectionProfile profile = getCurrentProfile(myFile); 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()); JavaHighlightInfoTypes.UNUSED_IMPORT.getAttributesKey());
HighlightInfoType.HighlightInfoTypeImpl configHighlightType = HighlightInfoType.HighlightInfoTypeImpl configHighlightType =
new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(unusedImportKey, myFile).getSeverity(), key); new HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(unusedImportKey, myFile).getSeverity(), key);

View File

@@ -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; package com.intellij.java.codeInspection;
import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.HighlightDisplayKey;
@@ -43,7 +43,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
final InspectionProfileImpl profile = new InspectionProfileImpl("test") { final InspectionProfileImpl profile = new InspectionProfileImpl("test") {
@Override @Override
public boolean isToolEnabled(final @Nullable HighlightDisplayKey key, PsiElement element) { 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 @Override
@@ -61,7 +61,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
@Override @Override
public boolean isToolEnabled(@Nullable HighlightDisplayKey key, PsiElement element) { 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);
} }
}; };
} }

View File

@@ -469,6 +469,7 @@ f:com.intellij.codeInsight.daemon.HighlightDisplayKey
- s:getAlternativeID(com.intellij.codeInsight.daemon.HighlightDisplayKey):java.lang.String - s:getAlternativeID(com.intellij.codeInsight.daemon.HighlightDisplayKey):java.lang.String
- s:getDisplayNameByKey(com.intellij.codeInsight.daemon.HighlightDisplayKey):java.lang.String - s:getDisplayNameByKey(com.intellij.codeInsight.daemon.HighlightDisplayKey):java.lang.String
- getID():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):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,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 - s:register(java.lang.String,java.lang.String,java.lang.String):com.intellij.codeInsight.daemon.HighlightDisplayKey

View File

@@ -158,6 +158,15 @@ public final class HighlightDisplayKey {
return myShortName; return myShortName;
} }
/**
* @see LocalInspectionTool#getShortName()
*
* @return short name of inspection tool
*/
public String getShortName() {
return myShortName;
}
/** /**
* @see LocalInspectionTool#getID() * @see LocalInspectionTool#getID()
* *

View File

@@ -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; package com.intellij.codeInsight.daemon.impl;
import com.intellij.codeHighlighting.Pass; import com.intellij.codeHighlighting.Pass;
@@ -13,7 +13,10 @@ import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.injected.editor.DocumentWindow; import com.intellij.injected.editor.DocumentWindow;
import com.intellij.lang.ASTNode; 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.lang.injection.InjectedLanguageManager;
import com.intellij.modcommand.ModCommandAction; import com.intellij.modcommand.ModCommandAction;
import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diagnostic.Logger;
@@ -766,7 +769,7 @@ public class HighlightInfo implements Segment {
myCanCleanup = false; myCanCleanup = false;
} }
else { else {
InspectionToolWrapper<?, ?> toolWrapper = profile.getInspectionTool(myKey.toString(), element); InspectionToolWrapper<?, ?> toolWrapper = profile.getInspectionTool(myKey.getShortName(), element);
myCanCleanup = toolWrapper != null && toolWrapper.isCleanupTool(); myCanCleanup = toolWrapper != null && toolWrapper.isCleanupTool();
} }
} }
@@ -806,7 +809,7 @@ public class HighlightInfo implements Segment {
IntentionManager intentionManager = IntentionManager.getInstance(); IntentionManager intentionManager = IntentionManager.getInstance();
List<IntentionAction> newOptions = intentionManager.getStandardIntentionOptions(key, element); List<IntentionAction> newOptions = intentionManager.getStandardIntentionOptions(key, element);
InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getCurrentProfile(); InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getCurrentProfile();
InspectionToolWrapper<?, ?> toolWrapper = profile.getInspectionTool(key.toString(), element); InspectionToolWrapper<?, ?> toolWrapper = profile.getInspectionTool(key.getShortName(), element);
if (toolWrapper != null) { if (toolWrapper != null) {
myCanCleanup = toolWrapper.isCleanupTool(); myCanCleanup = toolWrapper.isCleanupTool();

View File

@@ -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; package com.intellij.codeInspection.ex;
import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeHighlighting.HighlightDisplayLevel;
@@ -185,11 +185,13 @@ public class InspectionProfileImpl extends NewInspectionProfile {
@Override @Override
public @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element) { public @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element) {
Project project = element == null ? null : element.getProject(); 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; HighlightDisplayLevel level = tools != null ? tools.getLevel(element) : HighlightDisplayLevel.WARNING;
if (!myProfileManager.getSeverityRegistrar().isSeverityValid(level.getSeverity().getName())) { if (!myProfileManager.getSeverityRegistrar().isSeverityValid(level.getSeverity().getName())) {
level = HighlightDisplayLevel.WARNING; level = HighlightDisplayLevel.WARNING;
setErrorLevel(inspectionToolKey, level, project); if (tools != null) {
setErrorLevel(inspectionToolKey, level, project);
}
} }
return level; return level;
} }
@@ -708,7 +710,7 @@ public class InspectionProfileImpl extends NewInspectionProfile {
} }
private @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, @Nullable Project project) { private @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, @Nullable Project project) {
return getTools(key.toString(), project).getLevel(); return getTools(key.getShortName(), project).getLevel();
} }
@TestOnly @TestOnly
@@ -757,7 +759,7 @@ public class InspectionProfileImpl extends NewInspectionProfile {
} }
public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, Project project) { 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; mySchemeState = SchemeState.POSSIBLY_CHANGED;
} }
@@ -766,7 +768,7 @@ public class InspectionProfileImpl extends NewInspectionProfile {
if (key == null) { if (key == null) {
return false; 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); 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) { 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) { public void removeScope(@NotNull String toolShortName, @NotNull String scopeName, @NotNull Project project) {
@@ -951,13 +953,13 @@ public class InspectionProfileImpl extends NewInspectionProfile {
@Transient @Transient
public @NotNull HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, @Nullable NamedScope scope, @NotNull Project project) { 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; return tools != null ? tools.getLevel(scope, project) : HighlightDisplayLevel.WARNING;
} }
@Transient @Transient
public @Nullable TextAttributesKey getEditorAttributesKey(@NotNull HighlightDisplayKey key, @Nullable NamedScope scope, @NotNull Project project) { 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; 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) { 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; mySchemeState = SchemeState.POSSIBLY_CHANGED;
} }
@@ -982,7 +984,7 @@ public class InspectionProfileImpl extends NewInspectionProfile {
public void setEditorAttributesKey(@NotNull List<? extends HighlightDisplayKey> keys, @Nullable TextAttributesKey attributesKey, @Nullable String scopeName, @NotNull Project project) { public void setEditorAttributesKey(@NotNull List<? extends HighlightDisplayKey> keys, @Nullable TextAttributesKey attributesKey, @Nullable String scopeName, @NotNull Project project) {
for (HighlightDisplayKey key : keys) { for (HighlightDisplayKey key : keys) {
setEditorAttributesKey(key.toString(), attributesKey == null ? null : attributesKey.getExternalName(), scopeName, project); setEditorAttributesKey(key.getShortName(), attributesKey == null ? null : attributesKey.getExternalName(), scopeName, project);
} }
} }

View File

@@ -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; package com.intellij.codeInsight.daemon.impl;
import com.intellij.codeHighlighting.HighlightDisplayLevel; 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.progress.ProgressManager;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectTypeService; 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.registry.Registry;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
@@ -183,7 +186,7 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
HighlightSeverity severity = highlightInfoType.getSeverity(psiElement); HighlightSeverity severity = highlightInfoType.getSeverity(psiElement);
TextAttributesKey attributesKey = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes(); TextAttributesKey attributesKey = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes();
if (problemDescriptor.getHighlightType() == ProblemHighlightType.GENERIC_ERROR_OR_WARNING && attributesKey == null) { 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()) TextAttributes attributes = attributesKey == null || editorColorsScheme == null || severity.getName().equals(attributesKey.getExternalName())
? severityRegistrar.getTextAttributesBySeverity(severity) ? severityRegistrar.getTextAttributesBySeverity(severity)
@@ -406,7 +409,7 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
if (((ProblemDescriptorBase)descriptor).getEnforcedTextAttributes() != null) { if (((ProblemDescriptorBase)descriptor).getEnforcedTextAttributes() != null) {
needEmptyAction = false; 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); String displayNameByKey = HighlightDisplayKey.getDisplayNameByKey(key);
LOG.assertTrue(displayNameByKey != null, key.toString()); LOG.assertTrue(displayNameByKey != null, key.toString());

View File

@@ -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; package com.intellij.codeInspection.actions;
import com.intellij.analysis.AnalysisScope; import com.intellij.analysis.AnalysisScope;
@@ -40,7 +40,7 @@ public final class RunInspectionIntention implements IntentionAction, HighPriori
private final String myShortName; private final String myShortName;
public RunInspectionIntention(@NotNull HighlightDisplayKey key) { public RunInspectionIntention(@NotNull HighlightDisplayKey key) {
myShortName = key.toString(); myShortName = key.getShortName();
} }
@Override @Override

View File

@@ -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; package com.intellij.codeInspection.ex;
import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.HighlightDisplayKey;
@@ -26,7 +26,7 @@ public class DisableInspectionToolAction extends IntentionAndQuickFixAction impl
} }
public DisableInspectionToolAction(final HighlightDisplayKey key) { public DisableInspectionToolAction(final HighlightDisplayKey key) {
myToolId = key.toString(); myToolId = key.getShortName();
} }
@NotNull @NotNull

View File

@@ -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; package com.intellij.codeInspection.ex;
@@ -26,7 +26,7 @@ public final class EditInspectionToolsSettingsAction implements IntentionAction,
private final String myShortName; private final String myShortName;
public EditInspectionToolsSettingsAction(@NotNull HighlightDisplayKey key) { public EditInspectionToolsSettingsAction(@NotNull HighlightDisplayKey key) {
myShortName = key.toString(); myShortName = key.getShortName();
} }
@Override @Override

View File

@@ -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 package com.intellij.codeInspection.ex
import com.intellij.openapi.components.BaseState 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.ui.tree.TreeUtil
import com.intellij.util.xmlb.annotations.Tag import com.intellij.util.xmlb.annotations.Tag
import com.intellij.util.xmlb.annotations.XCollection import com.intellij.util.xmlb.annotations.XCollection
import java.util.*
import javax.swing.tree.DefaultMutableTreeNode import javax.swing.tree.DefaultMutableTreeNode
import javax.swing.tree.TreePath import javax.swing.tree.TreePath
@@ -71,7 +70,7 @@ internal class VisibleTreeState : BaseState() {
var node = _node var node = _node
val expandedNode: State val expandedNode: State
if (node is InspectionConfigTreeNode.Tool) { if (node is InspectionConfigTreeNode.Tool) {
expandedNode = State(node.key.toString()) expandedNode = State(node.key.shortName)
} }
else { else {
val buf = StringBuilder() val buf = StringBuilder()

View File

@@ -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; package com.intellij.profile.codeInspection.ui;
import com.intellij.analysis.AnalysisBundle; import com.intellij.analysis.AnalysisBundle;
@@ -192,7 +192,7 @@ public class SingleInspectionProfilePanel extends JPanel {
for (int i = 0; i < root.getChildCount(); i++) { for (int i = 0; i < root.getChildCount(); i++) {
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)root.getChildAt(i); final InspectionConfigTreeNode child = (InspectionConfigTreeNode)root.getChildAt(i);
if (child instanceof InspectionConfigTreeNode.Tool) { if (child instanceof InspectionConfigTreeNode.Tool) {
if (((InspectionConfigTreeNode.Tool)child).getKey().toString().equals(name)) { if (((InspectionConfigTreeNode.Tool)child).getKey().getShortName().equals(name)) {
return child; return child;
} }
} }
@@ -238,7 +238,7 @@ public class SingleInspectionProfilePanel extends JPanel {
} else if (forceInclude) return false; } else if (forceInclude) return false;
} }
for (Set<String> keySet : keySetList) { for (Set<String> keySet : keySetList) {
if (keySet.contains(descriptor.getKey().toString())) { if (keySet.contains(descriptor.getKey().getShortName())) {
if (!forceInclude) { if (!forceInclude) {
return true; return true;
} }
@@ -376,7 +376,7 @@ public class SingleInspectionProfilePanel extends JPanel {
private void loadDescriptorsConfigs(boolean onlyModified) { private void loadDescriptorsConfigs(boolean onlyModified) {
myInitialToolDescriptors.values().stream().flatMap(ToolDescriptors::getDescriptors).forEach(d -> { myInitialToolDescriptors.values().stream().flatMap(ToolDescriptors::getDescriptors).forEach(d -> {
if (!onlyModified || myProfile.isProperSetting(d.getKey().toString())) { if (!onlyModified || myProfile.isProperSetting(d.getKey().getShortName())) {
d.loadConfig(); d.loadConfig();
} }
}); });
@@ -405,7 +405,7 @@ public class SingleInspectionProfilePanel extends JPanel {
if (selectionPath != null) { if (selectionPath != null) {
InspectionConfigTreeNode node = (InspectionConfigTreeNode)selectionPath.getLastPathComponent(); InspectionConfigTreeNode node = (InspectionConfigTreeNode)selectionPath.getLastPathComponent();
if (node instanceof InspectionConfigTreeNode.Tool) { 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) { if (node.isProperSetting() != properSetting) {
myAlarm.cancelAllRequests(); myAlarm.cancelAllRequests();
myAlarm.addRequest(() -> myTreeTable.repaint(), 300); myAlarm.addRequest(() -> myTreeTable.repaint(), 300);
@@ -706,7 +706,7 @@ public class SingleInspectionProfilePanel extends JPanel {
private boolean includeDoNotShow(Collection<? extends InspectionConfigTreeNode.Tool> nodes) { private boolean includeDoNotShow(Collection<? extends InspectionConfigTreeNode.Tool> nodes) {
final Project project = getProject(); final Project project = getProject();
return !ContainerUtil.exists(nodes, node -> { 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 && return tool instanceof GlobalInspectionToolWrapper &&
((GlobalInspectionToolWrapper)tool).getSharedLocalInspectionToolWrapper() == null; ((GlobalInspectionToolWrapper)tool).getSharedLocalInspectionToolWrapper() == null;
}); });
@@ -761,7 +761,7 @@ public class SingleInspectionProfilePanel extends JPanel {
final Project project = getProject(); final Project project = getProject();
final InspectionConfigTreeNode.Tool singleNode = myTreeTable.getStrictlySelectedToolNode(); final InspectionConfigTreeNode.Tool singleNode = myTreeTable.getStrictlySelectedToolNode();
final ScopeToolState toolState = singleNode != null ? 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(); boolean showDefaultConfigurationOptions = toolState == null || toolState.getTool().getTool().showDefaultConfigurationOptions();
if (singleNode != null) { if (singleNode != null) {
// Inspection tool node selected // Inspection tool node selected
@@ -803,7 +803,7 @@ public class SingleInspectionProfilePanel extends JPanel {
final Set<String> scopesNames = new HashSet<>(); final Set<String> scopesNames = new HashSet<>();
for (final InspectionConfigTreeNode.Tool node : nodes) { for (final InspectionConfigTreeNode.Tool node : nodes) {
final List<ScopeToolState> nonDefaultTools = myProfile.getNonDefaultTools(node.getDefaultDescriptor().getKey().toString(), project); final List<ScopeToolState> nonDefaultTools = myProfile.getNonDefaultTools(node.getDefaultDescriptor().getKey().getShortName(), project);
for (final ScopeToolState tool : nonDefaultTools) { for (final ScopeToolState tool : nonDefaultTools) {
scopesNames.add(tool.getScopeName()); scopesNames.add(tool.getScopeName());
} }
@@ -845,7 +845,7 @@ public class SingleInspectionProfilePanel extends JPanel {
final NamedScope scope = node.getDefaultDescriptor().getScope(); final NamedScope scope = node.getDefaultDescriptor().getScope();
final boolean doUpdate = myProfile.getEditorAttributesKey(node.getKey(), scope, project) != key; final boolean doUpdate = myProfile.getEditorAttributesKey(node.getKey(), scope, project) != key;
if (doUpdate) { if (doUpdate) {
myProfile.setEditorAttributesKey(node.getKey().toString(), key.getExternalName(), null, project); myProfile.setEditorAttributesKey(node.getKey().getShortName(), key.getExternalName(), null, project);
toUpdate.add(node); toUpdate.add(node);
} }
} }
@@ -873,7 +873,7 @@ public class SingleInspectionProfilePanel extends JPanel {
|| myProfile.getEditorAttributesKey(key, scope, project) != null; || myProfile.getEditorAttributesKey(key, scope, project) != null;
if (doUpdate) { if (doUpdate) {
myProfile.setErrorLevel(key, level, null, project); 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); updateHighlightingChooser(nodes, project, highlightingChooser);
toUpdate.add(node); toUpdate.add(node);
} }
@@ -1046,7 +1046,7 @@ public class SingleInspectionProfilePanel extends JPanel {
private boolean isThoughOneNodeEnabled(Collection<? extends InspectionConfigTreeNode.Tool> nodes) { private boolean isThoughOneNodeEnabled(Collection<? extends InspectionConfigTreeNode.Tool> nodes) {
final Project project = getProject(); final Project project = getProject();
for (final InspectionConfigTreeNode.Tool node : nodes) { for (final InspectionConfigTreeNode.Tool node : nodes) {
final String toolId = node.getKey().toString(); final String toolId = node.getKey().getShortName();
if (myProfile.getTools(toolId, project).isEnabled()) { if (myProfile.getTools(toolId, project).isEnabled()) {
return true; return true;
} }
@@ -1310,7 +1310,7 @@ public class SingleInspectionProfilePanel extends JPanel {
} }
} }
final List<ScopeToolState> tools = profile.getNonDefaultTools(desc.getKey().toString(), project); final List<ScopeToolState> tools = profile.getNonDefaultTools(desc.getKey().getShortName(), project);
if (tools.size() != descriptors.size()) { if (tools.size() != descriptors.size()) {
return true; return true;
} }

View File

@@ -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; package com.intellij.profile.codeInspection.ui.inspectionsTree;
import com.intellij.analysis.AnalysisBundle; import com.intellij.analysis.AnalysisBundle;
@@ -252,7 +252,7 @@ public final class InspectionsConfigTreeTable extends TreeTable {
else { else {
final MultiColoredHighlightSeverityIconSink sink = new MultiColoredHighlightSeverityIconSink(); final MultiColoredHighlightSeverityIconSink sink = new MultiColoredHighlightSeverityIconSink();
for (final HighlightDisplayKey selectedInspectionsNode : inspectionsKeys) { for (final HighlightDisplayKey selectedInspectionsNode : inspectionsKeys) {
final String toolId = selectedInspectionsNode.toString(); final String toolId = selectedInspectionsNode.getShortName();
if (mySettings.getInspectionProfile().getTools(toolId, mySettings.getProject()).isEnabled()) { if (mySettings.getInspectionProfile().getTools(toolId, mySettings.getProject()).isEnabled()) {
sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()), sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()),
mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject())); mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject()));
@@ -271,7 +271,7 @@ public final class InspectionsConfigTreeTable extends TreeTable {
private Boolean isEnabled(@NotNull List<HighlightDisplayKey> selectedInspectionsNodes) { private Boolean isEnabled(@NotNull List<HighlightDisplayKey> selectedInspectionsNodes) {
return selectedInspectionsNodes return selectedInspectionsNodes
.stream() .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)) .flatMap(tools -> tools.isEnabled() ? tools.getTools().stream().map(ScopeToolState::isEnabled) : Stream.of(false))
.distinct() .distinct()
.collect(MoreCollectors.onlyOne()).orElse(null); .collect(MoreCollectors.onlyOne()).orElse(null);
@@ -292,7 +292,7 @@ public final class InspectionsConfigTreeTable extends TreeTable {
final InspectionProfileImpl profile = mySettings.getInspectionProfile(); final InspectionProfileImpl profile = mySettings.getInspectionProfile();
for (final InspectionConfigTreeNode.Tool aNode : InspectionsAggregationUtil.getInspectionsNodes((InspectionConfigTreeNode)node)) { 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); mySettings.onChanged(aNode);
} }
updateRightPanel(); updateRightPanel();
@@ -327,7 +327,7 @@ public final class InspectionsConfigTreeTable extends TreeTable {
final InspectionProfileImpl profile = mySettings.getInspectionProfile(); final InspectionProfileImpl profile = mySettings.getInspectionProfile();
for (HighlightDisplayKey tool : tools) { for (HighlightDisplayKey tool : tools) {
InspectionProfileImpl.setToolEnabled(newState, profile, tool.toString(), mySettings.getProject()); InspectionProfileImpl.setToolEnabled(newState, profile, tool.getShortName(), mySettings.getProject());
} }
for (InspectionConfigTreeNode node : nodes) { for (InspectionConfigTreeNode node : nodes) {

View File

@@ -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; package com.intellij.profile.codeInspection.ui.table;
import com.intellij.application.options.colors.ColorAndFontOptions; import com.intellij.application.options.colors.ColorAndFontOptions;
@@ -182,7 +182,7 @@ public final class ScopesAndSeveritiesTable extends JBTable {
for(final InspectionConfigTreeNode.Tool node : nodes) { for(final InspectionConfigTreeNode.Tool node : nodes) {
final HighlightDisplayKey key = node.getKey(); final HighlightDisplayKey key = node.getKey();
myKeys.add(key); myKeys.add(key);
myKeyNames.add(key.toString()); myKeyNames.add(key.getShortName());
} }
myInspectionProfile = inspectionProfile; myInspectionProfile = inspectionProfile;

View File

@@ -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 package org.jetbrains.kotlin.idea.highlighting
import com.intellij.codeInsight.daemon.HighlightDisplayKey import com.intellij.codeInsight.daemon.HighlightDisplayKey
@@ -53,7 +53,7 @@ class KotlinUnusedHighlightingVisitor(private val ktFile: KtFile) {
deadCodeInfoType = if (deadCodeKey == null) null else deadCodeInfoType = if (deadCodeKey == null) null else
HighlightInfoType.HighlightInfoTypeImpl( HighlightInfoType.HighlightInfoTypeImpl(
profile.getErrorLevel(deadCodeKey, ktFile).severity, 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 enabled = deadCodeInspection != null
&& deadCodeInfoType != null && deadCodeInfoType != null

View File

@@ -141,7 +141,7 @@ public class SpellCheckingEditorCustomization extends SimpleEditorCustomization
@Override @Override
public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) { 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));
} }
} }
} }