### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/Member.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java,v retrieving revision 1.48 diff -u -r1.48 Member.java --- model/org/eclipse/jdt/internal/core/Member.java 24 Oct 2007 13:50:51 -0000 1.48 +++ model/org/eclipse/jdt/internal/core/Member.java 20 May 2008 15:04:45 -0000 @@ -301,7 +301,7 @@ } } if (docOffset != -1) { - return new SourceRange(docOffset + start, docEnd - docOffset + 1); + return new SourceRange(docOffset + start, docEnd - docOffset); } } catch (InvalidInputException ex) { // try if there is inherited Javadoc #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/GetSourceTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java,v retrieving revision 1.22 diff -u -r1.22 GetSourceTests.java --- src/org/eclipse/jdt/core/tests/model/GetSourceTests.java 10 Apr 2008 14:38:21 -0000 1.22 +++ src/org/eclipse/jdt/core/tests/model/GetSourceTests.java 20 May 2008 15:04:46 -0000 @@ -163,6 +163,54 @@ assertNull("Should not be a constant", constant); } + /* + * Ensures that the Javadoc range for a method is correct. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=232944 ) + */ + public void testJavadocRange01() throws CoreException { + try { + String cuSource = + "package p;\n" + + "class A{\n" + + " /**\n" + + " * swsw\n" + + " */\n" + + " void m(){\n" + + " }\n" + + "}"; + createFile("/P/p/A.java", cuSource); + IMethod method = getCompilationUnit("/P/p/A.java").getType("A").getMethod("m", new String[0]); + assertSourceEquals( + "Unexpected Javadoc'", + "/**\n" + + " * swsw\n" + + " */", + getSource(cuSource, method.getJavadocRange())); + } finally { + deleteFile("/P/p/A.java"); + } + } + + /* + * Ensures that the Javadoc range for a class is correct. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=232944 ) + */ + public void testJavadocRange02() throws CoreException { + try { + String cuSource = + "package p;\n" + + "/** X */class A {}"; + createFile("/P/p/A.java", cuSource); + IType type = getCompilationUnit("/P/p/A.java").getType("A"); + assertSourceEquals( + "Unexpected Javadoc'", + "/** X */", + getSource(cuSource, type.getJavadocRange())); + } finally { + deleteFile("/P/p/A.java"); + } + } + /** * Ensure the source for an import contains the 'import' keyword, * name, and terminator.