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


Java ITypeBinding.getKey方法代碼示例

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


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

示例1: addNewTypeBinding

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
protected void addNewTypeBinding(ITypeBinding typeBinding) {
	// Skip over primitive types, which includes void
	if (typeBinding == null || typeBinding.isPrimitive()) {
		return;
	}
	String key = typeBinding.getKey();
	if (!mapKeyToType.containsKey(key)) {
		mapKeyToType.put(key, typeBinding);
	}
	
	String qualifiedName = typeBinding.getQualifiedName();
	if (!mapNameToType.containsKey(qualifiedName)) {
		mapNameToType.put(qualifiedName, typeBinding);
	}
	
	// Add supertypes, and implemented interfaces as well!
	ITypeBinding superclassType = typeBinding.getSuperclass();
	if ( superclassType != null ) {
		addNewTypeBinding(superclassType);
	}
	
	ITypeBinding[] interfaces = typeBinding.getInterfaces();
	for(ITypeBinding itfBinding : interfaces)  { 
		addNewTypeBinding(itfBinding);
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:27,代碼來源:WorkspaceUtilities.java

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

示例3: checkMethodInHierarchy

import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
 * Checks if the new method somehow conflicts with an already existing
 * method in the hierarchy. The following checks are done:
 * <ul>
 * <li>if the new method overrides a method defined in the given type or in
 * one of its super classes.</li>
 * </ul>
 *
 * @param type
 * @param methodName
 * @param returnType
 * @param parameters
 * @return the status
 */
public static RefactoringStatus checkMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding returnType, ITypeBinding[] parameters) {
	RefactoringStatus result = new RefactoringStatus();
	IMethodBinding method = Bindings.findMethodInHierarchy(type, methodName, parameters);
	if (method != null) {
		boolean returnTypeClash = false;
		ITypeBinding methodReturnType = method.getReturnType();
		if (returnType != null && methodReturnType != null) {
			String returnTypeKey = returnType.getKey();
			String methodReturnTypeKey = methodReturnType.getKey();
			if (returnTypeKey == null && methodReturnTypeKey == null) {
				returnTypeClash = returnType != methodReturnType;
			} else if (returnTypeKey != null && methodReturnTypeKey != null) {
				returnTypeClash = !returnTypeKey.equals(methodReturnTypeKey);
			}
		}
		ITypeBinding dc = method.getDeclaringClass();
		if (returnTypeClash) {
			result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_returnTypeClash, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName()) }),
					JavaStatusContext.create(method));
		} else {
			if (method.isConstructor()) {
				result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(dc.getName()) }));
			} else {
				result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_overrides, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName()) }),
						JavaStatusContext.create(method));
			}
		}
	}
	return result;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:45,代碼來源:Checks.java


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