From 9800c43aa57d2a592544dc05fcd9a3291b617dc5 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 14 Jul 2016 14:52:46 +0300 Subject: [PATCH] inspection view: use getFamilyName() for fixes grouping IDEA-155841 --- .../ui/DefaultInspectionToolPresentation.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java index d1265d2c0652..0dca01963e3b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java @@ -618,7 +618,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro @NotNull Map descriptorMap, @Nullable CommonProblemDescriptor[] allowedDescriptors) { final Set allowedDescriptorSet = allowedDescriptors == null ? null : ContainerUtil.newHashSet(allowedDescriptors); - Map result = new com.intellij.util.containers.HashMap<>(); + Map result = new com.intellij.util.containers.HashMap<>(); boolean isFirst = true; for (RefEntity refElement : refElements) { final CommonProblemDescriptor[] descriptors = descriptorMap.get(refElement); @@ -632,34 +632,34 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro if (isFirst) { for (QuickFix fix : fixes) { if (fix == null) continue; - final Class klass = getFixClass(fix); LocalQuickFixWrapper quickFixWrapper = new LocalQuickFixWrapper(fix, myToolWrapper); - result.put(klass, quickFixWrapper); + result.put(fix.getFamilyName(), quickFixWrapper); } isFirst = false; } else { - for (Class clazz : new ArrayList<>(result.keySet())) { + for (String familyName : new ArrayList<>(result.keySet())) { boolean isFound = false; for (QuickFix fix : fixes) { if (fix == null) continue; - final Class klass = getFixClass(fix); - if (clazz.equals(klass)) { + if (familyName.equals(fix.getFamilyName())) { isFound = true; - final QuickFixAction quickFixAction = result.get(clazz); + final LocalQuickFixWrapper quickFixAction = result.get(fix.getFamilyName()); + LOG.assertTrue(getFixClass(fix).equals(getFixClass(quickFixAction.getFix())), + "QuickFix-es with the same getFamilyName() should be the same class instances. " + + "Please assign reported exception for the fix \"" + fix.getClass().getName() + "\" developer"); try { - String familyName = fix.getFamilyName(); - ((LocalQuickFixWrapper)quickFixAction).setText(StringUtil.escapeMnemonics(familyName)); + quickFixAction.setText(StringUtil.escapeMnemonics(fix.getFamilyName())); } catch (AbstractMethodError e) { //for plugin compatibility - ((LocalQuickFixWrapper)quickFixAction).setText("Name is not available"); + quickFixAction.setText("Name is not available"); } break; } } if (!isFound) { - result.remove(clazz); + result.remove(familyName); if (result.isEmpty()) { return QuickFixAction.EMPTY; }