コード例 #1
0
 private void appendSuppressSection(final StringBuffer buf) {
   final InspectionTool tool = getTool();
   if (tool != null) {
     final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
     if (key != null) { // dummy entry points
       final SuppressActionWrapper.SuppressTreeAction[] suppressActions =
           new SuppressActionWrapper(
                   myView.getProject(), tool, myView.getTree().getSelectionPaths())
               .getChildren(null);
       if (suppressActions.length > 0) {
         final List<AnAction> activeSuppressActions = new ArrayList<AnAction>();
         for (SuppressActionWrapper.SuppressTreeAction suppressAction : suppressActions) {
           if (suppressAction.isAvailable()) {
             activeSuppressActions.add(suppressAction);
           }
         }
         if (!activeSuppressActions.isEmpty()) {
           int idx = 0;
           @NonNls final String br = "<br>";
           buf.append(br);
           HTMLComposerImpl.appendHeading(
               buf, InspectionsBundle.message("inspection.export.results.suppress"));
           for (AnAction suppressAction : activeSuppressActions) {
             buf.append(br);
             if (idx == activeSuppressActions.size() - 1) {
               buf.append(br);
             }
             HTMLComposer.appendAfterHeaderIndention(buf);
             @NonNls
             final String href =
                 "<a HREF=\"file://bred.txt#suppress:"
                     + idx
                     + "\">"
                     + suppressAction.getTemplatePresentation().getText()
                     + "</a>";
             buf.append(href);
             idx++;
           }
         }
       }
     }
   }
 }
コード例 #2
0
 private void performFix(
     final RefEntity element,
     final CommonProblemDescriptor descriptor,
     final int idx,
     final QuickFix fix) {
   final Runnable command =
       new Runnable() {
         @Override
         public void run() {
           ApplicationManager.getApplication()
               .runWriteAction(
                   new Runnable() {
                     @Override
                     public void run() {
                       final PsiModificationTracker tracker =
                           PsiManager.getInstance(myView.getProject()).getModificationTracker();
                       final long startCount = tracker.getModificationCount();
                       CommandProcessor.getInstance()
                           .markCurrentCommandAsGlobal(myView.getProject());
                       // CCE here means QuickFix was incorrectly inherited
                       fix.applyFix(myView.getProject(), descriptor);
                       if (startCount != tracker.getModificationCount()) {
                         final DescriptorProviderInspection tool =
                             ((DescriptorProviderInspection) myView.getTree().getSelectedTool());
                         if (tool != null) {
                           tool.ignoreProblem(element, descriptor, idx);
                         }
                         myView.updateView(false);
                       }
                     }
                   });
         }
       };
   CommandProcessor.getInstance()
       .executeCommand(myView.getProject(), command, fix.getName(), null);
 }