Search in sources :

Example 6 with NonJSDocComment

use of com.google.javascript.rhino.NonJSDocComment in project closure-compiler by google.

the class ParserTest method testInlineNonJSDocCommentAttachmentToVar.

@Test
public void testInlineNonJSDocCommentAttachmentToVar() {
    isIdeMode = true;
    parsingMode = JsDocParsing.INCLUDE_ALL_COMMENTS;
    Node letNode = parse("let /* blah */ x = 'a';").getFirstChild();
    assertNode(letNode).hasType(Token.LET);
    NonJSDocComment nonJSDocComment = letNode.getFirstChild().getNonJSDocComment();
    assertThat(nonJSDocComment).isNotNull();
    assertThat(nonJSDocComment.isInline()).isTrue();
    assertThat(nonJSDocComment.isEndingAsLineComment()).isFalse();
    assertThat(nonJSDocComment.getCommentString()).contains("/* blah */");
}
Also used : Node(com.google.javascript.rhino.Node) NodeSubject.assertNode(com.google.javascript.rhino.testing.NodeSubject.assertNode) NonJSDocComment(com.google.javascript.rhino.NonJSDocComment) Test(org.junit.Test)

Example 7 with NonJSDocComment

use of com.google.javascript.rhino.NonJSDocComment in project closure-compiler by google.

the class IRFactory method transform.

Node transform(ParseTree tree) {
    JSDocInfo info = parseJSDocInfoOnTree(tree);
    NonJSDocComment comment = parseNonJSDocCommentAt(tree.getStart(), false);
    Node node = transformDispatcher.process(tree);
    if (info != null) {
        node = maybeInjectCastNode(tree, info, node);
        node.setJSDocInfo(info);
    }
    if (comment != null) {
        node.setNonJSDocComment(comment);
    }
    setSourceInfo(node, tree);
    return node;
}
Also used : Node(com.google.javascript.rhino.Node) JSDocInfo(com.google.javascript.rhino.JSDocInfo) NonJSDocComment(com.google.javascript.rhino.NonJSDocComment)

Aggregations

NonJSDocComment (com.google.javascript.rhino.NonJSDocComment)7 Node (com.google.javascript.rhino.Node)5 JSDocInfo (com.google.javascript.rhino.JSDocInfo)3 NodeSubject.assertNode (com.google.javascript.rhino.testing.NodeSubject.assertNode)2 Test (org.junit.Test)2 Comment (com.google.javascript.jscomp.parsing.parser.trees.Comment)1 Token (com.google.javascript.rhino.Token)1 Nullable (javax.annotation.Nullable)1