예제 #1
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_LValue_9034131902188086416(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.VariableNameDeclaration");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode name =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.VariableNameDeclaration", null);
                    SPropertyOperations.set(name, "name", pattern);
                    return name;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    SNode name =
                        VariableNameDeclaration_Behavior.testName_9034131902194480300(
                            _context.getCurrentTargetNode(), pattern);
                    if ((name != null)) {
                      return false;
                    }
                    return REGEXP_x583g4_a0a2a2a0a0a0a2a0a1a6.matcher(pattern).matches();
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
예제 #2
0
  public static List<SubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_TypeClause_1185801400389(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.lang.typesystem.structure.NormalTypeClause");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        SNode wrappedConcept =
            SConceptOperations.findConceptDeclaration(
                "jetbrains.mps.baseLanguage.structure.Expression");
        IChildNodeSetter setter =
            new AbstractChildNodeSetter() {
              private SNode wrapNode(
                  SNode nodeToWrap, SModel model, @Nullable EditorContext editorContext) {
                SNode normalTypeClause =
                    SNodeFactoryOperations.createNewNode(
                        model, "jetbrains.mps.lang.typesystem.structure.NormalTypeClause", null);
                SLinkOperations.setTarget(normalTypeClause, "normalType", nodeToWrap, true);
                return normalTypeClause;
              }

              public boolean returnSmallPart(SNode nodeToWrap) {
                return false;
              }

              @Override
              public SNode doExecute(
                  SNode pn, SNode oc, SNode nc, IScope sc, @Nullable EditorContext editorContext) {
                SNode wrappedNode = wrapNode(nc, nc.getModel(), editorContext);
                _context
                    .getChildSetter()
                    .execute(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedNode,
                        operationContext.getScope(),
                        editorContext);
                return (returnSmallPart(nc) ? nc : wrappedNode);
              }
            };
        ListSequence.fromList(result)
            .addSequence(
                ListSequence.fromList(
                    ModelActions.createChildNodeSubstituteActions(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedConcept,
                        setter,
                        operationContext)));
      }
    }
    return result;
  }
예제 #3
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_IGeneralizedWordUnit_3263637656457821343(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.bash.structure.SimpleWord");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode newNode =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.SimpleWord", null);
                    SPropertyOperations.set(newNode, "word", pattern);
                    return newNode;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    if (strictly) {
                      return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a3.matcher(pattern).matches();
                    } else {
                      return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0d.matcher(pattern).matches();
                    }
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
예제 #4
0
  public static List<SubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_CExpression_6585869519574739818(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.nanoc.structure.CExpression");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode result =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.nanoc.structure.IntConst", null);
                    SPropertyOperations.set(result, "value", pattern);
                    return result;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    if (strictly) {
                      return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a2.matcher(pattern).matches();
                    } else {
                      return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0c.matcher(pattern).matches();
                    }
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
예제 #5
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_LinePart_1237218108602(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mpslite.structure.ConstantLinePart");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode constant =
                        SNodeFactoryOperations.createNewNode(
                            model, "jetbrains.mpslite.structure.ConstantLinePart", null);
                    SPropertyOperations.set(constant, "text", pattern);
                    return constant;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    return REGEXP_x583g4_a0a0a2a0a0a0a2a0a1a0.matcher(pattern).matches();
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
예제 #6
0
 public static List<SubstituteAction>
     nodeSubstituteActionsBuilder_ActionsFactory_Statement_7750890258732378172(
         final IOperationContext operationContext,
         final NodeSubstituteActionsFactoryContext _context) {
   List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
   {
     SNode outputConcept =
         SConceptOperations.findConceptDeclaration(
             "jetbrains.mps.lang.typesystem.structure.CreateLessThanInequationStatement");
     SNode childConcept = (SNode) _context.getChildConcept();
     if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
       Iterable<String> queryResult =
           new Computable<Iterable<String>>() {
             public Iterable<String> compute() {
               return ListSequence.fromListAndArray(
                   new ArrayList<String>(), "infer typeof", "check typeof");
             }
           }.compute();
       if (queryResult != null) {
         for (final String item : queryResult) {
           ListSequence.fromList(result)
               .addElement(
                   new DefaultChildNodeSubstituteAction(
                       outputConcept,
                       item,
                       _context.getParentNode(),
                       _context.getCurrentTargetNode(),
                       _context.getChildSetter(),
                       operationContext.getScope()) {
                     public SNode createChildNode(
                         Object parameterObject, SModel model, String pattern) {
                       SNode rule =
                           SNodeFactoryOperations.createNewNode(
                               "jetbrains.mps.lang.typesystem.structure.CreateLessThanInequationStatement",
                               null);
                       if ((item).equals("check typeof")) {
                         SPropertyOperations.set(rule, "checkOnly", "" + (true));
                       }
                       return rule;
                     }
                   });
         }
       }
     }
   }
   return result;
 }
예제 #7
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_ElementPart_1225239967704(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.sampleXML.structure.Text");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode text =
                        SConceptOperations.createNewNode(
                            "jetbrains.mps.sampleXML.structure.Text", null);
                    SPropertyOperations.set(text, "name", pattern);
                    return text;
                  }

                  public String getMatchingText(String pattern) {
                    if (!(pattern.startsWith("<"))) {
                      return pattern;
                    }
                    return "";
                  }

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
예제 #8
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_ArgumentClause_3391577739832644582(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.baseLanguage.constructors.structure.ListArgumentsClause");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    return SNodeFactoryOperations.createNewNode(
                        "jetbrains.mps.baseLanguage.constructors.structure.ListArgumentsClause",
                        null);
                  }

                  public String getMatchingText(String pattern) {
                    return "listof";
                  }

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }
 public static boolean static_canBeAChild(
     SNode node,
     SNode parentNode,
     SNode link,
     SNode childConcept,
     final IOperationContext operationContext) {
   SNode dtype =
       BehaviorReflection.invokeVirtual(
           (Class<SNode>) ((Class) Object.class),
           SNodeOperations.as(
               SNodeOperations.getParent(parentNode),
               "jetbrains.mps.baseLanguage.structure.TypeDerivable"),
           "virtual_deriveType_1213877435747",
           new Object[] {
             SNodeOperations.as(parentNode, "jetbrains.mps.baseLanguage.structure.Expression")
           });
   return (dtype == null)
       || SConceptOperations.isSuperConceptOf(
           SNodeOperations.getConceptDeclaration(dtype),
           "jetbrains.mps.baseLanguage.collections.structure.MapType");
 }
예제 #10
0
  public static List<SubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_CStatement_6585869519574700079(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.nanoc.structure.VarDeclStatement");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        SNode wrappedConcept =
            SConceptOperations.findConceptDeclaration("jetbrains.mps.nanoc.structure.CType");
        IChildNodeSetter setter =
            new AbstractChildNodeSetter() {
              private SNode wrapNode(
                  SNode nodeToWrap, SModel model, @Nullable EditorContext editorContext) {
                SNode result =
                    SNodeFactoryOperations.createNewNode(
                        "jetbrains.mps.nanoc.structure.VarDeclStatement", null);
                SLinkOperations.setTarget(result, "type", nodeToWrap, true);
                return result;
              }

              public boolean returnSmallPart(SNode nodeToWrap) {
                return false;
              }

              @Override
              public SNode doExecute(
                  SNode pn, SNode oc, SNode nc, IScope sc, @Nullable EditorContext editorContext) {
                SNode wrappedNode = wrapNode(nc, nc.getModel(), editorContext);
                _context
                    .getChildSetter()
                    .execute(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedNode,
                        operationContext.getScope(),
                        editorContext);
                return (returnSmallPart(nc) ? nc : wrappedNode);
              }
            };
        ListSequence.fromList(result)
            .addSequence(
                ListSequence.fromList(
                    ModelActions.createChildNodeSubstituteActions(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedConcept,
                        setter,
                        operationContext)));
      }
    }
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.nanoc.structure.CExpressionStatement");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        SNode wrappedConcept =
            SConceptOperations.findConceptDeclaration("jetbrains.mps.nanoc.structure.CExpression");
        IChildNodeSetter setter =
            new AbstractChildNodeSetter() {
              private SNode wrapNode(
                  SNode nodeToWrap, SModel model, @Nullable EditorContext editorContext) {
                SNode expressionStatement =
                    SNodeFactoryOperations.createNewNode(
                        "jetbrains.mps.nanoc.structure.CExpressionStatement", null);
                SLinkOperations.setTarget(expressionStatement, "expression", nodeToWrap, true);
                return expressionStatement;
              }

              public boolean returnSmallPart(SNode nodeToWrap) {
                return false;
              }

              @Override
              public SNode doExecute(
                  SNode pn, SNode oc, SNode nc, IScope sc, @Nullable EditorContext editorContext) {
                SNode wrappedNode = wrapNode(nc, nc.getModel(), editorContext);
                _context
                    .getChildSetter()
                    .execute(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedNode,
                        operationContext.getScope(),
                        editorContext);
                return (returnSmallPart(nc) ? nc : wrappedNode);
              }
            };
        ListSequence.fromList(result)
            .addSequence(
                ListSequence.fromList(
                    ModelActions.createChildNodeSubstituteActions(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedConcept,
                        setter,
                        operationContext)));
      }
    }
    return result;
  }
예제 #11
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_Expression_1592896280557600187(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.baseLanguage.constructors.structure.CustomConstructorUsage");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        Computable computable =
            new Computable() {
              public Object compute() {
                List<SNode> containers =
                    SModelOperations.getRootsIncludingImported(
                        _context.getModel(),
                        operationContext.getScope(),
                        "jetbrains.mps.baseLanguage.constructors.structure.CustomConstructorContainer");
                List<SNode> customConstructors = new ArrayList<SNode>();
                for (SNode container : ListSequence.fromList(containers)) {
                  ListSequence.fromList(customConstructors)
                      .addSequence(
                          ListSequence.fromList(
                              SLinkOperations.getTargets(container, "constructors", true)));
                }
                return customConstructors;
              }
            };
        Iterable<SNode> queryResult = (Iterable) computable.compute();
        if (queryResult != null) {
          for (final SNode item : queryResult) {
            ListSequence.fromList(result)
                .addElement(
                    new DefaultChildNodeSubstituteAction(
                        outputConcept,
                        item,
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        _context.getChildSetter(),
                        operationContext.getScope()) {
                      public SNode createChildNode(
                          Object parameterObject, SModel model, String pattern) {
                        SNode usage =
                            SNodeFactoryOperations.createNewNode(
                                "jetbrains.mps.baseLanguage.constructors.structure.CustomConstructorUsage",
                                null);
                        SLinkOperations.setTarget(usage, "customConstructor", (item), false);
                        return usage;
                      }

                      public String getMatchingText(String pattern) {
                        return SPropertyOperations.getString((item), "leftParenthesis")
                            + "..."
                            + SPropertyOperations.getString((item), "rightParenthesis");
                      }

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

                      public String getDescriptionText(String pattern) {
                        return SPropertyOperations.getString((item), "shortDescription");
                      }
                    });
          }
        }
      }
    }
    return result;
  }
예제 #12
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_ArgumentClause_994932413699396071(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.baseLanguage.constructors.structure.CustomArgumentClause");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        SNode wrappedConcept =
            SConceptOperations.findConceptDeclaration("jetbrains.mps.baseLanguage.structure.Type");
        IChildNodeSetter setter =
            new AbstractChildNodeSetter() {
              public SNode wrapNode(SNode nodeToWrap, SModel model) {
                SNode result =
                    SNodeFactoryOperations.createNewNode(
                        "jetbrains.mps.baseLanguage.constructors.structure.CustomArgumentClause",
                        null);
                SNode parameter =
                    SNodeFactoryOperations.addNewChild(
                        result,
                        "parameter",
                        "jetbrains.mps.baseLanguage.constructors.structure.CustomConstructorParameter");
                SLinkOperations.setTarget(parameter, "type", nodeToWrap, true);
                return result;
              }

              public boolean returnSmallPart(SNode nodeToWrap) {
                return false;
              }

              public SNode doExecute(SNode pn, SNode oc, SNode nc, IScope sc) {
                SNode wrappedNode = this.wrapNode(nc, nc.getModel());
                _context
                    .getChildSetter()
                    .execute(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedNode,
                        operationContext.getScope());
                if (this.returnSmallPart(nc)) {
                  return nc;
                } else {
                  return wrappedNode;
                }
              }
            };
        ListSequence.fromList(result)
            .addSequence(
                ListSequence.fromList(
                    ModelActions.createChildSubstituteActions(
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        wrappedConcept,
                        setter,
                        operationContext)));
      }
    }
    return result;
  }
예제 #13
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_Command_9034131902186646660(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.VariableAssingment");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode assingment =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.VariableAssingment", null);
                    SNode lvalue = null;
                    String newVarName = pattern;
                    if (newVarName.endsWith("=")) {
                      newVarName = newVarName.substring(0, pattern.length() - 1);
                    }
                    SNode name =
                        VariableNameDeclaration_Behavior.testName_9034131902194480300(
                            _context.getCurrentTargetNode(), newVarName);
                    if ((name != null)) {
                      lvalue =
                          SNodeFactoryOperations.createNewNode(
                              "jetbrains.mps.bash.structure.VariableReference", null);
                      SLinkOperations.setTarget(
                          SNodeOperations.cast(
                              lvalue, "jetbrains.mps.bash.structure.VariableReference"),
                          "variable",
                          name,
                          false);
                    }
                    if ((lvalue == null)) {
                      lvalue =
                          SNodeFactoryOperations.createNewNode(
                              "jetbrains.mps.bash.structure.VariableNameDeclaration", null);
                      SPropertyOperations.set(
                          SNodeOperations.cast(
                              lvalue, "jetbrains.mps.bash.structure.VariableNameDeclaration"),
                          "name",
                          newVarName);
                    }
                    SLinkOperations.setTarget(assingment, "lvalue", lvalue, true);
                    return assingment;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    SNode name =
                        VariableNameDeclaration_Behavior.testName_9034131902194480300(
                            _context.getCurrentTargetNode(), pattern);
                    if ((name != null)) {
                      return true;
                    }
                    return REGEXP_x583g4_a0a2a2a0a0a0a2a0a1a5.matcher(pattern).matches();
                  }
                });
      }
    }
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.VariableAssingment");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) {
        Computable computable =
            new Computable() {
              public Object compute() {
                return SLinkOperations.getTargets(
                    SNodeOperations.getAncestor(
                        _context.getParentNode(),
                        "jetbrains.mps.bash.structure.ShellScript",
                        true,
                        false),
                    "usedVars",
                    true);
              }
            };
        Iterable<SNode> queryResult = (Iterable) computable.compute();
        if (queryResult != null) {
          for (final SNode item : queryResult) {
            ListSequence.fromList(result)
                .addElement(
                    new DefaultChildNodeSubstituteAction(
                        outputConcept,
                        item,
                        _context.getParentNode(),
                        _context.getCurrentTargetNode(),
                        _context.getChildSetter(),
                        operationContext.getScope()) {
                      public SNode createChildNode(
                          Object parameterObject, SModel model, String pattern) {
                        SNode variableAssignment =
                            SNodeFactoryOperations.createNewNode(
                                "jetbrains.mps.bash.structure.VariableAssingment", null);
                        SNode lvalue =
                            SNodeFactoryOperations.createNewNode(
                                "jetbrains.mps.bash.structure.VariableReference", null);
                        SLinkOperations.setTarget(lvalue, "variable", (item), false);
                        SLinkOperations.setTarget(variableAssignment, "lvalue", lvalue, true);
                        return variableAssignment;
                      }

                      public String getDescriptionText(String pattern) {
                        return "variable assignment";
                      }
                    });
          }
        }
      }
    }
    return result;
  }
예제 #14
0
  public static List<INodeSubstituteAction>
      nodeSubstituteActionsBuilder_ActionsFactory_ArithmeticExpression_3263637656458342517(
          final IOperationContext operationContext,
          final NodeSubstituteActionsFactoryContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.bash.structure.DecimalConstant");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode newNode =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.DecimalConstant", null);
                    try {
                      SPropertyOperations.set(newNode, "value", "" + Integer.parseInt(pattern));
                    } catch (NumberFormatException e) {
                      SPropertyOperations.set(newNode, "value", "" + (0));
                    }
                    return newNode;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    if (strictly) {
                      return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a4.matcher(pattern).matches();
                    } else {
                      return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0e.matcher(pattern).matches();
                    }
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.BasedIntegerLiteral");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode basedIntConst =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.BasedIntegerLiteral", null);
                    try {
                      int index = pattern.indexOf("#");
                      SPropertyOperations.set(
                          basedIntConst,
                          "base",
                          "" + (Integer.parseInt(pattern.substring(0, index))));
                      SPropertyOperations.set(
                          basedIntConst,
                          "value",
                          "" + (Integer.parseInt(pattern.substring(index + 1))));
                    } catch (NumberFormatException e) {
                      SPropertyOperations.set(basedIntConst, "base", "" + (10));
                      SPropertyOperations.set(basedIntConst, "value", "" + (0));
                    }
                    return basedIntConst;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    return REGEXP_x583g4_a0a0a2a0a0a0a2a0a2a4.matcher(pattern).matches();
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    {
      SNode outputConcept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.HexIntegerLiteral");
      SNode childConcept = (SNode) _context.getChildConcept();
      if (outputConcept == null
          || SConceptOperations.isSuperConceptOf(
              childConcept, NameUtil.nodeFQName(outputConcept))) {
        ListSequence.fromList(result)
            .addElement(
                new DefaultSimpleSubstituteAction(
                    outputConcept,
                    _context.getParentNode(),
                    _context.getCurrentTargetNode(),
                    _context.getChildSetter(),
                    operationContext.getScope()) {
                  public SNode createChildNode(
                      Object parameterObject, SModel model, String pattern) {
                    SNode hexadecimalIntConst =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.HexIntegerLiteral", null);
                    try {
                      SPropertyOperations.set(hexadecimalIntConst, "value", pattern.substring(2));
                    } catch (NumberFormatException e) {
                      SPropertyOperations.set(hexadecimalIntConst, "value", "0");
                    }
                    return hexadecimalIntConst;
                  }

                  public boolean hasSubstitute() {
                    return true;
                  }

                  public boolean canSubstitute_internal(String pattern, boolean strictly) {
                    return REGEXP_x583g4_a0a0a2a0a0a0a2a0a3a4.matcher(pattern).matches();
                  }

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

                  public String getVisibleMatchingText(String pattern) {
                    return this.getMatchingText(pattern);
                  }
                });
      }
    }
    return result;
  }