Пример #1
0
 @Nullable
 private InspectionTool getTool() {
   if (myView != null) {
     return myView.getTree().getSelectedTool();
   }
   return null;
 }
Пример #2
0
 public void invokeLocalFix(int idx) {
   if (myView.getTree().getSelectionCount() != 1) return;
   final InspectionTreeNode node =
       (InspectionTreeNode) myView.getTree().getSelectionPath().getLastPathComponent();
   if (node instanceof ProblemDescriptionNode) {
     final ProblemDescriptionNode problemNode = (ProblemDescriptionNode) node;
     final CommonProblemDescriptor descriptor = problemNode.getDescriptor();
     final RefEntity element = problemNode.getElement();
     invokeFix(element, descriptor, idx);
   } else if (node instanceof RefElementNode) {
     RefElementNode elementNode = (RefElementNode) node;
     RefEntity element = elementNode.getElement();
     CommonProblemDescriptor descriptor = elementNode.getProblem();
     if (descriptor != null) {
       invokeFix(element, descriptor, idx);
     }
   }
 }
Пример #3
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++;
           }
         }
       }
     }
   }
 }
Пример #4
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);
 }