@Override 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, false); 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; } /* API
public MethodBinding getImplicitMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { // retrieve an exact visible match (if possible) MethodBinding methodBinding = findExactMethod(receiverType, selector, argumentTypes, invocationSite); if (methodBinding == null) methodBinding = findMethod(receiverType, selector, argumentTypes, invocationSite, false); if (methodBinding != null) { // skip it if we did not find anything if (methodBinding.isValidBinding()) if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotVisible); return methodBinding; } return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound); } }
public FieldBinding getFieldForCodeSnippet(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) { FieldBinding field = findFieldForCodeSnippet(receiverType, fieldName, invocationSite); if (field == null) return new ProblemFieldBinding(receiverType instanceof ReferenceBinding ? (ReferenceBinding) receiverType : null, fieldName, ProblemReasons.NotFound); else return field; } /* API
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) { MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); if (methodBinding != null) { if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) { return methodBinding; int compatibleIndex = 0; for (int i = 0, length = methods.length; i < length; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite, Scope.APPLICABILITY); if (compatibleMethod != null) compatible[compatibleIndex++] = compatibleMethod; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) { visible[visibleIndex++] = method; return inferInvocationType(invocationSite, visible[0], argumentTypes); return mostSpecificClassMethodBinding(visible, visibleIndex, invocationSite);
public Binding getBinding(char[][] compoundName, int mask, InvocationSite invocationSite, ReferenceBinding receiverType) { Binding binding = getBinding(compoundName[0], mask | Binding.TYPE | Binding.PACKAGE, invocationSite, true /*resolve*/); invocationSite.setFieldIndex(1); if (!binding.isValidBinding() || binding instanceof VariableBinding) (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!this.canBeSeenByForCodeSnippet((ReferenceBinding) binding, receiverType)) return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), (ReferenceBinding) binding, ProblemReasons.NotVisible); break foundType; char[] nextName = compoundName[currentIndex++]; invocationSite.setFieldIndex(currentIndex); if ((binding = findFieldForCodeSnippet(typeBinding, nextName, invocationSite)) != null) { if (!binding.isValidBinding()) { return new ProblemFieldBinding( if ((binding = findMemberType(nextName, typeBinding)) == null) return new ProblemBinding(CharOperation.subarray(compoundName, 0, currentIndex), typeBinding, ProblemReasons.NotFound); if (!binding.isValidBinding())
if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) { CodeSnippetScope localScope = new CodeSnippetScope(scope); this.binding = localScope.getFieldForCodeSnippet(this.delegateThis.type, this.token, this); return checkFieldAccess(scope); } else {
if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) { CodeSnippetScope localScope = new CodeSnippetScope(scope); this.binding = localScope.getFieldForCodeSnippet(this.delegateThis.type, this.tokens[0], this); if (this.binding.isValidBinding()) { return checkFieldAccess(scope); CodeSnippetScope localScope = new CodeSnippetScope(scope); if ((this.binding = localScope.getBinding(this.tokens, this.bits & RestrictiveFlagMASK, this, (ReferenceBinding) this.delegateThis.type)).isValidBinding()) { this.bits &= ~RestrictiveFlagMASK; // clear bits this.bits |= Binding.FIELD;
return null; CodeSnippetScope localScope = new CodeSnippetScope(scope); MethodBinding privateBinding = this.receiver instanceof CodeSnippetThisReference && ((CodeSnippetThisReference) this.receiver).isImplicit ? localScope.getImplicitMethod((ReferenceBinding)this.delegateThis.type, this.selector, argumentTypes, this) : localScope.getMethod(this.delegateThis.type, this.selector, argumentTypes, this); if (!privateBinding.isValidBinding()) { if (this.binding.declaringClass == null) {
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) { MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); if (methodBinding != null) { if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) { return methodBinding; int compatibleIndex = 0; for (int i = 0, length = methods.length; i < length; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite); if (compatibleMethod != null) compatible[compatibleIndex++] = compatibleMethod; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) { visible[visibleIndex++] = method; return new ProblemMethodBinding(compatible[0], TypeConstants.INIT, compatible[0].parameters, ProblemReasons.NotVisible); return mostSpecificClassMethodBinding(visible, visibleIndex, invocationSite);
return this.resolvedType; CodeSnippetScope localScope = new CodeSnippetScope(scope); MethodBinding privateBinding = localScope.getConstructor((ReferenceBinding)this.delegateThis.type, argumentTypes, this); if (!privateBinding.isValidBinding()) { if (this.binding.declaringClass == null) {
public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, null); if (exactMethod != null){ if (receiverType.isInterface() || canBeSeenByForCodeSnippet(exactMethod, receiverType, invocationSite, this)) return exactMethod; } return null; } // Internal use only
public Binding getBinding(char[][] compoundName, int mask, InvocationSite invocationSite, ReferenceBinding receiverType) { Binding binding = getBinding(compoundName[0], mask | Binding.TYPE | Binding.PACKAGE, invocationSite, true /*resolve*/); invocationSite.setFieldIndex(1); if (!binding.isValidBinding() || binding instanceof VariableBinding) (ReferenceBinding)((ReferenceBinding)binding).closestMatch(), binding.problemId()); if (!this.canBeSeenByForCodeSnippet((ReferenceBinding) binding, receiverType)) return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), (ReferenceBinding) binding, ProblemReasons.NotVisible); break foundType; char[] nextName = compoundName[currentIndex++]; invocationSite.setFieldIndex(currentIndex); if ((binding = findFieldForCodeSnippet(typeBinding, nextName, invocationSite)) != null) { if (!binding.isValidBinding()) { return new ProblemFieldBinding( if ((binding = findMemberType(nextName, typeBinding)) == null) return new ProblemBinding(CharOperation.subarray(compoundName, 0, currentIndex), typeBinding, ProblemReasons.NotFound); if (!binding.isValidBinding())
if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) { CodeSnippetScope localScope = new CodeSnippetScope(scope); this.binding = localScope.getFieldForCodeSnippet(this.delegateThis.type, this.token, this); return checkFieldAccess(scope); } else {
if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) { CodeSnippetScope localScope = new CodeSnippetScope(scope); this.binding = localScope.getFieldForCodeSnippet(this.delegateThis.type, this.tokens[0], this); if (this.binding.isValidBinding()) { return checkFieldAccess(scope); CodeSnippetScope localScope = new CodeSnippetScope(scope); if ((this.binding = localScope.getBinding(this.tokens, this.bits & RestrictiveFlagMASK, this, (ReferenceBinding) this.delegateThis.type)).isValidBinding()) { this.bits &= ~RestrictiveFlagMASK; // clear bits this.bits |= Binding.FIELD;
return null; CodeSnippetScope localScope = new CodeSnippetScope(scope); MethodBinding privateBinding = this.receiver instanceof CodeSnippetThisReference && ((CodeSnippetThisReference) this.receiver).isImplicit ? localScope.getImplicitMethod((ReferenceBinding)this.delegateThis.type, this.selector, this.argumentTypes, this) : localScope.getMethod(this.delegateThis.type, this.selector, this.argumentTypes, this); if (!privateBinding.isValidBinding()) { if (this.binding.declaringClass == null) {
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) { MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); if (methodBinding != null) { if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) { return methodBinding; int compatibleIndex = 0; for (int i = 0, length = methods.length; i < length; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite); if (compatibleMethod != null) compatible[compatibleIndex++] = compatibleMethod; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) { visible[visibleIndex++] = method; return new ProblemMethodBinding(compatible[0], TypeConstants.INIT, compatible[0].parameters, ProblemReasons.NotVisible); return mostSpecificClassMethodBinding(visible, visibleIndex, invocationSite);
return this.resolvedType; CodeSnippetScope localScope = new CodeSnippetScope(scope); MethodBinding privateBinding = localScope.getConstructor((ReferenceBinding)this.delegateThis.type, this.argumentTypes, this); if (!privateBinding.isValidBinding()) { if (this.binding.declaringClass == null) {
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) { MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); if (methodBinding != null) { if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) { return methodBinding; int compatibleIndex = 0; for (int i = 0, length = methods.length; i < length; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite, Scope.APPLICABILITY); if (compatibleMethod != null) compatible[compatibleIndex++] = compatibleMethod; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) { visible[visibleIndex++] = method; return inferInvocationType(invocationSite, visible[0], argumentTypes); return mostSpecificClassMethodBinding(visible, visibleIndex, invocationSite);
public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) { MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, null); if (exactMethod != null){ if (receiverType.isInterface() || canBeSeenByForCodeSnippet(exactMethod, receiverType, invocationSite, this)) return exactMethod; } return null; } // Internal use only
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; } /* API