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


Java ITypeBinding.isRawType方法代碼示例

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


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

示例1: getTypeBoundsForSubsignature

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static Set<ITypeBinding> getTypeBoundsForSubsignature(ITypeBinding typeParameter) {
	ITypeBinding[] typeBounds= typeParameter.getTypeBounds();
	int count= typeBounds.length;
	if (count == 0) {
		return Collections.emptySet();
	}

	Set<ITypeBinding> result= new HashSet<>(typeBounds.length);
	for (int i= 0; i < typeBounds.length; i++) {
		ITypeBinding bound= typeBounds[i];
		if ("java.lang.Object".equals(typeBounds[0].getQualifiedName())) {
			continue;
		} else if (containsTypeVariables(bound)) {
			result.add(bound.getErasure()); // try to achieve effect of "rename type variables"
		} else if (bound.isRawType()) {
			result.add(bound.getTypeDeclaration());
		} else {
			result.add(bound);
		}
	}
	return result;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:23,代碼來源:Bindings.java

示例2: getExplicitCast

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Returns the type to which an inlined variable initializer should be cast, or
 * <code>null</code> if no cast is necessary.
 *
 * @param initializer the initializer expression of the variable to inline
 * @param reference the reference to the variable (which is to be inlined)
 * @return a type binding to which the initializer should be cast, or <code>null</code> iff no cast is necessary
 * @since 3.6
 */
public static ITypeBinding getExplicitCast(Expression initializer, Expression reference) {
	ITypeBinding initializerType= initializer.resolveTypeBinding();
	ITypeBinding referenceType= reference.resolveTypeBinding();
	if (initializerType == null || referenceType == null) {
		return null;
	}

	if (initializerType.isPrimitive() && referenceType.isPrimitive() && ! referenceType.isEqualTo(initializerType)) {
		return referenceType;

	} else if (initializerType.isPrimitive() && ! referenceType.isPrimitive()) { // initializer is autoboxed
		ITypeBinding unboxedReferenceType= Bindings.getUnboxedTypeBinding(referenceType, reference.getAST());
		if (!unboxedReferenceType.isEqualTo(initializerType)) {
			return unboxedReferenceType;
		} else if (needsExplicitBoxing(reference)) {
			return referenceType;
		}

	} else if (! initializerType.isPrimitive() && referenceType.isPrimitive()) { // initializer is autounboxed
		ITypeBinding unboxedInitializerType= Bindings.getUnboxedTypeBinding(initializerType, reference.getAST());
		if (!unboxedInitializerType.isEqualTo(referenceType)) {
			return referenceType;
		}

	} else if (initializerType.isRawType() && referenceType.isParameterizedType()) {
		return referenceType; // don't lose the unchecked conversion

	} else if (initializer instanceof LambdaExpression || initializer instanceof MethodReference) {
		if (isTargetAmbiguous(reference, isExplicitlyTypedLambda(initializer))) {
			return referenceType;
		} else {
			ITypeBinding targetType= getTargetType(reference);
			if (targetType == null || targetType != referenceType) {
				return referenceType;
			}
		}

	} else if (! TypeRules.canAssign(initializerType, referenceType)) {
		if (!Bindings.containsTypeVariables(referenceType)) {
			return referenceType;
		}
	}

	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:55,代碼來源:ASTNodes.java


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