本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding类的典型用法代码示例。如果您正苦于以下问题:Java ReferenceBinding类的具体用法?Java ReferenceBinding怎么用?Java ReferenceBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReferenceBinding类属于org.eclipse.jdt.internal.compiler.lookup包,在下文中一共展示了ReferenceBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typeBindingToSignature
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
private static String typeBindingToSignature(TypeBinding binding) {
binding = binding.erasure();
if (binding != null && binding.isBaseType()) {
return new String (binding.sourceName());
} else if (binding instanceof ReferenceBinding) {
String pkg = binding.qualifiedPackageName() == null ? "" : new String(binding.qualifiedPackageName());
String qsn = binding.qualifiedSourceName() == null ? "" : new String(binding.qualifiedSourceName());
return pkg.isEmpty() ? qsn : (pkg + "." + qsn);
} else if (binding instanceof ArrayBinding) {
StringBuilder out = new StringBuilder();
out.append(typeBindingToSignature(binding.leafComponentType()));
for (int i = 0; i < binding.dimensions(); i++) out.append("[]");
return out.toString();
}
return "";
}
示例2: getApplicableExtensionMethods
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
static List<Extension> getApplicableExtensionMethods(EclipseNode typeNode, Annotation ann, TypeBinding receiverType) {
List<Extension> extensions = new ArrayList<Extension>();
if ((typeNode != null) && (ann != null) && (receiverType != null)) {
BlockScope blockScope = ((TypeDeclaration) typeNode.get()).initializerScope;
EclipseNode annotationNode = typeNode.getNodeFor(ann);
AnnotationValues<ExtensionMethod> annotation = createAnnotation(ExtensionMethod.class, annotationNode);
boolean suppressBaseMethods = false;
try {
suppressBaseMethods = annotation.getInstance().suppressBaseMethods();
} catch (AnnotationValueDecodeFail fail) {
fail.owner.setError(fail.getMessage(), fail.idx);
}
for (Object extensionMethodProvider : annotation.getActualExpressions("value")) {
if (extensionMethodProvider instanceof ClassLiteralAccess) {
TypeBinding binding = ((ClassLiteralAccess) extensionMethodProvider).type.resolveType(blockScope);
if (binding == null) continue;
if (!binding.isClass() && !binding.isEnum()) continue;
Extension e = new Extension();
e.extensionMethods = getApplicableExtensionMethodsDefinedInProvider(typeNode, (ReferenceBinding) binding, receiverType);
e.suppressBaseMethods = suppressBaseMethods;
extensions.add(e);
}
}
}
return extensions;
}
示例3: getApplicableExtensionMethodsDefinedInProvider
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
private static List<MethodBinding> getApplicableExtensionMethodsDefinedInProvider(EclipseNode typeNode, ReferenceBinding extensionMethodProviderBinding,
TypeBinding receiverType) {
List<MethodBinding> extensionMethods = new ArrayList<MethodBinding>();
CompilationUnitScope cuScope = ((CompilationUnitDeclaration) typeNode.top().get()).scope;
for (MethodBinding method : extensionMethodProviderBinding.methods()) {
if (!method.isStatic()) continue;
if (!method.isPublic()) continue;
if (method.parameters == null || method.parameters.length == 0) continue;
TypeBinding firstArgType = method.parameters[0];
if (receiverType.isProvablyDistinct(firstArgType) && !receiverType.isCompatibleWith(firstArgType.erasure())) continue;
TypeBinding[] argumentTypes = Arrays.copyOfRange(method.parameters, 1, method.parameters.length);
if ((receiverType instanceof ReferenceBinding) && ((ReferenceBinding) receiverType).getExactMethod(method.selector, argumentTypes, cuScope) != null) continue;
extensionMethods.add(method);
}
return extensionMethods;
}
示例4: 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;
}
示例5: 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;
}
示例6: getConstructors
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
@Override
@NonNull
public Iterable<ResolvedMethod> getConstructors() {
if (mBinding instanceof ReferenceBinding) {
ReferenceBinding cls = (ReferenceBinding) mBinding;
MethodBinding[] methods = cls.getMethods(TypeConstants.INIT);
if (methods != null) {
int count = methods.length;
List<ResolvedMethod> result = Lists.newArrayListWithExpectedSize(count);
for (MethodBinding method : methods) {
if (method.isConstructor()) {
result.add(new EcjResolvedMethod(method));
}
}
return result;
}
}
return Collections.emptyList();
}
示例7: 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;
}
示例8: getAnnotationInstance
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
synchronized IAnnotationBinding getAnnotationInstance(org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding internalInstance) {
if (internalInstance == null) return null;
ReferenceBinding annotationType = internalInstance.getAnnotationType();
if (!this.isRecoveringBindings) {
if (annotationType == null || ((annotationType.tagBits & TagBits.HasMissingType) != 0)) {
return null;
}
}
IAnnotationBinding domInstance =
(IAnnotationBinding) this.bindingTables.compilerBindingsToASTBindings.get(internalInstance);
if (domInstance != null)
return domInstance;
domInstance = new AnnotationBinding(internalInstance, this);
this.bindingTables.compilerBindingsToASTBindings.put(internalInstance, domInstance);
return domInstance;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:DefaultBindingResolver.java
示例9: manageEnclosingInstanceAccessIfNecessary
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
ReferenceBinding superTypeErasure = (ReferenceBinding) this.binding.declaringClass.erasure();
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) {
// perform some emulation work in case there is some and we are inside a local type only
if (superTypeErasure.isNestedType()
&& currentScope.enclosingSourceType().isLocalType()) {
if (superTypeErasure.isLocalType()) {
((LocalTypeBinding) superTypeErasure).addInnerEmulationDependent(currentScope, this.qualification != null);
} else {
// locally propagate, since we already now the desired shape for sure
currentScope.propagateInnerEmulation(superTypeErasure, this.qualification != null);
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:ExplicitConstructorCall.java
示例10: getEnclosedElements
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
@Override
public List<? extends Element> getEnclosedElements() {
PackageBinding binding = (PackageBinding)_binding;
LookupEnvironment environment = binding.environment;
char[][][] typeNames = null;
INameEnvironment nameEnvironment = binding.environment.nameEnvironment;
if (nameEnvironment instanceof FileSystem) {
typeNames = ((FileSystem) nameEnvironment).findTypeNames(binding.compoundName);
}
HashSet<Element> set = new HashSet<Element>();
if (typeNames != null) {
for (char[][] typeName : typeNames) {
ReferenceBinding type = environment.getType(typeName);
if (type != null && type.isValidBinding()) {
set.add(_env.getFactory().newElement(type));
}
}
}
ArrayList<Element> list = new ArrayList<Element>(set.size());
list.addAll(set);
return Collections.unmodifiableList(list);
}
示例11: checkNeedForEnclosingInstanceCast
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
/**
* Casting an enclosing instance will considered as useful if removing it would actually bind to a different type
*/
public static void checkNeedForEnclosingInstanceCast(BlockScope scope, Expression enclosingInstance, TypeBinding enclosingInstanceType, TypeBinding memberType) {
if (scope.compilerOptions().getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return;
TypeBinding castedExpressionType = ((CastExpression)enclosingInstance).expression.resolvedType;
if (castedExpressionType == null) return; // cannot do better
// obvious identity cast
if (TypeBinding.equalsEquals(castedExpressionType, enclosingInstanceType)) {
scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance);
} else if (castedExpressionType == TypeBinding.NULL){
return; // tolerate null enclosing instance cast
} else {
TypeBinding alternateEnclosingInstanceType = castedExpressionType;
if (castedExpressionType.isBaseType() || castedExpressionType.isArrayType()) return; // error case
if (TypeBinding.equalsEquals(memberType, scope.getMemberType(memberType.sourceName(), (ReferenceBinding) alternateEnclosingInstanceType))) {
scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance);
}
}
}
示例12: findMethodForArray
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
ReferenceBinding object = getJavaLangObject();
MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
if (methodBinding != null) {
// handle the method clone() specially... cannot be protected or throw exceptions
if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
return methodBinding;
}
// answers closest approximation, may not check argumentTypes or visibility
methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
if (methodBinding == null)
return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
if (methodBinding.isValidBinding()) {
MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite);
if (compatibleMethod == null)
return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
methodBinding = compatibleMethod;
if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
}
return methodBinding;
}
示例13: typeMismatchError
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
public void typeMismatchError(TypeBinding typeArgument, TypeVariableBinding typeParameter, ReferenceBinding genericType, ASTNode location) {
if (location == null) { // binary case
this.handle(
IProblem.TypeArgumentMismatch,
new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) },
new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) },
ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
0,
0);
return;
}
this.handle(
IProblem.TypeArgumentMismatch,
new String[] { new String(typeArgument.readableName()), new String(genericType.readableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, false) },
new String[] { new String(typeArgument.shortReadableName()), new String(genericType.shortReadableName()), new String(typeParameter.sourceName), parameterBoundAsString(typeParameter, true) },
location.sourceStart,
location.sourceEnd);
}
示例14: getKind
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
@Override
public ElementKind getKind() {
if (null != _kindHint) {
return _kindHint;
}
ReferenceBinding refBinding = (ReferenceBinding)_binding;
// The order of these comparisons is important: e.g., enum is subset of class
if (refBinding.isEnum()) {
return ElementKind.ENUM;
}
else if (refBinding.isAnnotationType()) {
return ElementKind.ANNOTATION_TYPE;
}
else if (refBinding.isInterface()) {
return ElementKind.INTERFACE;
}
else if (refBinding.isClass()) {
return ElementKind.CLASS;
}
else {
throw new IllegalArgumentException("TypeElement " + new String(refBinding.shortReadableName()) + //$NON-NLS-1$
" has unexpected attributes " + refBinding.modifiers); //$NON-NLS-1$
}
}
示例15: unusedPrivateType
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入依赖的package包/类
public void unusedPrivateType(TypeDeclaration typeDecl) {
int severity = computeSeverity(IProblem.UnusedPrivateType);
if (severity == ProblemSeverities.Ignore) return;
if (excludeDueToAnnotation(typeDecl.annotations)) return;
ReferenceBinding type = typeDecl.binding;
this.handle(
IProblem.UnusedPrivateType,
new String[] {
new String(type.readableName()),
},
new String[] {
new String(type.shortReadableName()),
},
severity,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}