public static SNode findProperty(SNode node, String name) {
   boolean cpt =
       eq_yzaoi3_a0a0a0g(
               node.getConcept().getId(),
               "jetbrains.mps.lang.structure.structure.ConceptDeclaration")
           || eq_yzaoi3_a0a0a0g_0(
               node.getConcept().getId(),
               "jetbrains.mps.lang.structure.structure.InterfaceConceptDeclaration");
   SNode conceptNode = (cpt ? ((SNode) node) : SNodeOperations.getConceptDeclaration(node));
   return SModelSearchUtil.findConceptProperty(conceptNode, name);
 }
 public IsApplicableStatus isApplicableAndPattern(SNode argument) {
   {
     boolean b =
         SModelUtil_new.isAssignableConcept(
             argument.getConcept().getId(), this.getApplicableConceptFQName());
     return new IsApplicableStatus(b, null);
   }
 }
 public IsApplicableStatus isApplicableSupertypeAndPattern(SNode node) {
   {
     boolean b =
         SModelUtil_new.isAssignableConcept(
             node.getConcept().getId(), this.getApplicableSupertypeConceptFQName());
     return new IsApplicableStatus(b, null);
   }
 }
Esempio n. 4
0
 /**
  * It's unlikely subclasses or clients of the class shall forcefully fire events.
  *
  * @deprecated event firing, with smodel.SNode as argument, shall not be part of
  *     extapi.EditableSModelBase contract
  */
 @Deprecated
 @ToRemove(version = 3.3)
 public void firePropertyChanged(
     SNode node, String propertyName, String oldValue, String newValue) {
   LOG.assertLog(!getSModelInternal().isUpdateMode());
   SProperty prop = ((ConceptMetaInfoConverter) node.getConcept()).convertProperty(propertyName);
   getEventDispatch().firePropertyChange(node, prop, oldValue, newValue);
 }
Esempio n. 5
0
 /**
  * It's unlikely subclasses or clients of the class shall forcefully fire events.
  *
  * @deprecated event firing, with smodel.SNode as argument, shall not be part of
  *     extapi.EditableSModelBase contract
  */
 @Deprecated
 @ToRemove(version = 3.3)
 public void fireReferenceChanged(
     SNode node, String role, SReference oldValue, SReference newValue) {
   LOG.assertLog(!getSModelInternal().isUpdateMode());
   SReferenceLink link = ((ConceptMetaInfoConverter) node.getConcept()).convertAssociation(role);
   getEventDispatch().fireReferenceChange(node, link, oldValue, newValue);
 }
Esempio n. 6
0
 /**
  * It's unlikely subclasses or clients of the class shall forcefully fire events.
  *
  * @deprecated event firing, with smodel.SNode as argument, shall not be part of
  *     extapi.EditableSModelBase contract
  */
 @Deprecated
 @ToRemove(version = 3.3)
 public void fireNodeAdded(SNode node, String role, org.jetbrains.mps.openapi.model.SNode child) {
   LOG.assertLog(!getSModelInternal().isUpdateMode());
   SContainmentLink link =
       role == null
           ? null
           : ((ConceptMetaInfoConverter) node.getConcept()).convertAggregation(role);
   getEventDispatch().fireNodeAdd(node, link, child);
 }
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_supertypesOf_ClassifierType_Collection_g8re64_a0a;
     nodeToMatch_supertypesOf_ClassifierType_Collection_g8re64_a0a = nodeToMatch;
     if (!("jetbrains.mps.baseLanguage.structure.ClassifierType"
         .equals(
             nodeToMatch_supertypesOf_ClassifierType_Collection_g8re64_a0a
                 .getConcept()
                 .getId()))) {
       return false;
     }
     {
       SNodePointer pointer = SNODE_POINTER_832k9i_a0a0a0a0b0c0a0a0a0a0a0c;
       if (!(PatternUtil.matchReferentWithNode(
           pointer,
           nodeToMatch_supertypesOf_ClassifierType_Collection_g8re64_a0a.getReferenceTarget(
               "classifier")))) {
         return false;
       }
     }
     {
       String childRole_supertypesOf_ClassifierType_Collection_g8re64_ = "parameter";
       if (!(PatternUtil.hasNChildren(
           nodeToMatch_supertypesOf_ClassifierType_Collection_g8re64_a0a,
           childRole_supertypesOf_ClassifierType_Collection_g8re64_,
           1))) {
         return false;
       }
       {
         SNode childVar_supertypesOf_ClassifierType_Collection_g8re64_a0a0 =
             nodeToMatch_supertypesOf_ClassifierType_Collection_g8re64_a0a
                 .getChildren(childRole_supertypesOf_ClassifierType_Collection_g8re64_)
                 .get(0);
         this.patternVar_ELEMENT = childVar_supertypesOf_ClassifierType_Collection_g8re64_a0a0;
       }
     }
   }
   return true;
 }
Esempio n. 8
0
 @Deprecated
 public static boolean isRuntimeErrorType(SNode node) {
   if (node == null) return false;
   String conceptFqName = node.getConcept().getId();
   return "jetbrains.mps.lang.typesystem.structure.RuntimeErrorType".equals(conceptFqName);
 }
  private static List<INodeSubstituteAction> createActions_internal(
      SNode parentNode,
      SNode currentChild,
      SNode childConcept,
      IChildNodeSetter childSetter,
      IOperationContext context) {
    List<INodeSubstituteAction> resultActions = new ArrayList<INodeSubstituteAction>();
    if (childConcept == null) {
      return resultActions;
    }

    // special case
    if (childConcept == SModelUtil.getBaseConcept()) {
      if ((currentChild == null
          || currentChild.getConcept().getId().equals(SNodeUtil.concept_BaseConcept))) {
        resultActions = new ArrayList<INodeSubstituteAction>();
        ISearchScope conceptsSearchScope =
            SModelSearchUtil.createConceptsFromModelLanguagesScope(
                parentNode.getModel(), true, context.getScope());
        List<SNode> allVisibleConcepts = conceptsSearchScope.getNodes();
        for (final SNode visibleConcept : allVisibleConcepts) {
          resultActions.add(
              new DefaultChildNodeSubstituteAction(
                  visibleConcept, parentNode, currentChild, childSetter, context.getScope()) {
                public String getMatchingText(String pattern) {
                  return getMatchingText(pattern, true, true);
                }

                public String getVisibleMatchingText(String pattern) {
                  return getMatchingText(pattern);
                }

                public String getDescriptionText(String pattern) {
                  String fqName = NameUtil.nodeFQName(visibleConcept);
                  return "lang: "
                      + NameUtil.compactNamespace(NameUtil.namespaceFromConceptFQName(fqName));
                }

                public Icon getIconFor(String pattern) {
                  return getIconFor(pattern, true);
                }
              });
        }
        return resultActions;
      }

      // pretend we are going to substitute more concrete concept
      childConcept = ChildSubstituteActionsUtil.getRefinedChildConcept(currentChild);
    }

    Language primaryLanguage = SModelUtil.getDeclaringLanguage(childConcept);
    if (primaryLanguage == null) {
      LOG.error(
          "Couldn't build actions : couldn't get declaring language for concept "
              + org.jetbrains.mps.openapi.model.SNodeUtil.getDebugText(childConcept));
      return resultActions;
    }

    List<SNode> allBuilders =
        ChildSubstituteActionsUtil.getActionsBuilders(
            parentNode, currentChild, childConcept, childSetter, context);
    if (!ChildSubstituteActionsUtil.containsRemoveDefaults(allBuilders)) {
      resultActions.addAll(
          createPrimaryChildSubstituteActions(
              parentNode, currentChild, childConcept, childSetter, context));
    }

    for (SNode builder : allBuilders) {
      List<INodeSubstituteAction> addActions =
          ChildSubstituteActionsUtil.invokeActionFactory(
              builder, parentNode, currentChild, childConcept, childSetter, context);
      resultActions.addAll(addActions);
    }

    for (SNode builder : allBuilders) {
      resultActions =
          ChildSubstituteActionsUtil.applyActionFilter(
              builder, resultActions, parentNode, currentChild, childConcept, context);
    }

    if (childSetter instanceof DefaultChildNodeSetter
        || childSetter instanceof AbstractCellMenuPart_ReplaceNode_CustomNodeConcept
            && currentChild != null) {
      SNode linkDeclaration;
      if (childSetter instanceof DefaultChildNodeSetter) {
        linkDeclaration = ((DefaultChildNodeSetter) childSetter).myLinkDeclaration;
      } else {
        linkDeclaration = currentChild.getRoleLink();
      }

      Iterator<INodeSubstituteAction> it = resultActions.iterator();
      while (it.hasNext()) {
        INodeSubstituteAction action = it.next();

        SNode conceptNode = action.getOutputConcept();
        if (conceptNode == null) {
          continue;
        }

        if (!ModelConstraintsManager.canBeParent(parentNode, conceptNode, linkDeclaration, context)
            || !ModelConstraintsManager.canBeAncestor(parentNode, conceptNode, context)) {
          it.remove();
        }
      }
    }

    return resultActions;
  }
  private static List<INodeSubstituteAction> createSmartReferenceActions(
      final SNode smartConcept,
      final SNode smartReference,
      final SNode parentNode,
      final SNode currentChild,
      final IChildNodeSetter childSetter,
      final IOperationContext context) {

    if (parentNode == null) {
      return null;
    }

    // try to create referent-search-scope
    SNode linkDeclaration = null;
    int index = 0;
    if (currentChild != null) {
      linkDeclaration = currentChild.getRoleLink();
      index = parentNode.getChildren(currentChild.getRoleInParent()).indexOf(currentChild);
    }
    //    TODO generate wrapping setter to have access to original link
    //    if(childSetter instanceof WrappingSetter) {
    //      childSetter = ((WrappingSetter)childSetter).unwrap();
    //    }
    if (linkDeclaration == null && childSetter instanceof DefaultChildNodeSetter) {
      linkDeclaration = ((DefaultChildNodeSetter) childSetter).getLinkDeclaration();
    }

    //    TODO restore (when wrapping setter is created)
    //    if (linkDeclaration == null) {
    //      return null;
    //    }

    ReferenceDescriptor refDescriptor =
        ModelConstraintsUtil.getSmartReferenceDescriptor(
            parentNode,
            linkDeclaration == null ? null : SModelUtil.getLinkDeclarationRole(linkDeclaration),
            index,
            smartConcept);
    if (refDescriptor == null) return null;

    Scope searchScope = refDescriptor.getScope();
    if (searchScope == null) return null;

    // create smart actions
    final String targetConcept =
        NameUtil.nodeFQName(SModelUtil.getLinkDeclarationTarget(smartReference));
    List<INodeSubstituteAction> actions = new ArrayList<INodeSubstituteAction>();
    IReferencePresentation presentation = refDescriptor.getReferencePresentation();
    Iterable<SNode> referentNodes = searchScope.getAvailableElements(null);
    for (SNode referentNode : referentNodes) {
      if (referentNode == null
          || !referentNode
              .getConcept()
              .isSubConceptOf(SConceptRepository.getInstance().getConcept(targetConcept))) continue;
      actions.add(
          new SmartRefChildNodeSubstituteAction(
              referentNode,
              parentNode,
              currentChild,
              childSetter,
              context.getScope(),
              smartConcept,
              smartReference,
              presentation));
    }

    return actions;
  }