コード例 #1
0
  public static SNode virtual_getAttachStatementChild_4797501453850305563(
      SNode thisNode, SNode parentBuilder, SNode parentRef, SNode childRef) {

    SNode result =
        SNodeOperations.copyNode(
            SLinkOperations.getTarget(
                SLinkOperations.getTarget(thisNode, "declaration", false), "set", true));
    for (SNode p :
        SNodeOperations.getDescendants(
            result,
            "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderPropertyParent",
            false,
            new String[] {})) {
      SNodeOperations.replaceWithAnother(p, SNodeOperations.copyNode(parentRef));
    }
    for (SNode v :
        SNodeOperations.getDescendants(
            result,
            "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderPropertyValue",
            false,
            new String[] {})) {
      SNodeOperations.replaceWithAnother(v, SNodeOperations.copyNode(childRef));
    }
    return result;
  }
コード例 #2
0
ファイル: SimpleBuilder_Behavior.java プロジェクト: sprig/MPS
  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;
  }
コード例 #3
0
ファイル: postfix.java プロジェクト: JetBrains/MPS
 @Override
 public void execute(@NotNull String pattern) {
   final SNode result =
       SNodeFactoryOperations.createNewNode(
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x11adecdb4f0L,
                   "jetbrains.mps.baseLanguage.structure.PostfixIncrementExpression")),
           null);
   SLinkOperations.setTarget(
       result,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x120a4c1f269L,
           0x120a4c433a6L,
           "expression"),
       SNodeOperations.copyNode(_context.getNode()));
   SNodeOperations.replaceWithAnother(_context.getNode(), result);
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(), result, SelectionManager.LAST_CELL, -1);
   return;
 }
コード例 #4
0
ファイル: SimpleBuilder_Behavior.java プロジェクト: sprig/MPS
  public static SNode virtual_getAttachStatement_7288041816792215495(
      SNode thisNode, SNode childBuilder, SNode parentRef, SNode childRef) {

    if (SNodeOperations.isInstanceOf(
        childBuilder, "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilder")) {
      SNode simpleBuilder =
          SNodeOperations.cast(
              childBuilder, "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilder");
      for (SNode child :
          SimpleBuilderDeclaration_Behavior.call_getChildren_3816167865390856298(
              SLinkOperations.getTarget(thisNode, "declaration", false),
              SNodeOperations.getModel(thisNode),
              GlobalScope.getInstance())) {
        if (SimpleBuilderDeclaration_Behavior.call_isDescendant_3816167865390595157(
            SLinkOperations.getTarget(simpleBuilder, "declaration", false),
            SLinkOperations.getTarget(child, "child", false))) {
          SNode result =
              SNodeOperations.copyNode(SLinkOperations.getTarget(child, "attachStatement", true));
          for (SNode parent :
              SNodeOperations.getDescendants(
                  result,
                  "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderParentExpression",
                  false,
                  new String[] {})) {
            SNodeOperations.replaceWithAnother(parent, SNodeOperations.copyNode(parentRef));
          }
          for (SNode parent :
              SNodeOperations.getDescendants(
                  result,
                  "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderChildExpression",
                  false,
                  new String[] {})) {
            SNodeOperations.replaceWithAnother(parent, SNodeOperations.copyNode(childRef));
          }
          return result;
        }
      }
    }

    return BehaviorReflection.invokeSuper(
        (Class<SNode>) ((Class) Object.class),
        thisNode,
        "jetbrains.mps.baseLanguage.builders.structure.Builder",
        "virtual_getAttachStatement_7288041816792215495",
        new Object[] {childBuilder, parentRef, childRef});
  }
コード例 #5
0
 public static SNode sourceNodeQuery_1758784108619328008(
     final IOperationContext operationContext, final SourceSubstituteMacroNodeContext _context) {
   return ClassifierTypeUtil.getTypeCoercedToClassifierType(
       SNodeOperations.copyNode(
           TypeChecker.getInstance()
               .getTypeOf(
                   SNodeOperations.getParent(
                       IOperation_Behavior.call_getDotExpression_1224687669172(
                           _context.getNode())))));
 }
コード例 #6
0
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode castVariable =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement", null);
   SNode instanceOfExpression =
       SNodeOperations.cast(
           SLinkOperations.getTarget(node, "condition", true),
           "jetbrains.mps.baseLanguage.structure.InstanceOfExpression");
   SNode declaration = SLinkOperations.getTarget(castVariable, "localVariableDeclaration", true);
   SLinkOperations.setTarget(
       declaration,
       "type",
       SNodeOperations.copyNode(
           SLinkOperations.getTarget(instanceOfExpression, "classType", true)),
       true);
   List<String> variableSuffixes =
       BehaviorReflection.invokeVirtual(
           (Class<List<String>>) ((Class) Object.class),
           SLinkOperations.getTarget(instanceOfExpression, "classType", true),
           "virtual_getVariableSuffixes_1213877337304",
           new Object[] {});
   SPropertyOperations.set(declaration, "name", ListSequence.fromList(variableSuffixes).first());
   SNode castExpression =
       SNodeFactoryOperations.setNewChild(
           declaration, "initializer", "jetbrains.mps.baseLanguage.structure.CastExpression");
   SLinkOperations.setTarget(
       castExpression,
       "type",
       SNodeOperations.copyNode(
           SLinkOperations.getTarget(instanceOfExpression, "classType", true)),
       true);
   SLinkOperations.setTarget(
       castExpression,
       "expression",
       SNodeOperations.copyNode(
           SLinkOperations.getTarget(instanceOfExpression, "leftExpression", true)),
       true);
   ListSequence.fromList(
           SLinkOperations.getTargets(
               SLinkOperations.getTarget(node, "ifTrue", true), "statement", true))
       .insertElement(0, castVariable);
 }
コード例 #7
0
 public static SNode virtual_getType_228266671027861783(SNode thisNode) {
   SNode listType =
       SConceptOperations.createNewNode(
           "jetbrains.mps.core.query.structure.MqlOrderedSetType", null);
   SLinkOperations.setTarget(
       listType,
       "inner",
       SNodeOperations.copyNode(SLinkOperations.getTarget(thisNode, "elementType", true)),
       true);
   return listType;
 }
コード例 #8
0
ファイル: QueriesGenerated.java プロジェクト: wolfhesse/MPS
 public static SNode sourceNodeQuery_2403002034749657032(
     final IOperationContext operationContext, final SourceSubstituteMacroNodeContext _context) {
   SNode newDecl = SNodeOperations.copyNode(_context.getNode());
   ListSequence.fromList(SLinkOperations.getTargets(newDecl, "modifiers", true))
       .removeWhere(
           new IWhereFilter<SNode>() {
             public boolean accept(SNode it) {
               return SNodeOperations.isInstanceOf(
                   it, "jetbrains.mps.baseLanguage.doubleDispatch.structure.DispatchModifier");
             }
           });
   return newDecl;
 }
コード例 #9
0
 @Override
 protected void modifyPartToExtract() {
   SNode ret =
       SConceptOperations.createNewNode(
           SNodeOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf8cc67c7feL,
                   "jetbrains.mps.baseLanguage.structure.ReturnStatement")));
   SNode constant =
       SConceptOperations.createNewNode(
           SNodeOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf8cc56b201L,
                   "jetbrains.mps.baseLanguage.structure.BooleanConstant")));
   SPropertyOperations.set(
       constant,
       MetaAdapterFactory.getProperty(
           0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b201L, 0xf8cc56b202L, "value"),
       "" + (false));
   SLinkOperations.setTarget(
       ret,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7feL, 0xf8cc6bf96cL, "expression"),
       constant);
   ListSequence.fromList(this.myStatements).addElement(SNodeOperations.copyNode(ret));
   SPropertyOperations.set(
       constant,
       MetaAdapterFactory.getProperty(
           0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b201L, 0xf8cc56b202L, "value"),
       "" + (true));
   for (SNode exitPoint : ListSequence.fromList(this.myAnalyzer.getIntenalExitPoints())) {
     SNodeOperations.replaceWithAnother(exitPoint, SNodeOperations.copyNode(ret));
   }
 }
コード例 #10
0
ファイル: ExtractIconsUtil.java プロジェクト: qyqx/MPS
 public static void updateIconResourceBundle(SNode cb) {
   SModule module = SNodeOperations.getModel(cb).getModule();
   if (module instanceof Language) {
     SNode irb = getIconResourceBundle((Language) module);
     for (SNode ire :
         ListSequence.fromList(
                 SNodeOperations.getDescendants(
                     cb,
                     "jetbrains.mps.lang.resources.structure.IconResourceExpression",
                     false,
                     new String[] {}))
             .toListSequence()) {
       {
         Pattern _pattern_0 = REGEXP_st4ewd_a0a0a0b0b0b;
         Matcher _matcher_0 =
             _pattern_0.matcher(
                 IconResource_Behavior.call_getFilename_8974276187400030131(
                     SLinkOperations.getTarget(ire, "icon", true)));
         if (_matcher_0.find()) {
           final String iconName = _matcher_0.group(1).toUpperCase();
           SNode decl =
               ListSequence.fromList(SLinkOperations.getTargets(irb, "icons", true))
                   .findFirst(
                       new IWhereFilter<SNode>() {
                         public boolean accept(SNode it) {
                           return iconName.equals(SPropertyOperations.getString(it, "name"));
                         }
                       });
           if ((decl == null)) {
             decl =
                 SLinkOperations.addNewChild(
                     irb,
                     "icons",
                     "jetbrains.mps.lang.resources.structure.IconResourceDeclaration");
             SLinkOperations.setTarget(
                 decl,
                 "iconExpression",
                 _quotation_createNode_st4ewd_a0b0c0a0b0b0b(
                     SNodeOperations.copyNode(SLinkOperations.getTarget(ire, "icon", true))),
                 true);
             SPropertyOperations.set(decl, "name", iconName);
           }
           SNodeOperations.replaceWithAnother(
               ire, _quotation_createNode_st4ewd_a0a3a0a1a1a1(decl));
         }
       }
     }
   }
 }
コード例 #11
0
ファイル: MethodMatch.java プロジェクト: wolfhesse/MPS
 public List<SNode> getCallParameters() {
   List<SNode> callActualParams = new ArrayList<SNode>();
   for (SNode parameter : ListSequence.fromList(this.myParametersOrder)) {
     if (ListSequence.fromList(MapSequence.fromMap(this.myParamsToNodes).get(parameter))
         .isEmpty()) {
       ListSequence.fromList(callActualParams)
           .addElement(_quotation_createNode_5zfyci_a0a0a0a1a11());
     } else {
       ListSequence.fromList(callActualParams)
           .addElement(
               SNodeOperations.cast(
                   SNodeOperations.copyNode(
                       ListSequence.fromList(
                               MapSequence.fromMap(this.myParamsToNodes).get(parameter))
                           .getElement(0)),
                   "jetbrains.mps.baseLanguage.structure.Expression"));
     }
   }
   return callActualParams;
 }
 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);
   }
 }
コード例 #13
0
ファイル: Type_Behavior.java プロジェクト: Ju2ender/MPS
 public static SNode virtual_getLooseType_5744862332972792015(
     SNode thisNode, @NotNull Set<SNode> visitedTypes) {
   SNode looseType = SNodeOperations.copyNode(thisNode);
   for (SNode varRef :
       SNodeOperations.getNodeDescendants(
           looseType,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x102467229d8L,
               "jetbrains.mps.baseLanguage.structure.TypeVariableReference"),
           false,
           new SAbstractConcept[] {})) {
     SNodeOperations.replaceWithAnother(
         varRef,
         BehaviorReflection.invokeVirtual(
             (Class<SNode>) ((Class) Object.class),
             varRef,
             "virtual_getLooseType_5744862332972792015",
             new Object[] {visitedTypes}));
   }
   return looseType;
 }
コード例 #14
0
ファイル: MethodParameter.java プロジェクト: rr-develop/MPS
 public SNode getReference() {
   return SNodeOperations.copyNode(this.myVariableReference);
 }
コード例 #15
0
 /*package*/ static SNode deriveType_idhEwIVPz(@NotNull SNode __thisNode__, SNode expression) {
   SNode type = null;
   if (SNodeOperations.getParent(expression) == __thisNode__
       && SNodeOperations.hasRole(
           expression,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8cc67c7feL,
               0xf8cc6bf96cL,
               "expression"))) {
     SNode ancestor =
         SNodeOperations.getNodeAncestorWhereConceptInList(
             __thisNode__,
             new SAbstractConcept[] {
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf8cc56b1fcL,
                   "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration"),
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x108bbca0f48L,
                   "jetbrains.mps.baseLanguage.structure.ConceptFunction")
             },
             false,
             false);
     if (SNodeOperations.isInstanceOf(
         ancestor,
         MetaAdapterFactory.getConcept(
             0xf3061a5392264cc5L,
             0xa443f952ceaf5816L,
             0xf8cc56b1fcL,
             "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration"))) {
       type =
           SNodeOperations.copyNode(
               SLinkOperations.getTarget(
                   SNodeOperations.cast(
                       ancestor,
                       MetaAdapterFactory.getConcept(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0xf8cc56b1fcL,
                           "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration")),
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8cc56b1fcL,
                       0xf8cc56b1fdL,
                       "returnType")));
     } else {
       SNode expectedReturnType =
           ConceptFunction__BehaviorDescriptor.getExpectedReturnType_idhEwIGRD.invoke(
               SNodeOperations.cast(
                   ancestor,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x108bbca0f48L,
                       "jetbrains.mps.baseLanguage.structure.ConceptFunction")));
       if (SNodeOperations.isInstanceOf(
           expectedReturnType,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8c37f506dL,
               "jetbrains.mps.baseLanguage.structure.Type"))) {
         type =
             SNodeOperations.cast(
                 SNodeOperations.copyNode(expectedReturnType),
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0xf8c37f506dL,
                     "jetbrains.mps.baseLanguage.structure.Type"));
       }
     }
   }
   return type;
 }
コード例 #16
0
 @Override
 public SNode doRefactoring() {
   this.findDuplicates();
   SNode newDeclaration;
   if (myFieldInitialization == FieldInitializationPlace.FIELD) {
     newDeclaration =
         _quotation_createNode_baxqxe_a0a0c0b(
             myVisibilityLevel.getNode(),
             SNodeOperations.copyNode(this.getExpressionType()),
             SNodeOperations.copyNode(this.getExpression()),
             this.getName());
   } else {
     newDeclaration =
         _quotation_createNode_baxqxe_a0a0a2a1(
             myVisibilityLevel.getNode(),
             SNodeOperations.copyNode(this.getExpressionType()),
             this.getName());
   }
   if (myIsFinal) {
     SPropertyOperations.set(newDeclaration, "isFinal", "" + (true));
   }
   SNode classConcept =
       SNodeOperations.getAncestor(
           this.getExpression(),
           "jetbrains.mps.baseLanguage.structure.ClassConcept",
           false,
           false);
   MemberInsertingUtils.insertClassifierMemberInBestPlace(classConcept, newDeclaration);
   SNode assignStatement =
       _quotation_createNode_baxqxe_a0g0b(
           newDeclaration, SNodeOperations.copyNode(this.getExpression()));
   if (this.myFieldInitialization == FieldInitializationPlace.METHOD) {
     SNodeOperations.insertPrevSiblingChild(
         SNodeOperations.getAncestor(
             this.getExpression(), "jetbrains.mps.baseLanguage.structure.Statement", false, false),
         SNodeOperations.copyNode(assignStatement));
   }
   if (this.myFieldInitialization == FieldInitializationPlace.CONSTRUCTOR) {
     SNode declaration =
         SNodeOperations.getAncestor(
             this.getExpression(),
             "jetbrains.mps.baseLanguage.structure.ClassConcept",
             false,
             false);
     for (SNode constructor :
         Sequence.fromIterable(
             BehaviorReflection.invokeNonVirtual(
                 (Class<Iterable<SNode>>) ((Class) Object.class),
                 declaration,
                 "jetbrains.mps.baseLanguage.structure.ClassConcept",
                 "call_constructors_5292274854859503373",
                 new Object[] {}))) {
       List<SNode> statement =
           SLinkOperations.getTargets(
               SLinkOperations.getTarget(constructor, "body", true), "statement", true);
       if (ListSequence.fromList(statement).isNotEmpty()) {
         SNodeOperations.insertPrevSiblingChild(
             ListSequence.fromList(statement).first(), SNodeOperations.copyNode(assignStatement));
       } else {
         ListSequence.fromList(statement).addElement(SNodeOperations.copyNode(assignStatement));
       }
     }
   }
   replaceNode(this.getExpression(), newDeclaration);
   if (myIsReplacingAll) {
     for (SNode duplicate : ListSequence.fromList(myDuplicates)) {
       replaceNode(duplicate, newDeclaration);
     }
   }
   return newDeclaration;
 }
コード例 #17
0
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   {
     GeneratedMatchingPattern pattern_6isygg_a0a =
         new IterateOverIterable_Intention.Pattern_w1n2qe_a0a0a0a2h();
     SNode coercedNode_6isygg_a0a =
         TypeChecker.getInstance()
             .getRuntimeSupport()
             .coerce_(
                 TypeChecker.getInstance()
                     .getTypeOf(
                         SLinkOperations.getTarget(
                             node,
                             MetaAdapterFactory.getContainmentLink(
                                 0xf3061a5392264cc5L,
                                 0xa443f952ceaf5816L,
                                 0xf8cc56b213L,
                                 0xf8cc56b214L,
                                 "expression"))),
                 pattern_6isygg_a0a);
     if (coercedNode_6isygg_a0a != null) {
       SNode foreachStatement =
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x10a6933ce33L,
                       "jetbrains.mps.baseLanguage.structure.ForeachStatement")),
               null);
       SNode variableDeclaration =
           SNodeFactoryOperations.setNewChild(
               foreachStatement,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x10a697996feL,
                   0x10a6979f36bL,
                   "variable"),
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8cc67c7efL,
                       "jetbrains.mps.baseLanguage.structure.LocalVariableDeclaration")));
       SLinkOperations.setTarget(
           variableDeclaration,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x450368d90ce15bc3L,
               0x4ed4d318133c80ceL,
               "type"),
           SNodeOperations.copyNode(
               ((SNode) pattern_6isygg_a0a.getFieldValue("patternVar_elem"))));
       SPropertyOperations.set(
           variableDeclaration,
           MetaAdapterFactory.getProperty(
               0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"),
           NameUtil.toValidIdentifier(
               BaseConcept_BehaviorDescriptor.getPresentation_idhEwIMiw.invoke(
                   ((SNode) pattern_6isygg_a0a.getFieldValue("patternVar_elem")))));
       SLinkOperations.setTarget(
           foreachStatement,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x10a6933ce33L,
               0x10a6934ab66L,
               "iterable"),
           SNodeOperations.copyNode(
               SLinkOperations.getTarget(
                   node,
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8cc56b213L,
                       0xf8cc56b214L,
                       "expression"))));
       SNodeOperations.insertNextSiblingChild(node, foreachStatement);
       SNodeOperations.deleteNode(node);
     } else {
     }
   }
 }
コード例 #18
0
 public void execute(final SNode node, final EditorContext editorContext) {
   SNodeOperations.replaceWithAnother(
       node,
       _quotation_createNode_7558vk_a0a0a0(
           SNodeOperations.copyNode(SLinkOperations.getTarget(node, "argument", true))));
 }
コード例 #19
0
  public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
    try {
      SNode classConcept = GenerateGettersAndSetters_Action.this.getClassConcept(_params);
      SNodeReference[] fields;
      fields =
          Sequence.fromIterable(
                  GenerateGettersAndSetters_Action.this.getFieldDeclarationsWithoutGetterOrSetter(
                      classConcept, _params))
              .select(
                  new ISelector<SNode, SNodePointer>() {
                    public SNodePointer select(SNode it) {
                      return new SNodePointer(it);
                    }
                  })
              .toGenericArray(SNodePointer.class);

      SelectFieldsDialog selectFieldsDialog =
          new SelectFieldsDialog(
              fields,
              false,
              ((EditorContext) MapSequence.fromMap(_params).get("editorContext"))
                  .getOperationContext()
                  .getProject());
      selectFieldsDialog.setTitle("Select Fields to Generate Getters and Setters");
      selectFieldsDialog.show();

      if (!(selectFieldsDialog.isOK())) {
        return;
      }

      SNodeReference[] selectedFields =
          Sequence.fromIterable(
                  ((Iterable<SNodeReference>) selectFieldsDialog.getSelectedElements()))
              .toGenericArray(SNodeReference.class);

      SNode lastAdded = null;
      Project project =
          ((EditorContext) MapSequence.fromMap(_params).get("editorContext"))
              .getOperationContext()
              .getProject();
      for (SNodeReference fieldPtr : selectedFields) {
        final SNode field =
            SNodeOperations.cast(
                ((SNodePointer) fieldPtr).resolve(MPSModuleRepository.getInstance()),
                "jetbrains.mps.baseLanguage.structure.FieldDeclaration");
        final String getterName = GenerateGettersAndSettersUtil.getFieldGetterName(field, project);
        SNode fieldReference =
            SNodeFactoryOperations.createNewNode(
                "jetbrains.mps.baseLanguage.structure.VariableReference", null);
        SLinkOperations.setTarget(fieldReference, "variableDeclaration", field, false);
        ListSequence.fromList(SLinkOperations.getTargets(classConcept, "member", true))
            .addElement(
                _quotation_createNode_5trf1k_a0a4a41a0(
                    SLinkOperations.getTarget(field, "type", true), fieldReference, getterName));

        final String setterName = GenerateGettersAndSettersUtil.getFieldSetterName(field, project);
        String parameterName =
            GenerateGettersAndSettersUtil.getParameterNameForField(field, project);
        lastAdded =
            ListSequence.fromList(SLinkOperations.getTargets(classConcept, "member", true))
                .addElement(
                    _quotation_createNode_5trf1k_a0a0i0o0a(
                        SNodeOperations.copyNode(fieldReference),
                        SLinkOperations.getTarget(field, "type", true),
                        parameterName,
                        setterName));
      }
      if (lastAdded != null) {
        ((EditorContext) MapSequence.fromMap(_params).get("editorContext")).select(lastAdded);
      }
    } catch (Throwable t) {
      LOG.error("User's action execute method failed. Action:" + "GenerateGettersAndSetters", t);
    }
  }
コード例 #20
0
ファイル: Type_Behavior.java プロジェクト: Ju2ender/MPS
 public static SNode virtual_getBoxedType_1213877337320(SNode thisNode) {
   return SNodeOperations.copyNode(thisNode);
 }