Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 201750 Details for
Bug 354766
Javadoc content does not appear in content assist info window for non-static inner class constructors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed fix + regression test
patch_354766.txt (text/plain), 10.48 KB, created by
Olivier Thomann
on 2011-08-18 17:53:55 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-08-18 17:53:55 EDT
Size:
10.48 KB
patch
obsolete
>### 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.5 >diff -u -r1.5 JavadocContents.java >--- model/org/eclipse/jdt/internal/core/JavadocContents.java 20 Jan 2011 02:28:43 -0000 1.5 >+++ model/org/eclipse/jdt/internal/core/JavadocContents.java 18 Aug 2011 21:51:21 -0000 >@@ -128,7 +128,9 @@ > } > > if (range != null) { >- if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); >+ if (range == UNKNOWN_FORMAT) { >+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); >+ } > return String.valueOf(CharOperation.subarray(this.content, range[0], range[1])); > } > return null; >@@ -377,21 +379,24 @@ > IType declaringType = this.type; > if (declaringType.isMember()) { > int depth = 0; >- // might need to remove a part of the signature corresponding to the synthetic argument >- if (!Flags.isStatic(declaringType.getFlags())) { >+ // might need to remove a part of the signature corresponding to the synthetic argument (only for constructor) >+ if (method.isConstructor() && !Flags.isStatic(declaringType.getFlags())) { > depth++; > } > if (depth != 0) { > // depth is 1 > int indexOfOpeningParen = anchor.indexOf('('); >- if (indexOfOpeningParen == -1) return null; >+ if (indexOfOpeningParen == -1) { >+ // should not happen as this is a method signature >+ return null; >+ } > int index = indexOfOpeningParen; > indexOfOpeningParen++; > int indexOfComma = anchor.indexOf(',', index); > if (indexOfComma != -1) { > index = indexOfComma + 2; >+ anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index); > } >- anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index); > } > } > return anchor + JavadocConstants.ANCHOR_PREFIX_END; >#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.41 >diff -u -r1.41 AttachedJavadocTests.java >--- src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 3 Mar 2011 20:18:27 -0000 1.41 >+++ src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 18 Aug 2011 21:51:22 -0000 >@@ -44,7 +44,7 @@ > private static final String DEFAULT_DOC_FOLDER = "doc"; > > static { >-// TESTS_NAMES = new String[] { "testBug334652_4" }; >+// TESTS_NAMES = new String[] { "testBug354766" }; > // TESTS_NUMBERS = new int[] { 24 }; > // TESTS_RANGE = new int[] { 169, 180 }; > } >@@ -52,7 +52,7 @@ > public static Test suite() { > // hack to guarantee the test order > TestSuite suite = new Suite(AttachedJavadocTests.class.getName()); >- suite.addTest(new AttachedJavadocTests("test001")); >+ /*suite.addTest(new AttachedJavadocTests("test001")); > suite.addTest(new AttachedJavadocTests("test002")); > suite.addTest(new AttachedJavadocTests("test003")); > suite.addTest(new AttachedJavadocTests("test004")); >@@ -84,7 +84,8 @@ > suite.addTest(new AttachedJavadocTests("testBug334652")); > suite.addTest(new AttachedJavadocTests("testBug334652_2")); > suite.addTest(new AttachedJavadocTests("testBug334652_3")); >- suite.addTest(new AttachedJavadocTests("testBug334652_4")); >+ suite.addTest(new AttachedJavadocTests("testBug334652_4"));*/ >+ suite.addTest(new AttachedJavadocTests("testBug354766")); > return suite; > } > >@@ -964,4 +965,43 @@ > this.project.setRawClasspath(entries, null); > } > } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=354766 >+ public void testBug354766() throws CoreException, IOException { >+ IClasspathEntry[] entries = this.project.getRawClasspath(); >+ >+ try { >+ IClasspathAttribute attribute = >+ JavaCore.newClasspathAttribute( >+ IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, >+ "jar:platform:/resource/AttachedJavadocProject/bug354766_doc.zip!/"); >+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug354766.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/bug354766.jar")); >+ final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType(); >+ IMethod method = type.getMethod("foo", new String[0]); >+ assertNotNull(method); >+ assertTrue("Does not exist", method.exists()); >+ >+ String javadoc = method.getAttachedJavadoc(null); >+ assertNotNull(javadoc); >+ assertEquals( >+ "Wrong contents", >+ "<H3>\r\n" + >+ "foo</H3>\r\n" + >+ "<PRE>\r\n" + >+ "public void <B>foo</B>()</PRE>\r\n" + >+ "<DL>\r\n" + >+ "<DD>Test method\r\n" + >+ "<P>\r\n" + >+ "<DD><DL>\r\n" + >+ "</DL>\r\n" + >+ "</DD>\r\n" + >+ "</DL>\r\n", >+ javadoc); >+ } finally { >+ this.project.setRawClasspath(entries, null); >+ } >+ } > } >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java,v >retrieving revision 1.14 >diff -u -r1.14 MethodProposalInfo.java >--- ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java 1 Mar 2011 11:50:36 -0000 1.14 >+++ ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java 18 Aug 2011 21:51:22 -0000 >@@ -14,6 +14,7 @@ > import java.util.Map; > > import org.eclipse.jdt.core.CompletionProposal; >+import org.eclipse.jdt.core.Flags; > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IMember; > import org.eclipse.jdt.core.IMethod; >@@ -90,7 +91,7 @@ > */ > private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type) throws JavaModelException { > Map<String, char[]> typeVariables= computeTypeVariables(type); >- return findMethod(name, paramTypes, isConstructor, type.getMethods(), typeVariables); >+ return findMethod(name, paramTypes, isConstructor, type, typeVariables); > } > > /** >@@ -142,14 +143,15 @@ > * @param paramTypes The type signatures of the parameters e.g. > * <code>{"QString;","I"}</code> > * @param isConstructor If the method is a constructor >- * @param methods The methods to search in >+ * @param type the given type in which to search for methods > * @param typeVariables a map from type variables to concretely used types > * @return The found method or <code>null</code>, if nothing found > * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource > */ >- private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IMethod[] methods, Map<String, char[]> typeVariables) throws JavaModelException { >+ private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type, Map<String, char[]> typeVariables) throws JavaModelException { >+ IMethod[] methods = type.getMethods(); > for (int i= methods.length - 1; i >= 0; i--) { >- if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i], typeVariables)) { >+ if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i], typeVariables, type)) { > return methods[i]; > } > } >@@ -167,25 +169,39 @@ > * @param isConstructor Specifies if the method is a constructor > * @param method the method to be compared with this info's method > * @param typeVariables a map from type variables to types >+ * @param type the given type that declares the method > * @return Returns <code>true</code> if the method has the given name and > * parameter types and constructor state. > * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource > */ >- private boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod method, Map<String, char[]> typeVariables) throws JavaModelException { >+ private boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod method, Map<String, char[]> typeVariables, IType type) throws JavaModelException { > if (isConstructor || name.equals(method.getElementName())) { > if (isConstructor == method.isConstructor()) { > String[] otherParams= method.getParameterTypes(); // types may be type variables >- if (paramTypes.length == otherParams.length) { >+ String[] paramTypesTemp= paramTypes; >+ boolean isBinaryConstructorForNonStaticMemberClass= >+ method.isBinary() >+ && type.isMember() >+ && !Flags.isStatic(type.getFlags()); >+ if (isBinaryConstructorForNonStaticMemberClass) { >+ paramTypesTemp= new String[paramTypes.length + 1]; >+ System.arraycopy(paramTypes, 0, paramTypesTemp, 1, paramTypes.length); >+ } >+ if (paramTypesTemp.length == otherParams.length) { > fFallbackMatch= method; > String signature= method.getSignature(); > String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded > // no need to check method type variables since these are > // not yet bound when proposing a method >- for (int i= 0; i < paramTypes.length; i++) { >- String ourParamName= computeSimpleTypeName(paramTypes[i], typeVariables); >+ for (int i= 0; i < paramTypesTemp.length; i++) { >+ if (isBinaryConstructorForNonStaticMemberClass && i == 0) { >+ // skip this one >+ continue; >+ } >+ String ourParamName= computeSimpleTypeName(paramTypesTemp[i], typeVariables); > String otherParamName1= computeSimpleTypeName(otherParams[i], typeVariables); > String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i], typeVariables); >- >+ > if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) { > return false; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 354766
:
201749
|
201750
|
201751
|
201752
|
201753
|
201974
|
202006
|
202008
|
202020
|
206108
|
206119