Community
Participate
Working Groups
IDOMMember.getComments() appears to attempt to return the "doc comment" (that is, the Javadoc comment) for the member. The documentation is vague on this, but testing seems to suggest this is the intent. However, in cases where a member has more than one /** */-style comment, unusual results occur. For example, for in the following Java: /** * a first Javadoc comment */ // public void foo() { // } /** * a second Javadoc comment */ public void bar() {} getComments() returns: /** * a first Javadoc comment */ // public void foo() { // } /** * a second Javadoc comment */ This is inconsistent with the following example: // a non-javadoc comment /** * The javadoc for this */ /* * another non-javadoc */ public void foo() {} in which case, getComments() returns: /** * The javadoc for this */ In general, getComments() returns everything between the first and last detected javadoc-style comment for an element. This is inconsistent with the way javadoc itself works. Javadoc uses only the last javadoc comment immediately preceding the element. The current behavior is the result of code in the org.eclipse.jdt.internal.com.jdom.DOMBuilder methods enterAbstractMethod(), enterField() and enterType(). Proposed fixes and JUnit tests will be attached.
Created attachment 12863 [details] JUnit test cases illustrating the defect
Created attachment 12864 [details] Proposed Fix to DOMBuilder.java Fixes are flagged by a // FIXME comments.
IDOMMember has been deprecated in 3.0. As you opened this bug against 3.0, would it be possible to use DOM/AST nodes API which does not have this problem?
I'm aware JDOM is deprecated in 3.0. Unfortunately, I uncovered it while using EMF/JMerge which makes extensive use of JDOM. I have proposed a workaround to them (see Bugzilla #68396, if you want details). There is no point in you fixing this one if EMF does not fix 68396. Longer term, EMF/JMerge will have to be re-written to use AST/DOM, but this will be non-trivial.
Frederic - pls address in 3.0 stream. Will deliver along with next rollup.
Proposed fix looks good and pass all JDT/Core tests => no problem to put it in next rollup... I'll also add proposed tests to JDOM tests.
Fixed and released in JDK_1_5 stream and will be available in Cheetah06. New test class was added for additional tests: org.eclipse.jdt.tests.core.DOMTestsComments All test cases have been externalized in java file and put in a new project "CommentsTests" in "TestSolution" workspace...
Created attachment 12881 [details] Patch to apply in 3.0 maintenance stream These patches (jdt.core + jdt.core.tests) will be released in 3.0 maintenance stream when corresponding branch will be created in dev.eclipse.org repository. Note that these patches have been created on top of v_449 version which matches Eclipse 3.0 delivery...
Fixed and released in HEAD stream.
Verified for 3.0.1 RC1