Java Code Examples for org.eclipse.jdt.internal.corext.dom.Bindings#findOverriddenMethodInType()

The following examples show how to use org.eclipse.jdt.internal.corext.dom.Bindings#findOverriddenMethodInType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickAssistProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the functional interface method being implemented by the given method
 * reference.
 *
 * @param methodReference
 *            the method reference to get the functional method
 * @return the functional interface method being implemented by
 *         <code>methodReference</code> or <code>null</code> if it could not be
 *         derived
 */
public static IMethodBinding getFunctionalMethodForMethodReference(MethodReference methodReference) {
	ITypeBinding targetTypeBinding = ASTNodes.getTargetType(methodReference);
	if (targetTypeBinding == null) {
		return null;
	}

	IMethodBinding functionalMethod = targetTypeBinding.getFunctionalInterfaceMethod();
	if (functionalMethod.isSynthetic()) {
		functionalMethod = Bindings.findOverriddenMethodInType(functionalMethod.getDeclaringClass(), functionalMethod);
	}
	return functionalMethod;
}
 
Example 2
Source File: InferTypeArgumentsConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addConstraintsForOverriding(IMethodBinding methodBinding, ConstraintVariable2 returnTypeCv, ConstraintVariable2[] parameterTypeCvs) {
	boolean hasParameterElementCvs= false;
	for (int i= 0; i < parameterTypeCvs.length; i++)
		if (parameterTypeCvs[i] != null)
			hasParameterElementCvs= true;

	if (returnTypeCv == null && ! hasParameterElementCvs)
		return;

	ITypeBinding[] allSuperTypes= Bindings.getAllSuperTypes(methodBinding.getDeclaringClass());
	for (int i= 0; i < allSuperTypes.length; i++) {
		ITypeBinding superType= allSuperTypes[i];
		IMethodBinding superMethod= Bindings.findOverriddenMethodInType(superType, methodBinding);
		if (superMethod == null)
			continue;

		for (int p= 0; p < parameterTypeCvs.length; p++) {
			if (parameterTypeCvs[p] == null)
				continue;
			ParameterTypeVariable2 parameterTypeCv= fTCModel.makeParameterTypeVariable(superMethod, p);
			fTCModel.createElementEqualsConstraints(parameterTypeCv, parameterTypeCvs[p]);
		}

		if (returnTypeCv != null) {
			ReturnTypeVariable2 superMethodReturnTypeCv= fTCModel.makeReturnTypeVariable(superMethod);
			fTCModel.createElementEqualsConstraints(superMethodReturnTypeCv, returnTypeCv);
		}
	}
}
 
Example 3
Source File: ChangeTypeRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static IMethodBinding findMethod(IMethodBinding methodBinding, ITypeBinding type) {
	  if (methodBinding.getDeclaringClass().equals(type))
		  return methodBinding;
	  return Bindings.findOverriddenMethodInType(type, methodBinding);
}
 
Example 4
Source File: FullConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected static IMethodBinding findMethod(IMethodBinding methodBinding, ITypeBinding type) {
	if (methodBinding.getDeclaringClass().equals(type))
		return methodBinding;
	return Bindings.findOverriddenMethodInType(type, methodBinding);
}