Пример #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
 @Override
 public void doDispose() {
   for (LanguageErrorsComponent comp : MapSequence.fromMap(myNodePointersToComponents).values()) {
     comp.dispose();
   }
   for (EditorComponent component : myEditorComponents) {
     component.removeDisposeListener(myDisposeListener);
   }
   SModelRepository.getInstance().removeModelRepositoryListener(myRepositoryListener);
   for (SModel modelDescriptor :
       SetSequence.fromSetWithValues(new HashSet<SModel>(), myListenedModels)) {
     removeModelListener(modelDescriptor);
   }
   super.doDispose();
 }
Пример #3
0
 public void checkNode(
     final SNode node,
     LanguageErrorsComponent component,
     final IOperationContext operationContext,
     IScope scope) {
   if (operationContext == null) {
     return;
   }
   if (SNodeUtil.getMetaLevel(node) != 0) {
     return;
   }
   SNode concept = SNodeOperations.getConceptDeclaration(node);
   for (SReference ref : SNodeOperations.getReferences(node)) {
     SNode target = SLinkOperations.getTargetNode(ref);
     SNode ld = SLinkOperations.findLinkDeclaration(ref);
     // don't check unresolved and broken references, they should already have an error message
     if ((target == null) || ld == null) {
       continue;
     }
     component.addDependency(target);
     component.addDependency(ld);
     component.addDependency(node);
     component.addDependency(SNodeOperations.getParent(node));
     for (SNode c : SNodeOperations.getChildren(node)) {
       component.addDependency(c);
     }
     String linkRole = SModelUtil.getGenuineLinkRole(ld);
     final SNode linkTarget = SLinkOperations.getTarget(ld, "target", false);
     final INodeReferentSearchScopeProvider scopeProvider =
         ModelConstraintsUtil.getSearchScopeProvider(concept, linkRole);
     SearchScopeStatus searchScopeStatus =
         component.runCheckingAction(
             new _FunctionTypes._return_P0_E0<SearchScopeStatus>() {
               public SearchScopeStatus invoke() {
                 return ModelConstraintsUtil.createSearchScope(
                     scopeProvider,
                     SNodeOperations.getModel(node),
                     SNodeOperations.getParent(node),
                     node,
                     linkTarget,
                     operationContext);
               }
             });
     if (searchScopeStatus.isError()) {
       component.addError(
           node,
           searchScopeStatus.getMessage(),
           (SNode) null,
           new ReferenceMessageTarget(SLinkOperations.getRole(ref)));
     } else if (!(searchScopeStatus.isDefault()
         || searchScopeStatus.getSearchScope().isInScope(target))) {
       String name = target.getName();
       component.addError(
           node,
           "reference"
               + ((name == null ? "" : " " + name))
               + " ("
               + SLinkOperations.getRole(ref)
               + ") is out of search scope",
           searchScopeStatus.getReferenceValidatorNode(),
           new ReferenceMessageTarget(SLinkOperations.getRole(ref)));
     }
   }
 }
Пример #4
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;
  }