Refactor Java resolver components
- Move components from LazyJavaResolverContext to JavaResolverComponents - Drop LazyJavaClassResolver replacing it's usages with module resolver (now enum entries from another module as annotation arguments are being resolved, see test)
This commit is contained in:
+1
-1
@@ -7,5 +7,5 @@ public class KotlinA: AClass() {
|
||||
|
||||
fun paramA(p: AClass) {}
|
||||
|
||||
@AAnnotation fun annoA() {}
|
||||
@AAnnotation(AEnum.AX) fun annoA() {}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package custom;
|
||||
|
||||
public @interface AAnnotation {
|
||||
|
||||
AEnum value();
|
||||
}
|
||||
@@ -3,6 +3,6 @@ package custom;
|
||||
public class AClass {
|
||||
public AClass returnA() {}
|
||||
public void paramA(AClass a) {}
|
||||
@AAnnotation
|
||||
@AAnnotation(AEnum.AX)
|
||||
public void annoA() {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package custom;
|
||||
|
||||
public enum AEnum {
|
||||
AX;
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ public class KotlinB: AClass() {
|
||||
|
||||
public fun returnB(): BClass { }
|
||||
|
||||
@AAnnotation fun annoA() {}
|
||||
@AAnnotation(AEnum.AX) fun annoA() {}
|
||||
|
||||
@BAnnotation fun annoB() {}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package custom;
|
||||
public class BClass extends AClass {
|
||||
public AClass returnA() {}
|
||||
public void paramA(AClass a) {}
|
||||
@AAnnotation
|
||||
@AAnnotation(AEnum.AX)
|
||||
public void annoA() {}
|
||||
public BClass returnB() {}
|
||||
public void paramB(BClass b) {}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public class KotlinC: AClass() {
|
||||
|
||||
public fun returnB(): BClass { }
|
||||
|
||||
@AAnnotation fun annoA() {}
|
||||
@AAnnotation(AEnum.AX) fun annoA() {}
|
||||
|
||||
@BAnnotation fun annoB() {}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package custom;
|
||||
public class CClass extends BClass {
|
||||
public AClass returnA() {}
|
||||
public void paramA(AClass a) {}
|
||||
@AAnnotation
|
||||
@AAnnotation(AEnum.AX)
|
||||
public void annoA() {}
|
||||
public BClass returnB() {}
|
||||
public void paramB(BClass b) {}
|
||||
|
||||
+18
-4
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.JvmBuiltIns
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmAnalyzerFacade
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmPlatformParameters
|
||||
@@ -85,7 +86,7 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
|
||||
val configuration = KotlinTestUtils.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, emptyList(), moduleDirs.toList()
|
||||
)
|
||||
return KotlinCoreEnvironment.createForTests(testRootDisposable!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
}
|
||||
|
||||
private fun setupModules(environment: KotlinCoreEnvironment, moduleDirs: Array<File>): List<TestModule> {
|
||||
@@ -151,9 +152,22 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
|
||||
it.type.constructor.declarationDescriptor!!
|
||||
}.forEach { checkDescriptor(it, callable) }
|
||||
|
||||
callable.annotations.map {
|
||||
it.type.constructor.declarationDescriptor!!
|
||||
}.forEach { checkDescriptor(it, callable) }
|
||||
callable.annotations.forEach {
|
||||
val annotationClassDescriptor = it.type.constructor.declarationDescriptor as ClassDescriptor
|
||||
checkDescriptor(annotationClassDescriptor, callable)
|
||||
|
||||
Assert.assertEquals(
|
||||
"Annotation value arguments number is not equal to number of parameters in $callable",
|
||||
annotationClassDescriptor.constructors.single().valueParameters.size, it.allValueArguments.size)
|
||||
|
||||
it.allValueArguments.forEach {
|
||||
val argument = it.value
|
||||
if (argument is EnumValue) {
|
||||
Assert.assertEquals("Enum entry name should be <module-name>X", "X", argument.value.name.identifier.last().toString())
|
||||
checkDescriptor(argument.value, callable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkSupertypes(classDescriptor: ClassDescriptor) {
|
||||
|
||||
Reference in New Issue
Block a user