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


Java ITypeBinding.isSubTypeCompatible方法代碼示例

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


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

示例1: filterSubtypeExceptions

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<ITypeBinding> filterSubtypeExceptions(ITypeBinding[] exceptions) {
	List<ITypeBinding> filteredExceptions = new ArrayList<>();
	filteredExceptions.addAll(Arrays.asList(exceptions));

	for (Iterator<ITypeBinding> subtypeIterator = filteredExceptions.iterator(); subtypeIterator.hasNext();) {
		ITypeBinding iTypeBinding = subtypeIterator.next();
		for (Iterator<ITypeBinding> supertypeIterator = filteredExceptions.iterator(); supertypeIterator.hasNext();) {
			ITypeBinding superTypeBinding = supertypeIterator.next();
			if (!iTypeBinding.equals(superTypeBinding) && iTypeBinding.isSubTypeCompatible(superTypeBinding)) {
				subtypeIterator.remove();
				break;
			}
		}
	}
	return filteredExceptions;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:17,代碼來源:SurroundWithTryCatchRefactoring.java

示例2: isSubtypeCompatible

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Return B <: C ?
 * 
 * @param typeB
 * @param typeC
 * @return
 */
public static boolean isSubtypeCompatible(Type typeB, Type typeC) {
	// return typeC.isSubtypeCompatible(typeB);
	String typeBName = typeB.getFullyQualifiedName();
	Crystal crystal = Crystal.getInstance();
	ITypeBinding typeBindingB = crystal.getTypeBindingFromName(typeBName);

	String typeCName = typeC.getFullyQualifiedName();
	ITypeBinding typeBindingC = crystal.getTypeBindingFromName(typeCName);

	if (typeBindingB != null && typeBindingC != null) {
		return typeBindingB.isSubTypeCompatible(typeBindingC);
	}

	return false;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:23,代碼來源:Util.java

示例3: isSubtypeCompatible

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Return B <: C ?
 * @param typeB
 * @param typeC
 * @return
 */
public static boolean isSubtypeCompatible(Type typeB, Type typeC) {
    // return typeC.isSubtypeCompatible(typeB);
	String typeBName = typeB.getFullyQualifiedName();
	Crystal crystal = Crystal.getInstance();
	ITypeBinding typeBindingB = crystal.getTypeBindingFromName(typeBName);

	String typeCName = typeB.getFullyQualifiedName();
	ITypeBinding typeBindingC = crystal.getTypeBindingFromName(typeCName);
	
	if (typeBindingB != null && typeBindingC != null ) { 
		return typeBindingB.isSubTypeCompatible(typeBindingC);
	}
	
	return false;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:22,代碼來源:Utils.java

示例4: areSubTypeCompatible

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean areSubTypeCompatible(IMethodBinding overridden, IMethodBinding overridable) {

		if (overridden.getParameterTypes().length != overridable.getParameterTypes().length) {
			return false;
		}

		ITypeBinding overriddenReturn= overridden.getReturnType();
		ITypeBinding overridableReturn= overridable.getReturnType();
		if (overriddenReturn == null || overridableReturn == null) {
			return false;
		}

		if (!overriddenReturn.getErasure().isSubTypeCompatible(overridableReturn.getErasure())) {
			return false;
		}

		ITypeBinding[] overriddenTypes= overridden.getParameterTypes();
		ITypeBinding[] overridableTypes= overridable.getParameterTypes();
		Assert.isTrue(overriddenTypes.length == overridableTypes.length);
		for (int index= 0; index < overriddenTypes.length; index++) {
			final ITypeBinding overridableErasure= overridableTypes[index].getErasure();
			final ITypeBinding overriddenErasure= overriddenTypes[index].getErasure();
			if (!overridableErasure.isSubTypeCompatible(overriddenErasure) || !overridableErasure.getKey().equals(overriddenErasure.getKey())) {
				return false;
			}
		}
		ITypeBinding[] overriddenExceptions= overridden.getExceptionTypes();
		ITypeBinding[] overridableExceptions= overridable.getExceptionTypes();
		boolean checked= false;
		for (int index= 0; index < overriddenExceptions.length; index++) {
			checked= false;
			for (int offset= 0; offset < overridableExceptions.length; offset++) {
				if (overriddenExceptions[index].isSubTypeCompatible(overridableExceptions[offset])) {
					checked= true;
				}
			}
			if (!checked) {
				return false;
			}
		}
		return true;
	}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:43,代碼來源:Bindings.java


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