Made StandardLibraryReferenceResolver aware of class objects in built-ins.

This commit is contained in:
Evgeny Gerashchenko
2012-08-09 17:41:41 +04:00
parent b359592fd1
commit 592f01ed74
3 changed files with 16 additions and 2 deletions
@@ -117,15 +117,23 @@ public class StandardLibraryReferenceResolver extends AbstractProjectComponent {
@Nullable @Nullable
private DeclarationDescriptor findCurrentDescriptor(@NotNull DeclarationDescriptor originalDescriptor) { private DeclarationDescriptor findCurrentDescriptor(@NotNull DeclarationDescriptor originalDescriptor) {
DeclarationDescriptor parent = originalDescriptor.getContainingDeclaration();
if (originalDescriptor instanceof ClassDescriptor) { if (originalDescriptor instanceof ClassDescriptor) {
return bindingContext.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFQName(originalDescriptor).toSafe()); if (((ClassDescriptor) originalDescriptor).getKind() == ClassKind.OBJECT) {
if (parent == null) return null;
parent = findCurrentDescriptor(parent);
if (parent == null) return null;
return ((ClassDescriptor) parent).getClassObjectDescriptor();
}
else {
return bindingContext.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFQName(originalDescriptor).toSafe());
}
} }
else if (originalDescriptor instanceof NamespaceDescriptor) { else if (originalDescriptor instanceof NamespaceDescriptor) {
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR,
DescriptorUtils.getFQName(originalDescriptor).toSafe()); DescriptorUtils.getFQName(originalDescriptor).toSafe());
} }
else { else {
DeclarationDescriptor parent = originalDescriptor.getContainingDeclaration();
if (parent == null) return null; if (parent == null) return null;
parent = findCurrentDescriptor(parent); parent = findCurrentDescriptor(parent);
JetScope memberScope; JetScope memberScope;
+2
View File
@@ -0,0 +1,2 @@
val empty = IntRange.<ref>EMPTY
//jet/Ranges.jet:EMPTY
@@ -67,6 +67,10 @@ public class StandardLibraryReferenceResolverTest extends ResolveTestCase {
doTest(); doTest();
} }
public void testEmptyRange() throws Exception {
doTest();
}
public void testAllReferencesResolved() { public void testAllReferencesResolved() {
StandardLibraryReferenceResolver referenceResolver = getProject().getComponent(StandardLibraryReferenceResolver.class); StandardLibraryReferenceResolver referenceResolver = getProject().getComponent(StandardLibraryReferenceResolver.class);
for (DeclarationDescriptor descriptor : getAllStandardDescriptors(JetStandardClasses.STANDARD_CLASSES_NAMESPACE)) { for (DeclarationDescriptor descriptor : getAllStandardDescriptors(JetStandardClasses.STANDARD_CLASSES_NAMESPACE)) {