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

The following examples show how to use org.eclipse.jdt.internal.corext.dom.Bindings#isSubsignature() . 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: NewAsyncRemoteServiceInterfaceCreationWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * NOTE: This method comes from StubUtility2.
 */
@SuppressWarnings("deprecation")
private static IMethodBinding findOverridingMethod(IMethodBinding method,
    List<IMethodBinding> allMethods) {
  for (IMethodBinding cur : allMethods) {
    if (Bindings.areOverriddenMethods(cur, method)
        || Bindings.isSubsignature(cur, method)) {
      return cur;
    }
  }
  return null;
}
 
Example 2
Source File: SuperTypeConstraintsCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the original methods of the method hierarchy of the specified method.
 *
 * @param binding the method binding
 * @param type the current type
 * @param originals the original methods which have already been found (element type: <code>IMethodBinding</code>)
 * @param implementations <code>true</code> to favor implementation methods, <code>false</code> otherwise
 */
private static void getOriginalMethods(final IMethodBinding binding, final ITypeBinding type, final Collection<IMethodBinding> originals, final boolean implementations) {
	final ITypeBinding ancestor= type.getSuperclass();
	if (!implementations) {
		final ITypeBinding[] types= type.getInterfaces();
		for (int index= 0; index < types.length; index++)
			getOriginalMethods(binding, types[index], originals, implementations);
		if (ancestor != null)
			getOriginalMethods(binding, ancestor, originals, implementations);
	}
	if (implementations && ancestor != null)
		getOriginalMethods(binding, ancestor, originals, implementations);
	final IMethodBinding[] methods= type.getDeclaredMethods();
	IMethodBinding method= null;
	for (int index= 0; index < methods.length; index++) {
		method= methods[index];
		if (!binding.getKey().equals(method.getKey())) {
			boolean match= false;
			IMethodBinding current= null;
			for (final Iterator<IMethodBinding> iterator= originals.iterator(); iterator.hasNext();) {
				current= iterator.next();
				if (Bindings.isSubsignature(method, current))
					match= true;
			}
			if (!match && Bindings.isSubsignature(binding, method))
				originals.add(method);
		}
	}
}
 
Example 3
Source File: StubUtility2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static IMethodBinding findMethodBinding(IMethodBinding method, List<IMethodBinding> allMethods) {
	for (int i= 0; i < allMethods.size(); i++) {
		IMethodBinding curr= allMethods.get(i);
		if (Bindings.isSubsignature(method, curr)) {
			return curr;
		}
	}
	return null;
}
 
Example 4
Source File: StubUtility2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static IMethodBinding findOverridingMethod(IMethodBinding method, List<IMethodBinding> allMethods) {
	for (int i= 0; i < allMethods.size(); i++) {
		IMethodBinding curr= allMethods.get(i);
		if (Bindings.areOverriddenMethods(curr, method) || Bindings.isSubsignature(curr, method))
			return curr;
	}
	return null;
}
 
Example 5
Source File: StubUtility2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static void findUnimplementedInterfaceMethods(ITypeBinding typeBinding, HashSet<ITypeBinding> visited,
		ArrayList<IMethodBinding> allMethods, IPackageBinding currPack, ArrayList<IMethodBinding> toImplement) {
	
	if (visited.add(typeBinding)) {
		IMethodBinding[] typeMethods= typeBinding.getDeclaredMethods();
		
		nextMethod: for (int i= 0; i < typeMethods.length; i++) {
			IMethodBinding curr= typeMethods[i];
			for (Iterator<IMethodBinding> allIter= allMethods.iterator(); allIter.hasNext();) {
				IMethodBinding oneMethod= allIter.next();
				if (Bindings.isSubsignature(oneMethod, curr)) {
					// We've already seen a method that is a subsignature of curr.
					if (!Bindings.isSubsignature(curr, oneMethod)) {
						// oneMethod is a true subsignature of curr; let's go with oneMethod
						continue nextMethod;
					}
					// Subsignatures are equivalent.
					// Check visibility and return types ('getErasure()' tries to achieve effect of "rename type variables")
					if (Bindings.isVisibleInHierarchy(oneMethod, currPack)
							&& oneMethod.getReturnType().getErasure().isSubTypeCompatible(curr.getReturnType().getErasure())) {
						// oneMethod is visible and curr doesn't have a stricter return type; let's go with oneMethod
						continue nextMethod;
					}
					// curr is stricter than oneMethod, so let's remove oneMethod
					allIter.remove();
					toImplement.remove(oneMethod);
				} else if (Bindings.isSubsignature(curr, oneMethod)) {
					// curr is a true subsignature of oneMethod. Let's remove oneMethod.
					allIter.remove();
					toImplement.remove(oneMethod);
				}
			}
			if (Modifier.isAbstract(curr.getModifiers())) {
				toImplement.add(curr);
				allMethods.add(curr);
			}
		}
		ITypeBinding[] superInterfaces= typeBinding.getInterfaces();
		for (int i= 0; i < superInterfaces.length; i++)
			findUnimplementedInterfaceMethods(superInterfaces[i], visited, allMethods, currPack, toImplement);
	}
}