Package org.jrubyparser.ast

Examples of org.jrubyparser.ast.Node


  @Override
  public List<PPFunctionInfo> getLogFunctions(File file) throws IOException, RubySyntaxException {
    List<PPFunctionInfo> functions = Lists.newArrayList();
    Result result = internalParse(file);
    Node root = result.getAST();
    ClassNode logClass = new RubyClassFinder().findClass(root, "Puppet", "Util", "Log");
    if(logClass == null)
      return functions;

    for(Node n : logClass.getBody().childNodes()) {
View Full Code Here


    RubyParserWarningsCollector warnings = new RubyParserWarningsCollector();
    parser.setWarnings(warnings);

    LexerSource lexerSource = LexerSource.getSource(file, content, configuration);

    Node parserResult = null;
    try {
      parserResult = parser.parse(configuration, lexerSource).getAST();

    }
    catch(SyntaxException e) {
View Full Code Here

  public ModuleName getFullName() {
    return fullName;
  }

  private List<Node> getStringArguments(IArgumentNode callNode) throws IllegalArgumentException {
    Node argsNode = callNode.getArgs();
    if(!(argsNode instanceof ListNode))
      throw new IllegalArgumentException("IArgumentNode expected");
    ListNode args = (ListNode) argsNode;
    int top = args.size();
    ArrayList<Node> stringArgs = new ArrayList<Node>(top);
    for(int idx = 0; idx < top; ++idx) {
      Node argNode = args.get(idx);
      switch(argNode.getNodeType()) {
        case STRNODE:
        case FIXNUMNODE:
        case FLOATNODE:
        case NILNODE:
          stringArgs.add(argNode);
          break;
        default:
          addError(argNode.getPosition(), "Unexpected ruby code. Node type was: " + (argNode == null
              ? "null"
              : argNode.getClass().getSimpleName()));
      }
    }
    return stringArgs;
  }
View Full Code Here

   */
  private Node getTaskNameNodeFromArgNode(Node argsNode) {
    if(argsNode instanceof ArrayNode) {
      ArrayNode arrayNode = (ArrayNode) argsNode;
      if(arrayNode.size() > 0) {
        Node a = arrayNode.get(0);
        if(a instanceof HashNode) {
          HashNode argsHash = (HashNode) a;
          ListNode listNode = argsHash.getListNode();
          if(listNode.size() > 0)
            argsNode = listNode.get(0);
View Full Code Here

        List<String> receiver = constEvaluator.stringList(constEvaluator.eval(root.getReceiver()));
        boolean isRspec = receiver.equals(rspecTask);
        boolean isCucumber = !isRspec && receiver.equals(cucumberTask);
        if(isRspec || isCucumber) {
          // recognized as a task
          Node argsNode = getTaskNameNodeFromArgNode(root.getArgs());
          List<String> nameList = constEvaluator.stringList(constEvaluator.eval(argsNode));
          if(nameList.size() < 1) {
            if(isRspec)
              nameList = Lists.newArrayList("spec");
            else
View Full Code Here

    else if(fName.equals("task")) {
      // System.err.println("Found TASK (Fcall)");
      // argument is the name of the task
      // prepend with name parts from namespaces
      // pick up lastDesc
      Node argsNode = getTaskNameNodeFromArgNode(root.getArgs());
      String taskName = Joiner.on(":").join(
        Iterables.concat(Lists.reverse(nameStack), constEvaluator.stringList(constEvaluator.eval(argsNode))));

      resultMap.put(taskName, lastDesc);
      // System.err.println("Added task: " + taskName + " with description: " + lastDesc);
View Full Code Here

TOP

Related Classes of org.jrubyparser.ast.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.