Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 606-621
Link Here
|
606 |
} |
606 |
} |
607 |
|
607 |
|
608 |
// declaring type |
608 |
// declaring type |
609 |
char[] qualifiedPattern = qualifiedPattern(this.pattern.declaringSimpleName, this.pattern.declaringQualification); |
609 |
if (this.pattern.declaringSimpleName == null && this.pattern.declaringQualification == null) return methodLevel; // since any declaring class will do |
610 |
if (qualifiedPattern == null) return methodLevel; // since any declaring class will do |
|
|
611 |
|
610 |
|
612 |
boolean subType = !method.isStatic() && !method.isPrivate(); |
611 |
boolean subType = !method.isStatic() && !method.isPrivate(); |
613 |
if (subType && this.pattern.declaringQualification != null && method.declaringClass != null && method.declaringClass.fPackage != null) { |
612 |
if (subType && this.pattern.declaringQualification != null && method.declaringClass != null && method.declaringClass.fPackage != null) { |
614 |
subType = CharOperation.compareWith(this.pattern.declaringQualification, method.declaringClass.fPackage.shortReadableName()) == 0; |
613 |
subType = CharOperation.compareWith(this.pattern.declaringQualification, method.declaringClass.fPackage.shortReadableName()) == 0; |
615 |
} |
614 |
} |
616 |
int declaringLevel = subType |
615 |
int declaringLevel = subType |
617 |
? resolveLevelAsSubtype(qualifiedPattern, method.declaringClass, null) |
616 |
? resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass, null) |
618 |
: resolveLevelForType(qualifiedPattern, method.declaringClass); |
617 |
: resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass); |
619 |
return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel : methodLevel; // return the weaker match |
618 |
return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel : methodLevel; // return the weaker match |
620 |
} |
619 |
} |
621 |
protected int resolveLevel(MessageSend messageSend) { |
620 |
protected int resolveLevel(MessageSend messageSend) { |
Lines 642-654
Link Here
|
642 |
} |
641 |
} |
643 |
|
642 |
|
644 |
// receiver type |
643 |
// receiver type |
645 |
char[] qualifiedPattern = qualifiedPattern(this.pattern.declaringSimpleName, this.pattern.declaringQualification); |
644 |
if (this.pattern.declaringSimpleName == null && this.pattern.declaringQualification == null) return methodLevel; // since any declaring class will do |
646 |
if (qualifiedPattern == null) return methodLevel; // since any declaring class will do |
|
|
647 |
|
645 |
|
648 |
int declaringLevel; |
646 |
int declaringLevel; |
649 |
if (isVirtualInvoke(method, messageSend) && (messageSend.actualReceiverType instanceof ReferenceBinding)) { |
647 |
if (isVirtualInvoke(method, messageSend) && (messageSend.actualReceiverType instanceof ReferenceBinding)) { |
650 |
ReferenceBinding methodReceiverType = (ReferenceBinding) messageSend.actualReceiverType; |
648 |
ReferenceBinding methodReceiverType = (ReferenceBinding) messageSend.actualReceiverType; |
651 |
declaringLevel = resolveLevelAsSubtype(qualifiedPattern, methodReceiverType, method.parameters); |
649 |
declaringLevel = resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification, methodReceiverType, method.parameters); |
652 |
if (declaringLevel == IMPOSSIBLE_MATCH) { |
650 |
if (declaringLevel == IMPOSSIBLE_MATCH) { |
653 |
if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) { |
651 |
if (method.declaringClass == null || this.allSuperDeclaringTypeNames == null) { |
654 |
declaringLevel = INACCURATE_MATCH; |
652 |
declaringLevel = INACCURATE_MATCH; |
Lines 664-670
Link Here
|
664 |
return declaringLevel; |
662 |
return declaringLevel; |
665 |
} |
663 |
} |
666 |
} else { |
664 |
} else { |
667 |
declaringLevel = resolveLevelForType(qualifiedPattern, method.declaringClass); |
665 |
declaringLevel = resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass); |
668 |
} |
666 |
} |
669 |
return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel : methodLevel; // return the weaker match |
667 |
return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel : methodLevel; // return the weaker match |
670 |
} |
668 |
} |
Lines 676-685
Link Here
|
676 |
* Returns INACCURATE_MATCH if resolve fails |
674 |
* Returns INACCURATE_MATCH if resolve fails |
677 |
* Returns IMPOSSIBLE_MATCH if it doesn't. |
675 |
* Returns IMPOSSIBLE_MATCH if it doesn't. |
678 |
*/ |
676 |
*/ |
679 |
protected int resolveLevelAsSubtype(char[] qualifiedPattern, ReferenceBinding type, TypeBinding[] argumentTypes) { |
677 |
protected int resolveLevelAsSubtype(char[] simplePattern, char[] qualifiedPattern, ReferenceBinding type, TypeBinding[] argumentTypes) { |
680 |
if (type == null) return INACCURATE_MATCH; |
678 |
if (type == null) return INACCURATE_MATCH; |
681 |
|
679 |
|
682 |
int level = resolveLevelForType(qualifiedPattern, type); |
680 |
int level = resolveLevelForType(simplePattern, qualifiedPattern, type); |
683 |
if (level != IMPOSSIBLE_MATCH) { |
681 |
if (level != IMPOSSIBLE_MATCH) { |
684 |
MethodBinding method = argumentTypes == null ? null : getMethodBinding(type, argumentTypes); |
682 |
MethodBinding method = argumentTypes == null ? null : getMethodBinding(type, argumentTypes); |
685 |
if (((method != null && !method.isAbstract()) || !type.isAbstract()) && !type.isInterface()) { // if concrete, then method is overridden |
683 |
if (((method != null && !method.isAbstract()) || !type.isAbstract()) && !type.isInterface()) { // if concrete, then method is overridden |
Lines 690-696
Link Here
|
690 |
|
688 |
|
691 |
// matches superclass |
689 |
// matches superclass |
692 |
if (!type.isInterface() && !CharOperation.equals(type.compoundName, TypeConstants.JAVA_LANG_OBJECT)) { |
690 |
if (!type.isInterface() && !CharOperation.equals(type.compoundName, TypeConstants.JAVA_LANG_OBJECT)) { |
693 |
level = resolveLevelAsSubtype(qualifiedPattern, type.superclass(), argumentTypes); |
691 |
level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, type.superclass(), argumentTypes); |
694 |
if (level != IMPOSSIBLE_MATCH) { |
692 |
if (level != IMPOSSIBLE_MATCH) { |
695 |
if (argumentTypes != null) { |
693 |
if (argumentTypes != null) { |
696 |
// need to verify if method may be overridden |
694 |
// need to verify if method may be overridden |
Lines 714-720
Link Here
|
714 |
ReferenceBinding[] interfaces = type.superInterfaces(); |
712 |
ReferenceBinding[] interfaces = type.superInterfaces(); |
715 |
if (interfaces == null) return INACCURATE_MATCH; |
713 |
if (interfaces == null) return INACCURATE_MATCH; |
716 |
for (int i = 0; i < interfaces.length; i++) { |
714 |
for (int i = 0; i < interfaces.length; i++) { |
717 |
level = resolveLevelAsSubtype(qualifiedPattern, interfaces[i], null); |
715 |
level = resolveLevelAsSubtype(simplePattern, qualifiedPattern, interfaces[i], null); |
718 |
if (level != IMPOSSIBLE_MATCH) { |
716 |
if (level != IMPOSSIBLE_MATCH) { |
719 |
if (!type.isAbstract() && !type.isInterface()) { // if concrete class, then method is overridden |
717 |
if (!type.isAbstract() && !type.isInterface()) { // if concrete class, then method is overridden |
720 |
level |= OVERRIDDEN_METHOD_FLAVOR; |
718 |
level |= OVERRIDDEN_METHOD_FLAVOR; |