Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 354766 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavadocContents.java (-5 / +10 lines)
Lines 128-134 Link Here
128
		}
128
		}
129
		
129
		
130
		if (range != null) {
130
		if (range != null) {
131
			if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child));
131
			if (range == UNKNOWN_FORMAT) {
132
				throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child));
133
			}
132
			return String.valueOf(CharOperation.subarray(this.content, range[0], range[1]));
134
			return String.valueOf(CharOperation.subarray(this.content, range[0], range[1]));
133
		}
135
		}
134
		return null;
136
		return null;
Lines 377-397 Link Here
377
		IType declaringType = this.type;
379
		IType declaringType = this.type;
378
		if (declaringType.isMember()) {
380
		if (declaringType.isMember()) {
379
			int depth = 0;
381
			int depth = 0;
380
			// might need to remove a part of the signature corresponding to the synthetic argument
382
			// might need to remove a part of the signature corresponding to the synthetic argument (only for constructor)
381
			if (!Flags.isStatic(declaringType.getFlags())) {
383
			if (method.isConstructor() && !Flags.isStatic(declaringType.getFlags())) {
382
				depth++;
384
				depth++;
383
			}
385
			}
384
			if (depth != 0) {
386
			if (depth != 0) {
385
				// depth is 1
387
				// depth is 1
386
				int indexOfOpeningParen = anchor.indexOf('(');
388
				int indexOfOpeningParen = anchor.indexOf('(');
387
				if (indexOfOpeningParen == -1) return null;
389
				if (indexOfOpeningParen == -1) {
390
					// should not happen as this is a method signature
391
					return null;
392
				}
388
				int index = indexOfOpeningParen;
393
				int index = indexOfOpeningParen;
389
				indexOfOpeningParen++;
394
				indexOfOpeningParen++;
390
				int indexOfComma = anchor.indexOf(',', index);
395
				int indexOfComma = anchor.indexOf(',', index);
391
				if (indexOfComma != -1) {
396
				if (indexOfComma != -1) {
392
					index = indexOfComma + 2;
397
					index = indexOfComma + 2;
398
					anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index);
393
				}
399
				}
394
				anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index);
395
			}
400
			}
396
		}
401
		}
397
		return anchor + JavadocConstants.ANCHOR_PREFIX_END;
402
		return anchor + JavadocConstants.ANCHOR_PREFIX_END;
(-)src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java (-3 / +43 lines)
Lines 44-50 Link Here
44
	private static final String DEFAULT_DOC_FOLDER = "doc";
44
	private static final String DEFAULT_DOC_FOLDER = "doc";
45
45
46
	static {
46
	static {
47
//		TESTS_NAMES = new String[] { "testBug334652_4" };
47
//		TESTS_NAMES = new String[] { "testBug354766" };
48
//		TESTS_NUMBERS = new int[] { 24 };
48
//		TESTS_NUMBERS = new int[] { 24 };
49
//		TESTS_RANGE = new int[] { 169, 180 };
49
//		TESTS_RANGE = new int[] { 169, 180 };
50
	}
50
	}
Lines 52-58 Link Here
52
	public static Test suite() {
52
	public static Test suite() {
53
		// hack to guarantee the test order
53
		// hack to guarantee the test order
54
		TestSuite suite = new Suite(AttachedJavadocTests.class.getName());
54
		TestSuite suite = new Suite(AttachedJavadocTests.class.getName());
55
		suite.addTest(new AttachedJavadocTests("test001"));
55
		/*suite.addTest(new AttachedJavadocTests("test001"));
56
		suite.addTest(new AttachedJavadocTests("test002"));
56
		suite.addTest(new AttachedJavadocTests("test002"));
57
		suite.addTest(new AttachedJavadocTests("test003"));
57
		suite.addTest(new AttachedJavadocTests("test003"));
58
		suite.addTest(new AttachedJavadocTests("test004"));
58
		suite.addTest(new AttachedJavadocTests("test004"));
Lines 84-90 Link Here
84
		suite.addTest(new AttachedJavadocTests("testBug334652"));
84
		suite.addTest(new AttachedJavadocTests("testBug334652"));
85
		suite.addTest(new AttachedJavadocTests("testBug334652_2"));
85
		suite.addTest(new AttachedJavadocTests("testBug334652_2"));
86
		suite.addTest(new AttachedJavadocTests("testBug334652_3"));
86
		suite.addTest(new AttachedJavadocTests("testBug334652_3"));
87
		suite.addTest(new AttachedJavadocTests("testBug334652_4"));
87
		suite.addTest(new AttachedJavadocTests("testBug334652_4"));*/
88
		suite.addTest(new AttachedJavadocTests("testBug354766"));
88
		return suite;
89
		return suite;
89
	}
90
	}
90
91
Lines 964-967 Link Here
964
			this.project.setRawClasspath(entries, null);
965
			this.project.setRawClasspath(entries, null);
965
		}
966
		}
966
	}
967
	}
968
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=354766
969
	public void testBug354766() throws CoreException, IOException {
970
		IClasspathEntry[] entries = this.project.getRawClasspath();
971
972
		try {
973
			IClasspathAttribute attribute =
974
					JavaCore.newClasspathAttribute(
975
							IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
976
							"jar:platform:/resource/AttachedJavadocProject/bug354766_doc.zip!/");
977
					IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug354766.jar"), null, null, null, new IClasspathAttribute[] { attribute}, false);
978
			this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null);
979
			this.project.getResolvedClasspath(false);
980
981
			IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug354766.jar"));
982
			final IType type = jarRoot.getPackageFragment("com.test").getClassFile("PublicAbstractClass$InnerFinalException.class").getType();
983
			IMethod method = type.getMethod("foo", new String[0]);
984
			assertNotNull(method);
985
			assertTrue("Does not exist", method.exists());
986
987
			String javadoc = method.getAttachedJavadoc(null);
988
			assertNotNull(javadoc);
989
			assertEquals(
990
					"Wrong contents",
991
					"<H3>\r\n" + 
992
					"foo</H3>\r\n" + 
993
					"<PRE>\r\n" + 
994
					"public void <B>foo</B>()</PRE>\r\n" + 
995
					"<DL>\r\n" + 
996
					"<DD>Test method\r\n" + 
997
					"<P>\r\n" + 
998
					"<DD><DL>\r\n" + 
999
					"</DL>\r\n" + 
1000
					"</DD>\r\n" + 
1001
					"</DL>\r\n",
1002
					javadoc);
1003
		} finally {
1004
			this.project.setRawClasspath(entries, null);
1005
		}
1006
	}
967
}
1007
}
(-)ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java (-9 / +25 lines)
Lines 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.jdt.core.CompletionProposal;
16
import org.eclipse.jdt.core.CompletionProposal;
17
import org.eclipse.jdt.core.Flags;
17
import org.eclipse.jdt.core.IJavaProject;
18
import org.eclipse.jdt.core.IJavaProject;
18
import org.eclipse.jdt.core.IMember;
19
import org.eclipse.jdt.core.IMember;
19
import org.eclipse.jdt.core.IMethod;
20
import org.eclipse.jdt.core.IMethod;
Lines 90-96 Link Here
90
	 */
91
	 */
91
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type) throws JavaModelException {
92
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type) throws JavaModelException {
92
		Map<String, char[]> typeVariables= computeTypeVariables(type);
93
		Map<String, char[]> typeVariables= computeTypeVariables(type);
93
		return findMethod(name, paramTypes, isConstructor, type.getMethods(), typeVariables);
94
		return findMethod(name, paramTypes, isConstructor, type, typeVariables);
94
	}
95
	}
95
96
96
	/**
97
	/**
Lines 142-155 Link Here
142
	 * @param paramTypes The type signatures of the parameters e.g.
143
	 * @param paramTypes The type signatures of the parameters e.g.
143
	 *        <code>{"QString;","I"}</code>
144
	 *        <code>{"QString;","I"}</code>
144
	 * @param isConstructor If the method is a constructor
145
	 * @param isConstructor If the method is a constructor
145
	 * @param methods The methods to search in
146
	 * @param type the given type in which to search for methods
146
	 * @param typeVariables a map from type variables to concretely used types
147
	 * @param typeVariables a map from type variables to concretely used types
147
	 * @return The found method or <code>null</code>, if nothing found
148
	 * @return The found method or <code>null</code>, if nothing found
148
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
149
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
149
	 */
150
	 */
150
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IMethod[] methods, Map<String, char[]> typeVariables) throws JavaModelException {
151
	private IMethod findMethod(String name, String[] paramTypes, boolean isConstructor, IType type, Map<String, char[]> typeVariables) throws JavaModelException {
152
		IMethod[] methods = type.getMethods();
151
		for (int i= methods.length - 1; i >= 0; i--) {
153
		for (int i= methods.length - 1; i >= 0; i--) {
152
			if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i], typeVariables)) {
154
			if (isSameMethodSignature(name, paramTypes, isConstructor, methods[i], typeVariables, type)) {
153
				return methods[i];
155
				return methods[i];
154
			}
156
			}
155
		}
157
		}
Lines 167-191 Link Here
167
	 * @param isConstructor Specifies if the method is a constructor
169
	 * @param isConstructor Specifies if the method is a constructor
168
	 * @param method the method to be compared with this info's method
170
	 * @param method the method to be compared with this info's method
169
	 * @param typeVariables a map from type variables to types
171
	 * @param typeVariables a map from type variables to types
172
	 * @param type the given type that declares the method
170
	 * @return Returns <code>true</code> if the method has the given name and
173
	 * @return Returns <code>true</code> if the method has the given name and
171
	 *         parameter types and constructor state.
174
	 *         parameter types and constructor state.
172
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
175
	 * @throws JavaModelException if the method does not exist or if an exception occurs while accessing its corresponding resource
173
	 */
176
	 */
174
	private boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod method, Map<String, char[]> typeVariables) throws JavaModelException {
177
	private boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod method, Map<String, char[]> typeVariables, IType type) throws JavaModelException {
175
		if (isConstructor || name.equals(method.getElementName())) {
178
		if (isConstructor || name.equals(method.getElementName())) {
176
			if (isConstructor == method.isConstructor()) {
179
			if (isConstructor == method.isConstructor()) {
177
				String[] otherParams= method.getParameterTypes(); // types may be type variables
180
				String[] otherParams= method.getParameterTypes(); // types may be type variables
178
				if (paramTypes.length == otherParams.length) {
181
				String[] paramTypesTemp= paramTypes;
182
				boolean isBinaryConstructorForNonStaticMemberClass=
183
						method.isBinary()
184
						&& type.isMember()
185
						&& !Flags.isStatic(type.getFlags());
186
				if (isBinaryConstructorForNonStaticMemberClass) {
187
					paramTypesTemp= new String[paramTypes.length + 1];
188
					System.arraycopy(paramTypes, 0, paramTypesTemp, 1, paramTypes.length);
189
				}
190
				if (paramTypesTemp.length == otherParams.length) {
179
					fFallbackMatch= method;
191
					fFallbackMatch= method;
180
					String signature= method.getSignature();
192
					String signature= method.getSignature();
181
					String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded
193
					String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded
182
					// no need to check method type variables since these are
194
					// no need to check method type variables since these are
183
					// not yet bound when proposing a method
195
					// not yet bound when proposing a method
184
					for (int i= 0; i < paramTypes.length; i++) {
196
					for (int i= 0; i < paramTypesTemp.length; i++) {
185
						String ourParamName= computeSimpleTypeName(paramTypes[i], typeVariables);
197
						if (isBinaryConstructorForNonStaticMemberClass && i == 0) {
198
							// skip this one
199
							continue;
200
						}
201
						String ourParamName= computeSimpleTypeName(paramTypesTemp[i], typeVariables);
186
						String otherParamName1= computeSimpleTypeName(otherParams[i], typeVariables);
202
						String otherParamName1= computeSimpleTypeName(otherParams[i], typeVariables);
187
						String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i], typeVariables);
203
						String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i], typeVariables);
188
204
	
189
						if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
205
						if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
190
							return false;
206
							return false;
191
						}
207
						}

Return to bug 354766