List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding methods
public MethodBinding[] methods()
From source file:com.android.tools.lint.psi.EcjPsiBinaryClass.java
License:Apache License
@NonNull private PsiMethod[] findMethods(@Nullable String name, boolean includeInherited, boolean includeConstructors) { if (mBinding instanceof ReferenceBinding) { ReferenceBinding cls = (ReferenceBinding) mBinding; if (includeInherited) { List<EcjPsiBinaryMethod> result = null; while (cls != null) { MethodBinding[] methods = name != null ? cls.getMethods(name.toCharArray()) : cls.methods(); if (methods != null) { int count = methods.length; if (count > 0) { if (result == null) { result = Lists.newArrayListWithExpectedSize(count); }//from w ww. ja v a2s . co m for (MethodBinding method : methods) { if ((method.modifiers & Modifier.PRIVATE) != 0 && cls != mBinding) { // Ignore parent methods that are private continue; } if (includeConstructors || !method.isConstructor()) { // See if this method looks like it's masked boolean masked = false; for (PsiMethod m : result) { MethodBinding mb = ((EcjPsiBinaryMethod) m).getBinding(); if (mb.areParameterErasuresEqual(method)) { masked = true; break; } } if (masked) { continue; } result.add(new EcjPsiBinaryMethod(mManager, method)); } } } } cls = cls.superclass(); } return result != null ? result.toArray(PsiMethod.EMPTY_ARRAY) : PsiMethod.EMPTY_ARRAY; } else { MethodBinding[] methods = name != null ? cls.getMethods(name.toCharArray()) : cls.methods(); if (methods != null) { int count = methods.length; List<EcjPsiBinaryMethod> result = Lists.newArrayListWithExpectedSize(count); for (MethodBinding method : methods) { if (includeConstructors || !method.isConstructor()) { result.add(new EcjPsiBinaryMethod(mManager, method)); } } return result.toArray(PsiMethod.EMPTY_ARRAY); } } } return PsiMethod.EMPTY_ARRAY; }
From source file:com.google.gwt.dev.jjs.impl.BuildTypeMap.java
License:Apache License
private void processEnumType(ReferenceBinding binding, JEnumType type) { // Visit the synthetic values() and valueOf() methods. for (MethodBinding methodBinding : binding.methods()) { if (methodBinding instanceof SyntheticMethodBinding) { JMethod newMethod = processMethodBinding(methodBinding, type, type.getSourceInfo()); TypeBinding[] parameters = methodBinding.parameters; if (parameters.length == 0) { assert newMethod.getName().equals("values"); } else if (parameters.length == 1) { assert newMethod.getName().equals("valueOf"); assert typeMap.get(parameters[0]) == program.getTypeJavaLangString(); JProgram.createParameter(newMethod.getSourceInfo(), "name", program.getTypeJavaLangString(), true, false, newMethod); } else { assert false; }/* w w w . j a v a2 s . c o m*/ newMethod.freezeParamTypes(); } } }
From source file:com.google.gwt.dev.jjs.impl.BuildTypeMap.java
License:Apache License
private void resolve(JDeclaredType type, ReferenceBinding binding) { process(binding);//from w w w. j a v a 2 s .c o m for (FieldBinding fieldBinding : binding.fields()) { if (fieldBinding.isPrivate() || (type.getName().startsWith("java.") && !fieldBinding.isPublic() && !fieldBinding.isProtected())) { continue; } createField(type.getSourceInfo(), fieldBinding, type); } for (MethodBinding methodBinding : binding.methods()) { processExternalMethod(methodBinding, type); } if (binding instanceof BinaryTypeBinding) { // Unlike SourceTypeBindings, we have to explicitly ask for bridge methods // for BinaryTypeBindings. try { // TODO(tobyr) Fix so we don't have to use reflection. Method m = BinaryTypeBinding.class.getDeclaredMethod("bridgeMethods"); MethodBinding[] bridgeMethods = (MethodBinding[]) m.invoke(binding); for (MethodBinding methodBinding : bridgeMethods) { processExternalMethod(methodBinding, type); } } catch (Exception e) { throw new InternalCompilerException("Unexpected failure", e); } } }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTMethod.java
License:Open Source License
private boolean isDefinedInType(ReferenceBinding superClass) { for (MethodBinding inheritedMethod : superClass.methods()) { if (methodVerifier.doesMethodOverride(method, inheritedMethod)) { return true; }/* w ww .j a v a 2s . c o m*/ } return false; }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.UnknownClassMirror.java
License:Open Source License
@Override public List<MethodMirror> getDirectMethods() { if (methods == null) { doWithBindings(new ActionOnClassBinding() { @Override//from ww w. j a v a 2 s. c o m public void doWithBinding(IType classModel, ReferenceBinding klass) { MethodBinding[] directMethods; directMethods = klass.methods(); methods = new ArrayList<MethodMirror>(directMethods.length); for (MethodBinding method : directMethods) { if (!method.isBridge() && !method.isSynthetic() && !method.isPrivate()) methods.add(new JDTMethod(JDTClass.this, method)); } } }); } return methods; }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTMethod.java
License:Open Source License
private void doWithBindings(final ActionOnMethodBinding action) { final IType declaringClassModel = enclosingClass.getType(); if (!JDTModelLoader.doWithMethodBinding(declaringClassModel, bindingRef.get(), action)) { JDTModelLoader.doWithResolvedType(declaringClassModel, new JDTModelLoader.ActionOnResolvedType() { @Override/* w w w . j a v a 2 s . c o m*/ public void doWithBinding(ReferenceBinding declaringClass) { MethodBinding method = null; for (MethodBinding m : declaringClass.methods()) { if (CharOperation.equals(m.computeUniqueKey(), bindingKey)) { method = m; break; } } if (method == null) { throw new ModelResolutionException( "Method '" + readableName + "' not found in the binding of class '" + declaringClassModel.getFullyQualifiedName() + "'"); } bindingRef = new WeakReference<MethodBinding>(method); action.doWithBinding(declaringClassModel, declaringClass, method); } }); } }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTMethod.java
License:Open Source License
private boolean isDefinedInType(ReferenceBinding superClass, MethodBinding method) { MethodVerifier methodVerifier = superClass.getPackage().environment.methodVerifier(); for (MethodBinding inheritedMethod : superClass.methods()) { // skip ignored methods if (ignoreMethodInAncestorSearch(inheritedMethod)) { continue; }//from w w w . j ava 2 s . co m if (methodVerifier.doesMethodOverride(method, inheritedMethod)) { return true; } } return false; }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTMethod.java
License:Open Source License
private boolean isOverloadingInType(ReferenceBinding superClass, MethodBinding method) { MethodVerifier methodVerifier = superClass.getPackage().environment.methodVerifier(); for (MethodBinding inheritedMethod : superClass.methods()) { if (inheritedMethod.isPrivate() || inheritedMethod.isStatic() || inheritedMethod.isConstructor() || inheritedMethod.isBridge() || inheritedMethod.isSynthetic() || !Arrays.equals(inheritedMethod.constantPoolName(), method.selector)) continue; // skip ignored methods if (ignoreMethodInAncestorSearch(inheritedMethod)) { continue; }//from w w w . j a v a2 s. com // if it does not override it and has the same name, it's overloading if (!methodVerifier.doesMethodOverride(method, inheritedMethod)) { return true; } } return false; }
From source file:io.gige.compiler.internal.HackElements.java
License:Apache License
@Override public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults( AnnotationMirror a) {//from w w w. j av a2 s. c om Map<? extends ExecutableElement, ? extends AnnotationValue> map = super.getElementValuesWithDefaults(a); if (a instanceof AnnotationMirrorImpl) { AnnotationMirrorImpl impl = (AnnotationMirrorImpl) a; ReferenceBinding annoType = impl._binding.getAnnotationType(); for (MethodBinding method : annoType.methods()) { MethodBinding originalMethod = method.original(); AbstractMethodDeclaration methodDeclaration = originalMethod.sourceMethod(); if (methodDeclaration instanceof AnnotationMethodDeclaration) { AnnotationMethodDeclaration amd = (AnnotationMethodDeclaration) methodDeclaration; Expression exp = amd.defaultValue; if (exp instanceof QualifiedNameReference) { QualifiedNameReference qae = (QualifiedNameReference) exp; qae.bits |= ASTNode.RestrictiveFlagMASK; } } } } return map; }
From source file:lombok.eclipse.agent.PatchExtensionMethod.java
License:Open Source License
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);/*from w w w . j av a 2 s.c om*/ } return extensionMethods; }