[Analysis API] Remove 'ANALYSIS_CONTEXT_MODULE' Context module and context element should normally be the same for the element. Previously, the 'KaFirCompilerFacility' couldn't find implementation modules by itself if the given context module was a common one, so a special test directive was required to provide it. After KT-76457, it's no longer necessary. The commit fixes the test failure happened after fixing KT-86014: ``` (181,184) UNRESOLVED_REFERENCE Unresolved reference 'foo'. (189,192) UNRESOLVED_REFERENCE Unresolved reference 'bar'. ``` Before, the affected test passed only occacionally. The tested code fragment didn't have a proper context element as 'KtCodeFragmentTestModuleFactory.createModule' couldn't find it: the "<caret_context>" tag was in 'common' while the passed 'contextModule' was 'jvm' (subtituted from 'ANALYSIS_CONTEXT_MODULE'). However, before the fix for KT-86014, code fragments always got the current package's scope, and now they inherit it from the context element. In other words, no context element -> no scope -> "unresolved reference". Now, the code fragment initialization is correct, and scopes are properly given from the context element. ^KT-86014
diff --git a/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.kt b/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.kt index 6dec086..070a20a 100644 --- a/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.kt +++ b/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.kt
@@ -23,7 +23,6 @@ // MODULE: main // MODULE_KIND: CodeFragment // CONTEXT_MODULE: common -// ANALYSIS_CONTEXT_MODULE: jvm // FILE: fragment.kt // CODE_FRAGMENT_KIND: EXPRESSION
diff --git a/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.txt b/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.txt index dc5ddd0..605c9a0 100644 --- a/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.txt +++ b/analysis/analysis-api/testData/components/compilerFacility/compilation/codeFragments/expectFunctionWithDefaultParam.txt
@@ -20,7 +20,7 @@ // access flags 0x19 public final static run()I L0 - LINENUMBER 30 L0 + LINENUMBER 29 L0 ICONST_0 ICONST_1 ACONST_NULL
diff --git a/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/AnalysisApiTestDirectives.kt b/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/AnalysisApiTestDirectives.kt index 4faba9f..34d51a2 100644 --- a/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/AnalysisApiTestDirectives.kt +++ b/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/AnalysisApiTestDirectives.kt
@@ -41,16 +41,6 @@ applicability = DirectiveApplicability.Module ) - /* - Note: the 'contextElement' can be different from the 'contextModule'. - E.g., consider a multiplatform project where the contextElement is in 'commonMain', but the contextModule can be - configured as 'jvmMain' - */ - val ANALYSIS_CONTEXT_MODULE by stringDirective( - description = "Specifies the module name which should be treated as a context module for the current one (can overwrite 'CONTEXT_MODULE')", - applicability = DirectiveApplicability.Module - ) - /** * When applied to a library (source) module, specifies that the library module should depend on a [KaLibraryFallbackDependenciesModule][org.jetbrains.kotlin.analysis.api.projectStructure.KaLibraryFallbackDependenciesModule] * instead of the regular dependencies set by the test infrastructure.
diff --git a/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/projectStructure/TestModuleStructureFactory.kt b/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/projectStructure/TestModuleStructureFactory.kt index 2ee21932..031d8b4 100644 --- a/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/projectStructure/TestModuleStructureFactory.kt +++ b/analysis/analysis-test-framework/testFixtures/org/jetbrains/kotlin/analysis/test/framework/projectStructure/TestModuleStructureFactory.kt
@@ -82,14 +82,11 @@ val contextModuleName = testModule.directives.singleOrZeroValue(AnalysisApiTestDirectives.CONTEXT_MODULE) val contextModule = contextModuleName?.let(existingModules::getValue) - val analysisContextModuleName = testModule.directives.singleOrZeroValue(AnalysisApiTestDirectives.ANALYSIS_CONTEXT_MODULE) - val analysisContextModule = analysisContextModuleName?.let(existingModules::getValue) - val dependencyBinaryRoots = testModule.getDependencyBinaryRoots(existingModules) val ktTestModule = testServices .getKtModuleFactoryForTestModule(testModule) - .createModule(testModule, analysisContextModule ?: contextModule, dependencyBinaryRoots, testServices, project) + .createModule(testModule, contextModule, dependencyBinaryRoots, testServices, project) existingModules[testModule.name] = ktTestModule result.add(ktTestModule)