Пример #1
0
 @Override
 public void clear(SNode node, EditorComponent component) {
   SNodeReference sNodePointer = component.getEditedNodePointer();
   if (sNodePointer == null) {
     return;
   }
   LanguageErrorsComponent errorsComponent =
       MapSequence.fromMap(myNodePointersToComponents).get(sNodePointer);
   if (errorsComponent == null) {
     return;
   }
   errorsComponent.clear();
 }
Пример #2
0
  public Set<EditorMessage> doCreateMessages(
      SNode node, List<SModelEvent> list, boolean wasCheckedOnce, EditorContext editorContext) {
    myMessagesChanged = false;
    EditorComponent editorComponent = (EditorComponent) editorContext.getEditorComponent();
    SNode sNode = editorComponent.getEditedNode();
    SNodeReference sNodePointer = editorComponent.getEditedNodePointer();

    Set<EditorMessage> result = SetSequence.fromSet(new HashSet<EditorMessage>());
    if (sNode == null) {
      if (LOG.isEnabledFor(Priority.ERROR)) {
        LOG.error("edited node is null");
      }
      return result;
    }
    if (sNodePointer == null) {
      if (LOG.isEnabledFor(Priority.ERROR)) {
        LOG.error("edited NodePointer is null");
      }
      return result;
    }

    SModel descriptor = SNodeOperations.getModel(sNode);
    if (descriptor == null) {
      // descriptor is null for a replaced model
      // after model is replaced but before it is disposed (this can happen asyncronously)
      return result;
    }
    LanguageErrorsComponent errorsComponent =
        MapSequence.fromMap(myNodePointersToComponents)
            .get(new SNodePointer(SNodeOperations.getContainingRoot(sNode)));
    if (errorsComponent == null) {
      errorsComponent = new LanguageErrorsComponent(sNode);
      MapSequence.fromMap(myNodePointersToComponents).put(sNodePointer, errorsComponent);
    }
    if (!(editorComponent instanceof InspectorEditorComponent)
        && !(SetSequence.fromSet(myEditorComponents).contains(editorComponent))) {
      SetSequence.fromSet(myEditorComponents).addElement(editorComponent);
      editorComponent.addDisposeListener(myDisposeListener);
    }
    addModelListener(descriptor);

    if (!(wasCheckedOnce)) {
      errorsComponent.clear();
    }
    boolean changed = false;
    TypeCheckingContext typecheckingContext = editorComponent.getTypeCheckingContext();
    try {
      if (typecheckingContext != null) {
        typecheckingContext.setIsNonTypesystemComputation();
      }
      changed = errorsComponent.check(node, myRules, editorContext.getOperationContext());
    } finally {
      if (typecheckingContext != null) {
        typecheckingContext.resetIsNonTypesystemComputation();
      }
    }
    myMessagesChanged = changed;
    for (IErrorReporter errorReporter : errorsComponent.getErrors()) {
      MessageStatus status = errorReporter.getMessageStatus();
      String errorString = errorReporter.reportError();
      HighlighterMessage message =
          HighlightUtil.createHighlighterMessage(
              errorReporter.getSNode(),
              NameUtil.capitalize(status.getPresentation()) + ": " + errorString,
              errorReporter,
              LanguageEditorChecker.this,
              editorContext);
      SetSequence.fromSet(result).addElement(message);
    }
    return result;
  }