コード例 #1
0
 public QuickFixAction[] extractActiveFixes(
     final RefEntity[] refElements, final Map<RefEntity, Set<QuickFix>> actions) {
   if (refElements == null) return null;
   Map<Class, QuickFixAction> result = new java.util.HashMap<Class, QuickFixAction>();
   for (RefEntity refElement : refElements) {
     final Set<QuickFix> localQuickFixes = actions.get(refElement);
     if (localQuickFixes != null) {
       for (QuickFix fix : localQuickFixes) {
         if (fix == null) continue;
         final Class klass =
             fix instanceof IntentionWrapper
                 ? ((IntentionWrapper) fix).getAction().getClass()
                 : fix.getClass();
         final QuickFixAction quickFixAction = result.get(klass);
         if (quickFixAction != null) {
           try {
             String familyName = fix.getFamilyName();
             familyName =
                 familyName != null && familyName.length() > 0
                     ? "\'" + familyName + "\'"
                     : familyName;
             ((LocalQuickFixWrapper) quickFixAction)
                 .setText(
                     InspectionsBundle.message(
                         "inspection.descriptor.provider.apply.fix", familyName));
           } catch (AbstractMethodError e) {
             // for plugin compatibility
             ((LocalQuickFixWrapper) quickFixAction)
                 .setText(
                     InspectionsBundle.message("inspection.descriptor.provider.apply.fix", ""));
           }
         } else {
           LocalQuickFixWrapper quickFixWrapper = new LocalQuickFixWrapper(fix, this);
           result.put(klass, quickFixWrapper);
         }
       }
     }
   }
   return result.values().isEmpty()
       ? null
       : result.values().toArray(new QuickFixAction[result.size()]);
 }
 @Override
 @Nullable
 public QuickFixAction[] extractActiveFixes(
     @NotNull RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions) {
   Map<Class, QuickFixAction> result =
       new com.intellij.util.containers.HashMap<Class, QuickFixAction>();
   for (RefEntity refElement : refElements) {
     final Set<QuickFix> localQuickFixes = actions.get(refElement);
     if (localQuickFixes == null) continue;
     for (QuickFix fix : localQuickFixes) {
       if (fix == null) continue;
       final Class klass =
           fix instanceof ActionClassHolder
               ? ((ActionClassHolder) fix).getActionClass()
               : fix.getClass();
       final QuickFixAction quickFixAction = result.get(klass);
       if (quickFixAction != null) {
         try {
           String familyName = fix.getFamilyName();
           familyName = !familyName.isEmpty() ? "\'" + familyName + "\'" : familyName;
           ((LocalQuickFixWrapper) quickFixAction)
               .setText(
                   InspectionsBundle.message(
                       "inspection.descriptor.provider.apply.fix", familyName));
         } catch (AbstractMethodError e) {
           // for plugin compatibility
           ((LocalQuickFixWrapper) quickFixAction)
               .setText(InspectionsBundle.message("inspection.descriptor.provider.apply.fix", ""));
         }
       } else {
         LocalQuickFixWrapper quickFixWrapper = new LocalQuickFixWrapper(fix, myToolWrapper);
         result.put(klass, quickFixWrapper);
       }
     }
   }
   return result.values().isEmpty()
       ? null
       : result.values().toArray(new QuickFixAction[result.size()]);
 }