예제 #1
0
 private static HighlighterMessage createHighlighterMessage(
     SNode node,
     String message,
     MessageStatus status,
     IErrorReporter errorReporter,
     BaseEditorChecker checker) {
   if (errorReporter == null) {
     errorReporter =
         new SimpleErrorReporter(node, message, null, null, status, new NodeMessageTarget());
   }
   HighlighterMessage error =
       new HighlighterMessage(
           node,
           status,
           errorReporter.getErrorTarget(),
           getMessageColor(status),
           message,
           checker);
   error.setErrorReporter(errorReporter);
   for (QuickFixProvider quickFixProvider : errorReporter.getIntentionProviders()) {
     quickFixProvider.setIsError(error.getStatus() == MessageStatus.ERROR);
     error.addIntentionProvider(quickFixProvider);
   }
   return error;
 }
 protected void collectMessagesForNodesWithErrors(
     TypeCheckingContext context,
     final EditorContext editorContext,
     Set<EditorMessage> messages,
     boolean typesystemErrors) {
   for (Pair<SNode, List<IErrorReporter>> errorNode :
       context.getNodesWithErrors(typesystemErrors)) {
     List<IErrorReporter> errors = new ArrayList<IErrorReporter>(errorNode.o2);
     Collections.sort(
         errors,
         new Comparator<IErrorReporter>() {
           @Override
           public int compare(IErrorReporter o1, IErrorReporter o2) {
             return o2.getMessageStatus().compareTo(o1.getMessageStatus());
           }
         });
     boolean instantIntentionApplied = false;
     for (IErrorReporter errorReporter : errors) {
       MessageStatus status = errorReporter.getMessageStatus();
       String errorString = errorReporter.reportError();
       HighlighterMessage message =
           HighlightUtil.createHighlighterMessage(
               errorNode.o1,
               NameUtil.capitalize(status.getPresentation()) + ": " + errorString,
               errorReporter,
               AbstractTypesystemEditorChecker.this,
               editorContext);
       List<QuickFixProvider> intentionProviders = message.getIntentionProviders();
       final SNode quickFixNode = errorNode.o1;
       if (intentionProviders.size() == 1
           && intentionProviders.get(0) != null
           && intentionProviders.get(0).isExecutedImmediately()
           && !AbstractTypesystemEditorChecker.IMMEDIATE_QFIX_DISABLED) {
         QuickFixProvider intentionProvider = intentionProviders.get(0);
         if (!instantIntentionApplied) {
           instantIntentionApplied =
               applyInstantIntention(editorContext, quickFixNode, intentionProvider);
         }
       } else {
         messages.add(message);
       }
     }
   }
 }