Package com.google.javascript.jscomp.jsonml

Examples of com.google.javascript.jscomp.jsonml.JsonML


    if (jsonMLs.get(0).getType() == TagType.PrologueDecl) {
      FilePosition start = null;
      FilePosition end;
      List<Directive> directives = Lists.newArrayList();
      do {
        JsonML decl = jsonMLs.get(i++);
        end = positionFrom(decl);
        if (start == null) { start = end; }
        directives.add(new Directive(
            end, (String) decl.getAttribute(TagAttr.DIRECTIVE)));
      } while (i < n && jsonMLs.get(i).getType() == TagType.PrologueDecl);
      DirectivePrologue directive = new DirectivePrologue(
          FilePosition.span(start, end), null, directives);
      out.add(clazz.cast(directive));
    }
View Full Code Here


  }

  private FunctionConstructor toFunctionConstructor(JsonML jsonML) {
    FilePosition pos = positionFrom(jsonML);
    List<? extends JsonML> children = jsonML.getChildren();
    JsonML name = children.get(0);
    Identifier nameNode;
    if (name.getType() == TagType.Empty) {
      nameNode = new Identifier(positionFrom(name), null);
    } else {
      nameNode = toNode(name, Identifier.class);
    }
    List<FormalParam> params = Lists.newArrayList();
View Full Code Here

       .addChild(toInitOrIdPatt()).build();
  }

  JsonML toInitOrIdPatt() {
    Expression initializer = getInitializer();
    JsonML id = getIdentifier().toJsonML();
    if (initializer != null) {
      return JsonMLBuilder.builder(TagType.InitPatt, getFilePosition())
          .addChild(id)
          .addChild(initializer)
          .build();
View Full Code Here

      case FUNCTION_CALL:
        Expression fn = operands.get(0);
        if (is(fn, Operator.MEMBER_ACCESS)
                   || is(fn, Operator.SQUARE_BRACKET)) {
          Operation method = (Operation) fn;
          JsonML methodName = is(fn, Operator.MEMBER_ACCESS)
              ? ((Reference) method.children().get(1)).toJsonMLStr()
              : method.children().get(1).toJsonML();
          return JsonMLBuilder.builder(TagType.InvokeExpr, pos)
              .setAttribute(TagAttr.OP, method.getOperator().getSymbol())
              .addChild(method.children().get(0))
              .addChild(methodName)
              .addChildren(operands.subList(1, n))
              .build();
        } else if (fn instanceof Reference
                   && "eval".equals(((Reference) fn).getIdentifierName())) {
          return JsonMLBuilder.builder(TagType.EvalExpr, pos)
              .addChildren(operands.subList(1, n))
              .build();
        } else {
          return JsonMLBuilder.builder(TagType.CallExpr, pos)
              .addChildren(operands)
              .build();
        }
      case MEMBER_ACCESS:
      case SQUARE_BRACKET:
        JsonML property;
        if (op == Operator.MEMBER_ACCESS) {
          property = ((Reference) operands.get(1)).toJsonMLStr();
        } else {
          property = operands.get(1).toJsonML();
        }
View Full Code Here

    return ((Statement) children.get(n - 1)).hasHangingConditional();
  }

  public JsonML toJsonML() {
    FilePosition tailPos = FilePosition.endOf(getFilePosition());
    JsonML tail;
    List<? extends ParseTreeNode> parts = children();
    int k = parts.size();
    if ((k & 1) == 0) {
      tail = JsonMLBuilder.builder(TagType.EmptyStmt, tailPos).build();
    } else {
View Full Code Here

    }

    public boolean hasChildren() { return !children.isEmpty(); }

    public JsonML build() {
      return new JsonML(type, attrs, children);
    }
View Full Code Here

  }

  @Override
  public JsonML toJsonML() {
    FunctionConstructor fc = getInitializer();
    JsonML exprJsonMl = fc.toJsonML();
    return new JsonML(
        TagType.FunctionDecl, exprJsonMl.getAttributes(),
        exprJsonMl.getChildren());
  }
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.jsonml.JsonML

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.