當前位置: 首頁>>代碼示例>>Java>>正文


Java ITypeBinding.getInterfaces方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getInterfaces方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getInterfaces方法的具體用法?Java ITypeBinding.getInterfaces怎麽用?Java ITypeBinding.getInterfaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.dom.ITypeBinding的用法示例。


在下文中一共展示了ITypeBinding.getInterfaces方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isContext

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean isContext(ITypeBinding tbinding) {
	String executionContextClass = org.graphwalker.core.machine.ExecutionContext.class.getName();
	String contextClass = org.graphwalker.core.machine.Context.class.getName();
	while (tbinding != null) {
		String clazz = tbinding.getQualifiedName();
		if (executionContextClass.equals(clazz))
			return true;
		if (contextClass.equals(clazz))
			return true;
		ITypeBinding[] interfaces = tbinding.getInterfaces();
		for (int i = 0; i < interfaces.length; i++) {
			ITypeBinding interf = interfaces[i];
			if (contextClass.equals(interf.getQualifiedName()))
				return true;
		}
		tbinding = tbinding.getSuperclass();
	}
	return false;

}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:21,代碼來源:JDTManager.java

示例2: findFieldInHierarchy

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Finds the field specified by <code>fieldName</code> in
 * the type hierarchy denoted by the given type. Returns <code>null</code> if no such field
 * exists. If the field is defined in more than one super type only the first match is
 * returned. First the super class is examined and then the implemented interfaces.
 * @param type The type to search the field in
 * @param fieldName The name of the field to find
 * @return the variable binding representing the field
 */
public static IVariableBinding findFieldInHierarchy(ITypeBinding type, String fieldName) {
	IVariableBinding field= findFieldInType(type, fieldName);
	if (field != null) {
		return field;
	}
	ITypeBinding superClass= type.getSuperclass();
	if (superClass != null) {
		field= findFieldInHierarchy(superClass, fieldName);
		if (field != null) {
			return field;
		}
	}
	ITypeBinding[] interfaces= type.getInterfaces();
	for (int i= 0; i < interfaces.length; i++) {
		field= findFieldInHierarchy(interfaces[i], fieldName);
		if (field != null) {
			return field;
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:31,代碼來源:Bindings.java

示例3: findMethodInHierarchy

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Finds the method specified by <code>methodName</code> and <code>parameters</code> in
 * the type hierarchy denoted by the given type. Returns <code>null</code> if no such method
 * exists. If the method is defined in more than one super type only the first match is
 * returned. First the super class is examined and then the implemented interfaces.
 *
 * @param type The type to search the method in
 * @param methodName The name of the method to find
 * @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored.
 * @return the method binding representing the method
 */
public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding[] parameters) {
	IMethodBinding method= findMethodInType(type, methodName, parameters);
	if (method != null) {
		return method;
	}
	ITypeBinding superClass= type.getSuperclass();
	if (superClass != null) {
		method= findMethodInHierarchy(superClass, methodName, parameters);
		if (method != null) {
			return method;
		}
	}
	ITypeBinding[] interfaces= type.getInterfaces();
	for (int i= 0; i < interfaces.length; i++) {
		method= findMethodInHierarchy(interfaces[i], methodName, parameters);
		if (method != null) {
			return method;
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:33,代碼來源:Bindings.java

示例4: findOverriddenMethodInHierarchy

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Finds a method in the hierarchy of <code>type</code> that is overridden by <code>binding</code>.
 * Returns <code>null</code> if no such method exists. If the method is defined in more than one super type only the first match is
 * returned. First the super class is examined and then the implemented interfaces.
 * @param type The type to search the method in
 * @param binding The method that overrides
 * @return the method binding overridden the method
 */
public static IMethodBinding findOverriddenMethodInHierarchy(ITypeBinding type, IMethodBinding binding) {
	IMethodBinding method= findOverriddenMethodInType(type, binding);
	if (method != null) {
		return method;
	}
	ITypeBinding superClass= type.getSuperclass();
	if (superClass != null) {
		method= findOverriddenMethodInHierarchy(superClass, binding);
		if (method != null) {
			return method;
		}
	}
	ITypeBinding[] interfaces= type.getInterfaces();
	for (int i= 0; i < interfaces.length; i++) {
		method= findOverriddenMethodInHierarchy(interfaces[i], binding);
		if (method != null) {
			return method;
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:30,代碼來源:Bindings.java

示例5: visitInterfaces

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean visitInterfaces(ITypeBinding type, TypeBindingVisitor visitor, HashSet<ITypeBinding> visited) {
	boolean unvisited= visited.add(type);
	if (!unvisited) {
		return true;
	}
	ITypeBinding[] interfaces= type.getInterfaces();
	for (int i= 0; i < interfaces.length; i++) {
		if (!visitor.visit(interfaces[i])) {
			return false;
		}
		if (!visitInterfaces(interfaces[i], visitor, visited)) {
			return false;
		}
	}
	return true;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:17,代碼來源:Bindings.java

示例6: normalizeTypeBinding

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Normalizes a type binding received from an expression to a type binding that can be used inside a
 * declaration signature, but <em>not</em> as type of a declaration (use {@link #normalizeForDeclarationUse(ITypeBinding, AST)} for that).
 * <p>
 * Anonymous types are normalized to the super class or interface. For
 * null or void bindings, <code>null</code> is returned.
 * </p>
 *
 * @param binding the binding to normalize
 * @return the normalized binding, can be <code>null</code>
 *
 * @see #normalizeForDeclarationUse(ITypeBinding, AST)
 */
public static ITypeBinding normalizeTypeBinding(ITypeBinding binding) {
	if (binding != null && !binding.isNullType() && !isVoidType(binding)) {
		if (binding.isAnonymous()) {
			ITypeBinding[] baseBindings= binding.getInterfaces();
			if (baseBindings.length > 0) {
				return baseBindings[0];
			}
			return binding.getSuperclass();
		}
		if (binding.isCapture()) {
			return binding.getWildcard();
		}
		return binding;
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:30,代碼來源:Bindings.java

示例7: addNewTypeBinding

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
protected void addNewTypeBinding(ITypeBinding typeBinding) {
	// Skip over primitive types, which includes void
	if (typeBinding == null || typeBinding.isPrimitive()) {
		return;
	}
	String key = typeBinding.getKey();
	if (!mapKeyToType.containsKey(key)) {
		mapKeyToType.put(key, typeBinding);
	}
	
	String qualifiedName = typeBinding.getQualifiedName();
	if (!mapNameToType.containsKey(qualifiedName)) {
		mapNameToType.put(qualifiedName, typeBinding);
	}
	
	// Add supertypes, and implemented interfaces as well!
	ITypeBinding superclassType = typeBinding.getSuperclass();
	if ( superclassType != null ) {
		addNewTypeBinding(superclassType);
	}
	
	ITypeBinding[] interfaces = typeBinding.getInterfaces();
	for(ITypeBinding itfBinding : interfaces)  { 
		addNewTypeBinding(itfBinding);
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:27,代碼來源:WorkspaceUtilities.java

示例8: isDefinedInTypeOrSuperType

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private boolean isDefinedInTypeOrSuperType(final IMethodBinding methodBinding, ITypeBinding declaringClass) {
	while (declaringClass != null) {
		for (final IMethodBinding method : declaringClass.getDeclaredMethods()) {
			if (methodBinding.overrides(method)) {
				return true;
			}
		}
		for (final ITypeBinding type : declaringClass.getInterfaces()) {
			if (isDefinedInTypeOrSuperType(methodBinding, type)) {
				return true;
			}
		}
		declaringClass = declaringClass.getSuperclass();
	}
	return false;
}
 
開發者ID:fabotronix,項目名稱:jsr305CleanUp,代碼行數:17,代碼來源:Jsr305CleanUp.java

示例9: collectSuperTypes

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void collectSuperTypes(ITypeBinding curr, Set<ITypeBinding> collection) {
	if (collection.add(curr)) {
		ITypeBinding[] interfaces= curr.getInterfaces();
		for (int i= 0; i < interfaces.length; i++) {
			collectSuperTypes(interfaces[i], collection);
		}
		ITypeBinding superClass= curr.getSuperclass();
		if (superClass != null) {
			collectSuperTypes(superClass, collection);
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:13,代碼來源:Bindings.java

示例10: isSuperType

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Returns <code>true</code> if the given type is a super type of a candidate.
 * <code>true</code> is returned if the two type bindings are identical (TODO)
 * @param possibleSuperType the type to inspect
 * @param type the type whose super types are looked at
 * @param considerTypeArguments if <code>true</code>, consider type arguments of <code>type</code>
 * @return <code>true</code> iff <code>possibleSuperType</code> is
 * 		a super type of <code>type</code> or is equal to it
 */
public static boolean isSuperType(ITypeBinding possibleSuperType, ITypeBinding type, boolean considerTypeArguments) {
	if (type.isArray() || type.isPrimitive()) {
		return false;
	}
	if (! considerTypeArguments) {
		type= type.getTypeDeclaration();
	}
	if (Bindings.equals(type, possibleSuperType)) {
		return true;
	}
	ITypeBinding superClass= type.getSuperclass();
	if (superClass != null) {
		if (isSuperType(possibleSuperType, superClass, considerTypeArguments)) {
			return true;
		}
	}

	if (possibleSuperType.isInterface()) {
		ITypeBinding[] superInterfaces= type.getInterfaces();
		for (int i= 0; i < superInterfaces.length; i++) {
			if (isSuperType(possibleSuperType, superInterfaces[i], considerTypeArguments)) {
				return true;
			}
		}
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:37,代碼來源:Bindings.java

示例11: getOverridableMethods

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void getOverridableMethods(AST ast, ITypeBinding superBinding, List<IMethodBinding> allMethods) {
	IMethodBinding[] methods= superBinding.getDeclaredMethods();
	for (int offset= 0; offset < methods.length; offset++) {
		final int modifiers= methods[offset].getModifiers();
		if (!methods[offset].isConstructor() && !Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers)) {
			if (findOverridingMethod(methods[offset], allMethods) == null) {
				allMethods.add(methods[offset]);
			}
		}
	}
	ITypeBinding[] superInterfaces= superBinding.getInterfaces();
	for (int index= 0; index < superInterfaces.length; index++) {
		getOverridableMethods(ast, superInterfaces[index], allMethods);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:16,代碼來源:StubUtility2.java

示例12: checkInput

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public void checkInput(RefactoringStatus status, String methodName, ASTNode destination) {
	ITypeBinding[] arguments = getArgumentTypes();
	ITypeBinding type = ASTNodes.getEnclosingType(destination);
	status.merge(Checks.checkMethodInType(type, methodName, arguments));
	ITypeBinding superClass = type.getSuperclass();
	if (superClass != null) {
		status.merge(Checks.checkMethodInHierarchy(superClass, methodName, null, arguments));
	}
	for (ITypeBinding superInterface : type.getInterfaces()) {
		status.merge(Checks.checkMethodInHierarchy(superInterface, methodName, null, arguments));
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:13,代碼來源:ExtractMethodAnalyzer.java

示例13: getOverriddenMethod

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * General, recursive version.
 * @param declaringClass
 * @param methodBinding
 * @return
 */
private static IMethodBinding getOverriddenMethod(ITypeBinding declaringClass, IMethodBinding methodBinding) {
	IMethodBinding overriddenMethod = null;

	ITypeBinding[] paramTypes = methodBinding.getParameterTypes();
	String methodName = methodBinding.getName();

	ITypeBinding returnType = methodBinding.getReturnType();

	// Look at superclass
	ITypeBinding superclass = declaringClass.getSuperclass();
	if (superclass != null) {
		overriddenMethod = getMethodBinding(superclass, methodName, paramTypes, returnType);
		// Recursively look at superclass
		if (overriddenMethod == null ) {
			overriddenMethod = getOverriddenMethod(superclass, methodBinding);
		}
	}
	// Look at interfaces
	if (overriddenMethod == null) {
		for (ITypeBinding itfTypeBinding : declaringClass.getInterfaces()) {
			overriddenMethod = getMethodBinding(itfTypeBinding, methodName, paramTypes, returnType);
			if (  overriddenMethod != null ) {
				break;
			}
		}
	}

	return overriddenMethod;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:36,代碼來源:Utils.java

示例14: getDomainDeclsRecursive

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<String> getDomainDeclsRecursive(ITypeBinding typeBinding, AnnotationDatabase annoDB) {
	Set<String> domDecl = new HashSet<String>();
	domDecl.addAll(getDomainDecls(typeBinding, annoDB));
	if (typeBinding.getSuperclass() != null)
		domDecl.addAll(getDomainDecls(typeBinding.getSuperclass(), annoDB));
	ITypeBinding[] interfaces = typeBinding.getInterfaces();
	for (ITypeBinding iTypeBinding : interfaces) {
		domDecl.addAll(getDomainDecls(iTypeBinding, annoDB));
	}
	List<String> domDeclList = new ArrayList<String>();
	domDeclList.addAll(domDecl);
	return domDeclList;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:14,代碼來源:Utils.java

示例15: reviveTypeFromBinding

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public void reviveTypeFromBinding(Type type, ITypeBinding typeBinding) {
	// First process superclass
	ITypeBinding superTypeBinding = typeBinding.getSuperclass();
	if (superTypeBinding != null) {
		String superTypeBindingName = superTypeBinding.getQualifiedName();
		Type superType = getType(superTypeBindingName);
		if (superType != null) {
			reviveSuperType(type, superTypeBinding, superType);
		}
		else {
			// TODO: Do something. This should not have happened!
			// Probably due to java.lang.Object
			superType = Type.createFrom(superTypeBinding);
			// NOTE: Type.createFrom calls TypeAdapter.addType()
			// typeAdapter.addType(superType);
			
			reviveSuperType(type, superTypeBinding, superType);				
		}

	}

	// Then process super interfaces
	for (ITypeBinding itfTypeBinding : typeBinding.getInterfaces()) {
		String itfName = itfTypeBinding.getQualifiedName();
		Type itfType = getType(itfName);
		if (itfType != null) {
			reviveSuperType(type, itfTypeBinding, itfType);
		}
		else {
			// TODO: Do something. This should not have happened!
			itfType = Type.createFrom(itfTypeBinding);
				// NOTE: Type.createFrom calls TypeAdapter.addType()
			// typeAdapter.addType(itfType);
			
			reviveSuperType(type, itfTypeBinding, itfType);			
		}
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:39,代碼來源:TypeInfo.java


注:本文中的org.eclipse.jdt.core.dom.ITypeBinding.getInterfaces方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。