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


Java ITypeBinding.getErasure方法代碼示例

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


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

示例1: appendRawTypes

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private void appendRawTypes(List<ITypeBinding> rawTypes, Set<String> dejavu, ITypeBinding typeBinding, boolean includeTypeParameters) {
String key = typeBinding.getKey();
if (dejavu.contains(key)) {
	return;
}
dejavu.add(key);
ITypeBinding erasure = typeBinding.getErasure();
rawTypes.add(erasure);

if (!includeTypeParameters) {
	return;
}

ITypeBinding elementType = typeBinding.getElementType();
if (elementType != null) {
	this.appendRawTypes(rawTypes, dejavu, elementType, includeTypeParameters);
}

ITypeBinding[] typeArguments = typeBinding.getTypeArguments();
if (typeArguments != null) {
	for (ITypeBinding typeArgument : typeArguments) {
		this.appendRawTypes(rawTypes, dejavu, typeArgument, includeTypeParameters);
	}
}

ITypeBinding[] typeBounds = typeBinding.getTypeBounds();
if (typeBounds != null) {
	for (ITypeBinding typeBound : typeBounds) {
		this.appendRawTypes(rawTypes, dejavu, typeBound, includeTypeParameters);
	}
}
  }
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:33,代碼來源:DependenciesAstVisitor.java

示例2: normalizeForDeclarationUse

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Normalizes the binding so that it can be used as a type inside a declaration (e.g. variable
 * declaration, method return type, parameter type, ...).
 * For null bindings, java.lang.Object is returned.
 * For void bindings, <code>null</code> is returned.
 *
 * @param binding binding to normalize
 * @param ast current AST
 * @return the normalized type to be used in declarations, or <code>null</code>
 */
public static ITypeBinding normalizeForDeclarationUse(ITypeBinding binding, AST ast) {
	if (binding.isNullType())
	{
		return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
	}
	if (binding.isPrimitive()) {
		return binding;
	}
	binding= normalizeTypeBinding(binding);
	if (binding == null) {
		return binding;
	}
	if (binding.isArray()) {
		return normalizeForDeclarationUse(binding.getComponentType(), ast).createArrayType(1);
	}
	if (!binding.isWildcardType()) {
		return binding;
	}
	ITypeBinding bound= binding.getBound();
	if (bound == null || !binding.isUpperbound()) {
		ITypeBinding[] typeBounds= binding.getTypeBounds();
		if (typeBounds.length > 0) {
			return typeBounds[0];
		} else {
			return binding.getErasure();
		}
	} else {
		return bound;
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:41,代碼來源:Bindings.java

示例3: replaceWildcardsAndCaptures

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static ITypeBinding replaceWildcardsAndCaptures(ITypeBinding type) {
	while (type.isWildcardType() || type.isCapture() || (type.isArray() && type.getElementType().isCapture())) {
		ITypeBinding bound = type.getBound();
		type = (bound != null) ? bound : type.getErasure();
	}
	return type;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:8,代碼來源:StubUtility2.java

示例4: getParameterTypeNamesForSeeTag

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static String[] getParameterTypeNamesForSeeTag(IMethodBinding binding) {
	ITypeBinding[] typeBindings= binding.getParameterTypes();
	String[] result= new String[typeBindings.length];
	for (int i= 0; i < result.length; i++) {
		ITypeBinding curr= typeBindings[i];
		curr= curr.getErasure(); // Javadoc references use erased type
		result[i]= curr.getQualifiedName();
	}
	return result;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:11,代碼來源:StubUtility.java

示例5: 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

示例6: addIncompatibleReturnTypeProposals

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static void addIncompatibleReturnTypeProposals(IInvocationContext context, IProblemLocation problem,
		Collection<CUCorrectionProposal> proposals) throws JavaModelException {
	CompilationUnit astRoot= context.getASTRoot();
	ASTNode selectedNode= problem.getCoveringNode(astRoot);
	if (selectedNode == null) {
		return;
	}
	MethodDeclaration decl= ASTResolving.findParentMethodDeclaration(selectedNode);
	if (decl == null) {
		return;
	}
	IMethodBinding methodDeclBinding= decl.resolveBinding();
	if (methodDeclBinding == null) {
		return;
	}

	ITypeBinding returnType= methodDeclBinding.getReturnType();
	IMethodBinding overridden= Bindings.findOverriddenMethod(methodDeclBinding, false);
	if (overridden == null || overridden.getReturnType() == returnType) {
		return;
	}


	ICompilationUnit cu= context.getCompilationUnit();
	IMethodBinding methodDecl= methodDeclBinding.getMethodDeclaration();
	ITypeBinding overriddenReturnType= overridden.getReturnType();
	if (! JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
		overriddenReturnType= overriddenReturnType.getErasure();
	}
	proposals.add(new TypeChangeCorrectionProposal(cu, methodDecl, astRoot, overriddenReturnType, false, IProposalRelevance.CHANGE_RETURN_TYPE));

	ICompilationUnit targetCu= cu;

	IMethodBinding overriddenDecl= overridden.getMethodDeclaration();
	ITypeBinding overridenDeclType= overriddenDecl.getDeclaringClass();

	if (overridenDeclType.isFromSource()) {
		targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, overridenDeclType);
		if (targetCu != null && ASTResolving.isUseableTypeInContext(returnType, overriddenDecl, false)) {
			TypeChangeCorrectionProposal proposal= new TypeChangeCorrectionProposal(targetCu, overriddenDecl, astRoot, returnType, false, IProposalRelevance.CHANGE_RETURN_TYPE_OF_OVERRIDDEN);
			if (overridenDeclType.isInterface()) {
				proposal.setDisplayName(Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturnofimplemented_description, BasicElementLabels.getJavaElementName(overriddenDecl.getName())));
			} else {
				proposal.setDisplayName(Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturnofoverridden_description, BasicElementLabels.getJavaElementName(overriddenDecl.getName())));
			}
			proposals.add(proposal);
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:50,代碼來源:TypeMismatchSubProcessor.java


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