Ejemplo n.º 1
0
 @Override
 public AstNode character(String c) {
   StringLiteral s = new StringLiteral();
   s.setQuoteCharacter('\'');
   s.setValue(c);
   return s;
 }
Ejemplo n.º 2
0
 @Override
 public AstNode string(String value) {
   StringLiteral expr = new StringLiteral();
   expr.setQuoteCharacter('"');
   expr.setValue(value);
   return expr;
 }
Ejemplo n.º 3
0
 public void testJSDocAttachment13() {
   AstRoot root = parse("({/** attach me */ get 'foo'() {}});");
   assertNotNull(root.getComments());
   assertEquals(1, root.getComments().size());
   ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
   ParenthesizedExpression pt = (ParenthesizedExpression) st.getExpression();
   ObjectLiteral lit = (ObjectLiteral) pt.getExpression();
   StringLiteral stringLit = (StringLiteral) lit.getElements().get(0).getLeft();
   assertNotNull(stringLit.getJsDoc());
 }
Ejemplo n.º 4
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;
    }
  }
Ejemplo n.º 5
0
 public void testParseUnicodeFormatStringLiteral() {
   AstRoot root = parse("'A\u200DB'");
   ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
   StringLiteral stringLit = (StringLiteral) st.getExpression();
   assertEquals("A\u200DB", stringLit.getValue());
 }