Community
Participate
Working Groups
Build 20011025 1. Create the following CU: X.java ------ public class X { String s1 = "s1"; //comment for s1 } 2. Make sure that 'Show Source of Selected Element Only' is selected 3. In the Outline, select field 's1' Observe: The comment doesn't appear near the field declaration.
The positions provided by the Java Model don't include line comments. So the editor doesn't know about the trailing comment. There are two possible solutions: - the editor parses the CU using the (internal) scanner - the java model provides corresponding positions. Opt to postpone > 2.0
IMO the Java model should provide more support for comments to solve this. The UI should not start to parse the code and search for comments. Moving to Core for commenting
I would expect the comment behind to be part of the element. Please investigate.
There is no good solution for including comments in the nodes. This is why the setLeadingComment(...) is not implemented. Only the javadoc comments are properly handled now. This is a more generic problem. We need to find out how to map the comments and the DOM/AST tree. When we get something consistent, then we can fix this PR. A trailing comment can also be seen as the leading comment of the next statement or expression. For now I don't see how to manage the comments and the DOM/AST tree.
This bug is due to the fact that the SourceElementParser doesn't provide the declaration source end for a field. The fix is simple and requires to pass an extra argument in exitField.
Fixed and released in 2.1 stream. The end of the field is not its declaration source end which includes the trailing comment.
Change milestone.
Verified.