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


Java ITypeBinding.getElementType方法代碼示例

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


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

示例1: createName

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
static void createName(ITypeBinding type, boolean includePackage,
		List<String> list) {
	ITypeBinding baseType = type;
	if (type.isArray()) {
		baseType = type.getElementType();
	}
	if (!baseType.isPrimitive() && !baseType.isNullType()) {
		ITypeBinding declaringType = baseType.getDeclaringClass();
		if (declaringType != null) {
			createName(declaringType, includePackage, list);
		} else if (includePackage && !baseType.getPackage().isUnnamed()) {
			String[] components = baseType.getPackage().getNameComponents();
			for (int i = 0; i < components.length; i++) {
				list.add(components[i]);
			}
		}
	}
	if (!baseType.isAnonymous()) {
		list.add(type.getName());
	} else {
		list.add("$local$"); //$NON-NLS-1$
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:24,代碼來源:TypeProposalUtils.java

示例2: createName

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void createName(ITypeBinding type, boolean includePackage, List<String> list) {
	ITypeBinding baseType= type;
	if (type.isArray()) {
		baseType= type.getElementType();
	}
	if (!baseType.isPrimitive() && !baseType.isNullType()) {
		ITypeBinding declaringType= baseType.getDeclaringClass();
		if (declaringType != null) {
			createName(declaringType, includePackage, list);
		} else if (includePackage && !baseType.getPackage().isUnnamed()) {
			String[] components= baseType.getPackage().getNameComponents();
			for (int i= 0; i < components.length; i++) {
				list.add(components[i]);
			}
		}
	}
	if (!baseType.isAnonymous()) {
		list.add(type.getName());
	} else {
		list.add("$local$"); //$NON-NLS-1$
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:23,代碼來源:Bindings.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: getTargetTypeForArrayInitializer

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static ITypeBinding getTargetTypeForArrayInitializer(ArrayInitializer arrayInitializer) {
	ASTNode initializerParent= arrayInitializer.getParent();
	while (initializerParent instanceof ArrayInitializer) {
		initializerParent= initializerParent.getParent();
	}
	if (initializerParent instanceof ArrayCreation) {
		return ((ArrayCreation) initializerParent).getType().getElementType().resolveBinding();
	} else if (initializerParent instanceof VariableDeclaration) {
		ITypeBinding typeBinding= ((VariableDeclaration) initializerParent).getName().resolveTypeBinding();
		if (typeBinding != null) {
			return typeBinding.getElementType();
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:16,代碼來源:ASTNodes.java

示例5: add

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Tries to find the given type name and add it to the import structure.
 * @param ref the name node
 */
public void add(SimpleName ref) {
	String typeName= ref.getIdentifier();

	if (fImportsAdded.contains(typeName)) {
		return;
	}

	IBinding binding= ref.resolveBinding();
	if (binding != null) {
		if (binding.getKind() != IBinding.TYPE) {
			return;
		}
		ITypeBinding typeBinding= (ITypeBinding) binding;
		if (typeBinding.isArray()) {
			typeBinding= typeBinding.getElementType();
		}
		typeBinding= typeBinding.getTypeDeclaration();
		if (!typeBinding.isRecovered()) {
			if (needsImport(typeBinding, ref)) {
				fImpStructure.addImport(typeBinding);
				fImportsAdded.add(typeName);
			}
			return;
		}
	} else {
		if (fDoIgnoreLowerCaseNames && typeName.length() > 0) {
			char ch= typeName.charAt(0);
			if (Strings.isLowerCase(ch) && Character.isLetter(ch)) {
				return;
			}
		}
	}

	fImportsAdded.add(typeName);
	fUnresolvedTypes.put(typeName, new UnresolvedTypeData(ref));
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:41,代碼來源:OrganizeImportsOperation.java

示例6: getVariableNameSuggestions

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, ITypeBinding expectedType, Expression assignedExpression, Collection<String> excluded) {
	LinkedHashSet<String> res= new LinkedHashSet<>(); // avoid duplicates but keep order

	if (assignedExpression != null) {
		String nameFromExpression= getBaseNameFromExpression(project, assignedExpression, variableKind);
		if (nameFromExpression != null) {
			add(getVariableNameSuggestions(variableKind, project, nameFromExpression, 0, excluded, false), res); // pass 0 as dimension, base name already contains plural.
		}

		String nameFromParent= getBaseNameFromLocationInParent(assignedExpression);
		if (nameFromParent != null) {
			add(getVariableNameSuggestions(variableKind, project, nameFromParent, 0, excluded, false), res); // pass 0 as dimension, base name already contains plural.
		}
	}
	if (expectedType != null) {
		expectedType= Bindings.normalizeTypeBinding(expectedType);
		if (expectedType != null) {
			int dim= 0;
			if (expectedType.isArray()) {
				dim= expectedType.getDimensions();
				expectedType= expectedType.getElementType();
			}
			if (expectedType.isParameterizedType()) {
				expectedType= expectedType.getTypeDeclaration();
			}
			String typeName= expectedType.getName();
			if (typeName.length() > 0) {
				add(getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, false), res);
			}
		}
	}
	if (res.isEmpty()) {
		return getDefaultVariableNameSuggestions(variableKind, excluded);
	}
	return res.toArray(new String[res.size()]);
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:37,代碼來源:StubUtility.java

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

示例8: addSimilarTypeProposals

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void addSimilarTypeProposals(int kind, ICompilationUnit cu, Name node, int relevance,
		Collection<CUCorrectionProposal> proposals) throws CoreException {
	SimilarElement[] elements= SimilarElementsRequestor.findSimilarElement(cu, node, kind);

	// try to resolve type in context -> highest severity
	String resolvedTypeName= null;
	ITypeBinding binding= ASTResolving.guessBindingForTypeReference(node);
	if (binding != null) {
		ITypeBinding simpleBinding= binding;
		if (simpleBinding.isArray()) {
			simpleBinding= simpleBinding.getElementType();
		}
		simpleBinding= simpleBinding.getTypeDeclaration();

		if (!simpleBinding.isRecovered()) {
			resolvedTypeName= simpleBinding.getQualifiedName();
			CUCorrectionProposal proposal= createTypeRefChangeProposal(cu, resolvedTypeName, node, relevance + 2, elements.length);
			proposals.add(proposal);
			if (proposal instanceof AddImportCorrectionProposal) {
				proposal.setRelevance(relevance + elements.length + 2);
			}

			if (binding.isParameterizedType()
					&& (node.getParent() instanceof SimpleType || node.getParent() instanceof NameQualifiedType)
					&& !(node.getParent().getParent() instanceof Type)) {
				proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
			}
		}
	} else {
		ASTNode normalizedNode= ASTNodes.getNormalizedNode(node);
		if (!(normalizedNode.getParent() instanceof Type) && node.getParent() != normalizedNode) {
			ITypeBinding normBinding= ASTResolving.guessBindingForTypeReference(normalizedNode);
			if (normBinding != null && !normBinding.isRecovered()) {
				proposals.add(createTypeRefChangeFullProposal(cu, normBinding, normalizedNode, relevance + 5));
			}
		}
	}

	// add all similar elements
	for (int i= 0; i < elements.length; i++) {
		SimilarElement elem= elements[i];
		if ((elem.getKind() & SimilarElementsRequestor.ALL_TYPES) != 0) {
			String fullName= elem.getName();
			if (!fullName.equals(resolvedTypeName)) {
				proposals.add(createTypeRefChangeProposal(cu, fullName, node, relevance, elements.length));
			}
		}
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:50,代碼來源:UnresolvedElementsSubProcessor.java


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