@Override
    public void eventsHappenedInCommand(List<SModelEvent> events) {
      for (SModelEvent event : events) {
        if (event.getModelDescriptor() == null) continue;
        if (!myModels.contains(event.getModelDescriptor().getReference())) continue;

        if (event instanceof SModelRootEvent) {
          SModelRootEvent modelRootEvent = (SModelRootEvent) event;
          SNodeReference rootPointer =
              new jetbrains.mps.smodel.SNodePointer(modelRootEvent.getRoot());
          if (modelRootEvent.isRemoved() && myNodes.contains(rootPointer)) {
            myChanged = true;
            return;
          }
        } else if (event instanceof SModelChildEvent) {
          SModelChildEvent modelChildEvent = (SModelChildEvent) event;
          SNodeReference childPointer =
              new jetbrains.mps.smodel.SNodePointer(
                  modelChildEvent.getModel().getReference(),
                  modelChildEvent.getChild().getNodeId());
          if (modelChildEvent.isRemoved() && myNodes.contains(childPointer)) {
            myChanged = true;
            return;
          }
        }
      }
    }
Esempio n. 2
0
    @Override
    public void eventsHappenedInCommand(List<SModelEvent> events) {
      final List<SNode> changedNodes = new ArrayList<SNode>();
      for (SModelEvent e : events) {
        e.accept(
            new SModelEventVisitor() {
              @Override
              public void visitRootEvent(SModelRootEvent event) {
                changedNodes.add(event.getRoot());
              }

              @Override
              public void visitChildEvent(SModelChildEvent event) {
                changedNodes.add(event.getParent());
                changedNodes.add(event.getChild());
              }

              @Override
              public void visitPropertyEvent(SModelPropertyEvent event) {
                changedNodes.add(event.getNode());
              }

              @Override
              public void visitReferenceEvent(SModelReferenceEvent event) {
                changedNodes.add(event.getReference().getSourceNode());
              }
            });
      }

      for (SNode changeNode : changedNodes) {
        for (K key : myRecorder.getDependOn(changeNode)) {
          myCache.remove(key);
        }
      }
    }
  public void process(Collection<? extends SModelEvent> events) {
    AffectedNodes collector = new AffectedNodes();

    for (SModelEvent event : events) {
      event.accept(collector);
    }

    for (SModelReference mref : collector.getAffectedModelRefs()) {
      processAffected(mref, collector.getAffectedNodes(mref));
    }
  }