[Analysis API test] get rid of AbstractAnalysisApiBasedSingleModuleTest

^KT-64805
This commit is contained in:
Dmitrii Gridin
2024-01-09 15:41:03 +01:00
committed by Space Team
parent 095989b6fc
commit 476940c06b
17 changed files with 99 additions and 138 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.callRe
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.analysis.api.calls.KtCallInfo import org.jetbrains.kotlin.analysis.api.calls.KtCallInfo
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
@@ -16,10 +16,9 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractResolveCallTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractResolveCallTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val ktFile = ktFiles.first() val expression = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(mainFile)
val expression = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(ktFile)
val actual = executeOnPooledThreadInReadAction { val actual = executeOnPooledThreadInReadAction {
analyseForTest(expression) { analyseForTest(expression) {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.analysis.api.calls.KtCallCandidateInfo import org.jetbrains.kotlin.analysis.api.calls.KtCallCandidateInfo
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.compareCalls import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.compareCalls
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.stringRepresentation
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
@@ -18,10 +18,9 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractResolveCandidatesTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractResolveCandidatesTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val ktFile = ktFiles.first() val expression = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(mainFile)
val expression = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(ktFile)
val actual = executeOnPooledThreadInReadAction { val actual = executeOnPooledThreadInReadAction {
analyseForTest(expression) { analyseForTest(expression) {
@@ -1,22 +1,20 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.analysis.api.impl.base.test.cases.components.importOptimizer package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.importOptimizer
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractAnalysisApiImportOptimizerTest : AbstractAnalysisApiBasedSingleModuleTest(){ abstract class AbstractAnalysisApiImportOptimizerTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.first { it.name == "main.kt" } val importsAnalysis = analyseForTest(mainFile) {
analyseImports(mainFile)
val importsAnalysis = analyseForTest(mainKtFile) {
analyseImports(mainKtFile)
} }
val importAnalysisRendered = buildString { val importAnalysisRendered = buildString {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.analysis.api.components.KtScopeContext import org.jetbrains.kotlin.analysis.api.components.KtScopeContext
import org.jetbrains.kotlin.analysis.api.components.KtScopeKind import org.jetbrains.kotlin.analysis.api.components.KtScopeKind
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.scopeProvider.TestScopeRenderer.renderForTests import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.scopeProvider.TestScopeRenderer.renderForTests
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.utils.printer.prettyPrint import org.jetbrains.kotlin.analysis.utils.printer.prettyPrint
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
@@ -17,13 +17,12 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractFileImportingScopeContextTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractFileImportingScopeContextTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val ktFile = ktFiles.first() val renderDefaultImportingScope = Directives.RENDER_DEFAULT_IMPORTING_SCOPE in mainModule.directives
val renderDefaultImportingScope = Directives.RENDER_DEFAULT_IMPORTING_SCOPE in module.directives
analyseForTest(ktFile) { analyseForTest(mainFile) {
val ktScopeContext = ktFile.getImportingScopeContext() val ktScopeContext = mainFile.getImportingScopeContext()
val scopeContextStringRepresentation = render(ktScopeContext, renderDefaultImportingScope) val scopeContextStringRepresentation = render(ktScopeContext, renderDefaultImportingScope)
val scopeContextStringRepresentationPretty = render(ktScopeContext, renderDefaultImportingScope, printPretty = true) val scopeContextStringRepresentationPretty = render(ktScopeContext, renderDefaultImportingScope, printPretty = true)
@@ -37,7 +36,7 @@ abstract class AbstractFileImportingScopeContextTest : AbstractAnalysisApiBasedS
private fun render( private fun render(
importingScope: KtScopeContext, importingScope: KtScopeContext,
renderDefaultImportingScope: Boolean, renderDefaultImportingScope: Boolean,
printPretty: Boolean = false printPretty: Boolean = false,
): String = prettyPrint { ): String = prettyPrint {
renderForTests(importingScope, printPretty) { ktScopeKind -> renderForTests(importingScope, printPretty) { ktScopeKind ->
when (ktScopeKind) { when (ktScopeKind) {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.analysis.api.components.KtScopeContext import org.jetbrains.kotlin.analysis.api.components.KtScopeContext
import org.jetbrains.kotlin.analysis.api.components.KtScopeKind import org.jetbrains.kotlin.analysis.api.components.KtScopeKind
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.scopeProvider.TestScopeRenderer.renderForTests import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.scopeProvider.TestScopeRenderer.renderForTests
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.utils.printer.prettyPrint import org.jetbrains.kotlin.analysis.utils.printer.prettyPrint
import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtElement
@@ -18,13 +18,12 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractScopeContextForPositionTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractScopeContextForPositionTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val ktFile = ktFiles.first() val element = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(mainFile)
val element = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(ktFile)
analyseForTest(element) { elementToAnalyze -> analyseForTest(element) { elementToAnalyze ->
val scopeContext = ktFile.getScopeContextForPosition(elementToAnalyze) val scopeContext = mainFile.getScopeContextForPosition(elementToAnalyze)
val scopeContextStringRepresentation = renderForTests(elementToAnalyze, scopeContext) val scopeContextStringRepresentation = renderForTests(elementToAnalyze, scopeContext)
val scopeContextStringRepresentationPretty = renderForTests(elementToAnalyze, scopeContext, printPretty = true) val scopeContextStringRepresentationPretty = renderForTests(elementToAnalyze, scopeContext, printPretty = true)
@@ -37,7 +36,7 @@ abstract class AbstractScopeContextForPositionTest : AbstractAnalysisApiBasedSin
private fun KtAnalysisSession.renderForTests( private fun KtAnalysisSession.renderForTests(
element: KtElement, element: KtElement,
scopeContext: KtScopeContext, scopeContext: KtScopeContext,
printPretty: Boolean = false printPretty: Boolean = false,
): String = prettyPrint { ): String = prettyPrint {
appendLine("element: ${element.text}") appendLine("element: ${element.text}")
renderForTests(scopeContext, printPretty) { scopeKind -> renderForTests(scopeContext, printPretty) { scopeKind ->
@@ -1,12 +1,12 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.analysis.api.impl.base.test.cases.components.symbolDeclarationOverridesProvider package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.symbolDeclarationOverridesProvider
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
@@ -14,10 +14,10 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractIsSubclassOfTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractIsSubclassOfTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val subClass = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtClassOrObject>(ktFiles.first(), "sub") val subClass = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtClassOrObject>(mainFile, "sub")
val superClass = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtClassOrObject>(ktFiles.first(), "super") val superClass = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtClassOrObject>(mainFile, "super")
val actual = executeOnPooledThreadInReadAction { val actual = executeOnPooledThreadInReadAction {
analyseForTest(subClass) { analyseForTest(subClass) {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KtTypeRendererForSo
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtFunctionSymbol import org.jetbrains.kotlin.analysis.api.symbols.KtFunctionSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtSyntheticJavaPropertySymbol import org.jetbrains.kotlin.analysis.api.symbols.KtSyntheticJavaPropertySymbol
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.analysis.utils.printer.parentsOfType import org.jetbrains.kotlin.analysis.utils.printer.parentsOfType
@@ -21,9 +21,9 @@ import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.Variance
abstract class AbstractOverriddenDeclarationProviderTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractOverriddenDeclarationProviderTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val declaration = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(ktFiles.first()) val declaration = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(mainFile)
val actual = executeOnPooledThreadInReadAction { val actual = executeOnPooledThreadInReadAction {
analyseForTest(declaration) { analyseForTest(declaration) {
@@ -1,11 +1,11 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.analysis.api.impl.base.test.cases.references package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractReferenceImportAliasTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractReferenceImportAliasTest : AbstractAnalysisApiBasedTest() {
override fun configureTest(builder: TestConfigurationBuilder) { override fun configureTest(builder: TestConfigurationBuilder) {
super.configureTest(builder) super.configureTest(builder)
with(builder) { with(builder) {
@@ -24,10 +24,10 @@ abstract class AbstractReferenceImportAliasTest : AbstractAnalysisApiBasedSingle
} }
} }
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val element = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtSimpleNameExpression>(ktFiles.first()) val element = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtSimpleNameExpression>(mainFile)
val alias = element.mainReference.getImportAlias() val alias = element.mainReference.getImportAlias()
val expectedAlias = module.directives[Directives.TYPE_ALIAS].joinToString(" ") val expectedAlias = mainModule.directives[Directives.TYPE_ALIAS].joinToString(" ")
testServices.assertions.assertEquals(expectedAlias, alias?.text) testServices.assertions.assertEquals(expectedAlias, alias?.text)
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -7,26 +7,24 @@ package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references
import org.jetbrains.kotlin.analysis.api.components.ShortenStrategy import org.jetbrains.kotlin.analysis.api.components.ShortenStrategy
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references.ShorteningResultsRenderer.renderShorteningResults import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references.ShorteningResultsRenderer.renderShorteningResults
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractReferenceShortenerForWholeFileTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractReferenceShortenerForWholeFileTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val file = ktFiles.first()
val shortenings = executeOnPooledThreadInReadAction { val shortenings = executeOnPooledThreadInReadAction {
analyseForTest(file) { analyseForTest(mainFile) {
buildMap { buildMap {
this += "default settings" to collectPossibleReferenceShortenings(file, file.textRange) this += "default settings" to collectPossibleReferenceShortenings(mainFile, mainFile.textRange)
this += ShortenStrategy.entries.associateWith { option -> this += ShortenStrategy.entries.associateWith { option ->
val shorteningsForOption = collectPossibleReferenceShortenings( val shorteningsForOption = collectPossibleReferenceShortenings(
file, mainFile,
file.textRange, mainFile.textRange,
classShortenStrategy = { option }, classShortenStrategy = { option },
callableShortenStrategy = { option } callableShortenStrategy = { option }
) )
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references
import org.jetbrains.kotlin.analysis.api.components.ShortenOptions import org.jetbrains.kotlin.analysis.api.components.ShortenOptions
import org.jetbrains.kotlin.analysis.api.components.ShortenStrategy import org.jetbrains.kotlin.analysis.api.components.ShortenStrategy
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references.ShorteningResultsRenderer.renderShorteningResults import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references.ShorteningResultsRenderer.renderShorteningResults
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtElement
@@ -22,10 +22,9 @@ import org.jetbrains.kotlin.test.services.assertions
* *
* Note that it tests shortening only a single expression between <expr> and </expr> in the first file. * Note that it tests shortening only a single expression between <expr> and </expr> in the first file.
*/ */
abstract class AbstractReferenceShortenerTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractReferenceShortenerTest : AbstractAnalysisApiBasedTest() {
override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { val element = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(mainFile)
val element = testServices.expressionMarkerProvider.getSelectedElementOfType<KtElement>(ktFiles.first())
val shortenings = executeOnPooledThreadInReadAction { val shortenings = executeOnPooledThreadInReadAction {
analyseForTest(element) { analyseForTest(element) {
@@ -1,11 +1,11 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.analysis.api.standalone.fir.test.cases.components.psiDeclarationProvider package org.jetbrains.kotlin.analysis.api.standalone.fir.test.cases.components.psiDeclarationProvider
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
@@ -13,11 +13,10 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
public abstract class AbstractPsiDeclarationProviderSingleModuleTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractPsiDeclarationProviderSingleModuleTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.firstOrNull { it.name == "main.kt" } ?: ktFiles.first() val caretPosition = testServices.expressionMarkerProvider.getCaretPosition(mainFile)
val caretPosition = testServices.expressionMarkerProvider.getCaretPosition(mainKtFile) val ktReferences = findReferencesAtCaret(mainFile, caretPosition)
val ktReferences = findReferencesAtCaret(mainKtFile, caretPosition)
if (ktReferences.isEmpty()) { if (ktReferences.isEmpty()) {
testServices.assertions.fail { "No references at caret found" } testServices.assertions.fail { "No references at caret found" }
} }
@@ -30,7 +29,7 @@ public abstract class AbstractPsiDeclarationProviderSingleModuleTest : AbstractA
psiElements.joinToString(separator = "\n") { TestPsiElementRenderer.render(it) } psiElements.joinToString(separator = "\n") { TestPsiElementRenderer.render(it) }
} }
if (Directives.UNRESOLVED_REFERENCE in module.directives) { if (Directives.UNRESOLVED_REFERENCE in mainModule.directives) {
return return
} }
@@ -1,22 +0,0 @@
/*
* Copyright 2010-2022 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.
*/
package org.jetbrains.kotlin.analysis.test.framework.base
import org.jetbrains.kotlin.analysis.test.framework.project.structure.ktModuleProvider
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestModuleStructure
import org.jetbrains.kotlin.test.services.TestServices
abstract class AbstractAnalysisApiBasedSingleModuleTest : AbstractAnalysisApiBasedTest() {
final override fun doTestByModuleStructure(moduleStructure: TestModuleStructure, testServices: TestServices) {
val singleModule = moduleStructure.modules.single()
val ktFiles = testServices.ktModuleProvider.getModuleFiles(singleModule).filterIsInstance<KtFile>()
doTestByFileStructure(ktFiles, singleModule, testServices)
}
protected abstract fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices)
}
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -9,10 +9,9 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
abstract class AbstractAnalysisApiSingleFileTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractAnalysisApiSingleFileTest : AbstractAnalysisApiBasedTest() {
final override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val singleFile = ktFiles.first() doTestByFileStructure(mainFile, mainModule, testServices)
doTestByFileStructure(singleFile, module, testServices)
} }
protected abstract fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) protected abstract fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices)
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -10,23 +10,21 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
import org.jetbrains.kotlin.analysis.low.level.api.fir.compile.CompilationPeerCollector import org.jetbrains.kotlin.analysis.low.level.api.fir.compile.CompilationPeerCollector
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractCompilationPeerAnalysisTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractCompilationPeerAnalysisTest : AbstractAnalysisApiBasedTest() {
override val configurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false) override val configurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.single { it.name == "main.kt" } val project = mainFile.project
val sourceModule = ProjectStructureProvider.getModule(project, mainFile, contextualModule = null)
val project = mainKtFile.project
val sourceModule = ProjectStructureProvider.getModule(project, mainKtFile, contextualModule = null)
val resolveSession = sourceModule.getFirResolveSession(project) val resolveSession = sourceModule.getFirResolveSession(project)
val firFile = mainKtFile.getOrBuildFirFile(resolveSession) val firFile = mainFile.getOrBuildFirFile(resolveSession)
val compilationPeerData = CompilationPeerCollector.process(firFile) val compilationPeerData = CompilationPeerCollector.process(firFile)
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.
*/ */
@@ -11,14 +11,13 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.Analys
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.ContextCollector import org.jetbrains.kotlin.analysis.low.level.api.fir.util.ContextCollector
import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
import org.jetbrains.kotlin.fir.declarations.FirTowerDataContext import org.jetbrains.kotlin.fir.declarations.FirTowerDataContext
import org.jetbrains.kotlin.fir.renderer.FirRenderer import org.jetbrains.kotlin.fir.renderer.FirRenderer
import org.jetbrains.kotlin.fir.resolve.SessionHolderImpl import org.jetbrains.kotlin.fir.resolve.SessionHolderImpl
import org.jetbrains.kotlin.fir.resolve.dfa.Identifier
import org.jetbrains.kotlin.fir.resolve.dfa.RealVariable import org.jetbrains.kotlin.fir.resolve.dfa.RealVariable
import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.*
import org.jetbrains.kotlin.fir.scopes.impl.* import org.jetbrains.kotlin.fir.scopes.impl.*
@@ -34,21 +33,19 @@ import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
import java.lang.IllegalArgumentException import java.lang.IllegalArgumentException
abstract class AbstractContextCollectorTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractContextCollectorTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.single { it.name == "main.kt" } val project = mainFile.project
val sourceModule = ProjectStructureProvider.getModule(project, mainFile, contextualModule = null)
val project = mainKtFile.project
val sourceModule = ProjectStructureProvider.getModule(project, mainKtFile, contextualModule = null)
val resolveSession = sourceModule.getFirResolveSession(project) val resolveSession = sourceModule.getFirResolveSession(project)
val session = resolveSession.useSiteFirSession val session = resolveSession.useSiteFirSession
val sessionHolder = SessionHolderImpl(session, session.getScopeSession()) val sessionHolder = SessionHolderImpl(session, session.getScopeSession())
val firFile = mainKtFile.getOrBuildFirFile(resolveSession) val firFile = mainFile.getOrBuildFirFile(resolveSession)
val targetElement = testServices.expressionMarkerProvider val targetElement = testServices.expressionMarkerProvider
.getBottommostSelectedElementOfType(mainKtFile, KtElement::class.java) .getBottommostSelectedElementOfType(mainFile, KtElement::class.java)
val elementContext = ContextCollector.process(firFile, sessionHolder, targetElement) val elementContext = ContextCollector.process(firFile, sessionHolder, targetElement)
?: error("Context not found for element $targetElement") ?: error("Context not found for element $targetElement")
@@ -1,12 +1,12 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.light.classes.symbol.base package org.jetbrains.kotlin.light.classes.symbol.base
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.asJava.toLightElements import org.jetbrains.kotlin.asJava.toLightElements
import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDeclaration
@@ -17,14 +17,14 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractLightClassUtilTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractLightClassUtilTest : AbstractAnalysisApiBasedTest() {
override val configurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false) override val configurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
val ktFile = ktFiles.single() override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val declaration = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(ktFile) val declaration = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(mainFile)
val lightElements = declaration.toLightElements() val lightElements = declaration.toLightElements()
testServices.assertions.assertFalse(lightElements.isEmpty()) testServices.assertions.assertFalse(lightElements.isEmpty())
val directives = module.directives val directives = mainModule.directives
val expectedLightElements = directives[Directives.EXPECTED] val expectedLightElements = directives[Directives.EXPECTED]
testServices.assertions.assertEquals(expectedLightElements.size, lightElements.size) { testServices.assertions.assertEquals(expectedLightElements.size, lightElements.size) {
"Found ${lightElements.map { it.javaClass.name }}" "Found ${lightElements.map { it.javaClass.name }}"
@@ -1,12 +1,12 @@
/* /*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2024 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.light.classes.symbol.base package org.jetbrains.kotlin.light.classes.symbol.base
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
import org.jetbrains.kotlin.asJava.LightClassTestCommon import org.jetbrains.kotlin.asJava.LightClassTestCommon
@@ -17,11 +17,10 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractSymbolLightClassesEquivalentTest : AbstractAnalysisApiBasedSingleModuleTest() { abstract class AbstractSymbolLightClassesEquivalentTest : AbstractAnalysisApiBasedTest() {
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) { override fun doTestByMainFile(mainFile: KtFile, mainModule: TestModule, testServices: TestServices) {
val lightQName = LightClassTestCommon.fqNameInTestDataFile(testDataPath.toFile()) val lightQName = LightClassTestCommon.fqNameInTestDataFile(testDataPath.toFile())
val ktFile = ktFiles.first() val declaration = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(mainFile)
val declaration = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtDeclaration>(ktFile)
val lightElements = declaration.toLightElements() val lightElements = declaration.toLightElements()
testServices.assertions.assertFalse(lightElements.isEmpty()) testServices.assertions.assertFalse(lightElements.isEmpty())
if (lightElements.size > 1) { if (lightElements.size > 1) {