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


Java ITypeBinding.isArray方法代碼示例

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


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

示例4: isSuperType

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Returns <code>true</code> if the given type is a super type of a candidate.
 * <code>true</code> is returned if the two type bindings are identical (TODO)
 * @param possibleSuperType the type to inspect
 * @param type the type whose super types are looked at
 * @param considerTypeArguments if <code>true</code>, consider type arguments of <code>type</code>
 * @return <code>true</code> iff <code>possibleSuperType</code> is
 * 		a super type of <code>type</code> or is equal to it
 */
public static boolean isSuperType(ITypeBinding possibleSuperType, ITypeBinding type, boolean considerTypeArguments) {
	if (type.isArray() || type.isPrimitive()) {
		return false;
	}
	if (! considerTypeArguments) {
		type= type.getTypeDeclaration();
	}
	if (Bindings.equals(type, possibleSuperType)) {
		return true;
	}
	ITypeBinding superClass= type.getSuperclass();
	if (superClass != null) {
		if (isSuperType(possibleSuperType, superClass, considerTypeArguments)) {
			return true;
		}
	}

	if (possibleSuperType.isInterface()) {
		ITypeBinding[] superInterfaces= type.getInterfaces();
		for (int i= 0; i < superInterfaces.length; i++) {
			if (isSuperType(possibleSuperType, superInterfaces[i], considerTypeArguments)) {
				return true;
			}
		}
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:37,代碼來源:Bindings.java

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

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

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

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

示例9: visit

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
@Override
		public boolean visit(VariableDeclarationStatement param) {
			
			ITypeBinding type = param.getType().resolveBinding();
			if (hasAnnotation(param.modifiers()) && !type.isPrimitive()) {
				List<VariableDeclarationFragment> L = param.fragments();
				for (VariableDeclarationFragment oo : L) {

					SingleMemberAnnotation annotation = getAnnotation(param.modifiers());
					Expression value = annotation.getValue();
					if (value instanceof StringLiteral) { //@Domain("D")
						StringLiteral annotValue = (StringLiteral)value;
						String parserInput = annotValue.getLiteralValue();
						AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
						DomainParams annot = annotInfo.getAnnotation();	
						boolean b = annot.isObjectPublicDomain();
						if (b)
						{
							b = true;
						}


						boolean isDom = false;
						boolean isDomPars = false;
						String qualifiedName = "";
				
//						if (oo.resolveBinding().getDeclaringMethod() != null) {
//							qualifiedName = oo.resolveBinding().getDeclaringMethod().getDeclaringClass().getQualifiedName();
//
//							isDom = isDomain(oo.resolveBinding().getDeclaringMethod().getDeclaringClass(), annot);
//							isDomPars = isDomainParams(oo.resolveBinding().getDeclaringMethod().getDeclaringClass(),annot);
//
//
//						}
//						else 
						{

							qualifiedName = currentType.resolveBinding().getQualifiedName();

							isDom = isDomain(currentType.resolveBinding(), annot);
							isDomPars = isDomainParams(currentType.resolveBinding() , annot);		

						}
						
						ObjectMetricItem archMetricItem = new ObjectMetricItem(oo.resolveBinding().getKey(),oo.resolveBinding().getName().toString(),
								param.getType().resolveBinding().getQualifiedName().toString(),
								parserInput,
								qualifiedName,
								oo.toString(),
								Modifier.isStatic(param.getModifiers()),
								"LocalVariable",
								type.isArray(),
								type.isEnum(),
								type.isParameterizedType(),
								isDom,
								isDomPars,
								annot.isObjectPublicDomain()
							);
						
						
							
						if (!objectsHashtable.containsKey(archMetricItem.toString())) {
							objectsHashtable.put(archMetricItem.toString(), archMetricItem);
						}
						
						// TODO: src.triplets for Local variables
					}
				}
			}
				return super.visit(param);
		}
 
開發者ID:aroog,項目名稱:code,代碼行數:72,代碼來源:AnnotatMetrics.java

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

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

示例12: traverseFields

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private void traverseFields(TypeDeclaration declaration) {
	FieldDeclaration[] fieldDeclarations = declaration.getFields();
	for (int i = 0; i < fieldDeclarations.length; i++) {
		FieldDeclaration fieldDeclaration = fieldDeclarations[i];
		ITypeBinding type = fieldDeclaration.getType().resolveBinding();

		if (hasAnnotation(fieldDeclaration.modifiers()) && !type.isPrimitive()) {

			List ff = fieldDeclaration.fragments();
			for (Object ff1 : ff) {
				VariableDeclaration V = (VariableDeclaration) ff1;
				String key = V.resolveBinding().getKey();
				String name = V.getName().getIdentifier();
				String objectType = fieldDeclaration.getType().resolveBinding().getQualifiedName();
				
				String enclosingType = declaration.resolveBinding().getQualifiedName();
			
				String ast = fieldDeclaration.getAST().toString();
				boolean isStatic = Modifier.isStatic(fieldDeclaration.getModifiers());
				//					
				SingleMemberAnnotation annotation = getAnnotation(fieldDeclaration.modifiers());
				Expression value = annotation.getValue();
				if (value instanceof StringLiteral) { //@Domain("D")
					StringLiteral annotValue = (StringLiteral)value;
					String parserInput = annotValue.getLiteralValue();
					AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
					DomainParams annot = annotInfo.getAnnotation();	
				
					boolean isDomainParam = isDomainParams(declaration.resolveBinding(), annot);
					boolean isDomain = isDomain(declaration.resolveBinding(), annot);
					ObjectMetricItem archMetricItem = new ObjectMetricItem(key,name,
							objectType,
							parserInput,
							enclosingType,
							ast,
							isStatic,
							"Field",
							type.isArray(),
							type.isEnum(),
							type.isParameterizedType(),
							isDomain,
							isDomainParam,
							annot.isObjectPublicDomain()
					);
					// TODO: Do we need the following two lines?
					archMetricItem.setDomainParams(isDomainParam);
					archMetricItem.setDomain(isDomain);
					if (!objectsHashtable.containsKey(archMetricItem.toString())) {							
						objectsHashtable.put(archMetricItem.toString(), archMetricItem);
					}
					
					// TODO: src.triplets for Field
				}

				else
				{
					//this should not happen
					System.out.println("Error in field declaration: "+ value);
				}
			}
		}
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:64,代碼來源:AnnotatMetrics.java

示例13: isRuntimeException

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Checks whether the passed type binding is a runtime exception.
 *
 * @param thrownException the type binding
 *
 * @return <code>true</code> if the passed type binding is a runtime exception;
 * 	otherwise <code>false</code> is returned
 */
public static boolean isRuntimeException(ITypeBinding thrownException) {
	if (thrownException == null || thrownException.isPrimitive() || thrownException.isArray()) {
		return false;
	}
	return findTypeInHierarchy(thrownException, "java.lang.RuntimeException") != null; //$NON-NLS-1$
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:15,代碼來源:Bindings.java


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