Skip to content
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

Fix: Leading comments for anonymous classes (fixes: #158) #162

Merged

Conversation

mysticatea
Copy link
Member

The comment attachment process looks below:

  1. Leaf-nodes (A) gets comments that are before itself.
  2. Containing-nodes gets comments from A if the last leading comment of A is before itself.

In this (#158) case, since the ClassDeclaration does not have its Identifier, the Identifier of the first MethodDefinition gets the comment of the class.
And the Identifier gets also the comment of the method.
Next, the MethodDefinition gets the comments from the Identifier.

The ClassBody node does not get the comments from the MethodDefinition, because the last leading comment of the MethodDefinition is not before the ClassBody node. But the comment of the class is in the leading comments of the MethodDefinition.

So, I modified step 2 of the process.

  • It finds comments that are before containing-nodes from the leading comment list of A, and the containing-node gets those.

@mysticatea
Copy link
Member Author

This PR probably fixes #155 also, but I didn't write a test for it.

Please wait...

@mysticatea mysticatea force-pushed the fix-comment-attachment-for-anonymouse-class branch from 6ace498 to d535900 Compare July 10, 2015 17:53
@mysticatea
Copy link
Member Author

OK, I added a test for #155.
It's fixed :)

@nzakas
Copy link
Member

nzakas commented Jul 10, 2015

LGTM

nzakas added a commit that referenced this pull request Jul 10, 2015
…onymouse-class

Fix: Leading comments for anonymous classes (fixes: #158)
@nzakas nzakas merged commit e5d1f3c into eslint:master Jul 10, 2015
@mysticatea mysticatea deleted the fix-comment-attachment-for-anonymouse-class branch July 11, 2015 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants