当前位置: 首页>>代码示例>>Java>>正文


Java ReferenceBinding.superclass方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.superclass方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceBinding.superclass方法的具体用法?Java ReferenceBinding.superclass怎么用?Java ReferenceBinding.superclass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding的用法示例。


在下文中一共展示了ReferenceBinding.superclass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findSuperMethodBinding

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/** Computes the super method, if any, given a method binding */
private static MethodBinding findSuperMethodBinding(@NonNull MethodBinding binding) {
    try {
        ReferenceBinding superclass = binding.declaringClass.superclass();
        while (superclass != null) {
            MethodBinding[] methods = superclass.getMethods(binding.selector,
                    binding.parameters.length);
            for (MethodBinding method : methods) {
                if (method.areParameterErasuresEqual(binding)) {
                    return method;
                }
            }

            superclass = superclass.superclass();
        }
    } catch (Exception ignore) {
        // Work around ECJ bugs; see https://code.google.com/p/android/issues/detail?id=172268
    }

    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:EcjParser.java

示例2: isSubclassOf

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public boolean isSubclassOf(@NonNull String name, boolean strict) {
    if (mBinding instanceof ReferenceBinding) {
        ReferenceBinding cls = (ReferenceBinding) mBinding;
        if (strict) {
            cls = cls.superclass();
        }
        for (; cls != null; cls = cls.superclass()) {
            if (sameChars(name, cls.readableName())) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EcjParser.java

示例3: getField

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
@Nullable
public ResolvedField getField(@NonNull String name, boolean includeInherited) {
    if (mBinding instanceof ReferenceBinding) {
        ReferenceBinding cls = (ReferenceBinding) mBinding;
        while (cls != null) {
            FieldBinding[] fields = cls.fields();
            if (fields != null) {
                for (FieldBinding field : fields) {
                    if (sameChars(name, field.name)) {
                        return new EcjResolvedField(field);
                    }
                }
            }
            if (includeInherited) {
                cls = cls.superclass();
            } else {
                break;
            }
        }
    }

    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:EcjParser.java

示例4: directSupertypes

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
 public List<? extends TypeMirror> directSupertypes(TypeMirror t) {
     switch(t.getKind()) {
         case PACKAGE :
         case EXECUTABLE :
             throw new IllegalArgumentException("Invalid type mirror for directSupertypes"); //$NON-NLS-1$
         default:
             break;
     }
     TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) t;
     Binding binding = typeMirrorImpl._binding;
     if (binding instanceof ReferenceBinding) {
     	ReferenceBinding referenceBinding = (ReferenceBinding) binding;
     	ArrayList<TypeMirror> list = new ArrayList<TypeMirror>();
     	ReferenceBinding superclass = referenceBinding.superclass();
if (superclass != null) {
     		list.add(this._env.getFactory().newTypeMirror(superclass));
     	}
for (ReferenceBinding interfaceBinding : referenceBinding.superInterfaces()) {
     		list.add(this._env.getFactory().newTypeMirror(interfaceBinding));
}
return Collections.unmodifiableList(list);
     }
     return Collections.emptyList();
 }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:TypesImpl.java

示例5: inheritsAnno

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/**
 * Check whether an element has a superclass that is annotated with an @Inherited annotation.
 * @param element must be a class (not an interface, enum, etc.).
 * @param anno must be an annotation type, and must be @Inherited
 * @return true if element has a superclass that is annotated with anno
 */
private boolean inheritsAnno(ReferenceBinding element, ReferenceBinding anno) {
	ReferenceBinding searchedElement = element;
	do {
		if (searchedElement instanceof ParameterizedTypeBinding) {
			searchedElement = ((ParameterizedTypeBinding) searchedElement).genericType();
		}
		AnnotationBinding[] annos = Factory.getPackedAnnotationBindings(searchedElement.getAnnotations());
		for (AnnotationBinding annoBinding : annos) {
			if (annoBinding.getAnnotationType() == anno) { //$IDENTITY-COMPARISON$
				// element is annotated with anno
				return true;
			}
		}
	} while (null != (searchedElement = searchedElement.superclass()));
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:RoundEnvImpl.java

示例6: inheritsAnno

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/**
 * Check whether an element has a superclass that is annotated with an @Inherited annotation.
 * @param element must be a class (not an interface, enum, etc.).
 * @param anno must be an annotation type, and must be @Inherited
 * @return true if element has a superclass that is annotated with anno
 */
private boolean inheritsAnno(ReferenceBinding element, ReferenceBinding anno) {
	ReferenceBinding searchedElement = element;
	do {
		if (searchedElement instanceof ParameterizedTypeBinding) {
			searchedElement = ((ParameterizedTypeBinding) searchedElement).genericType();
		}
		AnnotationBinding[] annos = searchedElement.getAnnotations();
		for (AnnotationBinding annoBinding : annos) {
			if (annoBinding.getAnnotationType() == anno) {
				// element is annotated with anno
				return true;
			}
		}
	} while (null != (searchedElement = searchedElement.superclass()));
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:23,代码来源:RoundEnvImpl.java

示例7: getSuperClass

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Nullable
@Override
public ResolvedClass getSuperClass() {
    if (mBinding instanceof ReferenceBinding) {
        ReferenceBinding refBinding = (ReferenceBinding) mBinding;
        ReferenceBinding superClass = refBinding.superclass();
        if (superClass != null) {
            return new EcjResolvedClass(superClass);
        }
    }

    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:EcjParser.java

示例8: getAllMembers

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/**
 * Compute a list of all the visible entities in this type.  Specifically:
 * <ul>
 * <li>All nested types declared in this type, including interfaces and enums</li>
 * <li>All protected or public nested types declared in this type's superclasses
 * and superinterfaces, that are not hidden by a name collision</li>
 * <li>All methods declared in this type, including constructors but not
 * including static or instance initializers, and including abstract
 * methods and unimplemented methods declared in interfaces</li>
 * <li>All protected or public methods declared in this type's superclasses,
 * that are not overridden by another method, but not including constructors
 * or initializers. Includes abstract methods and methods declared in
 * superinterfaces but not implemented</li>
 * <li>All fields declared in this type, including constants</li>
 * <li>All non-private fields declared in this type's superclasses and
 * superinterfaces, that are not hidden by a name collision.</li>
 * </ul>
 */
@Override
public List<? extends Element> getAllMembers(TypeElement type) {
	if (null == type || !(type instanceof TypeElementImpl)) {
		return Collections.emptyList();
	}
	ReferenceBinding binding = (ReferenceBinding)((TypeElementImpl)type)._binding;
	// Map of element simple name to binding
	Map<String, ReferenceBinding> types = new HashMap<String, ReferenceBinding>();
	// Javac implementation does not take field name collisions into account
	List<FieldBinding> fields = new ArrayList<FieldBinding>();
	// For methods, need to compare parameters, not just names
	Map<String, Set<MethodBinding>> methods = new HashMap<String, Set<MethodBinding>>();
	Set<ReferenceBinding> superinterfaces = new LinkedHashSet<ReferenceBinding>();
	boolean ignoreVisibility = true;
	while (null != binding) {
		addMembers(binding, ignoreVisibility, types, fields, methods);
		Set<ReferenceBinding> newfound = new LinkedHashSet<ReferenceBinding>();
		collectSuperInterfaces(binding, superinterfaces, newfound);
		for (ReferenceBinding superinterface : newfound) {
			addMembers(superinterface, false, types, fields, methods);
		}
		superinterfaces.addAll(newfound);
		binding = binding.superclass();
		ignoreVisibility = false;
	}
	List<Element> allMembers = new ArrayList<Element>();
	for (ReferenceBinding nestedType : types.values()) {
		allMembers.add(_env.getFactory().newElement(nestedType));
	}
	for (FieldBinding field : fields) {
		allMembers.add(_env.getFactory().newElement(field));
	}
	for (Set<MethodBinding> sameNamedMethods : methods.values()) {
		for (MethodBinding method : sameNamedMethods) {
			allMembers.add(_env.getFactory().newElement(method));
		}
	}
	return allMembers;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:58,代码来源:ElementsImpl.java

示例9: getSuperclass

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public TypeMirror getSuperclass() {
	ReferenceBinding binding = (ReferenceBinding)_binding;
	ReferenceBinding superBinding = binding.superclass();
	if (null == superBinding || binding.isInterface()) {
		return _env.getFactory().getNoType(TypeKind.NONE);
	}
	// superclass of a type must be a DeclaredType
	return _env.getFactory().newTypeMirror(superBinding);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:TypeElementImpl.java

示例10: resolveType

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public TypeBinding resolveType(BlockScope scope) {

		this.constant = Constant.NotAConstant;
		ReferenceBinding enclosingReceiverType = scope.enclosingReceiverType();
		if (!checkAccess(scope, enclosingReceiverType))
			return null;
		if (enclosingReceiverType.id == T_JavaLangObject) {
			scope.problemReporter().cannotUseSuperInJavaLangObject(this);
			return null;
		}
		return this.resolvedType = enclosingReceiverType.superclass();
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:SuperReference.java

示例11: invalidEnclosingType

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {

	if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
	if (enclosingType.sourceName != null && enclosingType.sourceName.length == 0) return;

	int flag = IProblem.UndefinedType; // default
	switch (type.problemId()) {
		case ProblemReasons.NotFound : // 1
			flag = IProblem.UndefinedType;
			break;
		case ProblemReasons.NotVisible : // 2
			flag = IProblem.NotVisibleType;
			break;
		case ProblemReasons.Ambiguous : // 3
			flag = IProblem.AmbiguousType;
			break;
		case ProblemReasons.InternalNameProvided :
			flag = IProblem.InternalTypeNameProvided;
			break;
		case ProblemReasons.NoError : // 0
		default :
			needImplementation(expression); // want to fail to see why we were here...
			break;
	}

	this.handle(
		flag,
		new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
		new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
		expression.sourceStart,
		expression.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:ProblemReporter.java

示例12: resolveType

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public TypeBinding resolveType(BlockScope scope) {

		this.constant = Constant.NotAConstant;
		if (!checkAccess(scope.methodScope()))
			return null;
		ReferenceBinding enclosingReceiverType = scope.enclosingReceiverType();
		if (enclosingReceiverType.id == T_JavaLangObject) {
			scope.problemReporter().cannotUseSuperInJavaLangObject(this);
			return null;
		}
		return this.resolvedType = enclosingReceiverType.superclass();
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:13,代码来源:SuperReference.java

示例13: searchVisibleMethods

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
private void searchVisibleMethods(
		ReferenceBinding receiverType,
		Scope scope,
		InvocationSite invocationSite,
		Scope invocationScope,
		boolean onlyStaticMethods,
		boolean notInJavadoc,
		ObjectVector methodsFound) {
	ReferenceBinding currentType = receiverType;
	if (notInJavadoc) {
		if (receiverType.isInterface()) {
			searchVisibleInterfaceMethods(
					new ReferenceBinding[]{currentType},
					receiverType,
					scope,
					invocationSite,
					invocationScope,
					onlyStaticMethods,
					methodsFound);

			currentType = scope.getJavaLangObject();
		}
	}
	boolean hasPotentialDefaultAbstractMethods = true;
	while (currentType != null) {

		MethodBinding[] methods = currentType.availableMethods();
		if (methods != null) {
			searchVisibleLocalMethods(
					methods,
					receiverType,
					scope,
					invocationSite,
					invocationScope,
					onlyStaticMethods,
					methodsFound);
		}

		if (notInJavadoc &&
				hasPotentialDefaultAbstractMethods &&
				(currentType.isAbstract() ||
						currentType.isTypeVariable() ||
						currentType.isIntersectionType() ||
						currentType.isEnum())){

			ReferenceBinding[] superInterfaces = currentType.superInterfaces();
			if (superInterfaces != null && currentType.isIntersectionType()) {
				for (int i = 0; i < superInterfaces.length; i++) {
					superInterfaces[i] = (ReferenceBinding)superInterfaces[i].capture(invocationScope, invocationSite.sourceEnd());
				}
			}

			searchVisibleInterfaceMethods(
					superInterfaces,
					receiverType,
					scope,
					invocationSite,
					invocationScope,
					onlyStaticMethods,
					methodsFound);
		} else {
			hasPotentialDefaultAbstractMethods = false;
		}
		if(currentType.isParameterizedType()) {
			currentType = ((ParameterizedTypeBinding)currentType).genericType().superclass();
		} else {
			currentType = currentType.superclass();
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:71,代码来源:InternalExtendedCompletionContext.java

示例14: canBeSeenByForCodeSnippet

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
	if (fieldBinding.isPublic()) return true;

	ReferenceBinding invocationType = (ReferenceBinding) receiverType;
	if (TypeBinding.equalsEquals(invocationType, fieldBinding.declaringClass)) return true;

	if (fieldBinding.isProtected()) {
		// answer true if the invocationType is the declaringClass or they are in the same package
		// OR the invocationType is a subclass of the declaringClass
		//    AND the receiverType is the invocationType or its subclass
		//    OR the field is a static field accessed directly through a type
		if (TypeBinding.equalsEquals(invocationType, fieldBinding.declaringClass)) return true;
		if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
		if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
			if (invocationSite.isSuperAccess()) return true;
			// receiverType can be an array binding in one case... see if you can change it
			if (receiverType instanceof ArrayBinding)
				return false;
			if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
				return true;
			if (fieldBinding.isStatic())
				return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
		}
		return false;
	}

	if (fieldBinding.isPrivate()) {
		// answer true if the receiverType is the declaringClass
		// AND the invocationType and the declaringClass have a common enclosingType
		if (TypeBinding.notEquals(receiverType, fieldBinding.declaringClass)) return false;

		if (TypeBinding.notEquals(invocationType, fieldBinding.declaringClass)) {
			ReferenceBinding outerInvocationType = invocationType;
			ReferenceBinding temp = outerInvocationType.enclosingType();
			while (temp != null) {
				outerInvocationType = temp;
				temp = temp.enclosingType();
			}

			ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
			temp = outerDeclaringClass.enclosingType();
			while (temp != null) {
				outerDeclaringClass = temp;
				temp = temp.enclosingType();
			}
			if (TypeBinding.notEquals(outerInvocationType, outerDeclaringClass)) return false;
		}
		return true;
	}

	// isDefault()
	if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;

	// receiverType can be an array binding in one case... see if you can change it
	if (receiverType instanceof ArrayBinding)
		return false;
	ReferenceBinding type = (ReferenceBinding) receiverType;
	PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
	TypeBinding originalDeclaringClass = fieldBinding.declaringClass .original();
	do {
		if (type.isCapture()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=285002
			if (TypeBinding.equalsEquals(originalDeclaringClass, type.erasure().original())) return true;	
		} else {
			if (TypeBinding.equalsEquals(originalDeclaringClass, type.original())) return true;
		}
		if (declaringPackage != type.fPackage) return false;
	} while ((type = type.superclass()) != null);
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:70,代码来源:CodeSnippetScope.java

示例15: canBeSeenByForCodeSnippet

import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public final boolean canBeSeenByForCodeSnippet(FieldBinding fieldBinding, TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
	if (fieldBinding.isPublic()) return true;

	ReferenceBinding invocationType = (ReferenceBinding) receiverType;
	if (invocationType == fieldBinding.declaringClass) return true;

	if (fieldBinding.isProtected()) {
		// answer true if the invocationType is the declaringClass or they are in the same package
		// OR the invocationType is a subclass of the declaringClass
		//    AND the receiverType is the invocationType or its subclass
		//    OR the field is a static field accessed directly through a type
		if (invocationType == fieldBinding.declaringClass) return true;
		if (invocationType.fPackage == fieldBinding.declaringClass.fPackage) return true;
		if (fieldBinding.declaringClass.isSuperclassOf(invocationType)) {
			if (invocationSite.isSuperAccess()) return true;
			// receiverType can be an array binding in one case... see if you can change it
			if (receiverType instanceof ArrayBinding)
				return false;
			if (invocationType.isSuperclassOf((ReferenceBinding) receiverType))
				return true;
			if (fieldBinding.isStatic())
				return true; // see 1FMEPDL - return invocationSite.isTypeAccess();
		}
		return false;
	}

	if (fieldBinding.isPrivate()) {
		// answer true if the receiverType is the declaringClass
		// AND the invocationType and the declaringClass have a common enclosingType
		if (receiverType != fieldBinding.declaringClass) return false;

		if (invocationType != fieldBinding.declaringClass) {
			ReferenceBinding outerInvocationType = invocationType;
			ReferenceBinding temp = outerInvocationType.enclosingType();
			while (temp != null) {
				outerInvocationType = temp;
				temp = temp.enclosingType();
			}

			ReferenceBinding outerDeclaringClass = fieldBinding.declaringClass;
			temp = outerDeclaringClass.enclosingType();
			while (temp != null) {
				outerDeclaringClass = temp;
				temp = temp.enclosingType();
			}
			if (outerInvocationType != outerDeclaringClass) return false;
		}
		return true;
	}

	// isDefault()
	if (invocationType.fPackage != fieldBinding.declaringClass.fPackage) return false;

	// receiverType can be an array binding in one case... see if you can change it
	if (receiverType instanceof ArrayBinding)
		return false;
	ReferenceBinding type = (ReferenceBinding) receiverType;
	PackageBinding declaringPackage = fieldBinding.declaringClass.fPackage;
	TypeBinding originalDeclaringClass = fieldBinding.declaringClass .original();
	do {
		if (type.isCapture()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=285002
			if (originalDeclaringClass == type.erasure().original()) return true;	
		} else {
			if (originalDeclaringClass == type.original()) return true;
		}
		if (declaringPackage != type.fPackage) return false;
	} while ((type = type.superclass()) != null);
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:70,代码来源:CodeSnippetScope.java


注:本文中的org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.superclass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。