Java Code Examples for org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#superInterfaces()
The following examples show how to use
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#superInterfaces() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypesImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@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(); }
Example 2
Source File: TypeElementImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public List<? extends TypeMirror> getInterfaces() { ReferenceBinding binding = (ReferenceBinding)_binding; if (null == binding.superInterfaces() || binding.superInterfaces().length == 0) { return Collections.emptyList(); } List<TypeMirror> interfaces = new ArrayList<TypeMirror>(binding.superInterfaces().length); for (ReferenceBinding interfaceBinding : binding.superInterfaces()) { TypeMirror interfaceType = _env.getFactory().newTypeMirror(interfaceBinding); if (interfaceType.getKind() == TypeKind.ERROR) { if (this._env.getSourceVersion().compareTo(SourceVersion.RELEASE_6) > 0) { // for jdk 7 and above, add error types interfaces.add(interfaceType); } } else { interfaces.add(interfaceType); } } return Collections.unmodifiableList(interfaces); }
Example 3
Source File: ElementsImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Recursively depth-first walk the tree of superinterfaces of a type, collecting * all the unique superinterface bindings. (Note that because of generics, a type may * have multiple unique superinterface bindings corresponding to the same interface * declaration.) * @param existing bindings already in this set will not be re-added or recursed into * @param newfound newly found bindings will be added to this set */ private void collectSuperInterfaces(ReferenceBinding type, Set<ReferenceBinding> existing, Set<ReferenceBinding> newfound) { for (ReferenceBinding superinterface : type.superInterfaces()) { if (!existing.contains(superinterface) && !newfound.contains(superinterface)) { newfound.add(superinterface); collectSuperInterfaces(superinterface, existing, newfound); } } }
Example 4
Source File: SelectionOnMessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private MethodBinding findNonDefaultAbstractMethod(MethodBinding methodBinding) { ReferenceBinding[] itsInterfaces = methodBinding.declaringClass.superInterfaces(); if (itsInterfaces != Binding.NO_SUPERINTERFACES) { ReferenceBinding[] interfacesToVisit = itsInterfaces; int nextPosition = interfacesToVisit.length; for (int i = 0; i < nextPosition; i++) { ReferenceBinding currentType = interfacesToVisit[i]; MethodBinding[] methods = currentType.getMethods(methodBinding.selector); if(methods != null) { for (int k = 0; k < methods.length; k++) { if(methodBinding.areParametersEqual(methods[k])) return methods[k]; } } if ((itsInterfaces = currentType.superInterfaces()) != Binding.NO_SUPERINTERFACES) { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface : for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (TypeBinding.equalsEquals(next, interfacesToVisit[b])) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } } return methodBinding; }
Example 5
Source File: Expression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void getAllInheritedMethods0(ReferenceBinding binding, ArrayList<MethodBinding> collector) { if (!binding.isInterface()) return; MethodBinding[] methodBindings = binding.methods(); for (int i = 0, max = methodBindings.length; i < max; i++) { collector.add(methodBindings[i]); } ReferenceBinding[] superInterfaces = binding.superInterfaces(); for (int i = 0, max = superInterfaces.length; i < max; i++) { getAllInheritedMethods0(superInterfaces[i], collector); } }
Example 6
Source File: PatchDelegate.java From EasyMPermission with MIT License | 4 votes |
private static void addAllMethodBindings0(List<BindingTuple> list, TypeBinding binding, Set<String> banList, char[] fieldName, ASTNode responsible) throws DelegateRecursion { if (binding instanceof SourceTypeBinding) ((SourceTypeBinding) binding).scope.environment().globalOptions.storeAnnotations = true; if (binding == null) return; TypeBinding inner; if (binding instanceof ParameterizedTypeBinding) { inner = ((ParameterizedTypeBinding) binding).genericType(); } else { inner = binding; } if (inner instanceof SourceTypeBinding) { ClassScope cs = ((SourceTypeBinding)inner).scope; if (cs != null) { try { Reflection.classScopeBuildFieldsAndMethodsMethod.invoke(cs); } catch (Exception e) { // See 'Reflection' class for why we ignore this exception. } } } if (binding instanceof ReferenceBinding) { ReferenceBinding rb = (ReferenceBinding) binding; MethodBinding[] availableMethods = rb.availableMethods(); FieldBinding[] availableFields = rb.availableFields(); failIfContainsAnnotation(binding, availableMethods); failIfContainsAnnotation(binding, availableFields); MethodBinding[] parameterizedSigs = availableMethods; MethodBinding[] baseSigs = parameterizedSigs; if (binding instanceof ParameterizedTypeBinding) { baseSigs = ((ParameterizedTypeBinding)binding).genericType().availableMethods(); if (baseSigs.length != parameterizedSigs.length) { // The last known state of eclipse source says this can't happen, so we rely on it, // but if this invariant is broken, better to go with 'arg0' naming instead of crashing. baseSigs = parameterizedSigs; } } for (int i = 0; i < parameterizedSigs.length; i++) { MethodBinding mb = parameterizedSigs[i]; String sig = printSig(mb); if (mb.isStatic()) continue; if (mb.isBridge()) continue; if (mb.isConstructor()) continue; if (mb.isDefaultAbstract()) continue; if (!mb.isPublic()) continue; if (mb.isSynthetic()) continue; if (!banList.add(sig)) continue; // If add returns false, it was already in there. BindingTuple pair = new BindingTuple(mb, baseSigs[i], fieldName, responsible); list.add(pair); } addAllMethodBindings0(list, rb.superclass(), banList, fieldName, responsible); ReferenceBinding[] interfaces = rb.superInterfaces(); if (interfaces != null) { for (ReferenceBinding iface : interfaces) addAllMethodBindings0(list, iface, banList, fieldName, responsible); } } }
Example 7
Source File: InternalExtendedCompletionContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void searchVisibleInterfaceMethods( ReferenceBinding[] itsInterfaces, ReferenceBinding receiverType, Scope scope, InvocationSite invocationSite, Scope invocationScope, boolean onlyStaticMethods, ObjectVector methodsFound) { if (itsInterfaces != Binding.NO_SUPERINTERFACES) { ReferenceBinding[] interfacesToVisit = itsInterfaces; int nextPosition = interfacesToVisit.length; for (int i = 0; i < nextPosition; i++) { ReferenceBinding currentType = interfacesToVisit[i]; MethodBinding[] methods = currentType.availableMethods(); if(methods != null) { searchVisibleLocalMethods( methods, receiverType, scope, invocationSite, invocationScope, onlyStaticMethods, methodsFound); } itsInterfaces = currentType.superInterfaces(); if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface : for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (TypeBinding.equalsEquals(next, interfacesToVisit[b])) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } } }
Example 8
Source File: InternalExtendedCompletionContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
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(); } } }
Example 9
Source File: TypeBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public synchronized ITypeBinding[] getInterfaces() { if (this.prototype != null) { return this.prototype.getInterfaces(); } if (this.interfaces != null) { return this.interfaces; } if (this.binding == null) return this.interfaces = NO_TYPE_BINDINGS; switch (this.binding.kind()) { case Binding.ARRAY_TYPE : case Binding.BASE_TYPE : return this.interfaces = NO_TYPE_BINDINGS; } ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; ReferenceBinding[] internalInterfaces = null; try { internalInterfaces = referenceBinding.superInterfaces(); } catch (RuntimeException e) { /* in case a method cannot be resolvable due to missing jars on the classpath * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 */ org.eclipse.jdt.internal.core.util.Util.log(e, "Could not retrieve interfaces"); //$NON-NLS-1$ } int length = internalInterfaces == null ? 0 : internalInterfaces.length; if (length != 0) { ITypeBinding[] newInterfaces = new ITypeBinding[length]; int interfacesCounter = 0; for (int i = 0; i < length; i++) { ITypeBinding typeBinding = this.resolver.getTypeBinding(internalInterfaces[i]); if (typeBinding == null) { continue; } newInterfaces[interfacesCounter++] = typeBinding; } if (length != interfacesCounter) { System.arraycopy(newInterfaces, 0, (newInterfaces = new ITypeBinding[interfacesCounter]), 0, interfacesCounter); } return this.interfaces = newInterfaces; } return this.interfaces = NO_TYPE_BINDINGS; }