Example #1
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_VarDecl_6585869519574765725(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    ListSequence.fromList(result)
        .addElement(
            new AbstractSideTransformHintSubstituteAction(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.nanoc.structure.CExpression"),
                _context.getSourceNode()) {
              public SNode doSubstitute(
                  @Nullable final EditorContext editorContext, String pattern) {
                return SNodeFactoryOperations.setNewChild(
                    _context.getSourceNode(),
                    "initializer",
                    "jetbrains.mps.nanoc.structure.CExpression");
              }

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

              public String getVisibleMatchingText(String pattern) {
                return getMatchingText(pattern);
              }
            });
    return result;
  }
Example #2
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_IGeneralizedWordUnit_3147078024758607987(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.ArithmeticExpansion");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  SNode newNode =
                      SNodeFactoryOperations.createNewNode(
                          "jetbrains.mps.bash.structure.ArithmeticExpansion", null);
                  SNodeOperations.insertNextSiblingChild(_context.getSourceNode(), newNode);
                  return newNode;
                }

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

                public String getVisibleMatchingText(String pattern) {
                  return this.getMatchingText(pattern);
                }
              });
    }
    return result;
  }
Example #3
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_VarRef_6585869519574772785(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    ListSequence.fromList(result)
        .addElement(
            new AbstractSideTransformHintSubstituteAction(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.nanoc.structure.CAssignmentExpression"),
                _context.getSourceNode()) {
              public SNode doSubstitute(
                  @Nullable final EditorContext editorContext, String pattern) {
                SNode result =
                    SNodeOperations.replaceWithAnother(
                        _context.getSourceNode(),
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.nanoc.structure.CAssignmentExpression", null));
                return SLinkOperations.setTarget(
                    result, "variable", _context.getSourceNode(), true);
              }

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

              public String getVisibleMatchingText(String pattern) {
                return getMatchingText(pattern);
              }
            });
    return result;
  }
Example #4
0
  public static List<INodeSubstituteAction> sideTransform_ActionsFactory_Attribute_1225239967737(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.sampleXML.structure.Attribute");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  //  add next attribute
                  SNode nextAttr =
                      SConceptOperations.createNewNode(
                          "jetbrains.mps.sampleXML.structure.Attribute", null);
                  SPropertyOperations.set(
                      nextAttr, "name", ((pattern == null ? null : pattern.trim())));
                  SNodeOperations.insertNextSiblingChild(_context.getSourceNode(), nextAttr);
                  return nextAttr;
                }

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

                public String getVisibleMatchingText(String pattern) {
                  return this.getMatchingText(pattern);
                }
              });
    }
    return result;
  }
Example #5
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_ArithmeticExpression_3263637656461345409(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      final String[] lastPattern = new String[1];
      List<INodeSubstituteAction> list =
          ModelActions.createChildSubstituteActions(
              _context.getSourceNode(),
              null,
              SConceptOperations.findConceptDeclaration(
                  "jetbrains.mps.bash.structure.BinaryArithmeticExpression"),
              new AbstractChildNodeSetter() {
                public SNode doExecute(
                    SNode parentNode, SNode oldChild, SNode newChild, IScope p3) {
                  return substitute(newChild, lastPattern[0]);
                }

                private SNode substitute(SNode result, String pattern) {
                  SNode source =
                      SNodeOperations.cast(
                          _context.getSourceNode(),
                          "jetbrains.mps.bash.structure.ArithmeticExpression");
                  while (SNodeOperations.isInstanceOf(
                      SNodeOperations.getParent(source),
                      "jetbrains.mps.bash.structure.BinaryArithmeticExpression")) {
                    SNode parent =
                        SNodeOperations.cast(
                            SNodeOperations.getParent(source),
                            "jetbrains.mps.bash.structure.BinaryArithmeticExpression");
                    if (SConceptPropertyOperations.getInteger(result, "priority")
                        < SConceptPropertyOperations.getInteger(parent, "priority")) {
                      source = parent;
                    } else {
                      break;
                    }
                  }
                  SNodeOperations.replaceWithAnother(source, result);
                  SLinkOperations.setTarget(result, "leftExpression", source, true);
                  return result;
                }
              },
              operationContext);
      for (final INodeSubstituteAction action : list) {
        ListSequence.fromList(result)
            .addElement(
                new NodeSubstituteActionWrapper(action) {
                  @Override
                  public SNode substitute(@Nullable EditorContext context, String pattern) {
                    lastPattern[0] = pattern;
                    return super.substitute(context, pattern);
                  }
                });
      }
    }
    return result;
  }
Example #6
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_Expression_2879868312063092085(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    ListSequence.fromList(result)
        .addElement(
            new AbstractSideTransformHintSubstituteAction(
                SConceptOperations.findConceptDeclaration(
                    "jetbrains.mps.lang.pattern.structure.OrPattern"),
                _context.getSourceNode()) {
              public SNode doSubstitute(
                  @Nullable final EditorContext editorContext, String pattern) {
                SNode orPattern =
                    SNodeFactoryOperations.createNewNode(
                        "jetbrains.mps.lang.pattern.structure.OrPattern", null);
                SNodeOperations.replaceWithAnother(_context.getSourceNode(), orPattern);
                return SLinkOperations.setTarget(
                    ListSequence.fromList(SLinkOperations.getTargets(orPattern, "clause", true))
                        .first(),
                    "patternNode",
                    _context.getSourceNode(),
                    true);
              }

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

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

              @Override
              protected boolean isEnabled() {
                SNode sourceNode = getSourceNode();
                SNode parent = SNodeOperations.getParent(sourceNode);
                SNode containingLink = SNodeOperations.getContainingLinkDeclaration(sourceNode);
                return parent == null
                    || containingLink == null
                    || (ModelConstraints.canBeParent(
                            parent,
                            SConceptOperations.findConceptDeclaration(
                                "jetbrains.mps.lang.pattern.structure.OrPattern"),
                            containingLink,
                            null,
                            null)
                        && ModelConstraints.canBeAncestor(
                            parent,
                            null,
                            SConceptOperations.findConceptDeclaration(
                                "jetbrains.mps.lang.pattern.structure.OrPattern"),
                            null));
              }
            });
    return result;
  }
Example #7
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_FollowingCommandList_8474643070113186812(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      final String[] lastPattern = new String[1];
      List<INodeSubstituteAction> list =
          ModelActions.createChildSubstituteActions(
              _context.getSourceNode(),
              null,
              SConceptOperations.findConceptDeclaration(
                  "jetbrains.mps.bash.structure.FollowingCommandList"),
              new AbstractChildNodeSetter() {
                public SNode doExecute(
                    SNode parentNode, SNode oldChild, SNode newChild, IScope p3) {
                  return substitute(newChild, lastPattern[0]);
                }

                private SNode substitute(SNode result, String pattern) {
                  SNodeOperations.replaceWithAnother(_context.getSourceNode(), result);
                  SNodeFactoryOperations.setNewChild(
                      SLinkOperations.getTarget(
                          SLinkOperations.getTarget(result, "baseCommand", true), "base", true),
                      "command",
                      "jetbrains.mps.bash.structure.AbstractCommand");
                  SLinkOperations.setTarget(
                      SLinkOperations.getTarget(result, "baseCommand", true),
                      "following",
                      _context.getSourceNode(),
                      true);
                  return result;
                }
              },
              operationContext);
      for (final INodeSubstituteAction action : list) {
        ListSequence.fromList(result)
            .addElement(
                new NodeSubstituteActionWrapper(action) {
                  @Override
                  public SNode substitute(@Nullable EditorContext context, String pattern) {
                    lastPattern[0] = pattern;
                    return super.substitute(context, pattern);
                  }
                });
      }
    }
    return result;
  }
Example #8
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_ConditionalExpression_3835416431562813067(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      final String[] lastPattern = new String[1];
      List<INodeSubstituteAction> list =
          ModelActions.createChildSubstituteActions(
              _context.getSourceNode(),
              null,
              SConceptOperations.findConceptDeclaration(
                  "jetbrains.mps.bash.structure.CombiningConditionalExpression"),
              new AbstractChildNodeSetter() {
                public SNode doExecute(
                    SNode parentNode, SNode oldChild, SNode newChild, IScope p3) {
                  return substitute(newChild, lastPattern[0]);
                }

                private SNode substitute(SNode result, String pattern) {
                  SNode source =
                      SNodeOperations.cast(
                          _context.getSourceNode(),
                          "jetbrains.mps.bash.structure.ConditionalExpression");
                  SNodeOperations.replaceWithAnother(source, result);
                  SLinkOperations.setTarget(result, "right", source, true);
                  return result;
                }
              },
              operationContext);
      for (final INodeSubstituteAction action : list) {
        ListSequence.fromList(result)
            .addElement(
                new NodeSubstituteActionWrapper(action) {
                  @Override
                  public SNode substitute(@Nullable EditorContext context, String pattern) {
                    lastPattern[0] = pattern;
                    return super.substitute(context, pattern);
                  }
                });
      }
    }
    return result;
  }
Example #9
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_CExpression_6585869519574743615(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      final String[] lastPattern = new String[1];
      List<SubstituteAction> list =
          ModelActions.createChildNodeSubstituteActions(
              _context.getSourceNode(),
              null,
              SConceptOperations.findConceptDeclaration("jetbrains.mps.nanoc.structure.CBinaryOp"),
              new AbstractChildNodeSetter() {
                public SNode doExecute(
                    SNode parentNode,
                    SNode oldChild,
                    SNode newChild,
                    IScope p3,
                    @Nullable EditorContext editorContext) {
                  return substitute(newChild, lastPattern[0], editorContext);
                }

                private SNode substitute(
                    SNode result, String pattern, @Nullable EditorContext editorContext) {
                  SNodeOperations.replaceWithAnother(_context.getSourceNode(), result);
                  SLinkOperations.setTarget(result, "right", _context.getSourceNode(), true);
                  return result;
                }
              },
              operationContext);
      for (final SubstituteAction action : list) {
        ListSequence.fromList(result)
            .addElement(
                new NodeSubstituteActionWrapper(action) {
                  @Override
                  public SNode substitute(@Nullable EditorContext context, String pattern) {
                    lastPattern[0] = pattern;
                    return super.substitute(context, pattern);
                  }
                });
      }
    }
    return result;
  }
Example #10
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_Command_8457058248752905941(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.CommentedCommandList");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  SNode comment =
                      SNodeFactoryOperations.createNewNode(
                          "jetbrains.mps.bash.structure.CommentedCommandList", null);
                  SNode sourceCommandList =
                      SNodeOperations.getAncestor(
                          _context.getSourceNode(),
                          "jetbrains.mps.bash.structure.CommandList",
                          false,
                          false);
                  SNodeOperations.replaceWithAnother(sourceCommandList, comment);
                  SLinkOperations.setTarget(comment, "commandList", sourceCommandList, true);
                  return comment;
                }

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

                public String getVisibleMatchingText(String pattern) {
                  return this.getMatchingText(pattern);
                }
              });
    }
    return result;
  }
Example #11
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_CommandTerminator_2635812496400429947(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration("jetbrains.mps.bash.structure.CommentedText");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  SNode commonCommand =
                      SNodeOperations.getAncestor(
                          _context.getSourceNode(),
                          "jetbrains.mps.bash.structure.CommandList",
                          false,
                          false);
                  SNodeFactoryOperations.setNewChild(
                      commonCommand, "comment", "jetbrains.mps.bash.structure.CommentedText");
                  return SLinkOperations.getTarget(commonCommand, "comment", true);
                }

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

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

                public String getDescriptionText(String pattern) {
                  return "simple text comment";
                }
              });
    }
    return result;
  }
Example #12
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_FollowingCommandList_8474643070110067667(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      SNode concept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.CommentedFollowingCommandList");
      ListSequence.fromList(result)
          .addElement(
              new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) {
                public SNode doSubstitute(String pattern) {
                  SNode comment =
                      SNodeFactoryOperations.createNewNode(
                          "jetbrains.mps.bash.structure.CommentedFollowingCommandList", null);
                  SNodeOperations.replaceWithAnother(_context.getSourceNode(), comment);
                  SLinkOperations.setTarget(comment, "command", _context.getSourceNode(), true);
                  return comment;
                }

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

                public String getVisibleMatchingText(String pattern) {
                  return this.getMatchingText(pattern);
                }
              });
    }
    return result;
  }
Example #13
0
  public static List<SubstituteAction> sideTransform_ActionsFactory_Expression_1175609466956(
      final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) {
    List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>());
    {
      Iterable<SNode> parameterObjects =
          new Computable<Iterable<SNode>>() {
            public Iterable<SNode> compute() {
              List<SNode> subconcepts =
                  SConceptOperations.getAllSubConcepts(
                      SConceptOperations.findConceptDeclaration(
                          "jetbrains.mps.lang.typesystem.structure.AbstractEquationStatement"),
                      _context.getModel(),
                      operationContext.getScope());
              final IScope scope = operationContext.getScope();
              return ListSequence.fromList(subconcepts)
                  .where(
                      new IWhereFilter<SNode>() {
                        public boolean accept(SNode it) {
                          return AbstractConceptDeclaration_Behavior
                              .call_isDefaultSubstitutableConcept_1213877394594(
                                  it,
                                  SConceptOperations.findConceptDeclaration(
                                      "jetbrains.mps.lang.typesystem.structure.AbstractEquationStatement"),
                                  scope);
                        }
                      })
                  .toListSequence();
            }
          }.compute();
      if (parameterObjects != null) {
        for (final SNode item : parameterObjects) {
          ListSequence.fromList(result)
              .addElement(
                  new AbstractSideTransformHintSubstituteAction(
                      SConceptOperations.findConceptDeclaration(
                          "jetbrains.mps.lang.typesystem.structure.AbstractEquationStatement"),
                      item,
                      _context.getSourceNode()) {
                    public SNode doSubstitute(
                        @Nullable final EditorContext editorContext, String pattern) {
                      SNode result =
                          SNodeFactoryOperations.createNewNode(NameUtil.nodeFQName((item)), null);
                      SNode statement =
                          SNodeOperations.getAncestor(
                              _context.getSourceNode(),
                              "jetbrains.mps.baseLanguage.structure.Statement",
                              false,
                              false);
                      if (statement == null) {
                        return null;
                      }
                      SNodeOperations.replaceWithAnother(statement, result);
                      SNode left =
                          SNodeFactoryOperations.createNewNode(
                              "jetbrains.mps.lang.typesystem.structure.NormalTypeClause", null);
                      SLinkOperations.setTarget(left, "normalType", _context.getSourceNode(), true);
                      SLinkOperations.setTarget(result, "leftExpression", left, true);
                      return result;
                    }

                    @Override
                    protected boolean isEnabled() {
                      SNode sourceNode = getSourceNode();
                      SNode parent = SNodeOperations.getParent(sourceNode);
                      SNode containingLink =
                          SNodeOperations.getContainingLinkDeclaration(sourceNode);
                      return parent == null
                          || containingLink == null
                          || (ModelConstraints.canBeParent(
                                  parent,
                                  SConceptOperations.findConceptDeclaration(
                                      "jetbrains.mps.lang.typesystem.structure.AbstractEquationStatement"),
                                  containingLink,
                                  null,
                                  null)
                              && ModelConstraints.canBeAncestor(
                                  parent,
                                  null,
                                  SConceptOperations.findConceptDeclaration(
                                      "jetbrains.mps.lang.typesystem.structure.AbstractEquationStatement"),
                                  null));
                    }
                  });
        }
      }
    }
    return result;
  }
Example #14
0
  public static List<INodeSubstituteAction>
      sideTransform_ActionsFactory_AbstractCommand_975347375211919463(
          final IOperationContext operationContext,
          final SideTransformActionsBuilderContext _context) {
    List<INodeSubstituteAction> result =
        ListSequence.fromList(new ArrayList<INodeSubstituteAction>());
    {
      final SNode concept =
          SConceptOperations.findConceptDeclaration(
              "jetbrains.mps.bash.structure.RedirectedCommand");
      Computable computable =
          new Computable() {
            public Object compute() {
              return ListSequence.fromListAndArray(new ArrayList<String>(), ">", "&>", "<");
            }
          };
      Iterable<String> parameterObjects = (Iterable<String>) computable.compute();
      assert parameterObjects != null;
      for (final String item : parameterObjects) {
        ListSequence.fromList(result)
            .addElement(
                new AbstractSideTransformHintSubstituteAction(
                    concept, item, _context.getSourceNode()) {
                  public SNode doSubstitute(String pattern) {
                    SNode redirectedCommand =
                        SNodeFactoryOperations.createNewNode(
                            "jetbrains.mps.bash.structure.RedirectedCommand", null);
                    SNode redirection;
                    if ((item).equals(">")) {
                      redirection =
                          SNodeFactoryOperations.createNewNode(
                              "jetbrains.mps.bash.structure.OutputRedirection", null);
                    } else if ((item).equals("&>")) {
                      redirection =
                          SNodeFactoryOperations.createNewNode(
                              "jetbrains.mps.bash.structure.OutputErrorRedirection", null);
                    } else {
                      redirection =
                          SNodeFactoryOperations.createNewNode(
                              "jetbrains.mps.bash.structure.InputRedirection", null);
                    }
                    ListSequence.fromList(
                            SLinkOperations.getTargets(redirectedCommand, "redirection", true))
                        .addElement(redirection);
                    SNode command = _context.getSourceNode();
                    SNodeOperations.replaceWithAnother(_context.getSourceNode(), redirectedCommand);
                    SLinkOperations.setTarget(redirectedCommand, "command", command, true);
                    return redirectedCommand;
                  }

                  public String getDescriptionText(String pattern) {
                    if ((item).equals(">")) {
                      return "redirect output";
                    } else if ((item).equals("&>")) {
                      return "redirect error output";
                    }
                    return "redirect input";
                  }
                });
      }
    }
    return result;
  }