public void applyRule(
     final SNode classifier,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   OverridingMethodsFinder finder = new OverridingMethodsFinder(classifier);
   Set<SNode> overridingMethods = finder.getOverridingMethods();
   for (SNode method : SLinkOperations.getTargets(classifier, "method", true)) {
     for (SNode annotationInstance : SLinkOperations.getTargets(method, "annotation", true)) {
       if (SLinkOperations.getTarget(annotationInstance, "annotation", false)
               == SNodeOperations.getNode(
                   "f:java_stub#6354ebe7-c22a-4a0f-ac54-50b52ab9b065#java.lang(JDK/java.lang@java_stub)",
                   "~Override")
           && !(SetSequence.fromSet(overridingMethods).contains(method))) {
         {
           MessageTarget errorTarget = new NodeMessageTarget();
           IErrorReporter _reporter_2309309498 =
               typeCheckingContext.reportTypeError(
                   annotationInstance,
                   "Method does not override method from its superclass",
                   "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                   "4540477783368646804",
                   null,
                   errorTarget);
         }
         break;
       }
     }
   }
 }
Пример #2
0
 public static boolean virtual_isMpsStartRequired_3310779261129403089(SNode thisNode) {
   for (SNode annotationInstance :
       ListSequence.fromList(SLinkOperations.getTargets(thisNode, "annotation", true))) {
     if (SLinkOperations.getTarget(annotationInstance, "annotation", false)
         .equals(
             SNodeOperations.getNode(
                 "f:java_stub#920eaa0e-ecca-46bc-bee7-4e5c59213dd6#jetbrains.mps(Testbench/jetbrains.mps@java_stub)",
                 "~MPSLaunch"))) {
       return true;
     }
   }
   for (SNode method :
       SLinkOperations.getTargets(
           SLinkOperations.getTarget(thisNode, "testMethodList", true), "testMethod", true)) {
     for (SNode annotationInstance : SLinkOperations.getTargets(method, "annotation", true)) {
       if (SLinkOperations.getTarget(annotationInstance, "annotation", false)
           .equals(
               SNodeOperations.getNode(
                   "f:java_stub#920eaa0e-ecca-46bc-bee7-4e5c59213dd6#jetbrains.mps(Testbench/jetbrains.mps@java_stub)",
                   "~MPSLaunch"))) {
         return true;
       }
     }
   }
   return false;
 }
Пример #3
0
 public void synchronize() {
   Set<SNode> existingBlocks = new HashSet<SNode>(myBlocks);
   ListIterator<SNode> blocksIterator = myBlocks.listIterator();
   Set<SNode> existingConnectors = new HashSet<SNode>(myConnectors);
   ListIterator<SNode> connectorsIterator = myConnectors.listIterator();
   syncDiagramElements(
       SLinkOperations.getTargets(getSNode(), "component", true),
       blocksIterator,
       existingBlocks,
       connectorsIterator,
       existingConnectors);
   syncDiagramElements(
       ListSequence.fromList(SLinkOperations.getTargets(getSNode(), "component", true))
           .translate(
               new ITranslator2<SNode, SNode>() {
                 public Iterable<SNode> translate(SNode it) {
                   return SLinkOperations.getTargets(it, "dep", true);
                 }
               }),
       blocksIterator,
       existingBlocks,
       connectorsIterator,
       existingConnectors);
   purgeTailNodes(blocksIterator);
   purgeTailNodes(connectorsIterator);
 }
Пример #4
0
  public static SNode virtual_getCreatorExpression_7057666463730727863(
      SNode thisNode, SNode parentRef) {
    SNode result =
        SNodeOperations.copyNode(
            SLinkOperations.getTarget(
                SLinkOperations.getTarget(thisNode, "declaration", false), "creator", true));

    List<SNode> params =
        SLinkOperations.getTargets(
            SLinkOperations.getTarget(thisNode, "declaration", false), "parameter", true);
    List<SNode> args = SLinkOperations.getTargets(thisNode, "argument", true);
    if (ListSequence.fromList(params).count() != ListSequence.fromList(args).count()) {
      throw new RuntimeException();
    }

    for (SNode ref :
        SNodeOperations.getDescendants(
            result,
            "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderParameterReference",
            false,
            new String[] {})) {
      int index =
          ListSequence.fromList(params).indexOf(SLinkOperations.getTarget(ref, "parameter", false));
      SNodeOperations.replaceWithAnother(
          ref, SNodeOperations.copyNode(ListSequence.fromList(args).getElement(index)));
    }

    return result;
  }
Пример #5
0
 public Set<? extends IVertex> getNexts() {
   if (targets == null) {
     if (ListSequence.fromList(SLinkOperations.getTargets(module, "dependencies", true))
         .isEmpty()) {
       targets = Collections.emptySet();
     } else {
       targets = new HashSet<CycleHelper.Module>();
       for (SNode ref :
           ListSequence.fromList(SLinkOperations.getTargets(module, "dependencies", true))
               .where(
                   new IWhereFilter<SNode>() {
                     public boolean accept(SNode it) {
                       return SNodeOperations.isInstanceOf(
                           it, "jetbrains.mps.build.workflow.structure.BwfJavaModuleReference");
                     }
                   })) {
         CycleHelper.Module tm =
             map.get(
                 SLinkOperations.getTarget(
                     SNodeOperations.cast(
                         ref, "jetbrains.mps.build.workflow.structure.BwfJavaModuleReference"),
                     "target",
                     false));
         if (tm == null) {
           genContext.showErrorMessage(ref, "internal problem: unsatisfied local dependency");
         } else {
           targets.add(tm);
         }
       }
     }
   }
   return targets;
 }
 public void doGenerateText(SNode node) {
   if (getBuffer().hasPositionsSupport()) {
     TraceInfoGenerationUtil.createPositionInfo(this, node);
   }
   for (SNode item : SLinkOperations.getTargets(node, "item", true)) {
     if (item != ListSequence.fromList(SLinkOperations.getTargets(node, "item", true)).first()) {
       TextGenManager.instance()
           .appendNodeText(
               this.getContext(),
               this.getBuffer(),
               SLinkOperations.getTarget(node, "separator", true),
               this.getSNode());
     }
     TextGenManager.instance()
         .appendNodeText(this.getContext(), this.getBuffer(), item, this.getSNode());
   }
   if (getBuffer().hasPositionsSupport()) {
     {
       String traceableProperty = "";
       try {
         traceableProperty =
             BehaviorReflection.invokeVirtual(
                 String.class,
                 SNodeOperations.cast(
                     node, "jetbrains.mps.lang.traceable.structure.TraceableConcept"),
                 "virtual_getTraceableProperty_5067982036267369901",
                 new Object[] {});
       } catch (Throwable t) {
         LOG.error("Can't calculate traceable prorerty for a node " + node + ".", t);
       }
       TraceInfoGenerationUtil.fillPositionInfo(this, node, traceableProperty);
     }
   }
 }
Пример #7
0
 public static Object insertMacro_varValue_3961775458390375615(
     final TemplateQueryContext _context) {
   StringBuilder res = new StringBuilder();
   Set<String> used = new HashSet<String>();
   Iterable<SNode> dependencies =
       SLinkOperations.getTargets(_context.getNode(), "dependencies", true);
   for (SNode part : ((List<SNode>) _context.getVariable("var:taskParts"))) {
     dependencies =
         Sequence.fromIterable(dependencies)
             .concat(
                 ListSequence.fromList(
                     SLinkOperations.getTargets(part, "additionalDependencies", true)));
   }
   for (SNode dep : dependencies) {
     String d =
         SPropertyOperations.getString(SLinkOperations.getTarget(dep, "target", false), "name");
     if (used.add(d)) {
       if (res.length() > 0) {
         res.append(", ");
       }
       res.append(d);
     }
   }
   return res.toString();
 }
Пример #8
0
    @Override
    public void addNested(SNode decl, final SNode nestedDecl, ClassInfo.Nested nested) {
      SNode node =
          ListSequence.fromList(SLinkOperations.getTargets(decl, "nested", true))
              .where(
                  new IWhereFilter<SNode>() {
                    public boolean accept(SNode it) {
                      return eq_ixz87t_a0a0a0a0a0a0a0l9(
                          SLinkOperations.getTarget(it, "declaration", false), nestedDecl);
                    }
                  })
              .first();
      if ((node != null)) {
        for (String name : nested.getNames()) {
          this.addNestedName(decl, node, name);
        }
        return;
      }

      SNode nref = _quotation_createNode_ixz87t_a0d0l9(nestedDecl);
      if (eq_ixz87t_a0e0l9(SLinkOperations.getTarget(nref, "declaration", false), nestedDecl)) {
        for (String name : nested.getNames()) {
          this.addNestedName(decl, nref, name);
        }
      }
      ListSequence.fromList(SLinkOperations.getTargets(decl, "nested", true)).addElement(nref);
    }
 public void applyRule(
     final SNode annotationInstance,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   SNode annotation = SLinkOperations.getTarget(annotationInstance, "annotation", false);
   for (SNode annotationMethod : SLinkOperations.getTargets(annotation, "method", true)) {
     if ((SLinkOperations.getTarget(annotationMethod, "defaultValue", true) != null)) {
       continue;
     }
     boolean found = false;
     for (SNode annotationInstanceValue :
         SLinkOperations.getTargets(annotationInstance, "value", true)) {
       if (SLinkOperations.getTarget(annotationInstanceValue, "key", false) == annotationMethod) {
         found = true;
         break;
       }
     }
     if (!(found)) {
       {
         MessageTarget errorTarget = new NodeMessageTarget();
         IErrorReporter _reporter_2309309498 =
             typeCheckingContext.reportTypeError(
                 annotationInstance,
                 "'"
                     + SPropertyOperations.getString(annotationMethod, "name")
                     + "' missing though required",
                 "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                 "6624237184121162632",
                 null,
                 errorTarget);
       }
     }
   }
 }
 public void build(
     final IOperationContext operationContext, final DataFlowBuilderContext _context) {
   _context
       .getBuilder()
       .build((SNode) SLinkOperations.getTarget(_context.getNode(), "leftExpression", true));
   _context
       .getBuilder()
       .build((SNode) SLinkOperations.getTarget(_context.getNode(), "rightExpression", true));
   if ((SLinkOperations.getTarget(_context.getNode(), "errorString", true) != null)) {
     _context
         .getBuilder()
         .build((SNode) SLinkOperations.getTarget(_context.getNode(), "errorString", true));
   }
   if ((SLinkOperations.getTarget(_context.getNode(), "nodeToCheck", true) != null)) {
     _context
         .getBuilder()
         .build((SNode) SLinkOperations.getTarget(_context.getNode(), "nodeToCheck", true));
   }
   if (ListSequence.fromList(
           SLinkOperations.getTargets(_context.getNode(), "helginsIntention", true))
       .isNotEmpty()) {
     for (SNode intetntion :
         SLinkOperations.getTargets(_context.getNode(), "helginsIntention", true)) {
       _context.getBuilder().build((SNode) intetntion);
     }
   }
 }
 private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
   Iterable<SNode> nodes =
       ListSequence.fromList(SNodeOperations.getChildren(SNodeOperations.getParent(node)))
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return SNodeOperations.isInstanceOf(
                       it, "jetbrains.mps.lang.generator.structure.NodeMacro");
                 }
               });
   boolean seen = false;
   for (SNode n : nodes) {
     if (seen) {
       if (SNodeOperations.isInstanceOf(
           n, "jetbrains.mps.lang.generator.structure.CopySrcNodeMacro")) {
         SNode m =
             SLinkOperations.getTarget(
                 SNodeOperations.cast(
                     n, "jetbrains.mps.lang.generator.structure.CopySrcNodeMacro"),
                 "sourceNodeQuery",
                 true);
         if ((m == null)
             || (SLinkOperations.getTarget(m, "body", true) == null)
             || ListSequence.fromList(
                     SLinkOperations.getTargets(
                         SLinkOperations.getTarget(m, "body", true), "statement", true))
                 .isEmpty()
             || ListSequence.fromList(
                         SLinkOperations.getTargets(
                             SLinkOperations.getTarget(m, "body", true), "statement", true))
                     .count()
                 > 1) {
           return false;
         }
         SNode st =
             ListSequence.fromList(
                     SLinkOperations.getTargets(
                         SLinkOperations.getTarget(m, "body", true), "statement", true))
                 .first();
         return SNodeOperations.isInstanceOf(
                 st, "jetbrains.mps.baseLanguage.structure.ExpressionStatement")
             && SNodeOperations.isInstanceOf(
                 SLinkOperations.getTarget(
                     SNodeOperations.cast(
                         st, "jetbrains.mps.baseLanguage.structure.ExpressionStatement"),
                     "expression",
                     true),
                 "jetbrains.mps.lang.generator.structure.TemplateFunctionParameter_sourceNode");
       } else {
         return false;
       }
     } else if (n == node) {
       seen = true;
     }
   }
   return false;
 }
Пример #12
0
 public static List<SNode> call_getAllSuperClassifiers_4892662966716545618(SNode thisNode) {
   Set<SNode> seen = SetSequence.fromSet(new HashSet<SNode>());
   List<SNode> result = new ArrayList<SNode>();
   Queue<SNode> q = QueueSequence.fromQueue(new LinkedList<SNode>());
   QueueSequence.fromQueue(q).addLastElement(thisNode);
   while (QueueSequence.fromQueue(q).isNotEmpty()) {
     SNode qn = QueueSequence.fromQueue(q).removeFirstElement();
     ListSequence.fromList(result).addElement(qn);
     if (SNodeOperations.isInstanceOf(qn, "jetbrains.mps.baseLanguage.structure.ClassConcept")) {
       if ((SLinkOperations.getTarget(
               SNodeOperations.cast(qn, "jetbrains.mps.baseLanguage.structure.ClassConcept"),
               "superclass",
               true)
           != null)) {
         SNode cl =
             SLinkOperations.getTarget(
                 SLinkOperations.getTarget(
                     SNodeOperations.cast(qn, "jetbrains.mps.baseLanguage.structure.ClassConcept"),
                     "superclass",
                     true),
                 "classifier",
                 false);
         if (seen.add(cl)) {
           QueueSequence.fromQueue(q).addLastElement(cl);
         }
       }
       for (SNode i :
           SLinkOperations.getTargets(
               SNodeOperations.cast(qn, "jetbrains.mps.baseLanguage.structure.ClassConcept"),
               "implementedInterface",
               true)) {
         SNode cl = SLinkOperations.getTarget(i, "classifier", false);
         if (seen.add(cl)) {
           QueueSequence.fromQueue(q).addLastElement(cl);
         }
       }
     } else if (SNodeOperations.isInstanceOf(
         qn, "jetbrains.mps.baseLanguage.structure.Interface")) {
       for (SNode i :
           SLinkOperations.getTargets(
               SNodeOperations.cast(qn, "jetbrains.mps.baseLanguage.structure.Interface"),
               "extendedInterface",
               true)) {
         SNode cl = SLinkOperations.getTarget(i, "classifier", false);
         if (seen.add(cl)) {
           QueueSequence.fromQueue(q).addLastElement(cl);
         }
       }
     }
   }
   SNode obj = _quotation_createNode_xjj00_a0f0m();
   if (seen.add(SLinkOperations.getTarget(obj, "classifier", false))) {
     ListSequence.fromList(result).addElement(SLinkOperations.getTarget(obj, "classifier", false));
   }
   return result;
 }
 private static boolean renderingCondition_1xd1xh_a0a(
     SNode node, EditorContext editorContext, IScope scope) {
   return ListSequence.fromList(SLinkOperations.getTargets(node, "actualArgument", true))
           .isNotEmpty()
       || (SLinkOperations.getTarget(node, "template", false) != null)
           && ListSequence.fromList(
                   SLinkOperations.getTargets(
                       SLinkOperations.getTarget(node, "template", false), "parameter", true))
               .isNotEmpty();
 }
Пример #14
0
    private void addNestedName(SNode declaration, SNode nref, String name) {
      for (SNode ref : SLinkOperations.getTargets(nref, "role", true)) {
        if (eq_ixz87t_a0a0a0m9(
            SPropertyOperations.getString(
                SLinkOperations.getTarget(ref, "declaration", false), "name"),
            name)) {
          return;
        }
      }

      if (eq_ixz87t_a0c0m9(
          SPropertyOperations.getString(
              SLinkOperations.getTarget(nref, "declaration", false), "name"),
          name)) {
        ListSequence.fromList(SLinkOperations.getTargets(nref, "role", true))
            .addElement(
                Generator.GENERATOR.createDeclarationReference(
                    SNodeOperations.cast(
                        SLinkOperations.getTarget(nref, "declaration", false),
                        "jetbrains.mps.build.generictasks.structure.BuiltInTaskDeclaration")));
        return;
      }

      SNode parentDeclaration =
          SNodeOperations.cast(
              SLinkOperations.getTarget(nref, "declaration", false),
              "jetbrains.mps.build.generictasks.structure.BuiltInTaskDeclaration");
      SNode parentRef = Generator.GENERATOR.createDeclarationReference(parentDeclaration);
      SNode fake;
      if (SNodeOperations.isInstanceOf(
          parentDeclaration,
          "jetbrains.mps.build.generictasks.structure.TaskInterfaceDeclaration")) {
        fake =
            Generator.GENERATOR.createInterfaceDeclaration(
                name,
                SPropertyOperations.getString(parentDeclaration, "classname"),
                SPropertyOperations.getBoolean(parentDeclaration, "depracated"));
        ListSequence.fromList(SLinkOperations.getTargets(fake, "interfaces", true))
            .addElement(parentRef);
      } else {
        fake =
            Generator.GENERATOR.createDeclaration(
                name,
                SPropertyOperations.getString(parentDeclaration, "classname"),
                SPropertyOperations.getBoolean(parentDeclaration, "abstract"),
                SPropertyOperations.getBoolean(parentDeclaration, "canHaveInternalText"),
                SPropertyOperations.getBoolean(parentDeclaration, "depracated"));
        SLinkOperations.setTarget(fake, "parentRef", parentRef, true);
      }
      SPropertyOperations.set(fake, "fake", "" + (true));
      ListSequence.fromList(SLinkOperations.getTargets(nref, "role", true))
          .addElement(Generator.GENERATOR.createDeclarationReference(fake));
      ListSequence.fromList(SLinkOperations.getTargets(declaration, "fakeDeclaration", true))
          .addElement(fake);
    }
Пример #15
0
 public void performActions(Program o, SNode node) {
   SNode m = node;
   SNode targetNode = node;
   while (SNodeOperations.isInstanceOf(
           SNodeOperations.getParent(targetNode),
           "jetbrains.mps.baseLanguage.structure.DotExpression")
       && SLinkOperations.getTarget(
               SNodeOperations.cast(
                   SNodeOperations.getParent(targetNode),
                   "jetbrains.mps.baseLanguage.structure.DotExpression"),
               "operation",
               true)
           == targetNode) {
     targetNode = SNodeOperations.getParent(targetNode);
   }
   if (SLinkOperations.getTargets(
           SLinkOperations.getTarget(m, "baseMethodDeclaration", false), "annotation", true)
       != null) {
     for (SNode annotation :
         SLinkOperations.getTargets(
             SLinkOperations.getTarget(m, "baseMethodDeclaration", false), "annotation", true)) {
       if (SLinkOperations.getTarget(annotation, "annotation", false)
           == SNodeOperations.getNode(
               "f:java_stub#3f233e7f-b8a6-46d2-a57f-795d56775243#org.jetbrains.annotations(Annotations/org.jetbrains.annotations@java_stub)",
               "~Nullable")) {
         {
           Object object = node;
           if (((Program) o).contains(object)) {
             boolean before = false;
             int position = ((Program) (o)).getEnd(object);
             Instruction instruction = new nullableInstruction(targetNode);
             instruction.setSource(node);
             ((Program) (o)).insert(instruction, position, true, before);
           }
         }
       }
       if (SLinkOperations.getTarget(annotation, "annotation", false)
           == SNodeOperations.getNode(
               "f:java_stub#3f233e7f-b8a6-46d2-a57f-795d56775243#org.jetbrains.annotations(Annotations/org.jetbrains.annotations@java_stub)",
               "~NotNull")) {
         {
           Object object = node;
           if (((Program) o).contains(object)) {
             boolean before = false;
             int position = ((Program) (o)).getEnd(object);
             Instruction instruction = new notNullInstruction(targetNode);
             instruction.setSource(node);
             ((Program) (o)).insert(instruction, position, true, before);
           }
         }
       }
     }
   }
 }
Пример #16
0
 public static void innerClassifiers(SNode concept, final SNodeTextGen textGen) {
   for (SNode classifier : SLinkOperations.getTargets(concept, "staticInnerClassifiers", true)) {
     TextGenManager.instance()
         .appendNodeText(
             textGen.getContext(), textGen.getBuffer(), classifier, textGen.getSNode());
     if (!(classifier.equals(
         ListSequence.fromList(SLinkOperations.getTargets(concept, "staticInnerClassifiers", true))
             .last()))) {
       textGen.appendNewLine();
     }
   }
 }
  public void process() {
    VisibleArtifacts artifacts = new VisibleArtifacts(project, genContext);
    artifacts.collect();
    UnpackHelper helper = new UnpackHelper(artifacts, genContext);
    for (SNode dep :
        SNodeOperations.getDescendants(
            project,
            "jetbrains.mps.build.structure.BuildExternalDependency",
            false,
            new String[] {})) {
      BehaviorReflection.invokeVirtual(
          Void.class,
          dep,
          "virtual_fetchDependencies_5908258303322131137",
          new Object[] {
            artifacts,
            new FetchDependenciesProcessor.RequiredDependenciesBuilderImpl(artifacts, dep, helper)
          });
    }
    helper.eval();

    List<SNode> statements = helper.getStatements();
    if (!(ListSequence.fromList(statements).isEmpty())) {
      SNode wf =
          SModelOperations.createNewNode(
              SNodeOperations.getModel(project),
              null,
              "jetbrains.mps.build.structure.BuildCustomWorkflow");
      SNode taskpart =
          SModelOperations.createNewNode(
              SNodeOperations.getModel(project),
              null,
              "jetbrains.mps.build.workflow.structure.BwfTaskPart");
      SLinkOperations.setTarget(
          taskpart,
          "task",
          SLinkOperations.getTarget(_quotation_createNode_t02zqv_a0a2a7a3(), "target", false),
          false);
      ListSequence.fromList(SLinkOperations.getTargets(wf, "parts", true)).addElement(taskpart);
      SNode stask =
          SModelOperations.createNewNode(
              SNodeOperations.getModel(project),
              null,
              "jetbrains.mps.build.workflow.structure.BwfSubTask");
      SPropertyOperations.set(stask, "name", "fetch");
      ListSequence.fromList(SLinkOperations.getTargets(taskpart, "subTasks", true))
          .addElement(stask);
      ListSequence.fromList(SLinkOperations.getTargets(stask, "statements", true))
          .addSequence(ListSequence.fromList(statements));
      ListSequence.fromList(SLinkOperations.getTargets(project, "aspects", true)).addElement(wf);
    }
  }
Пример #18
0
 public static Iterable<SNode> sourceNodesQuery_7385586609667799717(
     final SourceSubstituteMacroNodesContext _context) {
   List<SNode> subTasks = new ArrayList<SNode>();
   ListSequence.fromList(subTasks)
       .addSequence(
           ListSequence.fromList(
               SLinkOperations.getTargets(_context.getNode(), "subTasks", true)));
   for (SNode part : ((List<SNode>) _context.getVariable("var:taskParts"))) {
     ListSequence.fromList(subTasks)
         .addSequence(ListSequence.fromList(SLinkOperations.getTargets(part, "subTasks", true)));
   }
   new SubTaskOrderHelper(subTasks, _context).sort();
   return subTasks;
 }
Пример #19
0
 @Override
 public void addInterface(SNode declaration, SNode interfaceDeclaration) {
   for (SNode in : SLinkOperations.getTargets(declaration, "interfaces", true)) {
     if (eq_ixz87t_a0a0a0f9(
         SPropertyOperations.getString(
             SLinkOperations.getTarget(in, "declaration", false), "name"),
         SPropertyOperations.getString(interfaceDeclaration, "name"))) {
       return;
     }
   }
   SNode ref = Generator.GENERATOR.createDeclarationReference(interfaceDeclaration);
   ListSequence.fromList(SLinkOperations.getTargets(declaration, "interfaces", true))
       .addElement(ref);
 }
Пример #20
0
 public void synchronize() {
   super.synchronizeViewWithModel();
   myPropertyCell_pj4dhh_a0a.synchronize();
   myPropertyCell_pj4dhh_a1a.synchronize();
   myPropertyCell_pj4dhh_a2a.synchronize();
   myPropertyCell_pj4dhh_a3a.synchronize();
   syncPortNodes(
       SLinkOperations.getTargets(getSNode(), "inputPorts", true),
       myInputPorts.listIterator(),
       new HashSet<SNode>(myInputPorts));
   syncPortNodes(
       SLinkOperations.getTargets(getSNode(), "outputPorts", true),
       myOutputPorts.listIterator(),
       new HashSet<SNode>(myOutputPorts));
 }
Пример #21
0
 public void doGenerateText(SNode node) {
   TextGenManager.instance()
       .appendNodeText(
           this.getContext(),
           this.getBuffer(),
           SLinkOperations.getTarget(node, "componentType", true),
           this.getSNode());
   if (ListSequence.fromList(SLinkOperations.getTargets(node, "dimensionExpression", true))
       .isNotEmpty()) {
     for (SNode item : SLinkOperations.getTargets(node, "dimensionExpression", true)) {
       TextGenManager.instance()
           .appendNodeText(this.getContext(), this.getBuffer(), item, this.getSNode());
     }
   }
 }
    public void execute(final SNode node, final EditorContext editorContext) {
      SNode statement =
          SConceptOperations.createNewNode(
              "org.jetbrains.mps.samples.IfAndUnless.structure.MyIfStatement", null);
      SLinkOperations.setTarget(
          statement, "condition", SLinkOperations.getTarget(node, "condition", true), true);
      SNode ifBody =
          SConceptOperations.createNewNode(
              "org.jetbrains.mps.samples.IfAndUnless.structure.TrueFlow", null);
      ListSequence.fromList(SLinkOperations.getTargets(ifBody, "statement", true))
          .addSequence(
              ListSequence.fromList(
                  SLinkOperations.getTargets(
                      SLinkOperations.getTarget(node, "ifTrue", true), "statement", true)));
      SLinkOperations.setTarget(statement, "body", ifBody, true);

      SLinkOperations.setTarget(
          statement,
          "alternative",
          SConceptOperations.createNewNode(
              "org.jetbrains.mps.samples.IfAndUnless.structure.FalseFlow", null),
          true);
      if (SNodeOperations.isInstanceOf(
          SLinkOperations.getTarget(node, "ifFalseStatement", true),
          "jetbrains.mps.baseLanguage.structure.BlockStatement")) {
        ListSequence.fromList(
                SLinkOperations.getTargets(
                    SLinkOperations.getTarget(statement, "alternative", true), "statement", true))
            .addSequence(
                ListSequence.fromList(
                    SLinkOperations.getTargets(
                        SLinkOperations.getTarget(
                            SNodeOperations.cast(
                                SLinkOperations.getTarget(node, "ifFalseStatement", true),
                                "jetbrains.mps.baseLanguage.structure.BlockStatement"),
                            "statements",
                            true),
                        "statement",
                        true)));
      } else {
        ListSequence.fromList(
                SLinkOperations.getTargets(
                    SLinkOperations.getTarget(statement, "alternative", true), "statement", true))
            .addElement(SLinkOperations.getTarget(node, "ifFalseStatement", true));
      }
      SNodeOperations.replaceWithAnother(node, statement);
      editorContext.select(SLinkOperations.getTarget(statement, "condition", true));
    }
Пример #23
0
 public static Iterable sourceNodesQuery_2323553266848914918(
     final IOperationContext operationContext, final SourceSubstituteMacroNodesContext _context) {
   return ListSequence.fromList(
           SLinkOperations.getTargets(
               ((SNode) _context.getVariable("methodDecl")), "parameter", true))
       .skip(1);
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   // produce throw statement
   SNode throwStatement =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.ThrowStatement", null);
   SNode newExpr = _quotation_createNode_a1x6vi_a0c0a();
   SLinkOperations.setTarget(throwStatement, "throwable", newExpr, true);
   // produce if statement
   SNode ifStatement =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.IfStatement", null);
   SNode notExpr =
       SNodeFactoryOperations.setNewChild(
           ifStatement, "condition", "jetbrains.mps.baseLanguage.structure.NotExpression");
   SLinkOperations.setTarget(
       notExpr, "expression", SLinkOperations.getTarget(node, "condition", true), true);
   SNodeFactoryOperations.setNewChild(
       ifStatement, "ifTrue", "jetbrains.mps.baseLanguage.structure.StatementList");
   ListSequence.fromList(
           SLinkOperations.getTargets(
               SLinkOperations.getTarget(ifStatement, "ifTrue", true), "statement", true))
       .insertElement(0, throwStatement);
   // replace assert with if
   SNodeOperations.replaceWithAnother(node, ifStatement);
 }
Пример #25
0
  public static boolean baseMappingRule_Condition_2379134940425784781(
      final IOperationContext operationContext, final BaseMappingRuleContext _context) {
    boolean methodHasDispatchModifier =
        SNodeOperations.isInstanceOf(
                SNodeOperations.getParent(_context.getNode()),
                "jetbrains.mps.baseLanguage.structure.MethodDeclaration")
            && ListSequence.fromList(
                    SLinkOperations.getTargets(
                        SNodeOperations.cast(
                            SNodeOperations.getParent(_context.getNode()),
                            "jetbrains.mps.baseLanguage.structure.MethodDeclaration"),
                        "modifiers",
                        true))
                .any(
                    new IWhereFilter<SNode>() {
                      public boolean accept(SNode it) {
                        return SNodeOperations.isInstanceOf(
                            it,
                            "jetbrains.mps.baseLanguage.doubleDispatch.structure.DispatchModifier");
                      }
                    });

    return methodHasDispatchModifier
        && Sequence.fromIterable(
                DispatchGenUtil.getMatchingMethods(
                    SNodeOperations.cast(
                        SNodeOperations.getParent(_context.getNode()),
                        "jetbrains.mps.baseLanguage.structure.MethodDeclaration")))
            .isNotEmpty();
  }
Пример #26
0
 public static Object referenceMacro_GetReferent_2323553266849548486(
     final IOperationContext operationContext, final ReferenceMacroContext _context) {
   return ListSequence.fromList(
           SLinkOperations.getTargets(
               ((SNode) _context.getVariable("methodDecl")), "parameter", true))
       .first();
 }
Пример #27
0
 private static boolean renderingCondition_arlg9k_a1a(
     SNode node, EditorContext editorContext, IScope scope) {
   return ListSequence.fromList(
           SLinkOperations.getTargets(
               SLinkOperations.getTarget(node, "baseMethodDeclaration", false), "parameter", true))
       .isNotEmpty();
 }
Пример #28
0
 public static List<SNode> virtual_getTestMethods_2148145109766218395(SNode thisNode) {
   List<SNode> result = new ArrayList<SNode>();
   if (!(SPropertyOperations.getBoolean(thisNode, "abstractClass"))) {
     ListSequence.fromList(result)
         .addSequence(
             ListSequence.fromList(
                 SLinkOperations.getTargets(
                     SLinkOperations.getTarget(thisNode, "testMethodList", true),
                     "testMethod",
                     true)));
     if (SNodeOperations.isInstanceOf(
         SLinkOperations.getTarget(
             SLinkOperations.getTarget(thisNode, "superclass", true), "classifier", false),
         "jetbrains.mps.baseLanguage.unitTest.structure.ITestCase")) {
       ListSequence.fromList(result)
           .addSequence(
               ListSequence.fromList(
                   BehaviorReflection.invokeVirtual(
                       (Class<List<SNode>>) ((Class) Object.class),
                       SNodeOperations.cast(
                           SLinkOperations.getTarget(
                               SLinkOperations.getTarget(thisNode, "superclass", true),
                               "classifier",
                               false),
                           "jetbrains.mps.baseLanguage.unitTest.structure.ITestCase"),
                       "virtual_getTestMethods_2148145109766218395",
                       new Object[] {})));
     }
   }
   return result;
 }
Пример #29
0
 public void test_RemoveParameter() throws Exception {
   this.addNodeById("1230052944082");
   this.addNodeById("1230052944093");
   ChangeMethodSignatureParameters params =
       new ChangeMethodSignatureParameters(
           SNodeOperations.cast(
               this.getNodeById("1230052944084"),
               "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"));
   ListSequence.fromList(SLinkOperations.getTargets(params.getDeclaration(), "parameter", true))
       .clear();
   ChangeMethodSignatureRefactoring ref =
       new ChangeMethodSignatureRefactoring(
           params,
           SNodeOperations.cast(
               this.getNodeById("1230052944084"),
               "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"));
   ref.doRefactoring();
   {
     List<SNode> nodesBefore =
         ListSequence.fromListAndArray(
             new ArrayList<SNode>(),
             SNodeOperations.cast(
                 this.getNodeById("1230052944083"),
                 "jetbrains.mps.baseLanguage.structure.ClassConcept"));
     List<SNode> nodesAfter =
         ListSequence.fromListAndArray(
             new ArrayList<SNode>(),
             SNodeOperations.cast(
                 this.getNodeById("1230052944094"),
                 "jetbrains.mps.baseLanguage.structure.ClassConcept"));
     Assert.assertNull(
         "nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!",
         NodesMatcher.matchNodes(nodesBefore, nodesAfter));
   }
 }
Пример #30
0
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode newLine =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.IndentLayoutOnNewLineStyleClassItem", null);
   SPropertyOperations.set(newLine, "flag", "" + (true));
   ListSequence.fromList(SLinkOperations.getTargets(node, "styleItem", true)).addElement(newLine);
 }