Duplicated comments in output from Esprima
When given the Esprima output from program:
var obj =
{
// Pre-a comment
a: function()
{
var foo = 1; // hello
}
,b: function()
{
}
};
// comment above
function bar()
{
// comment below
var i = 1;
}
/**
* This is some documentation for this function
*/
function foo()
{
}
(available here)
escodegen.generate will produce the program:
var obj = {
a: function () {
var foo = 1; // hello
},
b: function () {
}
}; // comment above
// comment above
function bar() {
// comment below
var i = 1;
} /**
* This is some documentation for this function
*/
/**
* This is some documentation for this function
*/
function foo() {
}
The comments seem duplicated - is this the expected behavior for the output from Esprima? I saw that @Constellation did the work in Esprima for attachComments so wondering if this was an intentional duplication in the Esprima AST output.
+1
https://github.com/ecomfe/edp/issues/273
Right. I'll investigate it.
Could you show me how to create this AST? It seems that AST already has duplicated comments. https://gist.github.com/mduvall/8018844 In this case, this output is expected.
Me too
Having this issue as well.
I'm also being affected by this. Is this a bug on escodegen or esprima? Is a PR welcome?
I have the same issue.
Any word on this @Constellation ? I still see this issue today. The AST is created from a file that has single copies of each comment, but some of these comments are attached to both the trailing comments of a node and the leading comments of the following node, causing escodegen to output duplicates.
I think this is an issue to Esprima because the parsed AST contains duplicate comments.
/cc @ariya @michaelficarra What do you think of?
Ah, @Constellation sorry that's likely the case. Esprima should consider a comment as leading or trailing, but not both. It looks like a bug there because this doesn't happen for all comments that could be interpreted as leading or trailing.
+1 Any news about this issue?