### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavadocContents.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java,v retrieving revision 1.4 diff -u -r1.4 JavadocContents.java --- model/org/eclipse/jdt/internal/core/JavadocContents.java 19 Nov 2010 19:06:48 -0000 1.4 +++ model/org/eclipse/jdt/internal/core/JavadocContents.java 19 Jan 2011 20:08:03 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,6 @@ import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IJavaModelStatusConstants; -import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; @@ -378,31 +377,19 @@ IType declaringType = this.type; if (declaringType.isMember()) { int depth = 0; - final String packageFragmentName = declaringType.getPackageFragment().getElementName(); // might need to remove a part of the signature corresponding to the synthetic argument - final IJavaProject javaProject = declaringType.getJavaProject(); - char[][] typeNames = CharOperation.splitOn('.', typeQualifiedName.toCharArray()); - if (!Flags.isStatic(declaringType.getFlags())) depth++; - StringBuffer typeName = new StringBuffer(); - for (int i = 0, max = typeNames.length; i < max; i++) { - if (typeName.length() == 0) { - typeName.append(typeNames[i]); - } else { - typeName.append('.').append(typeNames[i]); - } - IType resolvedType = javaProject.findType(packageFragmentName, String.valueOf(typeName)); - if (resolvedType != null && resolvedType.isMember() && !Flags.isStatic(resolvedType.getFlags())) depth++; + if (!Flags.isStatic(declaringType.getFlags())) { + depth++; } if (depth != 0) { + // depth is 1 int indexOfOpeningParen = anchor.indexOf('('); if (indexOfOpeningParen == -1) return null; int index = indexOfOpeningParen; indexOfOpeningParen++; - for (int i = 0; i < depth; i++) { - int indexOfComma = anchor.indexOf(',', index); - if (indexOfComma != -1) { - index = indexOfComma + 2; - } + int indexOfComma = anchor.indexOf(',', index); + if (indexOfComma != -1) { + index = indexOfComma + 2; } anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index); } #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.39 diff -u -r1.39 AttachedJavadocTests.java --- src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 30 Nov 2010 15:26:42 -0000 1.39 +++ src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 19 Jan 2011 20:08:03 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,7 +43,7 @@ private static final String DEFAULT_DOC_FOLDER = "doc"; static { -// TESTS_NAMES = new String[] { "test010" }; +// TESTS_NAMES = new String[] { "testBug334652_4" }; // TESTS_NUMBERS = new int[] { 24 }; // TESTS_RANGE = new int[] { 169, 180 }; } @@ -783,4 +783,149 @@ this.project.setOptions(options); } } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652 + public void testBug334652() throws CoreException, IOException { + IClasspathEntry[] entries = this.project.getRawClasspath(); + + try { + IClasspathAttribute attribute = + JavaCore.newClasspathAttribute( + IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, + "jar:platform:/resource/AttachedJavadocProject/bug334652_doc.zip!/NoJavaDocForInnerClass/doc"); + IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652.jar"), null, null, null, new IClasspathAttribute[] { attribute}, false); + this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); + this.project.getResolvedClasspath(false); + + IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652.jar")); + final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType(); + IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass;", "Ljava.lang.String;", "Ljava.lang.String;"}); + assertNotNull(method); + assertTrue("Does not exist", method.exists()); + + String javadoc = method.getAttachedJavadoc(null); + assertNotNull(javadoc); + assertEquals("Wrong contents", "

\r\n" + + "PublicAbstractClass.InnerFinalException

\r\n" + + "
\r\n" + 
+					"public PublicAbstractClass.InnerFinalException(java.lang.String property,\r\n" + 
+					"                                               java.lang.String msg)
\r\n" + + "
\r\n" + + "
javadoc for InnerFinalException(String property, String msg)\r\n" + + "

\r\n" + + "

\r\n" + + "
Parameters:
property - the property argument
msg - the message argument
\r\n" + + "
\r\n", javadoc); + } finally { + this.project.setRawClasspath(entries, null); + } + } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652 + public void testBug334652_2() throws CoreException, IOException { + IClasspathEntry[] entries = this.project.getRawClasspath(); + + try { + IClasspathAttribute attribute = + JavaCore.newClasspathAttribute( + IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, + "jar:platform:/resource/AttachedJavadocProject/bug334652(2)_doc.zip!/doc"); + IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(2).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false); + this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); + this.project.getResolvedClasspath(false); + + IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(2).jar")); + final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType(); + IMethod method = type.getMethod("InnerFinalException", new String[] { "Ljava.lang.String;", "Ljava.lang.String;"}); + assertNotNull(method); + assertTrue("Does not exist", method.exists()); + + String javadoc = method.getAttachedJavadoc(null); + assertNotNull(javadoc); + assertEquals("Wrong contents", "

\r\n" + + "PublicAbstractClass.InnerFinalException

\r\n" + + "
\r\n" + 
+					"public PublicAbstractClass.InnerFinalException(java.lang.String property,\r\n" + 
+					"                                               java.lang.String msg)
\r\n" + + "
\r\n" + + "
javadoc for InnerFinalException(String property, String msg)\r\n" + + "

\r\n" + + "

\r\n" + + "
Parameters:
property - the property argument
msg - the message argument
\r\n" + + "
\r\n", javadoc); + } finally { + this.project.setRawClasspath(entries, null); + } + } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652 + public void testBug334652_3() throws CoreException, IOException { + IClasspathEntry[] entries = this.project.getRawClasspath(); + + try { + IClasspathAttribute attribute = + JavaCore.newClasspathAttribute( + IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, + "jar:platform:/resource/AttachedJavadocProject/bug334652(3)_doc.zip!/doc"); + IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(3).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false); + this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); + this.project.getResolvedClasspath(false); + + IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(3).jar")); + final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$A$InnerFinalException.class").getType(); + IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass$A;", "Ljava.lang.String;", "Ljava.lang.String;"}); + assertNotNull(method); + assertTrue("Does not exist", method.exists()); + + String javadoc = method.getAttachedJavadoc(null); + assertNotNull(javadoc); + assertEquals("Wrong contents", + "

\r\n" + + "PublicAbstractClass.A.InnerFinalException

\r\n" + + "
\r\n" + 
+					"public PublicAbstractClass.A.InnerFinalException(java.lang.String property,\r\n" + 
+					"                                                 java.lang.String msg)
\r\n" + + "
\r\n" + + "
javadoc for InnerFinalException(String property, String msg)\r\n" + + "

\r\n" + + "

\r\n" + + "
Parameters:
property - the property argument
msg - the message argument
\r\n" + + "
\r\n", javadoc); + } finally { + this.project.setRawClasspath(entries, null); + } + } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=334652 + public void testBug334652_4() throws CoreException, IOException { + IClasspathEntry[] entries = this.project.getRawClasspath(); + + try { + IClasspathAttribute attribute = + JavaCore.newClasspathAttribute( + IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, + "jar:platform:/resource/AttachedJavadocProject/bug334652(4)_doc.zip!/doc"); + IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug334652(4).jar"), null, null, null, new IClasspathAttribute[] { attribute}, false); + this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); + this.project.getResolvedClasspath(false); + + IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug334652(4).jar")); + final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$A$InnerFinalException.class").getType(); + IMethod method = type.getMethod("InnerFinalException", new String[] { "Lcom.test.PublicAbstractClass$A;", "Ljava.lang.String;", "Ljava.lang.String;"}); + assertNotNull(method); + assertTrue("Does not exist", method.exists()); + + String javadoc = method.getAttachedJavadoc(null); + assertNotNull(javadoc); + assertEquals("Wrong contents", "

\r\n" + + "PublicAbstractClass.A.InnerFinalException

\r\n" + + "
\r\n" + 
+					"public PublicAbstractClass.A.InnerFinalException(java.lang.String property,\r\n" + 
+					"                                                 java.lang.String msg)
\r\n" + + "
\r\n" + + "
javadoc for InnerFinalException(String property, String msg)\r\n" + + "

\r\n" + + "

\r\n" + + "
Parameters:
property - the property argument
msg - the message argument
\r\n" + + "
\r\n", javadoc); + } finally { + this.project.setRawClasspath(entries, null); + } + } }