private static String getSmartMatchingText(
     SNode referenceNodeConcept, SNode referentNode, boolean visible) {
   String referentMatchingText = NodePresentationUtil.matchingText(referentNode, true, visible);
   if (ReferenceConceptUtil.hasSmartAlias(referenceNodeConcept)) {
     return ReferenceConceptUtil.getPresentationFromSmartAlias(
         referenceNodeConcept, referentMatchingText);
   }
   return referentMatchingText;
 }
Exemplo n.º 2
0
 public static String virtual_getPresentation_1213877396640(SNode thisNode) {
   if (SNodeOperations.isInstanceOf(
       thisNode,
       MetaAdapterFactory.getInterfaceConcept(
           0xceab519525ea4f22L,
           0x9b92103b95ca8c0cL,
           0x110396eaaa4L,
           "jetbrains.mps.lang.core.structure.INamedConcept"))) {
     String name =
         SPropertyOperations.getString(
             SNodeOperations.cast(
                 thisNode,
                 MetaAdapterFactory.getInterfaceConcept(
                     0xceab519525ea4f22L,
                     0x9b92103b95ca8c0cL,
                     0x110396eaaa4L,
                     "jetbrains.mps.lang.core.structure.INamedConcept")),
             MetaAdapterFactory.getProperty(
                 0xceab519525ea4f22L,
                 0x9b92103b95ca8c0cL,
                 0x110396eaaa4L,
                 0x110396ec041L,
                 "name"));
     if (name != null) {
       return name;
     }
     return "<no name>["
         + SPropertyOperations.getString(
             SNodeOperations.getConceptDeclaration(thisNode),
             MetaAdapterFactory.getProperty(
                 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"))
         + "]";
   }
   // --
   String smartRefPresentation = ReferenceConceptUtil.getPresentation(thisNode);
   if (smartRefPresentation != null) {
     return smartRefPresentation;
   }
   // --
   String conceptAlias =
       SPropertyOperations.getString(
           SNodeOperations.getConceptDeclaration(thisNode),
           MetaAdapterFactory.getProperty(
               0xc72da2b97cce4447L,
               0x8389f407dc1158b7L,
               0x1103553c5ffL,
               0x46ab0ad5826c74caL,
               "conceptAlias"));
   if (conceptAlias != null) {
     return conceptAlias;
   }
   // --
   return SPropertyOperations.getString(
       SNodeOperations.getConceptDeclaration(thisNode),
       MetaAdapterFactory.getProperty(
           0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
 }
Exemplo n.º 3
0
  public List<INodeSubstituteAction> createActions() {
    if (myLinkDeclaration == null) {
      return Collections.emptyList();
    }
    EditorComponent editor = mySubstituteInfo.getEditorContext().getNodeEditorComponent();
    EditorCell referenceCell =
        editor.findNodeCellWithRole(
            mySourceNode,
            ((String)
                BehaviorManager.getInstance()
                    .invoke(
                        Object.class,
                        SNodeOperations.cast(
                            myLinkDeclaration,
                            "jetbrains.mps.lang.structure.structure.LinkDeclaration"),
                        "call_getGenuineRole_1213877254542",
                        new Class[] {SNode.class})));

    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 =
          SNodeOperations.cast(
              parent.getLinkDeclaration(role),
              "jetbrains.mps.lang.structure.structure.LinkDeclaration");
      return ModelActions.createChildSubstituteActions(
          parent,
          mySourceNode,
          SLinkOperations.getTarget(roleLink, "target", false),
          new DefaultChildNodeSetter(roleLink),
          mySubstituteInfo.getOperationContext());
    }
    return ModelActions.createReferentSubstituteActions(
        mySourceNode, myCurrentReferent, myLinkDeclaration, mySubstituteInfo.getOperationContext());
  }
  public static List<INodeSubstituteAction> createDefaultActions(
      @NotNull SNode applicableConcept,
      SNode parentNode,
      SNode currentChild,
      IChildNodeSetter setter,
      IOperationContext operationContext) {

    String conceptFqName = NameUtil.nodeFQName(applicableConcept);
    SNode link = null;
    if (setter instanceof DefaultChildNodeSetter) {
      DefaultChildNodeSetter defaultSetter = (DefaultChildNodeSetter) setter;
      link = defaultSetter.getLinkDeclaration();
    }

    IScope scope = operationContext.getScope();

    if (!ModelConstraintsManager.canBeChild(conceptFqName, operationContext, parentNode, link)) {
      return new ArrayList<INodeSubstituteAction>();
    }

    SNode smartRef = ReferenceConceptUtil.getCharacteristicReference(applicableConcept);
    if (smartRef != null) {
      List<INodeSubstituteAction> smartActions =
          createSmartReferenceActions(
              applicableConcept, smartRef, parentNode, currentChild, setter, operationContext);
      if (smartActions != null) {
        return smartActions;
      } else {
        return Collections.emptyList();
      }
    } else {
      return Arrays.asList(
          (INodeSubstituteAction)
              new DefaultChildNodeSubstituteAction(
                  applicableConcept, parentNode, currentChild, setter, scope));
    }
  }