-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
attachComments
doesn't attach comments found in function signature
#23
Comments
This is the issue of escodegen. |
@Constellation I don't see it so.
|
Exact example with output: var x = function (/* signature comment */) {
return 'foo' + 'bar';
};
/* raz */
x(function (other) { return other }); test.js var esprima = require('esprima')
, estraverse = require('estraverse')
, inspect = require('util').inspect
, code = require('fs').readFileSync(__dirname + '/example.js')
, inspectOpts = { depth: 10, colors: true };
var ast = esprima.parse(code, { comment: true, range: true, tokens: true });
console.log("Comments", inspect(ast.comments, inspectOpts)); // All comments there
ast = estraverse.attachComments(ast, ast.comments, ast.tokens);
console.log("Attached?: ", inspect(ast.body, inspectOpts)); // No comments attached After running above, with latest node, and latest versions of involved packages, you get following output: Comments in AST as generated by esprima:
AST after comments being attached:
You can clearly see, that signature comment was not attached by |
So can you please clarify further, or reopen the issue |
Ah, I missed it. In this case, var x = function (/* signature comment */) {
return 'foo' + 'bar';
};
/* raz */
x(function (other) { return other }) We cannot attach |
@Constellation it's only the case if there are no arguments in signature, it all works fine if there is at least one argument, e.g. for following So is there any chance to have that reopened? |
Reopened.
Right. In this case (there are no arguments), currently I don't have reasonable way to solve this. (function /* comment */ () { }); |
Is there any update on this? |
Code:
Handling:
Result:
We miss comment in function signature
The text was updated successfully, but these errors were encountered: