### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/BinaryMethod.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java,v retrieving revision 1.97 diff -u -r1.97 BinaryMethod.java --- model/org/eclipse/jdt/internal/core/BinaryMethod.java 22 Nov 2007 11:51:58 -0000 1.97 +++ model/org/eclipse/jdt/internal/core/BinaryMethod.java 14 Mar 2008 10:14:16 -0000 @@ -251,19 +251,8 @@ try { javadocContents = extractJavadoc(declaringType, javadocContents); } catch(JavaModelException e) { - // ignore + javadocContents = null; } - } else { - // let's see if we can retrieve them from the debug infos - char[][] argumentNames = info.getArgumentNames(); - if (argumentNames != null && argumentNames.length == paramCount) { - String[] names = new String[paramCount]; - for (int i = 0; i < paramCount; i++) { - names[i] = new String(argumentNames[i]); - } - return this.parameterNames = names; - } - return getRawParameterNames(paramCount); } if (javadocContents != null && javadocContents != BinaryType.EMPTY_JAVADOC) { final int indexOfOpenParen = javadocContents.indexOf('('); @@ -651,8 +640,7 @@ indexOfBottom = contents.indexOf(JavadocConstants.END_OF_CLASS_DATA, indexOfEndLink); } if (indexOfBottom == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); - indexOfNextMethod = Math.min(indexOfNextMethod, indexOfBottom); - if (indexOfNextMethod == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); + indexOfNextMethod = indexOfNextMethod == -1 ? indexOfBottom : Math.min(indexOfNextMethod, indexOfBottom); return contents.substring(indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH, indexOfNextMethod); } } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java,v retrieving revision 1.31 diff -u -r1.31 AttachedJavadocTests.java --- src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 21 Sep 2007 13:16:32 -0000 1.31 +++ src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 14 Mar 2008 10:14:19 -0000 @@ -35,6 +35,8 @@ import org.eclipse.jdt.core.JavaModelException; public class AttachedJavadocTests extends ModifyingResourceTests { + private static final String DEFAULT_DOC_FOLDER = "doc"; + static { // TESTS_NAMES = new String[] { "test010" }; // TESTS_NUMBERS = new int[] { 20 }; @@ -52,18 +54,9 @@ super(name); } - /** - * Create project and set the jar placeholder. - */ - public void setUpSuite() throws Exception { - super.setUpSuite(); - - this.project = setUpJavaProject("AttachedJavadocProject", "1.5"); //$NON-NLS-1$ - Map options = this.project.getOptions(true); - options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "2000"); //$NON-NLS-1$ - this.project.setOptions(options); + private void setJavadocLocationAttribute(String folderName) throws JavaModelException { IClasspathEntry[] entries = this.project.getRawClasspath(); - IResource resource = this.project.getProject().findMember("/doc/"); //$NON-NLS-1$ + IResource resource = this.project.getProject().findMember("/"+folderName+"/"); //$NON-NLS-1$ assertNotNull("doc folder cannot be null", resource); //$NON-NLS-1$ URI locationURI = resource.getLocationURI(); assertNotNull("doc folder cannot be null", locationURI); //$NON-NLS-1$ @@ -85,6 +78,18 @@ } } this.project.setRawClasspath(entries, null); + } + /** + * Create project and set the jar placeholder. + */ + public void setUpSuite() throws Exception { + super.setUpSuite(); + + this.project = setUpJavaProject("AttachedJavadocProject", "1.5"); //$NON-NLS-1$ + Map options = this.project.getOptions(true); + options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "2000"); //$NON-NLS-1$ + this.project.setOptions(options); + this.setJavadocLocationAttribute(DEFAULT_DOC_FOLDER); IPackageFragmentRoot[] roots = this.project.getAllPackageFragmentRoots(); int count = 0; @@ -504,4 +509,30 @@ assertEquals("Wrong name", "arg0", paramNames[0]); //$NON-NLS-1$ assertEquals("Wrong name", "arg1", paramNames[1]); //$NON-NLS-1$ } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=221723 + // for a method + public void test023() throws JavaModelException { + try { + this.setJavadocLocationAttribute("specialDoc"); + + IPackageFragment packageFragment = this.root.getPackageFragment("p1.p2"); //$NON-NLS-1$ + assertNotNull("Should not be null", packageFragment); //$NON-NLS-1$ + IClassFile classFile = packageFragment.getClassFile("X.class"); //$NON-NLS-1$ + assertNotNull(classFile); + IType type = classFile.getType(); + IMethod method = type.getMethod("foo", new String[] {"I", "J", "Ljava.lang.String;"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + assertTrue(method.exists()); + String javadoc = method.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$ + assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$ + String[] paramNames = method.getParameterNames(); + assertNotNull(paramNames); + assertEquals("Wrong size", 3, paramNames.length); //$NON-NLS-1$ + assertEquals("Wrong name for first param", "i", paramNames[0]); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Wrong name for second param", "l", paramNames[1]); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Wrong name for third param", "s", paramNames[2]); //$NON-NLS-1$ //$NON-NLS-2$ + } finally { + this.setJavadocLocationAttribute(DEFAULT_DOC_FOLDER); + } + } } Index: workspace/AttachedJavadocProject/specialDoc/p1/p2/X.html =================================================================== RCS file: workspace/AttachedJavadocProject/specialDoc/p1/p2/X.html diff -N workspace/AttachedJavadocProject/specialDoc/p1/p2/X.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/AttachedJavadocProject/specialDoc/p1/p2/X.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,388 @@ + + + +
+ +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + p1.p2.X ++
public class X
+Class X javadoc +
+ +
+
+Nested Class Summary | +|
---|---|
+ class |
+X.A
+
++ Javadoc for member type A |
+
+ class |
+X.B
+
++ |
+
+Field Summary | +|
---|---|
+ int |
+f
+
++ Javadoc for field f |
+
+ int |
+f2
+
++ |
+
+ java.lang.String |
+f3
+
++ Real javadoc for f3 |
+
+Constructor Summary | +|
---|---|
X(int i)
+
++ Javadoc for constructor X(int) |
+
+Method Summary | +|
---|---|
+ void |
+bar(java.util.ArrayList<java.lang.String> array)
+
++ |
+
+ void |
+foo(java.util.Enumeration enumeration)
+
++ |
+
+ void |
+foo(int i,
+ long l,
+ java.lang.String s)
+
++ Javadoc for method foo |
+
+ void |
+foo2()
+
++ |
+
+ void |
+foo2(java.lang.Integer i)
+
++ Javadoc for method foo2 |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public int f+
+
+public java.lang.String f3+
+
+public int f2+
+Constructor Detail | +
---|
+public X(int i)+
+
+Method Detail | +
---|
+public void foo2(java.lang.Integer i)+
+
+public void foo2()+
+public void foo(java.util.Enumeration enumeration)+
+public void bar(java.util.ArrayList<java.lang.String> array)+
+public void foo(int i, + long l, + java.lang.String s)+
+
i
- the given intl
- the given longs
- the given string
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + p1.p2.X.B ++
public class X.B
+
+Constructor Summary | +|
---|---|
X.B()
+
++ |
+
+Method Summary | +
---|
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public X.B()+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + p1.p2.X.A ++
public class X.A
+Javadoc for member type A +
+ +
+
+Constructor Summary | +|
---|---|
X.A(float f)
+
++ Javadoc for constructor of A |
+
+Method Summary | +
---|
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public X.A(float f)+
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +