public void execute(final SNode node, final EditorContext editorContext) {
   EditorCell selectedCell = editorContext.getSelectedCell();
   if (!(selectedCell.isReferenceCell())) {
     return;
   }
   SNode contextNode =
       SNodeOperations.cast(
           selectedCell.getSNode(), "jetbrains.mps.lang.core.structure.BaseConcept");
   if (contextNode == null) {
     return;
   }
   String role = selectedCell.getRole();
   if (SNodeOperations.isInstanceOf(
       contextNode, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation")) {
     SNode attributedNode =
         SNodeOperations.cast(
             SNodeOperations.getParent(contextNode),
             "jetbrains.mps.lang.core.structure.BaseConcept");
     assert attributedNode != null;
     AttributeOperations.setAttribute(
         attributedNode,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
             role),
         null);
     return;
   }
   if (AttributeOperations.getAttribute(
           contextNode,
           new IAttributeDescriptor.LinkAttribute(
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
               role))
       != null) {
     AttributeOperations.setAttribute(
         contextNode,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
             role),
         null);
   } else {
     SNode referenceAntiquotation =
         SNodeFactoryOperations.setNewAttribute(
             contextNode,
             new IAttributeDescriptor.LinkAttribute(
                 SConceptOperations.findConceptDeclaration(
                     "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"),
                 role),
             "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation");
     if (selectedCell.isSingleNodeCell()) {
       SPropertyOperations.set(
           referenceAntiquotation,
           "label",
           SPropertyOperations.getString(
               SNodeOperations.getConceptDeclaration(contextNode), "name"));
     }
   }
 }
Example #2
0
 public static void addVariablePattern(EditorContext context) {
   EditorCell contextCell = context.getSelectedCell();
   SNode node = contextCell.getSNode();
   SNode linkDeclaration =
       SNodeOperations.cast(
           contextCell.getLinkDeclaration(),
           "jetbrains.mps.lang.structure.structure.LinkDeclaration");
   SNode genuineLinkDeclaration = SModelUtil.getGenuineLinkDeclaration(linkDeclaration);
   if (linkDeclaration != null
       && SPropertyOperations.hasValue(
           genuineLinkDeclaration, "metaClass", "reference", "reference")) {
     String role = SPropertyOperations.getString(genuineLinkDeclaration, "role");
     AttributeOperations.createAndSetAttrbiute(
         node,
         new IAttributeDescriptor.LinkAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration"),
             role),
         "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration");
   } else {
     AttributeOperations.createAndSetAttrbiute(
         node,
         new IAttributeDescriptor.NodeAttribute(
             SConceptOperations.findConceptDeclaration(
                 "jetbrains.mps.lang.pattern.structure.Pattern")),
         "jetbrains.mps.lang.pattern.structure.PatternVariableDeclaration");
   }
 }
 public void applyRule(
     final SNode nodeToCheck,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   SNode linkDeclaration = AttributeOperations.getLinkDeclaration(nodeToCheck);
   {
     SNode _nodeToCheck_1029348928467 = nodeToCheck;
     EquationInfo _info_12389875345 =
         new EquationInfo(
             _nodeToCheck_1029348928467,
             null,
             "r:00000000-0000-4000-0000-011c89590343(jetbrains.mps.lang.pattern.typesystem)",
             "1202486181555",
             0,
             null);
     typeCheckingContext.createEquation(
         (SNode)
             typeCheckingContext.typeOf(
                 _nodeToCheck_1029348928467,
                 "r:00000000-0000-4000-0000-011c89590343(jetbrains.mps.lang.pattern.typesystem)",
                 "1202486174317",
                 true),
         (SNode)
             _quotation_createNode_onvofq_a0b0b(
                 SLinkOperations.getTarget(linkDeclaration, "target", false)),
         _info_12389875345);
   }
 }
 private static boolean renderingCondition_1clvom_a0a(SNode node, EditorContext editorContext) {
   return (SLinkOperations.getTarget(node, "persistentConfiguration", false) == null)
       || (AttributeOperations.getAttribute(
               SLinkOperations.getTarget(node, "persistentConfiguration", false),
               new IAttributeDescriptor.NodeAttribute(
                   "jetbrains.mps.execution.settings.structure.DeprecatedAnnotation"))
           == null);
 }
    public void execute(final SNode node, final EditorContext editorContext) {
      DocCommentHelper.addJavadocLangIfMissing(node);

      if ((AttributeOperations.getAttribute(
              node,
              new IAttributeDescriptor.NodeAttribute(
                  SConceptOperations.findConceptDeclaration(
                      "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")))
          == null)) {
        SNodeFactoryOperations.setNewAttribute(
            node,
            new IAttributeDescriptor.NodeAttribute(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")),
            "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment");
        SNode line =
            SNodeFactoryOperations.addNewChild(
                AttributeOperations.getAttribute(
                    node,
                    new IAttributeDescriptor.NodeAttribute(
                        SConceptOperations.findConceptDeclaration(
                            "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))),
                "body",
                "jetbrains.mps.baseLanguage.javadoc.structure.CommentLine");
        SNodeFactoryOperations.addNewChild(
            line, "part", "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart");
      } else {
        AttributeOperations.setAttribute(
            node,
            new IAttributeDescriptor.NodeAttribute(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")),
            null);
      }
      editorContext.select(
          ListSequence.fromList(
                  SLinkOperations.getTargets(
                      AttributeOperations.getAttribute(
                          node,
                          new IAttributeDescriptor.NodeAttribute(
                              SConceptOperations.findConceptDeclaration(
                                  "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))),
                      "body",
                      true))
              .first());
    }
 public void execute(final SNode node, final EditorContext editorContext) {
   AttributeOperations.setAttribute(
       node,
       new IAttributeDescriptor.NodeAttribute(
           SConceptOperations.findConceptDeclaration(
               "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe")),
       SNodeFactoryOperations.createNewNode(
           "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe", null));
 }
 public String getDescription(final SNode node, final EditorContext editorContext) {
   return (AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty"))
           == null
       ? "Add figure parameter attribute"
       : "Remove figure parameter attribute");
 }
 public String getDescription(final SNode node, final EditorContext editorContext) {
   return ((AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   SConceptOperations.findConceptDeclaration(
                       "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")))
           == null)
       ? "Add Documentation Comment"
       : "Remove Documentation Comment");
 }
 public boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
   return SNodeOperations.isInstanceOf(
           SLinkOperations.getTarget(node, "operation", true),
           "jetbrains.mps.baseLanguage.structure.InstanceMethodCallOperation")
       && AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   SConceptOperations.findConceptDeclaration(
                       "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe")))
           == null;
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   if (AttributeOperations.getAttribute(
           node,
           new IAttributeDescriptor.NodeAttribute(
               "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty"))
       != null) {
     AttributeOperations.setAttribute(
         node,
         new IAttributeDescriptor.NodeAttribute(
             "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty"),
         null);
   } else {
     AttributeOperations.setAttribute(
         node,
         new IAttributeDescriptor.NodeAttribute(
             "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty"),
         SConceptOperations.createNewNode(
             "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty",
             null));
   }
 }
Example #11
0
 private static boolean renderingCondition_rjgbfl_a2a(SNode node, EditorContext editorContext) {
   return Sequence.fromIterable(
           AttributeOperations.getChildNodesAndAttributes(
               node,
               MetaAdapterFactory.getContainmentLink(
                   0x698a8d22a10447a0L,
                   0xba8d10e3ec237f13L,
                   0x36fb0dc9fd32c1b8L,
                   0x36fb0dc9fd37a1c2L,
                   "additionalDependencies")))
       .isNotEmpty();
 }
 private static boolean renderingCondition_gnweac_a1a(SNode node, EditorContext editorContext) {
   return !((boolean)
           BuildLayout_JarManifest__BehaviorDescriptor.isInJar_id5V$ev8kKReX.invoke(node))
       || Sequence.fromIterable(
               AttributeOperations.getChildNodesAndAttributes(
                   node,
                   MetaAdapterFactory.getContainmentLink(
                       0x798100da4f0a421aL,
                       0xb99171f8c50ce5d2L,
                       0x115d3b22faf20f2eL,
                       0x67af4eb97391dfc1L,
                       "name")))
           .isNotEmpty();
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode newAnnotation =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.test.structure.NodeOperationsContainer", null);
   AttributeOperations.setAttribute(
       node,
       new IAttributeDescriptor.NodeAttribute(
           "jetbrains.mps.lang.test.structure.NodeOperationsContainer"),
       newAnnotation);
   SNode warningCheck =
       SConceptOperations.createNewNode(
           "jetbrains.mps.lang.test.structure.NodeWarningCheckOperation", null);
   ListSequence.fromList(SLinkOperations.getTargets(newAnnotation, "nodeOperations", true))
       .addElement(warningCheck);
   SelectionUtil.selectCell(editorContext, warningCheck, SelectionManager.LAST_EDITABLE_CELL);
 }
Example #14
0
 public static boolean filterIssue(SNode node) {
   SNode container =
       AttributeOperations.getAttribute(
           node,
           new IAttributeDescriptor.NodeAttribute(
               "jetbrains.mps.lang.test.structure.NodeOperationsContainer"));
   if (container == null) {
     return true;
   }
   for (SNode property : SLinkOperations.getTargets(container, "nodeOperations", true)) {
     if (jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations.isInstanceOf(
         property, "jetbrains.mps.lang.test.structure.NodeErrorCheckOperation")) {
       return false;
     }
   }
   return true;
 }
 public void execute(SNode node) {
   SNodeOperations.deleteNode(
       AttributeOperations.getAttribute(
           SNodeOperations.cast(
               node,
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x101d9d3ca30L,
                   "jetbrains.mps.baseLanguage.structure.Classifier")),
           new IAttributeDescriptor.NodeAttribute(
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x53f7c33f069862f2L,
                   "jetbrains.mps.baseLanguage.structure.JavaImports"))));
 }
Example #16
0
 public static SNode getApplicableConcept_fromEnvironment(SNode node) {
   SNode ancestor =
       SNodeOperations.getAncestorWhereConceptInList(
           node,
           new String[] {
             "jetbrains.mps.lang.generator.structure.TemplateDeclaration",
             "jetbrains.mps.lang.generator.structure.BaseMappingRule",
             "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule"
           },
           false,
           false);
   if (SNodeOperations.isInstanceOf(
       ancestor, "jetbrains.mps.lang.generator.structure.TemplateDeclaration")) {
     return SLinkOperations.getTarget(
         SNodeOperations.cast(
             ancestor, "jetbrains.mps.lang.generator.structure.TemplateDeclaration"),
         "applicableConcept",
         false);
   }
   if (SNodeOperations.isInstanceOf(
       ancestor, "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule")) {
     return PatternReduction_MappingRule_Behavior.call_getConcept_1805153994417064763(
         SNodeOperations.cast(
             ancestor, "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule"));
   }
   if (SNodeOperations.isInstanceOf(
       ancestor, "jetbrains.mps.lang.generator.structure.BaseMappingRule")) {
     return SLinkOperations.getTarget(
         SNodeOperations.cast(ancestor, "jetbrains.mps.lang.generator.structure.BaseMappingRule"),
         "applicableConcept",
         false);
   }
   // ============
   SNode rootAnnotation =
       AttributeOperations.getAttribute(
           SNodeOperations.getContainingRoot(node),
           new IAttributeDescriptor.NodeAttribute(
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation")));
   return SLinkOperations.getTarget(
       SNodeOperations.cast(
           rootAnnotation, "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"),
       "applicableConcept",
       false);
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   List<SNode> configs =
       SModelOperations.getRoots(
           SNodeOperations.getModel(node),
           "jetbrains.mps.lang.generator.structure.MappingConfiguration");
   if (ListSequence.fromList(configs).count() > 1) {
     Iterable<SNode> sameVPackConfigs =
         ListSequence.fromList(configs)
             .where(
                 new IWhereFilter<SNode>() {
                   public boolean accept(SNode it) {
                     return Comparing.equal(
                         SPropertyOperations.getString(it, "virtualPackage"),
                         SPropertyOperations.getString(node, "virtualPackage"));
                   }
                 });
     if (Sequence.fromIterable(sameVPackConfigs).isNotEmpty()) {
       configs = Sequence.fromIterable(sameVPackConfigs).toListSequence();
     }
   }
   if (ListSequence.fromList(configs).count() > 1) {
     // TODO: let user to choose mapping config?
   }
   //  add new rule
   SNode rule =
       SNodeFactoryOperations.addNewChild(
           ListSequence.fromList(configs).first(),
           "rootMappingRule",
           "jetbrains.mps.lang.generator.structure.Root_MappingRule");
   SLinkOperations.setTarget(
       rule,
       "applicableConcept",
       SLinkOperations.getTarget(
           AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation")),
           "applicableConcept",
           false),
       false);
   SLinkOperations.setTarget(rule, "template", node, false);
   //  open in editor
   NavigationSupport.getInstance()
       .openNode(editorContext.getOperationContext(), rule, true, true);
 }
Example #18
0
 public static boolean call_isApplicable_5449224527592368025(
     SAbstractConcept thisConcept, SNode node) {
   return ListSequence.fromList(SNodeOperations.getReferences(node)).isNotEmpty()
       && (AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   MetaAdapterFactory.getConcept(
                       0x8585453e6bfb4d80L,
                       0x98deb16074f1d86cL,
                       0x7181d929c720809L,
                       "jetbrains.mps.lang.test.structure.ScopesTest")))
           == null)
       && !(SNodeOperations.isInstanceOf(
           node,
           MetaAdapterFactory.getConcept(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x7181d929c720809L,
               "jetbrains.mps.lang.test.structure.ScopesTest")));
 }
 private static Boolean isApplicable_id4IvydoGviup(
     @NotNull SAbstractConcept __thisConcept__, SNode node) {
   return Sequence.fromIterable(SNodeOperations.getReferences(node)).isNotEmpty()
       && (AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   MetaAdapterFactory.getConcept(
                       0x8585453e6bfb4d80L,
                       0x98deb16074f1d86cL,
                       0x7181d929c720809L,
                       "jetbrains.mps.lang.test.structure.ScopesTest")))
           == null)
       && !(SNodeOperations.isInstanceOf(
           node,
           MetaAdapterFactory.getConcept(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x7181d929c720809L,
               "jetbrains.mps.lang.test.structure.ScopesTest")));
 }
 public static SNode virtual_getExpectedReturnType_1213877374441(SNode thisNode) {
   SNode referenceMacro =
       SNodeOperations.getAncestor(
           thisNode, "jetbrains.mps.lang.generator.structure.ReferenceMacro", false, false);
   SNode attributedNode = SNodeOperations.getParent(referenceMacro);
   String linkRole = AttributeOperations.getLinkRole(referenceMacro);
   ConceptAndSuperConceptsScope linkSearchScope =
       new ConceptAndSuperConceptsScope(SNodeOperations.getConceptDeclaration(attributedNode));
   SNode link =
       SNodeOperations.cast(
           linkSearchScope.getMostSpecificLinkDeclarationByRole(linkRole),
           "jetbrains.mps.lang.structure.structure.LinkDeclaration");
   SNode targetConcept = SLinkOperations.getTarget(link, "target", false);
   SNode expectedNodeType = _quotation_createNode_mxwyp3_a0g0a(targetConcept);
   // reference may be resolved dynamically?
   if (SConceptOperations.isSubConceptOf(
       targetConcept, "jetbrains.mps.lang.core.structure.IResolveInfo")) {
     return _quotation_createNode_mxwyp3_a0a8a0(targetConcept);
   }
   return expectedNodeType;
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   List<SNode> TFs =
       SNodeOperations.getDescendants(
           SLinkOperations.getTarget(
               SLinkOperations.getTarget(node, "template", false), "contentNode", true),
           "jetbrains.mps.lang.generator.structure.TemplateFragment",
           true,
           new String[] {});
   if ((int) ListSequence.fromList(TFs).count() == 0) {
     JOptionPane.showMessageDialog(null, "No fragments found");
     return;
   }
   if (ListSequence.fromList(TFs).count() > 1) {
     JOptionPane.showMessageDialog(null, "Too many fragments");
     return;
   }
   // ------
   SNode oldTemplate = SLinkOperations.getTarget(node, "template", false);
   SNode fragmentToSet =
       SNodeOperations.copyNode(SNodeOperations.getParent(ListSequence.fromList(TFs).first()));
   SNode TFtoDelete =
       AttributeOperations.getAttribute(
           fragmentToSet,
           new IAttributeDescriptor.NodeAttribute(
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.lang.generator.structure.TemplateFragment")));
   SNodeOperations.deleteNode(TFtoDelete);
   SNode inlineTemplate =
       SNodeFactoryOperations.replaceWithNewChild(
           node, "jetbrains.mps.lang.generator.structure.InlineTemplate_RuleConsequence");
   SLinkOperations.setTarget(inlineTemplate, "templateNode", fragmentToSet, true);
   // ------
   int option =
       JOptionPane.showConfirmDialog(
           null, "Delete old template?", "", JOptionPane.YES_NO_OPTION);
   if (option == JOptionPane.YES_OPTION) {
     SNodeOperations.deleteNode(oldTemplate);
   }
 }
 private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
   SNode annotation =
       AttributeOperations.getAttribute(
           node,
           new IAttributeDescriptor.NodeAttribute(
               "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"));
   if (annotation == null) {
     return false;
   }
   if (SLinkOperations.getTarget(annotation, "applicableConcept", false) == null) {
     return false;
   }
   List<SNode> configs =
       SModelOperations.getRoots(
           SNodeOperations.getModel(node),
           "jetbrains.mps.lang.generator.structure.MappingConfiguration");
   if (ListSequence.fromList(configs).isEmpty()) {
     return false;
   }
   SNode usage =
       ListSequence.fromList(configs)
           .findFirst(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return ListSequence.fromList(
                               SLinkOperations.getTargets(it, "rootMappingRule", true))
                           .findFirst(
                               new IWhereFilter<SNode>() {
                                 public boolean accept(SNode it) {
                                   return SLinkOperations.getTarget(it, "template", false) == node;
                                 }
                               })
                       != null;
                 }
               });
   //  not used in rule yet?
   return usage == null;
 }
 public void doGenerateText(SNode node) {
   if (getBuffer().hasPositionsSupport()) {
     TraceInfoGenerationUtil.createUnitInfo(this, node);
   }
   if ((AttributeOperations.getAttribute(
           node,
           new IAttributeDescriptor.NodeAttribute(
               "jetbrains.mps.baseLanguage.javadoc.structure.ClassifierDocComment"))
       != null)) {
     appendNode(
         AttributeOperations.getAttribute(
             node,
             new IAttributeDescriptor.NodeAttribute(
                 "jetbrains.mps.baseLanguage.javadoc.structure.ClassifierDocComment")));
   }
   BaseLanguageTextGen.fileHeader(node, this);
   BaseLanguageTextGen.annotations(node, this);
   BaseLanguageTextGen.visibilityWithIndent(
       SLinkOperations.getTarget(node, "visibility", true), this);
   if (Classifier_Behavior.call_isInner_521412098689998677(node)
       && BehaviorReflection.invokeVirtual(
           Boolean.TYPE, node, "virtual_isStatic_7405920559687241224", new Object[] {})) {
     this.append("static ");
   }
   if (SPropertyOperations.getBoolean(node, "abstractClass")) {
     this.append("abstract ");
   }
   if (SPropertyOperations.getBoolean(node, "isFinal")) {
     this.append("final ");
   }
   this.append("class ");
   this.append(SPropertyOperations.getString(node, "name"));
   GenericDeclarationTextGen2.typeDeclarations(node, this);
   if ((SLinkOperations.getTarget(node, "superclass", true) != null)) {
     this.append(" extends ");
     appendNode(SLinkOperations.getTarget(node, "superclass", true));
   }
   if (ListSequence.fromList(SLinkOperations.getTargets(node, "implementedInterface", true))
       .isNotEmpty()) {
     this.append(" implements ");
     {
       Iterable<SNode> collection = SLinkOperations.getTargets(node, "implementedInterface", true);
       final SNode lastItem = Sequence.fromIterable(collection).last();
       for (SNode item : collection) {
         appendNode(item);
         if (item != lastItem) {
           append(", ");
         }
       }
     }
   }
   this.append(" ");
   BaseClassConceptTextGen.membersWithBrackets(node, true, this);
   this.appendNewLine();
   if (getBuffer().hasPositionsSupport()) {
     {
       String unitName = null;
       try {
         unitName =
             BehaviorReflection.invokeVirtual(
                 String.class,
                 SNodeOperations.cast(node, "jetbrains.mps.lang.traceable.structure.UnitConcept"),
                 "virtual_getUnitName_5067982036267369911",
                 new Object[] {});
       } catch (Throwable t) {
         if (LOG.isEnabledFor(Level.ERROR)) {
           LOG.error("Can't calculate unit name for a node " + node + ".", t);
         }
       }
       TraceInfoGenerationUtil.fillUnitInfo(this, node, unitName);
     }
   }
 }
Example #24
0
 public static SNode getEnclosing_SourceSubstituteMacro(SNode node, SNode currMacroNode) {
   if (node == null) {
     return null;
   }
   if (SNodeOperations.isInstanceOf(
           node, "jetbrains.mps.lang.generator.structure.InlineTemplate_RuleConsequence")
       || SNodeOperations.isInstanceOf(
           node,
           "jetbrains.mps.lang.generator.structure.InlineTemplateWithContext_RuleConsequence")) {
     SNode parent = SNodeOperations.getParent(node);
     if ((parent == null)
         || !(SNodeOperations.isInstanceOf(
             parent, "jetbrains.mps.lang.generator.structure.IfMacro"))
         || SLinkOperations.getTarget(
                 SNodeOperations.cast(parent, "jetbrains.mps.lang.generator.structure.IfMacro"),
                 "alternativeConsequence",
                 true)
             != node) {
       return null;
     }
   }
   List<SNode> attributes =
       AttributeOperations.getAttributeList(node, new IAttributeDescriptor.AllAttributes());
   SNode prevMacro = null;
   for (SNode attribute : ListSequence.fromList(attributes)) {
     if (attribute == currMacroNode) {
       break;
     }
     if (SNodeOperations.isInstanceOf(
         attribute, "jetbrains.mps.lang.generator.structure.SourceSubstituteMacro")) {
       if (SNodeOperations.isInstanceOf(
           attribute, "jetbrains.mps.lang.generator.structure.MapSrcNodeMacro")) {
         if (SLinkOperations.getTarget(
                 SNodeOperations.cast(
                     attribute, "jetbrains.mps.lang.generator.structure.MapSrcNodeMacro"),
                 "sourceNodeQuery",
                 true)
             == null) {
           // the query is optional - continue 'enclosing macro' look-up
           continue;
         }
       }
       if (SNodeOperations.isInstanceOf(
           attribute, "jetbrains.mps.lang.generator.structure.SwitchMacro")) {
         if (SLinkOperations.getTarget(
                 SNodeOperations.cast(
                     attribute, "jetbrains.mps.lang.generator.structure.SwitchMacro"),
                 "sourceNodeQuery",
                 true)
             == null) {
           // the query is optional - continue 'enclosing macro' look-up
           continue;
         }
       }
       // ========
       prevMacro =
           SNodeOperations.cast(
               attribute, "jetbrains.mps.lang.generator.structure.SourceSubstituteMacro");
     }
   }
   // ========
   if (prevMacro != null) {
     return prevMacro;
   }
   return getEnclosing_SourceSubstituteMacro(SNodeOperations.getParent(node), null);
 }
 private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
   SNode annotation =
       AttributeOperations.getAttribute(
           node,
           new IAttributeDescriptor.NodeAttribute(
               MetaAdapterFactory.getConcept(
                   0xb401a68083254110L,
                   0x8fd384331ff25befL,
                   0x11017244494L,
                   "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation")));
   if (annotation == null) {
     return false;
   }
   if (SLinkOperations.getTarget(
           annotation,
           MetaAdapterFactory.getReferenceLink(
               0xb401a68083254110L,
               0x8fd384331ff25befL,
               0x11017244494L,
               0x11017255ccfL,
               "applicableConcept"))
       != null) {
     return false;
   }
   List<SNode> configs =
       SModelOperations.roots(
           SNodeOperations.getModel(node),
           MetaAdapterFactory.getConcept(
               0xb401a68083254110L,
               0x8fd384331ff25befL,
               0xff0bea0475L,
               "jetbrains.mps.lang.generator.structure.MappingConfiguration"));
   if (ListSequence.fromList(configs).isEmpty()) {
     return false;
   }
   SNode usage =
       ListSequence.fromList(configs)
           .findFirst(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return ListSequence.fromList(
                               SLinkOperations.getChildren(
                                   it,
                                   MetaAdapterFactory.getContainmentLink(
                                       0xb401a68083254110L,
                                       0x8fd384331ff25befL,
                                       0xff0bea0475L,
                                       0x10fbbe00519L,
                                       "createRootRule")))
                           .findFirst(
                               new IWhereFilter<SNode>() {
                                 public boolean accept(SNode it) {
                                   return SLinkOperations.getTarget(
                                           it,
                                           MetaAdapterFactory.getReferenceLink(
                                               0xb401a68083254110L,
                                               0x8fd384331ff25befL,
                                               0x10fbbd5854aL,
                                               0x10fbbd5854dL,
                                               "templateNode"))
                                       == node;
                                 }
                               })
                       != null;
                 }
               });
   //  not used in rule yet?
   return usage == null;
 }
Example #26
0
  @Override
  public List<SearchResult<ModelCheckerIssue>> checkModel(
      SModel model, ProgressMonitor monitor, final IOperationContext operationContext) {
    List<SearchResult<ModelCheckerIssue>> results =
        ListSequence.fromList(new ArrayList<SearchResult<ModelCheckerIssue>>());
    String title =
        "Checking " + SModelOperations.getModelName(model) + " for wrong aspect dependencies...";
    monitor.start(title, 1);

    int modelKind = getModelKind(model, null);
    if (modelKind == OTHER) {
      monitor.done();
      return results;
    }

    for (SNode node : ListSequence.fromList(SModelOperations.getNodes(model, null))) {
      if (monitor.isCanceled()) {
        break;
      }
      // Check for unresolved references
      for (final SReference ref : Sequence.fromIterable(SNodeOperations.getReferences(node))) {
        if ((AttributeOperations.getAttribute(
                node,
                new IAttributeDescriptor.LinkAttribute(
                    SConceptOperations.findConceptDeclaration(
                        "jetbrains.mps.lang.generator.structure.ReferenceMacro"),
                    SLinkOperations.getRole(ref)))
            != null)) {
          continue;
        }
        SNode targetNode = jetbrains.mps.util.SNodeOperations.getTargetNodeSilently(ref);
        if (targetNode == null) {
          addIssue(
              results,
              node,
              "Unresolved reference: " + SLinkOperations.getResolveInfo(ref),
              ModelChecker.SEVERITY_ERROR,
              "unresolved reference",
              new IModelCheckerFix() {
                public boolean doFix() {
                  return ResolverComponent.getInstance().resolve(ref, operationContext);
                }
              });
          continue;
        }

        SModel targetModel = SNodeOperations.getModel(targetNode);
        int targetKind = getModelKind(targetModel, ref);
        if (targetKind > modelKind) {
          addIssue(
              results,
              node,
              "Wrong reference: "
                  + SLinkOperations.getResolveInfo(ref)
                  + ", reference from "
                  + kindToString(modelKind)
                  + " to "
                  + kindToString(targetKind),
              ModelChecker.SEVERITY_ERROR,
              "wrong aspect dependency (" + kindToString(modelKind) + ")",
              null);
        }
      }
    }
    monitor.done();
    return results;
  }