예제 #1
0
  @RequiredReadAction
  @Override
  public void compose(StringBuffer buf, RefEntity refElement, CommonProblemDescriptor descriptor) {
    CommonProblemDescriptor[] descriptions = myTool.getDescriptions(refElement);

    int problemIdx = 0;
    if (descriptions != null) { // server-side inspections
      problemIdx = -1;
      for (int i = 0; i < descriptions.length; i++) {
        CommonProblemDescriptor description = descriptions[i];
        if (description == descriptor) {
          problemIdx = i;
          break;
        }
      }
      if (problemIdx == -1) return;
    }

    genPageHeader(buf, refElement);
    appendHeading(buf, InspectionsBundle.message("inspection.problem.synopsis"));
    //noinspection HardCodedStringLiteral
    buf.append("<br>");
    appendAfterHeaderIndention(buf);

    composeDescription(descriptor, problemIdx, buf, refElement);

    if (refElement instanceof RefElement && !refElement.isValid()) return;

    final QuickFix[] fixes = descriptor.getFixes();
    if (fixes != null && fixes.length > 0) {
      //noinspection HardCodedStringLiteral
      buf.append("<br><br>");
      appendHeading(buf, InspectionsBundle.message("inspection.problem.resolution"));
      //noinspection HardCodedStringLiteral
      buf.append("<br>");
      appendAfterHeaderIndention(buf);

      int idx = 0;
      for (QuickFix fix : fixes) {
        //noinspection HardCodedStringLiteral
        //noinspection HardCodedStringLiteral
        buf.append("<a HREF=\"file://bred.txt#invokelocal:").append(idx++);
        buf.append("\">");
        buf.append(fix.getName());
        //noinspection HardCodedStringLiteral
        buf.append("</a>");
        //noinspection HardCodedStringLiteral
        buf.append("<br>");
        appendAfterHeaderIndention(buf);
      }
    }
  }
예제 #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);
 }