I have several javascript files and parse it with a Rhino JavaScript parser.
but I can not get the comments.
How can I get comments?
here is part of my code.
run this code, the variable "comment" is null. also when running "astRoot.toSource ();", it only shows javascript code. No comments. he dissapeared!
[java code]
public void parser() { AstRoot astRoot = new Parser().parse(this.jsString, this.uri, 1); List<AstNode> statList = astRoot.getStatements(); for(Iterator<AstNode> iter = statList.iterator(); iter.hasNext();) { FunctionNode fNode = (FunctionNode)iter.next(); System.out.println("*** function Name : " + fNode.getName() + ", paramCount : " + fNode.getParamCount() + ", depth : " + fNode.depth()); AstNode bNode = fNode.getBody(); Block block = (Block)bNode; visitBody(block); } System.out.println(astRoot.toSource()); SortedSet<Comment> comment = astRoot.getComments(); if(comment == null) System.out.println("comment is null"); }
source share