Exemplo n.º 1
0
 public void testJSDocAttachment12() {
   AstRoot root = parse("({/** attach me */ get 1() {}});");
   assertNotNull(root.getComments());
   assertEquals(1, root.getComments().size());
   ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
   ParenthesizedExpression pt = (ParenthesizedExpression) st.getExpression();
   ObjectLiteral lit = (ObjectLiteral) pt.getExpression();
   NumberLiteral number = (NumberLiteral) lit.getElements().get(0).getLeft();
   assertNotNull(number.getJsDoc());
 }
Exemplo n.º 2
0
  public boolean visit(AstNode node) {
    if (node instanceof AstRoot) return true;
    else {
      Tree t = buildTree(node);
      Tree p = trees.get(node.getParent());
      p.addChild(t);

      if (node instanceof Name) {
        Name name = (Name) node;
        t.setLabel(name.getIdentifier());
      } else if (node instanceof StringLiteral) {
        StringLiteral literal = (StringLiteral) node;
        t.setLabel(literal.getValue());
      } else if (node instanceof NumberLiteral) {
        NumberLiteral l = (NumberLiteral) node;
        t.setLabel(l.getValue());
      }

      return true;
    }
  }
Exemplo n.º 3
0
 @Override
 public AstNode number(Number n) {
   NumberLiteral l = new NumberLiteral();
   l.setValue(n.toString());
   return l;
 }