예제 #1
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()));
 }
  public List<INodeSubstituteAction> createActions() {
    if (myLinkDeclaration == null) {
      return Collections.emptyList();
    }
    EditorComponent editor =
        (EditorComponent) mySubstituteInfo.getEditorContext().getEditorComponent();
    EditorCell referenceCell =
        editor.findNodeCellWithRole(
            mySourceNode,
            BehaviorReflection.invokeNonVirtual(
                String.class,
                myLinkDeclaration,
                "jetbrains.mps.lang.structure.structure.LinkDeclaration",
                "call_getGenuineRole_1213877254542",
                new Object[] {}));

    if (referenceCell != null
        && referenceCell.getContainingBigCell().getFirstLeaf() == referenceCell
        && ReferenceConceptUtil.getCharacteristicReference(
                SNodeOperations.getConceptDeclaration(mySourceNode))
            == myLinkDeclaration
        && SNodeOperations.getParent(mySourceNode) != null
        && ListSequence.fromList(SNodeOperations.getChildren(mySourceNode)).isEmpty()) {
      SNode parent = SNodeOperations.getParent(mySourceNode);
      String role = SNodeOperations.getContainingLinkRole(mySourceNode);
      SNode roleLink =
          ((SNode)
              SModelSearchUtil.findLinkDeclaration(
                  SNodeOperations.getConceptDeclaration(parent), role));
      return ModelActions.createChildSubstituteActions(
          parent,
          mySourceNode,
          SLinkOperations.getTarget(roleLink, "target", false),
          new DefaultChildNodeSetter(roleLink),
          mySubstituteInfo.getOperationContext());
    }
    return ModelActions.createReferentSubstituteActions(
        mySourceNode, myCurrentReferent, myLinkDeclaration, mySubstituteInfo.getOperationContext());
  }
예제 #3
0
 public static SNode findLinkDeclaration(String conceptFqName, String linkRole) {
   SNode concept = SModelUtil.findConceptDeclaration(conceptFqName);
   SNode linkDeclaration = SModelSearchUtil.findLinkDeclaration(concept, linkRole);
   return linkDeclaration;
 }