On May 18, 12:09 am, gozala <[email protected]> wrote:
> Hi,
>
> I'm trying to parse js source using rhino and then I would like to get
> a jsdoc comments which I suppose cane be collected from AstRoot via
> visitComments function. Unfortunately I can't get any comment node
> while I can get rest of the astNode's even visit and visitAll returns
> exactly the same ammount of AstNode's. Of course source I'm parsing
> has a comments.
The following code seems to work:
importPackage(org.mozilla.javascript);
var ce = new CompilerEnvirons();
ce.setRecordingComments(true);
ce.initFromContext(Context.getCurrentContext());
var p = new Parser(ce, null);
var ast = p.parse("/** FOO */\nfunction foo() {}", 'sourcename', 0);
ast.debugPrint();
ast.getComments().first().toSource();
This may be a better way to retrieve comments. In particular, there
seems to be a getJsDoc() method in AST nodes, but it always returns
null for me. This script is just the result of 10 minutes exploration
in the helma-ng shell i did during a meeting yesterday, but it may be
useful as a starting point.
Hannes
> Do I need to do something else to get comment nodes or might I'm doing
> something wrong ?
> Thanks
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino