コード例 #1
0
 @Override
 public void childRemoved(SModelChildEvent event) {
   if (SNodeOperations.isInstanceOf(
       ((SNode) event.getParent()),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x101d9d3ca30L,
           "jetbrains.mps.baseLanguage.structure.Classifier"))) {
     if (!(SNodeOperations.isInstanceOf(
         ((SNode) event.getChild()),
         MetaAdapterFactory.getConcept(
             0xf3061a5392264cc5L,
             0xa443f952ceaf5816L,
             0xf8cc56b1fcL,
             "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration")))) {
       return;
     }
   }
   if (SNodeOperations.isInstanceOf(
       ((SNode) event.getParent()),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf8cc56b1fcL,
           "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration"))) {
     String role = event.getChildRole();
     if (!("parameter".equals(role))) {
       return;
     }
   }
   super.childRemoved(event);
 }
コード例 #2
0
 @Override
 public void childRemoved(SModelChildEvent event) {
   if (SNodeOperations.isInstanceOf(
       ((SNode) event.getParent()),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x101d9d3ca30L,
           "jetbrains.mps.baseLanguage.structure.Classifier"))) {
     String role = event.getChildRole();
     if (!(("typeVariableDeclaration".equals(role)
         || "superclass".equals(role)
         || "implementedInterface".equals(role)
         || "extendedInterface".equals(role)
         || "typeParameter".equals(role)))) {
       return;
     }
   }
   super.childRemoved(event);
 }
コード例 #3
0
    private void processChild(SModelChildEvent event, Map<SNode, Set<String>> childChanged) {
      SNode parent = event.getParent();
      if (parent.getModel() == null) {
        return;
      }
      final String childRole = event.getChildRole();

      // tyring to avoid update task execution for the same child role twice
      Set<String> childRoles = MapSequence.fromMap(childChanged).get(parent);
      if (childRoles == null) {
        childRoles = SetSequence.fromSet(new HashSet<String>());
        MapSequence.fromMap(childChanged).put(parent, childRoles);
      }
      if (SetSequence.fromSet(childRoles).contains(childRole)) {
        return;
      } else {
        SetSequence.fromSet(childRoles).addElement(childRole);
      }
      final SNodeId parentId = parent.getNodeId();

      final Wrappers._T<List<? extends SNode>> childrenRightAfterEvent =
          new Wrappers._T<List<? extends SNode>>(
              IterableUtil.asList(parent.getChildren(childRole)));
      childrenRightAfterEvent.value =
          ListSequence.fromList(childrenRightAfterEvent.value)
              .select(
                  new ISelector<SNode, SNode>() {
                    public SNode select(SNode n) {
                      return CopyUtil.copyAndPreserveId(n, false);
                    }
                  })
              .toListSequence();
      runUpdateTask(
          new _FunctionTypes._void_P0_E0() {
            public void invoke() {

              removeChanges(
                  parentId,
                  NodeGroupChange.class,
                  new _FunctionTypes._return_P1_E0<Boolean, NodeGroupChange>() {
                    public Boolean invoke(NodeGroupChange ch) {
                      return childRole.equals(ch.getRole());
                    }
                  });
              removeDescendantChanges(parentId, childRole);
              myLastParentAndNewChildrenIds =
                  MultiTuple.<SNodeId, List<SNodeId>>from(
                      parentId,
                      ListSequence.fromList(childrenRightAfterEvent.value)
                          .select(
                              new ISelector<SNode, SNodeId>() {
                                public SNodeId select(SNode n) {
                                  return n.getNodeId();
                                }
                              })
                          .toListSequence());
              buildAndAddChanges(
                  new _FunctionTypes._void_P1_E0<ChangeSetBuilder>() {
                    public void invoke(ChangeSetBuilder b) {
                      b.buildForNodeRole(
                          IterableUtil.asList(getOldNode(parentId).getChildren(childRole)),
                          childrenRightAfterEvent.value,
                          parentId,
                          childRole);
                    }
                  });
            }
          },
          parent,
          event);
    }