Loading deeply nested static method correctly.

This commit is contained in:
Evgeny Gerashchenko
2013-03-21 23:35:21 +04:00
parent 81381a206c
commit 17cc055152
4 changed files with 56 additions and 0 deletions
@@ -16,15 +16,23 @@
package org.jetbrains.jet.lang.resolve.java.scope;
import com.intellij.psi.PsiClass;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
import org.jetbrains.jet.lang.resolve.java.JavaSemanticServices;
import org.jetbrains.jet.lang.resolve.java.provider.ClassPsiDeclarationProvider;
import org.jetbrains.jet.lang.resolve.java.provider.PackagePsiDeclarationProvider;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import java.util.Collection;
import static org.jetbrains.jet.lang.resolve.java.scope.ScopeUtils.computeAllPackageDeclarations;
public final class JavaClassStaticMembersScope extends JavaClassMembersScope {
@NotNull
private final FqName packageFQN;
@@ -43,4 +51,14 @@ public final class JavaClassStaticMembersScope extends JavaClassMembersScope {
public NamespaceDescriptor getNamespace(@NotNull Name name) {
return getResolver().resolveNamespace(packageFQN.child(name), DescriptorSearchRule.INCLUDE_KOTLIN);
}
@NotNull
@Override
protected Collection<DeclarationDescriptor> computeAllDescriptors() {
Collection<DeclarationDescriptor> result = super.computeAllDescriptors();
for (PsiClass nested : declarationProvider.getPsiClass().getInnerClasses()) {
ContainerUtil.addIfNotNull(result, getNamespace(Name.identifier(nested.getName())));
}
return result;
}
}
@@ -0,0 +1,10 @@
package test;
public class DeeplyNestedStatic {
public static class Foo {
public static class Bar {
public static void method() {
}
}
}
}
@@ -0,0 +1,23 @@
package test
public open class DeeplyNestedStatic : java.lang.Object {
public constructor DeeplyNestedStatic()
public open class Foo : java.lang.Object {
public constructor Foo()
public open class Bar : java.lang.Object {
public constructor Bar()
}
}
}
package DeeplyNestedStatic {
package Foo {
package Bar {
public open fun method() : jet.Unit
}
}
}
@@ -1177,6 +1177,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
public void testDeeplyInnerClass() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/static/DeeplyInnerClass.java");
}
@TestMetadata("DeeplyNestedStatic.java")
public void testDeeplyNestedStatic() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/static/DeeplyNestedStatic.java");
}
@TestMetadata("Enum.java")
public void testEnum() throws Exception {