Open gastaldi opened 1 year ago
I believe a custom visitor needs to be implemented to gain access to comments, otherwise the JDT ignores them. I seem to remember this from some issue a long time ago, but here's an example. Hopefully it still applies:
@lincolnthree yes, I discovered that through my investigation as well. The problem is that the comments are stored in the CompilationUnit
but you can not modify them (or I haven't found a way yet to do it).
In Eclipse JDT terms, it's impossible when Method.setBody
is called to create a Block
containing Statements
and store comments in the respective CompilationUnit
. See https://github.com/forge/roaster/pull/269
Ah yeah that makes sense. I see you found a solution using document. Just curious since I'm 'lurking' - did you mean for these tests to be @Disabled
? Or is it still not working?
It's still not working. Unfortunately the solution with Document
doesn't work when the class is created on-the-fly
Greetings! Wondering about the status of this issue.
@oc007us no evolution so far, unfortunately. Open for suggestions 😉
@gastaldi, yes, it is a tricky one. I guess, there is a way to collect all comments and perhaps save them in the MethodImpl class. I am not sure if there is a way to insert them back when the entire CompilationUnit is written to a file.
@oc007us I guess it depends on if the MethodDeclaration
in JDT supports that, I am not a big fan of storing content that is not synchronized with the underlying JDT tree
@gastaldi, neither am I. The generated code in my case can be done away without comments. I will use the JavaDoc on the methods to add info. Thank you for looking into it!
Discussed in https://github.com/forge/roaster/discussions/267