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;
(-)ui/org/eclipse/jdt/internal/ui/text/java/MethodProposalInfo.java (-9 / +22 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 isConstructorForNonStaticMemberClass= isConstructor && type.isMember() && !Flags.isStatic(type.getFlags());
183
				if (isConstructorForNonStaticMemberClass) {
184
					paramTypesTemp= new String[paramTypes.length + 1];
185
					System.arraycopy(paramTypes, 0, paramTypesTemp, 1, paramTypes.length);
186
				}
187
				if (paramTypesTemp.length == otherParams.length) {
179
					fFallbackMatch= method;
188
					fFallbackMatch= method;
180
					String signature= method.getSignature();
189
					String signature= method.getSignature();
181
					String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded
190
					String[] otherParamsFromSignature= Signature.getParameterTypes(signature); // types are resolved / upper-bounded
182
					// no need to check method type variables since these are
191
					// no need to check method type variables since these are
183
					// not yet bound when proposing a method
192
					// not yet bound when proposing a method
184
					for (int i= 0; i < paramTypes.length; i++) {
193
					for (int i= 0; i < paramTypesTemp.length; i++) {
185
						String ourParamName= computeSimpleTypeName(paramTypes[i], typeVariables);
194
						if (isConstructorForNonStaticMemberClass && i == 0) {
195
							// skip this one
196
							continue;
197
						}
198
						String ourParamName= computeSimpleTypeName(paramTypesTemp[i], typeVariables);
186
						String otherParamName1= computeSimpleTypeName(otherParams[i], typeVariables);
199
						String otherParamName1= computeSimpleTypeName(otherParams[i], typeVariables);
187
						String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i], typeVariables);
200
						String otherParamName2= computeSimpleTypeName(otherParamsFromSignature[i], typeVariables);
188
201
	
189
						if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
202
						if (!ourParamName.equals(otherParamName1) && !ourParamName.equals(otherParamName2)) {
190
							return false;
203
							return false;
191
						}
204
						}

Return to bug 354766