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


Java ITypeBinding.getTypeBounds方法代碼示例

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


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

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) {
	ITypeBinding[] typeParams= binding.getTypeParameters();
	List<TypeParameter> typeParameters= decl.typeParameters();
	for (int i= 0; i < typeParams.length; i++) {
		ITypeBinding curr= typeParams[i];
		TypeParameter newTypeParam= ast.newTypeParameter();
		newTypeParam.setName(ast.newSimpleName(curr.getName()));
		ITypeBinding[] typeBounds= curr.getTypeBounds();
		if (typeBounds.length != 1 || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) {//$NON-NLS-1$
			List<Type> newTypeBounds= newTypeParam.typeBounds();
			for (int k= 0; k < typeBounds.length; k++) {
				newTypeBounds.add(imports.addImport(typeBounds[k], ast, context, TypeLocation.TYPE_BOUND));
			}
		}
		typeParameters.add(newTypeParam);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:18,代碼來源:StubUtility2.java

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

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


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