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


Java ITypeBinding.isTypeVariable方法代碼示例

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


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

示例1: containsTypeVariables

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static boolean containsTypeVariables(ITypeBinding type) {
	if (type.isTypeVariable()) {
		return true;
	}
	if (type.isArray()) {
		return containsTypeVariables(type.getElementType());
	}
	if (type.isCapture()) {
		return containsTypeVariables(type.getWildcard());
	}
	if (type.isParameterizedType()) {
		return containsTypeVariables(type.getTypeArguments());
	}
	if (type.isWildcardType() && type.getBound() != null) {
		return containsTypeVariables(type.getBound());
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:19,代碼來源:Bindings.java

示例2: endVisit

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
@Override
public void endVisit(SimpleName node) {
	if (skipNode(node) || node.isDeclaration()) {
		return;
	}
	IBinding binding = node.resolveBinding();
	if (binding instanceof IVariableBinding) {
		IVariableBinding variable = (IVariableBinding) binding;
		if (!variable.isField()) {
			setFlowInfo(node, new LocalFlowInfo(variable, FlowInfo.READ, fFlowContext));
		}
	} else if (binding instanceof ITypeBinding) {
		ITypeBinding type = (ITypeBinding) binding;
		if (type.isTypeVariable()) {
			setFlowInfo(node, new TypeVariableFlowInfo(type, fFlowContext));
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:19,代碼來源:FlowAnalyzer.java

示例3: removeUnwantedTypeAnnotations

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public IAnnotationBinding[] removeUnwantedTypeAnnotations(IAnnotationBinding[] annotations, TypeLocation location, ITypeBinding type) {
	if (location == TypeLocation.OTHER) {
		return NO_ANNOTATIONS;
	}
	if(type.isTypeVariable() || type.isWildcardType()) {
		return annotations;
	}
	boolean excludeAllNullAnnotations = NEVER_NULLNESS_LOCATIONS.contains(location);
	if (excludeAllNullAnnotations || fNonNullByDefaultLocations.contains(location)) {
		ArrayList<IAnnotationBinding> list= new ArrayList<>(annotations.length);
		for (IAnnotationBinding annotation : annotations) {
			ITypeBinding annotationType= annotation.getAnnotationType();
			if (annotationType != null) {
				if (annotationType.getQualifiedName().equals(fNonNullAnnotationName)) {
					// ignore @NonNull
				} else if (excludeAllNullAnnotations && annotationType.getQualifiedName().equals(fNullableAnnotationName)) {
					// also ignore @Nullable
				} else {
					list.add(annotation);
				}
			} else {
				list.add(annotation);
			}
		}
		return list.size() == annotations.length ? annotations : list.toArray(new IAnnotationBinding[list.size()]);
	} else {
		return annotations;
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:30,代碼來源:RedundantNullnessTypeAnnotationsFilter.java

示例4: sameParameter

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean sameParameter(ITypeBinding type, String candidate, IType scope) throws JavaModelException {
	if (type.getDimensions() != Signature.getArrayCount(candidate)) {
		return false;
	}

	// Normalizes types
	if (type.isArray()) {
		type= type.getElementType();
	}
	candidate= Signature.getElementType(candidate);

	if ((Signature.getTypeSignatureKind(candidate) == Signature.BASE_TYPE_SIGNATURE) != type.isPrimitive()) {
		return false;
	}

	if (type.isPrimitive() || type.isTypeVariable()) {
		return type.getName().equals(Signature.toString(candidate));
	} else {
		// normalize (quick hack until binding.getJavaElement works)
		candidate= Signature.getTypeErasure(candidate);
		type= type.getErasure();

		if (candidate.charAt(Signature.getArrayCount(candidate)) == Signature.C_RESOLVED) {
			return Signature.toString(candidate).equals(Bindings.getFullyQualifiedName(type));
		} else {
			String[][] qualifiedCandidates= scope.resolveType(Signature.toString(candidate));
			if (qualifiedCandidates == null || qualifiedCandidates.length == 0) {
				return false;
			}
			String packageName= type.getPackage().isUnnamed() ? "" : type.getPackage().getName(); //$NON-NLS-1$
			String typeName= getTypeQualifiedName(type);
			for (int i= 0; i < qualifiedCandidates.length; i++) {
				String[] qualifiedCandidate= qualifiedCandidates[i];
				if (	qualifiedCandidate[0].equals(packageName) &&
						qualifiedCandidate[1].equals(typeName)) {
					return true;
				}
			}
		}
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:43,代碼來源:Bindings.java

示例5: translateFtoA

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Translate a typeBinding with a formal type parameter into one with fully substituted type
 * based on the enclosing type
 * @param typeBinding: e.g., virtual field of type <E extends java.lang.Object>
 * @param actualBinding: the enclosing type, e.g., class ArrayList<courses.Course> 
 * 						where the generic type declaration is class ArrayList<E> {...}
 * @return typeBinding with the type substitution performed, e.g., courses.Course
 */
public static ITypeBinding translateFtoA(ITypeBinding typeBinding, ITypeBinding actualBinding) {
	ITypeBinding toTypeBindingActual = typeBinding;

	// HACK: Introduced bugs!		
	// Check that it is a generic type, to avoid generating a type that does not exist!
	// if(!typeBinding.isGenericType()) {
	// 	return typeBinding;
	// }
	
	// HACK: Introduced bugs!
	 if (typeBinding.isEqualTo(actualBinding)) {
		return typeBinding;
	 }
	
	// Instantiate generic types...
	if (actualBinding.isParameterizedType()) {
		ITypeBinding[] typeParameters = actualBinding.getErasure().getTypeParameters();
		int pIndex = -1;
		int index = 0;
		for(ITypeBinding typeParameter : typeParameters ) {
			if ( typeParameter.isEqualTo(typeBinding) ) {
				pIndex = index;
				break;
			}
			index++;
		}
		ITypeBinding[] typeArguments = actualBinding.getTypeArguments();
		if ( typeBinding.isTypeVariable() && typeArguments != null && pIndex != -1  && pIndex < typeArguments.length) {
			toTypeBindingActual = typeArguments[pIndex];
		}
		else {
			String[] typeArgumentString = getParameters(typeArguments);
			String bindingKey = BindingKey.createParameterizedTypeBindingKey(typeBinding.getKey(), typeArgumentString);
			toTypeBindingActual = GenHelper.mapBindingKeyToTypeBinding(bindingKey);
		}
	}
	


	return toTypeBindingActual;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:50,代碼來源:GenHelper.java


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