Beispiel #1
0
 private void processReference(SModelReferenceEvent event) {
   SReference ref = event.getReference();
   final SNode sourceNode = ref.getSourceNode();
   if (sourceNode.getModel() == null) {
     return;
   }
   final SNodeId nodeId = sourceNode.getNodeId();
   final String role = ref.getRole();
   runUpdateTask(
       new _FunctionTypes._void_P0_E0() {
         public void invoke() {
           removeChanges(
               nodeId,
               SetReferenceChange.class,
               new _FunctionTypes._return_P1_E0<Boolean, SetReferenceChange>() {
                 public Boolean invoke(SetReferenceChange ch) {
                   return role.equals(ch.getRole());
                 }
               });
           buildAndAddChanges(
               new _FunctionTypes._void_P1_E0<ChangeSetBuilder>() {
                 public void invoke(ChangeSetBuilder b) {
                   b.buildForReference(getOldNode(nodeId), sourceNode, role);
                 }
               });
         }
       },
       event.getReference().getSourceNode(),
       event);
 }
 @Override
 public SNodeReference getReferenceRoleId(SReference reference) {
   return MapSequence.fromMap(myReferenceRolesToPointers)
       .get(
           MultiTuple.<String, String>from(
               reference.getSourceNode().getConcept().getConceptId(), reference.getRole()));
 }
 @Override
 public void referenceRoleRead(SReference reference, SNodeReference linkPointer) {
   storeAndCheckConsistency(
       myReferenceRolesToPointers,
       MultiTuple.<String, String>from(
           reference.getSourceNode().getConcept().getConceptId(), reference.getRole()),
       linkPointer);
 }
Beispiel #4
0
 public static SNode findLinkDeclaration(SReference reference) {
   if (reference == null) {
     return null;
   }
   return ((SNode)
       SModelSearchUtil.findLinkDeclaration(
           jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations.getConceptDeclaration(
               ((SNode) reference.getSourceNode())),
           reference.getRole()));
 }
Beispiel #5
0
 public void updateUsage(SReference usage, SNode newTarget) {
   usage.getSourceNode().setReferenceTarget(usage.getLink(), newTarget);
 }