Exemplo n.º 1
0
 public static SNode call_getFieldDeclaration_1171743928471867409(SNode thisNode) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (SNode)
       descriptor.invoke(
           Object.class,
           SNodeOperations.cast(thisNode, "jetbrains.mps.lang.plugin.structure.ActionParameter"),
           "virtual_getFieldDeclaration_1171743928471867409",
           PARAMETERS_1171743928471867409);
 }
 public static SNode call_getCreatorMethod_4413749148913760565(SNode thisNode) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (SNode)
       descriptor.invoke(
           Object.class,
           SNodeOperations.cast(
               thisNode, "jetbrains.mps.lang.refactoring.structure.NodeMPSParameterType"),
           "virtual_getCreatorMethod_4413749148913760555",
           PARAMETERS_4413749148913760565);
 }
Exemplo n.º 3
0
 public static SNode call_getResultType_5389689214217665421(SNode thisNode) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (SNode)
       descriptor.invoke(
           Object.class,
           SNodeOperations.cast(
               thisNode,
               "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderPropertyBuilder"),
           "virtual_getResultType_7057666463730718251",
           PARAMETERS_5389689214217665421);
 }
Exemplo n.º 4
0
 public static boolean call_isLeaf_5389689214217569806(SNode thisNode) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (Boolean)
       descriptor.invoke(
           Boolean.class,
           SNodeOperations.cast(
               thisNode,
               "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderPropertyBuilder"),
           "virtual_isLeaf_7057666463730595159",
           PARAMETERS_5389689214217569806);
 }
Exemplo n.º 5
0
 public static String call_getUniqueId_8484425748929510087(SNode thisNode) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (String)
       descriptor.invoke(
           Object.class,
           SNodeOperations.cast(
               thisNode,
               "jetbrains.mps.lang.generator.generationParameters.structure.DefaultGeneratorParameter"),
           "virtual_getUniqueId_650531548511609559",
           PARAMETERS_8484425748929510087);
 }
Exemplo n.º 6
0
 public static SNode call_getCreatorExpression_5389689214217665417(
     SNode thisNode, SNode parentRef) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (SNode)
       descriptor.invoke(
           Object.class,
           SNodeOperations.cast(
               thisNode,
               "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderPropertyBuilder"),
           "virtual_getCreatorExpression_7057666463730727863",
           PARAMETERS_5389689214217665417,
           parentRef);
 }
Exemplo n.º 7
0
 public static SNode call_getAttachStatementChild_5389689214217667234(
     SNode thisNode, SNode parentBuilder, SNode parentRef, SNode childRef) {
   BehaviorDescriptor descriptor =
       ConceptRegistry.getInstance().getBehaviorDescriptorForInstanceNode(thisNode);
   return (SNode)
       descriptor.invoke(
           Object.class,
           SNodeOperations.cast(
               thisNode,
               "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderPropertyBuilder"),
           "virtual_getAttachStatementChild_4797501453850305563",
           PARAMETERS_5389689214217667234,
           parentBuilder,
           parentRef,
           childRef);
 }
  public void checkNode(
      final SNode node,
      LanguageErrorsComponent component,
      final IOperationContext operationContext,
      IScope scope) {
    final ConstraintsDescriptor newDescriptor =
        ConceptRegistry.getInstance().getConstraintsDescriptorNew(node.getConceptFqName());

    final CheckingNodeContext checkingNodeContext =
        new jetbrains.mps.smodel.structure.CheckingNodeContext();

    if (SNodeOperations.getParent(node) != null) {
      component.addDependency(SNodeOperations.getParent(node));
    }
    if (SNodeOperations.getParent(node) != null
        && !(jetbrains.mps.smodel.SNodeOperations.isUnknown(SNodeOperations.getParent(node)))) {
      final SNode link = SNodeOperations.getContainingLinkDeclaration(node);
      if (link == null) {
        component.addError(node, "Child in a role with unknown link", null);
        return;
      }
      boolean canBeChild =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ModelConstraintsManager.canBeChild(
                      newDescriptor,
                      node.getConceptFqName(),
                      operationContext,
                      SNodeOperations.getParent(node),
                      link,
                      checkingNodeContext);
                }
              });
      if (!(canBeChild)) {
        SNode rule = getBreakingNodeAndClearContext(checkingNodeContext);
        component.addError(
            node,
            "Node " + node + " cannot be child of node " + SNodeOperations.getParent(node),
            rule);
      }
    }

    if (node.isRoot()) {
      boolean canBeRoot =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ModelConstraintsManager.canBeRoot(
                      newDescriptor,
                      operationContext,
                      node.getConceptFqName(),
                      SNodeOperations.getModel(node),
                      checkingNodeContext);
                }
              });
      if (!(canBeRoot)) {
        SNode rule = getBreakingNodeAndClearContext(checkingNodeContext);
        component.addError(node, "Not rootable concept added as root", rule);
      }
    }

    for (SNode child : SNodeOperations.getChildren(node)) {
      component.addDependency(child);
      final SNode childConcept = SNodeOperations.getConceptDeclaration(child);
      final SNode childLink = SNodeOperations.getContainingLinkDeclaration(child);
      if (childLink == null) {
        continue;
      }
      boolean canBeParent =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ModelConstraintsManager.canBeParent(
                      newDescriptor,
                      node,
                      childConcept,
                      childLink,
                      operationContext,
                      checkingNodeContext);
                }
              });
      if (!(canBeParent)) {
        SNode rule = getBreakingNodeAndClearContext(checkingNodeContext);
        component.addError(node, "Node " + node + " cannot be parent of node " + child, rule);
      }

      // todo: do it right, with runCheckingAction!
      if (!(ModelConstraintsManager.canBeAncestor(
          node, childConcept, operationContext, checkingNodeContext))) {
        SNode rule =
            SNodeOperations.cast(
                getBreakingNodeAndClearContext(checkingNodeContext),
                "jetbrains.mps.lang.constraints.structure.ConstraintFunction_CanBeAnAncestor");
        component.addError(
            child,
            "Concept "
                + SLinkOperations.getTarget(
                    SNodeOperations.as(
                        SNodeOperations.getParent(rule),
                        "jetbrains.mps.lang.constraints.structure.ConceptConstraints"),
                    "concept",
                    false)
                + " cannot be ancestor of node "
                + child,
            rule);
      }
    }

    // Properties validation
    SNode concept = SNodeOperations.getConceptDeclaration(node);
    component.addDependency(concept);
    ConceptAndSuperConceptsScope chs = new ConceptAndSuperConceptsScope(concept);
    for (SNode parentConcept : chs.getConcepts()) {
      component.addDependency(parentConcept);
    }
    List<SNode> props =
        ((List<SNode>)
            chs.getNodes(
                new Condition<SNode>() {
                  public boolean met(SNode n) {
                    return SNodeOperations.isInstanceOf(
                        n, "jetbrains.mps.lang.structure.structure.PropertyDeclaration");
                  }
                }));
    for (SNode p : ListSequence.fromList(props)) {
      final PropertySupport ps = PropertySupport.getPropertySupport(p);
      final String propertyName = SPropertyOperations.getString(p, "name");
      if (propertyName == null) {
        LOG.error(
            "Property declaration has a null name, declaration id: "
                + p.getSNodeId()
                + ", model: "
                + SNodeOperations.getModel(p).getSModelFqName());
        continue;
      }
      final String value = ps.fromInternalValue(node.getProperty(propertyName));
      final PropertyConstraintsDescriptor propertyDescriptor =
          newDescriptor.getProperty(propertyName);
      boolean canSetValue =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ps.canSetValue(
                      propertyDescriptor, node, propertyName, value, operationContext.getScope());
                }
              });
      if (!(canSetValue)) {
        // RE-2426 Ñ disabling the "Property constraint violation for property" error messages

        /*
        // TODO this is a hack for anonymous classes
        if ("name".equals(SPropertyOperations.getString(p, "name")) && ("AnonymousClass".equals(SPropertyOperations.getString(concept, "name")) || "InternalAnonymousClass".equals(SPropertyOperations.getString(concept, "name")))) {
          continue;
        }
        // todo find a rule
        component.addError(node, "Property constraint violation for property \"" + SPropertyOperations.getString(p, "name") + "\"", null, new PropertyMessageTarget(SPropertyOperations.getString(p, "name")));
        */
      }
    }
  }