FIR IDE: restore FirLazyDeclarationResolveTest

This commit is contained in:
Ilya Kirillov
2021-06-21 16:42:01 +02:00
committed by TeamCityServer
parent c70629c22a
commit 61651c685c
7 changed files with 322 additions and 212 deletions
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByFqName
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByPsiTest import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByPsiTest
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByReferenceTest import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByReferenceTest
import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyBodiesCalculatorTest import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyBodiesCalculatorTest
//import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyDeclarationResolveTest import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyDeclarationResolveTest
import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirOnAirResolveTest import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirOnAirResolveTest
import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractPartialRawFirBuilderTestCase import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractPartialRawFirBuilderTestCase
import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostic.AbstractDiagnosticTraversalCounterTest import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostic.AbstractDiagnosticTraversalCounterTest
@@ -90,9 +90,10 @@ fun main(args: Array<String>) {
testClass<AbstractFirOnAirResolveTest> { testClass<AbstractFirOnAirResolveTest> {
model("onAirResolve") model("onAirResolve")
} }
// testClass<AbstractFirLazyDeclarationResolveTest> {
// model("lazyResolve") testClass<AbstractFirLazyDeclarationResolveTest> {
// } model("lazyResolve")
}
testClass<AbstractFileStructureTest> { testClass<AbstractFileStructureTest> {
model("fileStructure") model("fileStructure")
@@ -32,6 +32,26 @@ dependencies {
testCompile(project(":kotlin-test:kotlin-test-junit")) testCompile(project(":kotlin-test:kotlin-test-junit"))
testApiJUnit5() testApiJUnit5()
testCompile(project(":kotlin-reflect")) testCompile(project(":kotlin-reflect"))
testRuntimeOnly(intellijDep()) {
includeJars(
"jps-model",
"extensions",
"util",
"platform-api",
"platform-impl",
"idea",
"guava",
"trove4j",
"asm-all",
"log4j",
"jdom",
"streamex",
"bootstrap",
"jna",
rootProject = rootProject
)
}
} }
sourceSets { sourceSets {
@@ -1,3 +1,4 @@
RAW_FIR: RAW_FIR:
FILE: delegates.kt FILE: delegates.kt
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| {
@@ -632,28 +633,28 @@ FILE: delegates.kt
} }
public final [STATUS] [ResolvePhaseWithForAllDeclarationsKey=STATUS] fun receive([STATUS] value: R|kotlin/Int|): R|kotlin/Unit| { public final [STATUS] [ResolvePhaseWithForAllDeclarationsKey=STATUS] fun receive([STATUS] value: R|kotlin/Int|): R|kotlin/Unit| {
} }
public final [BODY_RESOLVE] [ResolvePhaseWithForAllDeclarationsKey=STATUS] val delegate: <ERROR TYPE REF: Symbol not found for ReadWriteProperty<R|kotlin/Any?|, R|kotlin/Int|>> = object : <ERROR TYPE REF: Symbol not found for ReadWriteProperty<R|kotlin/Any?|, R|kotlin/Int|>> { public final [BODY_RESOLVE] [ResolvePhaseWithForAllDeclarationsKey=STATUS] val delegate: R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>| = object : R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>| {
private [BODY_RESOLVE] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [BODY_RESOLVE] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
public final override [BODY_RESOLVE] fun getValue([BODY_RESOLVE] thisRef: R|kotlin/Any?|, [BODY_RESOLVE] property: R|kotlin/reflect/KProperty<*>|): R|kotlin/Int| { public final override operator [BODY_RESOLVE] fun getValue([BODY_RESOLVE] thisRef: R|kotlin/Any?|, [BODY_RESOLVE] property: R|kotlin/reflect/KProperty<*>|): R|kotlin/Int| {
^getValue Int(1) ^getValue Int(1)
} }
public final override [BODY_RESOLVE] fun setValue([BODY_RESOLVE] thisRef: R|kotlin/Any?|, [BODY_RESOLVE] property: R|kotlin/reflect/KProperty<*>|, [BODY_RESOLVE] value: R|kotlin/Int|): R|kotlin/Unit| { public final override operator [BODY_RESOLVE] fun setValue([BODY_RESOLVE] thisRef: R|kotlin/Any?|, [BODY_RESOLVE] property: R|kotlin/reflect/KProperty<*>|, [BODY_RESOLVE] value: R|kotlin/Int|): R|kotlin/Unit| {
} }
} }
[BODY_RESOLVE] public get(): <ERROR TYPE REF: Symbol not found for ReadWriteProperty<R|kotlin/Any?|, R|kotlin/Int|>> [BODY_RESOLVE] public get(): R|kotlin/properties/ReadWriteProperty<kotlin/Any?, kotlin/Int>|
public final [STATUS] [ResolvePhaseWithForAllDeclarationsKey=STATUS] val valueWithExplicitType: R|kotlin/Int|by delegate# public final [STATUS] [ResolvePhaseWithForAllDeclarationsKey=STATUS] val valueWithExplicitType: R|kotlin/Int|by delegate#
[STATUS] public get(): <implicit> { [STATUS] public get(): <implicit> {
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|) ^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
} }
public final [BODY_RESOLVE] [ResolvePhaseWithForAllDeclarationsKey=STATUS] val valueWithImplicitType: <ERROR TYPE REF: Unresolved name: getValue>by R|/delegate| public final [BODY_RESOLVE] [ResolvePhaseWithForAllDeclarationsKey=STATUS] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
[BODY_RESOLVE] public get(): <ERROR TYPE REF: Unresolved name: getValue> { [BODY_RESOLVE] public get(): R|kotlin/Int| {
^ D|/valueWithImplicitType|.<Unresolved name: getValue>#(Null(null), ::R|/valueWithImplicitType|) ^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
} }
public final [STATUS] [ResolvePhaseWithForAllDeclarationsKey=STATUS] var variableWithExplicitType: R|kotlin/Int|by delegate# public final [STATUS] [ResolvePhaseWithForAllDeclarationsKey=STATUS] var variableWithExplicitType: R|kotlin/Int|by delegate#
[STATUS] public get(): <implicit> { [STATUS] public get(): <implicit> {
@@ -902,10 +903,10 @@ FILE: delegates.kt
[BODY_RESOLVE] public set([BODY_RESOLVE] <set-?>: R|kotlin/Int|): R|kotlin/Unit| { [BODY_RESOLVE] public set([BODY_RESOLVE] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
D|/variableWithExplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|) D|/variableWithExplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|)
} }
public final [BODY_RESOLVE] [ResolvePhaseWithForAllDeclarationsKey=BODY_RESOLVE] var variableWithImplicitType: <ERROR TYPE REF: Unresolved name: getValue>by R|/delegate| public final [BODY_RESOLVE] [ResolvePhaseWithForAllDeclarationsKey=BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
[BODY_RESOLVE] public get(): <ERROR TYPE REF: Unresolved name: getValue> { [BODY_RESOLVE] public get(): R|kotlin/Int| {
^ D|/variableWithImplicitType|.<Unresolved name: getValue>#(Null(null), ::R|/variableWithImplicitType|) ^ D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/variableWithImplicitType|)
} }
[BODY_RESOLVE] public set([BODY_RESOLVE] <set-?>: <ERROR TYPE REF: Unresolved name: getValue>): R|kotlin/Unit| { [BODY_RESOLVE] public set([BODY_RESOLVE] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
D|/variableWithImplicitType|.<Unresolved name: setValue>#(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|) D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|)
} }
@@ -1,112 +1,110 @@
///* /*
// * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
// * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
// */ */
//
//package org.jetbrains.kotlin.idea.fir.low.level.api package org.jetbrains.kotlin.idea.fir.low.level.api
//
//import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.fir.*
//import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.kotlin.fir.declarations.*
//import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
//import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.idea.fir.low.level.api.api.withFirDeclaration
//import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveType
//import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo import org.jetbrains.kotlin.idea.fir.low.level.api.test.base.AbstractLowLevelApiSingleFileTest
//import org.jetbrains.kotlin.idea.caches.project.getModuleInfo import org.jetbrains.kotlin.psi.KtDeclaration
//import org.jetbrains.kotlin.idea.fir.low.level.api.api.withFirDeclaration import org.jetbrains.kotlin.psi.KtFile
//import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
//import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveType import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
//import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.declarationCanBeLazilyResolved import org.jetbrains.kotlin.test.services.TestModuleStructure
//import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.test.services.TestServices
//import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor import org.jetbrains.kotlin.test.services.assertions
//import org.jetbrains.kotlin.psi.KtCallableDeclaration import org.junit.jupiter.api.parallel.Execution
//import org.jetbrains.kotlin.psi.KtClassOrObject import org.junit.jupiter.api.parallel.ExecutionMode
//import org.jetbrains.kotlin.psi.KtDeclaration
//import org.jetbrains.kotlin.psi.KtFile /**
//import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType * Test that we do not resolve declarations we do not need & do not build bodies for them
//import org.jetbrains.kotlin.test.KotlinTestUtils */
//import java.io.File @Execution(ExecutionMode.SAME_THREAD)
// abstract class AbstractFirLazyDeclarationResolveTest : AbstractLowLevelApiSingleFileTest() {
///**
// * Test that we do not resolve declarations we do not need & do not build bodies for them private fun FirFile.findResolveMe(): FirDeclaration {
// */ val visitor = object : FirVisitorVoid() {
//abstract class AbstractFirLazyDeclarationResolveTest : KotlinLightCodeInsightFixtureTestCase() { var result: FirDeclaration? = null
// override fun isFirPlugin(): Boolean = true override fun visitElement(element: FirElement) {
// if (result != null) return
// private fun FirFile.findResolveMe(): FirDeclaration { val declaration = element.realPsi as? KtDeclaration
// val visitor = object : FirVisitorVoid() { if (element is FirDeclaration && declaration != null && declaration.name == "resolveMe") {
// var result: FirDeclaration? = null result = element
// override fun visitElement(element: FirElement) { return
// if (result != null) return }
// val declaration = element.realPsi as? KtDeclaration element.acceptChildren(this)
// if (element is FirDeclaration && declaration != null && declaration.name == "resolveMe") { }
// result = element
// return }
// } accept(visitor)
// element.acceptChildren(this) return visitor.result ?: error("declaration with name `resolveMe` was not found")
// } }
//
// } override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
// accept(visitor) val rendererOption = FirRenderer.RenderMode.WithDeclarationAttributes.copy(renderDeclarationResolvePhase = true)
// return visitor.result ?: error("declaration with name `resolveMe` was not found") val resultBuilder = StringBuilder()
// } resolveWithClearCaches(ktFile) { firModuleResolveState ->
// check(firModuleResolveState is FirModuleResolveStateImpl)
// val declarationToResolve = firModuleResolveState
// fun doTest(path: String) { .getOrBuildFirFile(ktFile)
// val testDataFile = File(path) .findResolveMe()
// val ktFile = myFixture.configureByText(testDataFile.name, FileUtil.loadFile(testDataFile)) as KtFile for (currentPhase in FirResolvePhase.values()) {
// val rendererOption = FirRenderer.RenderMode.WithDeclarationAttributes.copy(renderDeclarationResolvePhase = true) if (currentPhase.pluginPhase || currentPhase == FirResolvePhase.SEALED_CLASS_INHERITORS) continue
// val resultBuilder = StringBuilder() declarationToResolve.withFirDeclaration(firModuleResolveState, currentPhase) {
// resolveWithClearCaches(ktFile) { firModuleResolveState -> val firFile = firModuleResolveState.getOrBuildFirFile(ktFile)
// check(firModuleResolveState is FirModuleResolveStateImpl) resultBuilder.append("\n${currentPhase.name}:\n")
// val declarationToResolve = firModuleResolveState resultBuilder.append(firFile.render(rendererOption))
// .getOrBuildFirFile(ktFile) }
// .findResolveMe() }
// for (currentPhase in FirResolvePhase.values()) { }
// if (currentPhase.pluginPhase || currentPhase == FirResolvePhase.SEALED_CLASS_INHERITORS) continue
// declarationToResolve.withFirDeclaration(firModuleResolveState, currentPhase) { for (resolveType in ResolveType.values()) {
// val firFile = firModuleResolveState.getOrBuildFirFile(ktFile) resolveWithClearCaches(ktFile) { firModuleResolveState ->
// resultBuilder.append("\n${currentPhase.name}:\n") check(firModuleResolveState is FirModuleResolveStateImpl)
// resultBuilder.append(firFile.render(rendererOption)) val declarationToResolve = firModuleResolveState
// } .getOrBuildFirFile(ktFile)
// } .findResolveMe()
// }
// when (resolveType) {
// for (resolveType in ResolveType.values()) { ResolveType.CallableReturnType,
// resolveWithClearCaches(ktFile) { firModuleResolveState -> ResolveType.CallableBodyResolve,
// check(firModuleResolveState is FirModuleResolveStateImpl) ResolveType.CallableContracts -> if (declarationToResolve !is FirCallableDeclaration<*>) return@resolveWithClearCaches
// val declarationToResolve = firModuleResolveState ResolveType.ClassSuperTypes -> if (declarationToResolve !is FirClassLikeDeclaration<*>) return@resolveWithClearCaches
// .getOrBuildFirFile(ktFile) else -> {
// .findResolveMe() }
// }
// when (resolveType) {
// ResolveType.CallableReturnType, declarationToResolve.withFirDeclaration(resolveType, firModuleResolveState) {
// ResolveType.CallableBodyResolve, val firFile = firModuleResolveState.getOrBuildFirFile(ktFile)
// ResolveType.CallableContracts -> if (declarationToResolve !is FirCallableDeclaration<*>) return@resolveWithClearCaches resultBuilder.append("\n${resolveType.name}:\n")
// ResolveType.ClassSuperTypes -> if (declarationToResolve !is FirClassLikeDeclaration<*>) return@resolveWithClearCaches resultBuilder.append(firFile.render(rendererOption))
// else -> { }
// } }
// } }
//
// declarationToResolve.withFirDeclaration(resolveType, firModuleResolveState) { resolveWithClearCaches(ktFile) { firModuleResolveState ->
// val firFile = firModuleResolveState.getOrBuildFirFile(ktFile) check(firModuleResolveState is FirModuleResolveStateImpl)
// resultBuilder.append("\n${resolveType.name}:\n") val firFile = firModuleResolveState.getOrBuildFirFile(ktFile)
// resultBuilder.append(firFile.render(rendererOption)) firFile.withFirDeclaration(firModuleResolveState, FirResolvePhase.BODY_RESOLVE) {
// } resultBuilder.append("\nFILE RAW TO BODY:\n")
// } resultBuilder.append(firFile.render(rendererOption))
// } }
// }
// resolveWithClearCaches(ktFile) { firModuleResolveState ->
// check(firModuleResolveState is FirModuleResolveStateImpl) testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), resultBuilder.toString())
// val firFile = firModuleResolveState.getOrBuildFirFile(ktFile) }
// firFile.withFirDeclaration(firModuleResolveState, FirResolvePhase.BODY_RESOLVE) {
// resultBuilder.append("\nFILE RAW TO BODY:\n") override fun configureTest(builder: TestConfigurationBuilder) {
// resultBuilder.append(firFile.render(rendererOption)) super.configureTest(builder)
// } with(builder) {
// } defaultDirectives {
// +JvmEnvironmentConfigurationDirectives.WITH_STDLIB
// val expectedFileName = testDataFile.name.replace(".kt", ".txt") }
// KotlinTestUtils.assertEqualsToFile(testDataFile.parentFile.resolve(expectedFileName), resultBuilder.toString()) }
// } }
// }
// override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
//}
@@ -1,80 +1,146 @@
///* /*
// * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
// * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
// */ */
//
//package org.jetbrains.kotlin.idea.fir.low.level.api; package org.jetbrains.kotlin.idea.fir.low.level.api;
//
//import com.intellij.testFramework.TestDataPath; import com.intellij.testFramework.TestDataPath;
//import org.jetbrains.kotlin.test.util.KtTestUtil; import org.jetbrains.kotlin.test.util.KtTestUtil;
//import org.jetbrains.kotlin.test.TestMetadata; import org.jetbrains.kotlin.test.TestMetadata;
//import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
//import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
//
//import java.io.File; import java.io.File;
//import java.util.regex.Pattern; import java.util.regex.Pattern;
//
///** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */ /** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
//@SuppressWarnings("all") @SuppressWarnings("all")
//@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve") @TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve")
//@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
//public class FirLazyDeclarationResolveTestGenerated extends AbstractFirLazyDeclarationResolveTest { public class FirLazyDeclarationResolveTestGenerated extends AbstractFirLazyDeclarationResolveTest {
// @Test @Test
// public void testAllFilesPresentInLazyResolve() throws Exception { public void testAllFilesPresentInLazyResolve() throws Exception {
// KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve"), Pattern.compile("^(.+)\\.kt$"), null, true);
// } }
//
// @Test @Test
// @TestMetadata("classMembers.kt") @TestMetadata("annotations.kt")
// public void testClassMembers() throws Exception { public void testAnnotations() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/annotations.kt");
// } }
//
// @Test @Test
// @TestMetadata("delegates.kt") @TestMetadata("classMembers.kt")
// public void testDelegates() throws Exception { public void testClassMembers() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.kt");
// } }
//
// @Test @Test
// @TestMetadata("propertyWithGetter.kt") @TestMetadata("delegates.kt")
// public void testPropertyWithGetter() throws Exception { public void testDelegates() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.kt");
// } }
//
// @Test @Test
// @TestMetadata("propertyWithGetterAndSetter.kt") @TestMetadata("localDeclaration.kt")
// public void testPropertyWithGetterAndSetter() throws Exception { public void testLocalDeclaration() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/localDeclaration.kt");
// } }
//
// @Test @Test
// @TestMetadata("propertyWithInitializer.kt") @TestMetadata("localFunction.kt")
// public void testPropertyWithInitializer() throws Exception { public void testLocalFunction() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/localFunction.kt");
// } }
//
// @Test @Test
// @TestMetadata("secondaryConstructor.kt") @TestMetadata("parameterOfLocalSetter.kt")
// public void testSecondaryConstructor() throws Exception { public void testParameterOfLocalSetter() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/parameterOfLocalSetter.kt");
// } }
//
// @Test @Test
// @TestMetadata("topLevelFunctions.kt") @TestMetadata("parameterOfNonLocalSetter.kt")
// public void testTopLevelFunctions() throws Exception { public void testParameterOfNonLocalSetter() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/parameterOfNonLocalSetter.kt");
// } }
//
// @Test @Test
// @TestMetadata("topLevelFunctionsWithExpressionBodyAndExplicitType.kt") @TestMetadata("propertyWithGetter.kt")
// public void testTopLevelFunctionsWithExpressionBodyAndExplicitType() throws Exception { public void testPropertyWithGetter() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.kt");
// } }
//
// @Test @Test
// @TestMetadata("topLevelFunctionsWithImplicitType.kt") @TestMetadata("propertyWithGetterAndSetter.kt")
// public void testTopLevelFunctionsWithImplicitType() throws Exception { public void testPropertyWithGetterAndSetter() throws Exception {
// runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.kt"); runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.kt");
// } }
//}
@Test
@TestMetadata("propertyWithInitializer.kt")
public void testPropertyWithInitializer() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.kt");
}
@Test
@TestMetadata("secondaryConstructor.kt")
public void testSecondaryConstructor() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.kt");
}
@Test
@TestMetadata("superTypes.kt")
public void testSuperTypes() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/superTypes.kt");
}
@Test
@TestMetadata("superTypesLoop.kt")
public void testSuperTypesLoop() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/superTypesLoop.kt");
}
@Test
@TestMetadata("topLevelFunctions.kt")
public void testTopLevelFunctions() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.kt");
}
@Test
@TestMetadata("topLevelFunctionsWithExpressionBodyAndExplicitType.kt")
public void testTopLevelFunctionsWithExpressionBodyAndExplicitType() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.kt");
}
@Test
@TestMetadata("topLevelFunctionsWithImplicitType.kt")
public void testTopLevelFunctionsWithImplicitType() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.kt");
}
@Test
@TestMetadata("typeParameterOfLocalFunction.kt")
public void testTypeParameterOfLocalFunction() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfLocalFunction.kt");
}
@Test
@TestMetadata("typeParameterOfNonLocalFunction.kt")
public void testTypeParameterOfNonLocalFunction() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfNonLocalFunction.kt");
}
@Test
@TestMetadata("typeParameterOfTopFunction.kt")
public void testTypeParameterOfTopFunction() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfTopFunction.kt");
}
@Test
@TestMetadata("typeParameterOfTopSetter.kt")
public void testTypeParameterOfTopSetter() throws Exception {
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfTopSetter.kt");
}
}
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based package org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based
import com.intellij.mock.MockProject import com.intellij.mock.MockProject
import com.intellij.openapi.Disposable
import com.intellij.psi.PsiElementFinder import com.intellij.psi.PsiElementFinder
import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.ProjectScope import com.intellij.psi.search.ProjectScope
@@ -89,7 +90,7 @@ abstract class AbstractCompilerBasedTest : AbstractKotlinCompilerTest() {
val moduleInfo = TestModuleInfo(module) val moduleInfo = TestModuleInfo(module)
testServices.firModuleInfoProvider.registerModuleData(module, FirModuleInfoBasedModuleData(moduleInfo)) testServices.firModuleInfoProvider.registerModuleData(module, FirModuleInfoBasedModuleData(moduleInfo))
val configurator = FirModuleResolveStateConfiguratorForSingleModuleTestImpl(testServices, module, ktFiles, moduleInfo) val configurator = FirModuleResolveStateConfiguratorForSingleModuleTestImpl(testServices, module, ktFiles, moduleInfo, project)
with(project as MockProject) { with(project as MockProject) {
registerTestServices(configurator, ktFiles) registerTestServices(configurator, ktFiles)
@@ -162,6 +163,7 @@ class FirModuleResolveStateConfiguratorForSingleModuleTestImpl(
private val testModule: TestModule, private val testModule: TestModule,
private val ktFiles: Map<TestFile, KtFile>, private val ktFiles: Map<TestFile, KtFile>,
private val moduleInfo: ModuleInfo, private val moduleInfo: ModuleInfo,
private val parentDisposable: Disposable,
) : FirModuleResolveStateConfigurator() { ) : FirModuleResolveStateConfigurator() {
val moduleInfoProvider = testServices.firModuleInfoProvider val moduleInfoProvider = testServices.firModuleInfoProvider
val compilerConfigurationProvider = testServices.compilerConfigurationProvider val compilerConfigurationProvider = testServices.compilerConfigurationProvider
@@ -220,8 +222,7 @@ class FirModuleResolveStateConfiguratorForSingleModuleTestImpl(
} }
override fun configureSourceSession(session: FirSession) { override fun configureSourceSession(session: FirSession) {
@Suppress("IncorrectParentDisposable") PsiElementFinder.EP.getPoint(project).registerExtension(FirJavaElementFinder(session, project), parentDisposable)
PsiElementFinder.EP.getPoint(project).registerExtension(FirJavaElementFinder(session, project), project)
} }
} }
@@ -6,6 +6,8 @@
package org.jetbrains.kotlin.idea.fir.low.level.api.test.base package org.jetbrains.kotlin.idea.fir.low.level.api.test.base
import com.intellij.mock.MockProject import com.intellij.mock.MockProject
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import com.intellij.psi.PsiElementFinder import com.intellij.psi.PsiElementFinder
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.fir.session.FirModuleInfoBasedModuleData import org.jetbrains.kotlin.fir.session.FirModuleInfoBasedModuleData
@@ -24,6 +26,7 @@ import org.jetbrains.kotlin.test.services.*
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.TestInfo import org.junit.jupiter.api.TestInfo
import java.nio.file.Path import java.nio.file.Path
@@ -33,6 +36,20 @@ import kotlin.io.path.nameWithoutExtension
abstract class AbstractLowLevelApiTest { abstract class AbstractLowLevelApiTest {
private lateinit var testInfo: KotlinTestInfo private lateinit var testInfo: KotlinTestInfo
private var _disposable: Disposable? = null
protected val disposable: Disposable get() = _disposable!!
@BeforeEach
private fun intiDisposable(testInfo: TestInfo) {
_disposable = Disposer.newDisposable("disposable for ${testInfo.displayName}")
}
@AfterEach
private fun disposeDisposable() {
_disposable?.let { Disposer.dispose(it) }
_disposable = null
}
private val configure: TestConfigurationBuilder.() -> Unit = { private val configure: TestConfigurationBuilder.() -> Unit = {
globalDefaults { globalDefaults {
frontend = FrontendKinds.FIR frontend = FrontendKinds.FIR
@@ -84,7 +101,13 @@ abstract class AbstractLowLevelApiTest {
val moduleInfo = TestModuleInfo(singleModule) val moduleInfo = TestModuleInfo(singleModule)
testServices.firModuleInfoProvider.registerModuleData(singleModule, FirModuleInfoBasedModuleData(moduleInfo)) testServices.firModuleInfoProvider.registerModuleData(singleModule, FirModuleInfoBasedModuleData(moduleInfo))
val configurator = FirModuleResolveStateConfiguratorForSingleModuleTestImpl(testServices, singleModule, ktFiles, moduleInfo) val configurator = FirModuleResolveStateConfiguratorForSingleModuleTestImpl(
testServices,
singleModule,
ktFiles,
moduleInfo,
disposable
)
with(project as MockProject) { with(project as MockProject) {
registerTestServices(configurator, ktFiles) registerTestServices(configurator, ktFiles)