本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getSuperclass方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getSuperclass方法的具體用法?Java ITypeBinding.getSuperclass怎麽用?Java ITypeBinding.getSuperclass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getSuperclass方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isContext
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean isContext(ITypeBinding tbinding) {
String executionContextClass = org.graphwalker.core.machine.ExecutionContext.class.getName();
String contextClass = org.graphwalker.core.machine.Context.class.getName();
while (tbinding != null) {
String clazz = tbinding.getQualifiedName();
if (executionContextClass.equals(clazz))
return true;
if (contextClass.equals(clazz))
return true;
ITypeBinding[] interfaces = tbinding.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
ITypeBinding interf = interfaces[i];
if (contextClass.equals(interf.getQualifiedName()))
return true;
}
tbinding = tbinding.getSuperclass();
}
return false;
}
示例2: findFieldInHierarchy
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Finds the field specified by <code>fieldName</code> in
* the type hierarchy denoted by the given type. Returns <code>null</code> if no such field
* exists. If the field is defined in more than one super type only the first match is
* returned. First the super class is examined and then the implemented interfaces.
* @param type The type to search the field in
* @param fieldName The name of the field to find
* @return the variable binding representing the field
*/
public static IVariableBinding findFieldInHierarchy(ITypeBinding type, String fieldName) {
IVariableBinding field= findFieldInType(type, fieldName);
if (field != null) {
return field;
}
ITypeBinding superClass= type.getSuperclass();
if (superClass != null) {
field= findFieldInHierarchy(superClass, fieldName);
if (field != null) {
return field;
}
}
ITypeBinding[] interfaces= type.getInterfaces();
for (int i= 0; i < interfaces.length; i++) {
field= findFieldInHierarchy(interfaces[i], fieldName);
if (field != null) {
return field;
}
}
return null;
}
示例3: findMethodInHierarchy
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Finds the method specified by <code>methodName</code> and <code>parameters</code> in
* the type hierarchy denoted by the given type. Returns <code>null</code> if no such method
* exists. If the method is defined in more than one super type only the first match is
* returned. First the super class is examined and then the implemented interfaces.
*
* @param type The type to search the method in
* @param methodName The name of the method to find
* @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored.
* @return the method binding representing the method
*/
public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding[] parameters) {
IMethodBinding method= findMethodInType(type, methodName, parameters);
if (method != null) {
return method;
}
ITypeBinding superClass= type.getSuperclass();
if (superClass != null) {
method= findMethodInHierarchy(superClass, methodName, parameters);
if (method != null) {
return method;
}
}
ITypeBinding[] interfaces= type.getInterfaces();
for (int i= 0; i < interfaces.length; i++) {
method= findMethodInHierarchy(interfaces[i], methodName, parameters);
if (method != null) {
return method;
}
}
return null;
}
示例4: findOverriddenMethodInHierarchy
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Finds a method in the hierarchy of <code>type</code> that is overridden by <code>binding</code>.
* Returns <code>null</code> if no such method exists. If the method is defined in more than one super type only the first match is
* returned. First the super class is examined and then the implemented interfaces.
* @param type The type to search the method in
* @param binding The method that overrides
* @return the method binding overridden the method
*/
public static IMethodBinding findOverriddenMethodInHierarchy(ITypeBinding type, IMethodBinding binding) {
IMethodBinding method= findOverriddenMethodInType(type, binding);
if (method != null) {
return method;
}
ITypeBinding superClass= type.getSuperclass();
if (superClass != null) {
method= findOverriddenMethodInHierarchy(superClass, binding);
if (method != null) {
return method;
}
}
ITypeBinding[] interfaces= type.getInterfaces();
for (int i= 0; i < interfaces.length; i++) {
method= findOverriddenMethodInHierarchy(interfaces[i], binding);
if (method != null) {
return method;
}
}
return null;
}
示例5: isExceptionCaught
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
boolean isExceptionCaught(ITypeBinding excpetionType) {
for (Iterator<List<CatchClause>> exceptions= fExceptionStack.iterator(); exceptions.hasNext(); ) {
for (Iterator<CatchClause> catchClauses= exceptions.next().iterator(); catchClauses.hasNext(); ) {
SingleVariableDeclaration caughtException= catchClauses.next().getException();
IVariableBinding binding= caughtException.resolveBinding();
if (binding == null) {
continue;
}
ITypeBinding caughtype= binding.getType();
while (caughtype != null) {
if (caughtype == excpetionType) {
return true;
}
caughtype= caughtype.getSuperclass();
}
}
}
return false;
}
示例6: 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);
}
}
示例7: extractSupertypesForPostProcessing
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private void extractSupertypesForPostProcessing(RastNode type, ITypeBinding superTypeBinding) {
List<String> supertypes = postProcessSupertypes.get(type);
if (supertypes == null) {
supertypes = new ArrayList<String>();
postProcessSupertypes.put(type, supertypes);
}
while (superTypeBinding != null && superTypeBinding.isFromSource()) {
String superTypeName = superTypeBinding.getErasure().getQualifiedName();
supertypes.add(superTypeName);
superTypeBinding = superTypeBinding.getSuperclass();
}
}
示例8: extractSupertypesForPostProcessing
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private void extractSupertypesForPostProcessing(SDType type, ITypeBinding superTypeBinding) {
List<String> supertypes = postProcessSupertypes.get(type);
if (supertypes == null) {
supertypes = new ArrayList<String>();
postProcessSupertypes.put(type, supertypes);
}
while (superTypeBinding != null && superTypeBinding.isFromSource()) {
String superTypeName = superTypeBinding.getErasure().getQualifiedName();
supertypes.add(superTypeName);
superTypeBinding = superTypeBinding.getSuperclass();
}
}
示例9: collectSuperTypes
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static void collectSuperTypes(ITypeBinding curr, Set<ITypeBinding> collection) {
if (collection.add(curr)) {
ITypeBinding[] interfaces= curr.getInterfaces();
for (int i= 0; i < interfaces.length; i++) {
collectSuperTypes(interfaces[i], collection);
}
ITypeBinding superClass= curr.getSuperclass();
if (superClass != null) {
collectSuperTypes(superClass, collection);
}
}
}
示例10: createFrom
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
Type createFrom(ITypeBinding typeBinding) {
Type type = addType(typeBinding);
// TODO: Comment out this Subclass/Superclass stuff for now, since no longer being persisted.
// TypeInfo typeInfo = TypeInfo.getInstance();
// First process superclass
ITypeBinding superclass = typeBinding.getSuperclass();
if (superclass != null) {
Type superType = getType(superclass);
if (superType == null) {
superType = addType(superclass);
}
// TODO: MED. Do not call deprecated method
// typeInfo.addSubClass(superType, type);
// typeInfo.setSuperClass(type, superType);
}
// Then process super interfaces
for (ITypeBinding itfBinding : typeBinding.getInterfaces()) {
Type itfType = getType(itfBinding);
if (itfType == null) {
itfType = addType(itfBinding);
}
// TODO: MED. Do not call deprecated method
// TODO: HIGH. XXX. Do we want to use addSubClass for interfaces?
// typeInfo.addSubClass(itfType, type);
// typeInfo.addImplementedInterface(type, itfType);
}
return type;
}
示例11: 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;
}
示例12: getDomainDeclsRecursive
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<String> getDomainDeclsRecursive(ITypeBinding typeBinding, AnnotationDatabase annoDB) {
Set<String> domDecl = new HashSet<String>();
domDecl.addAll(getDomainDecls(typeBinding, annoDB));
if (typeBinding.getSuperclass() != null)
domDecl.addAll(getDomainDecls(typeBinding.getSuperclass(), annoDB));
ITypeBinding[] interfaces = typeBinding.getInterfaces();
for (ITypeBinding iTypeBinding : interfaces) {
domDecl.addAll(getDomainDecls(iTypeBinding, annoDB));
}
List<String> domDeclList = new ArrayList<String>();
domDeclList.addAll(domDecl);
return domDeclList;
}
示例13: getInvocationType
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Returns the binding of the type which declares the method being invoked.
*
* @param invocationNode the method invocation node
* @param methodBinding binding of the method being invoked
* @param invocationQualifier the qualifier used for method invocation, or <code>null</code> if
* none
* @return the binding of the type which declares the method being invoked, or <code>null</code>
* if the type cannot be resolved
*/
public static ITypeBinding getInvocationType(ASTNode invocationNode, IMethodBinding methodBinding, Expression invocationQualifier) {
ITypeBinding invocationType;
if (invocationNode instanceof MethodInvocation || invocationNode instanceof SuperMethodInvocation) {
if (invocationQualifier != null) {
invocationType= invocationQualifier.resolveTypeBinding();
if (invocationType != null && invocationNode instanceof SuperMethodInvocation) {
invocationType= invocationType.getSuperclass();
}
} else {
ITypeBinding enclosingType= getEnclosingType(invocationNode);
if (enclosingType != null && invocationNode instanceof SuperMethodInvocation) {
enclosingType= enclosingType.getSuperclass();
}
if (enclosingType != null) {
IMethodBinding methodInHierarchy= Bindings.findMethodInHierarchy(enclosingType, methodBinding.getName(), methodBinding.getParameterTypes());
if (methodInHierarchy != null) {
invocationType= enclosingType;
} else {
invocationType= methodBinding.getDeclaringClass();
}
} else {
// not expected
invocationType= methodBinding.getDeclaringClass();
}
}
} else {
invocationType= methodBinding.getDeclaringClass();
}
return invocationType;
}
示例14: getOverriddenMethod
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* General, recursive version.
* @param declaringClass
* @param methodBinding
* @return
*/
private static IMethodBinding getOverriddenMethod(ITypeBinding declaringClass, IMethodBinding methodBinding) {
IMethodBinding overriddenMethod = null;
ITypeBinding[] paramTypes = methodBinding.getParameterTypes();
String methodName = methodBinding.getName();
ITypeBinding returnType = methodBinding.getReturnType();
// Look at superclass
ITypeBinding superclass = declaringClass.getSuperclass();
if (superclass != null) {
overriddenMethod = getMethodBinding(superclass, methodName, paramTypes, returnType);
// Recursively look at superclass
if (overriddenMethod == null ) {
overriddenMethod = getOverriddenMethod(superclass, methodBinding);
}
}
// Look at interfaces
if (overriddenMethod == null) {
for (ITypeBinding itfTypeBinding : declaringClass.getInterfaces()) {
overriddenMethod = getMethodBinding(itfTypeBinding, methodName, paramTypes, returnType);
if ( overriddenMethod != null ) {
break;
}
}
}
return overriddenMethod;
}
示例15: catches
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private boolean catches(ITypeBinding catchTypeBinding, ITypeBinding throwTypeBinding) {
while (throwTypeBinding != null) {
if (throwTypeBinding == catchTypeBinding) {
return true;
}
throwTypeBinding = throwTypeBinding.getSuperclass();
}
return false;
}