-
Notifications
You must be signed in to change notification settings - Fork 174
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
feat: Add comments to JdtVisitor #368
Conversation
b91059a
to
609286c
Compare
Thank you! In case the comment is within a statement as follows, does return outerInstance.isPresent() //
? executableInvoker.invoke(constructor, outerInstance.get(), extensionContext, registry) //
: executableInvoker.invoke(constructor, extensionContext, registry); |
@tsantalis Very good question! I tried the following code snippet:
And this is the generated tree:
|
OK, I think it makes sense to have it like that from the AST point of view. |
@jrfaller |
Hi! Thanks a lot for the PR! I realize that activating the comments is done via a boolean on the constructor of JdtGenerator and I am afraid this way it won't be possible to use it from the command line. To overcome this may be the |
@jrfaller @pouryafard75 |
609286c
to
23c0001
Compare
@jrfaller I made it work with |
@jrfaller In case you have missed the previous msg. |
23c0001
to
e054db3
Compare
I have updated this one, to process non-attached javadocs too. |
@pouryafard75 Some of them could be actual javadocs of methods, classes, fields, etc. It is very rare to have Javadocs within the body of a method as shown below I think only these cases should be processed from the comment list, because all other normal Javadoc cases already exist as properties in the method, field, type declaration AST nodes. |
@tsantalis Attached JavaDocs actually have parents. Thats the way to distinguish them: |
@pouryafard75 Your PR is extensively tested and ready to be merged. |
Hi @tsantalis, @pouryafard75! Thanks a lot for improving the PR. Sorry to be a little over-careful with this one but it's on the JDT parser so it can have a lot of effect :) I have tried the option mechanism and I think it's not very convenient to use. By reading the code base again I think that finally the easiest way to have both ways to generate the tree would be to have a new TreeGenerator, similar to what I did for the change distiller tree generator here: https://github.com/GumTreeDiff/gumtree/blob/main/gen.jdt/src/main/java/com/github/gumtreediff/gen/jdt/cd/CdJdtTreeGenerator.java This way it can easily be set up using the @pouryafard75 could you try it? Cheers! |
@jrfaller What do you think about this new impl? |
8269d0a
to
57b6641
Compare
57b6641
to
6d76ef4
Compare
I have written separate Visitor and Generator for it. I think now its ready and functional. |
Perfect! Looks very nice! Thanks @pouryafard75 and @tsantalis !!! |
@pouryafard75 @tsantalis ICYMI, see also https://github.com/SpoonLabs/gumtree-spoon-ast-diff/ Gumtree-diff for Java with the full power of the Spoon API. |
@monperrus |
@jrfaller |
…tem property Visitor inspired by GumTreeDiff/gumtree#368
…tem property Visitor inspired by GumTreeDiff/gumtree#368
Hi @tsantalis ! I have just released 4.0.0-beta3 if I don't run into any bug with it should be soon released as 4.0.0! |
Hello, This is a fix for a very old issue #39.
The implementation might not be the best one, and I am very eager to improve it based on your feedbacks.
You can enable/disable the feature throughout the JdtTreeGenerator. By default its disabled since you might have a test environment tailored to the previous structure.
For the following code example:
The generated tree will be as follows: