Lines 2712-2717
Link Here
|
2712 |
} |
2712 |
} |
2713 |
} |
2713 |
} |
2714 |
} |
2714 |
} |
|
|
2715 |
// walk single static imports. A type found here will shadow types with same name in other CU's, or types coming |
2716 |
// from on-demand imports. JLS 7.5.3 |
2717 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318401 |
2718 |
if (imports != null) { |
2719 |
boolean foundInImport = false; |
2720 |
ReferenceBinding type = null; |
2721 |
nextImport : for (int i = 0, length = imports.length; i < length; i++) { |
2722 |
ImportBinding importBinding = imports[i]; |
2723 |
if (importBinding.isStatic()) { |
2724 |
ReferenceBinding temp = null; |
2725 |
if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) { |
2726 |
Binding resolvedImport = importBinding.resolvedImport; |
2727 |
if (resolvedImport == null) continue nextImport; |
2728 |
if (resolvedImport instanceof MethodBinding) { |
2729 |
// check to see if there are also member types with the same name |
2730 |
MethodBinding staticMethod = (MethodBinding) resolvedImport; |
2731 |
if (CharOperation.equals(staticMethod.selector, name)) { |
2732 |
// must find the importRef's type again since the field can be from an inherited type |
2733 |
char[][] importName = importBinding.reference.tokens; |
2734 |
TypeBinding referencedType = getType(importName, importName.length - 1); |
2735 |
if (referencedType != null) { |
2736 |
temp = findMemberType(name, staticMethod.declaringClass); |
2737 |
if (temp != null && !temp.isStatic()) temp = null; |
2738 |
} |
2739 |
} |
2740 |
} else if (resolvedImport instanceof FieldBinding) { |
2741 |
// check to see if there are also member types with the same name |
2742 |
FieldBinding staticField = (FieldBinding) resolvedImport; |
2743 |
if (CharOperation.equals(staticField.name, name)) { |
2744 |
// must find the importRef's type again since the field can be from an inherited type |
2745 |
char[][] importName = importBinding.reference.tokens; |
2746 |
TypeBinding referencedType = getType(importName, importName.length - 1); |
2747 |
if (referencedType != null) { |
2748 |
temp = findMemberType(name, staticField.declaringClass); |
2749 |
if (temp != null && !temp.isStatic()) temp = null; |
2750 |
} |
2751 |
} |
2752 |
} |
2753 |
if (temp != type && temp != null) { |
2754 |
if (temp.isValidBinding()) { |
2755 |
if (!temp.canBeSeenBy(unitScope.fPackage)) { |
2756 |
// Answer error binding - type is not visible |
2757 |
foundType = new ProblemReferenceBinding(new char[][]{name}, type, ProblemReasons.NotVisible); |
2758 |
} else { |
2759 |
ImportReference importReference = importBinding.reference; |
2760 |
if (importReference != null) { |
2761 |
importReference.bits |= ASTNode.Used; |
2762 |
} |
2763 |
if (foundInImport) { |
2764 |
// Answer error binding -- import on demand conflict; name found in two import on demand packages. |
2765 |
temp = new ProblemReferenceBinding(new char[][]{name}, type, ProblemReasons.Ambiguous); |
2766 |
if (typeOrPackageCache != null) |
2767 |
typeOrPackageCache.put(name, temp); |
2768 |
return temp; |
2769 |
} |
2770 |
type = temp; |
2771 |
foundInImport = true; |
2772 |
} |
2773 |
} else if (foundType == null) { |
2774 |
foundType = temp; |
2775 |
} |
2776 |
} |
2777 |
} |
2778 |
} |
2779 |
} |
2780 |
if (type != null) { |
2781 |
if (typeOrPackageCache != null) |
2782 |
typeOrPackageCache.put(name, type); |
2783 |
return type; |
2784 |
} |
2785 |
} |
2715 |
|
2786 |
|
2716 |
// check if the name is in the current package, skip it if its a sub-package |
2787 |
// check if the name is in the current package, skip it if its a sub-package |
2717 |
PackageBinding currentPackage = unitScope.fPackage; |
2788 |
PackageBinding currentPackage = unitScope.fPackage; |