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

Scanning of Comments on CompilationUnit? #2798

Closed
pvojtechovsky opened this issue Nov 29, 2018 · 7 comments
Closed

Scanning of Comments on CompilationUnit? #2798

pvojtechovsky opened this issue Nov 29, 2018 · 7 comments

Comments

@pvojtechovsky
Copy link
Collaborator

If we move comment at the beginning of the file to compilation unit (like In #2683), then such comment is not visited when scanning from rootPackage, because compilation unit is part of secondary model (mapping of classes to files) and is not part of primary model (semantic java).

Is it OK?

Note: it breaks some tests like CtScannerTest#testScan with contract: all AST nodes are visited through method "scan"

WDYT?

@monperrus
Copy link
Collaborator

It seems OK to me. Conceptually, comments are not first-class AST nodes (they have nothing to do with the program behavior).

@stefanleh
Copy link

It seems OK to me. Conceptually, comments are not first-class AST nodes (they have nothing to do with the program behavior).

That might be true, but nobody likes the comments moved around when modifying the code via processors. In my current project the comments were used for defining extension points in the code, which is for sure not what they are for, but it worked for them many years pretty well. Now i cant change the code via processors but need to use the processors for finding the parts i need to change then by regex. So i would love spoon handling comments as first class citizens.

@surli
Copy link
Collaborator

surli commented Nov 30, 2018

So i would love spoon handling comments as first class citizens.

for me it really looks like another usecase for #2774

@pvojtechovsky
Copy link
Collaborator Author

pvojtechovsky commented Dec 2, 2018

Thank you for your feedback.
@stefanleh do you have an concept how the comments can become first class citizens in Spoon model? Please make a new issue with that concept.

@surli
Copy link
Collaborator

surli commented Dec 3, 2018

Not sure why the issue has been closed (might be a mistake) so I reopen it.

@surli surli reopened this Dec 3, 2018
@pvojtechovsky
Copy link
Collaborator Author

I closed this issue intentionally. My origin question was answered. So it can be closed.
And "comments as first class citizens" belong to different issue - if anybody wants to discuss it.

@surli
Copy link
Collaborator

surli commented Dec 3, 2018

Sorry I read it before finishing my coffee this morning, I missed the last sentence of your answer. 😪 Closing it again.

@surli surli closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants