FIR IDE: move analysis api fir test sources to the analysis directory
This commit is contained in:
+129
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir
|
||||
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleModuleTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtDeclarationRendererOptions
|
||||
import org.jetbrains.kotlin.analysis.api.components.RendererModifier
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtNamedSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithKind
|
||||
import org.jetbrains.kotlin.idea.references.KtReference
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractReferenceResolveTest : AbstractHLApiSingleModuleTest() {
|
||||
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||
super.configureTest(builder)
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+JvmEnvironmentConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
useDirectives(Directives)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.first { it.name == "main.kt" }
|
||||
val caretPosition = testServices.expressionMarkerProvider.getCaretPosition(mainKtFile)
|
||||
val ktReferences = findReferencesAtCaret(mainKtFile, caretPosition)
|
||||
if (ktReferences.isEmpty()) {
|
||||
testServices.assertions.fail { "No references at caret found" }
|
||||
}
|
||||
|
||||
val resolvedTo = analyse(mainKtFile) {
|
||||
val symbols = ktReferences.flatMap { it.resolveToSymbols() }
|
||||
checkReferenceResultForValidity(module, testServices, symbols)
|
||||
renderResolvedTo(symbols)
|
||||
}
|
||||
|
||||
if (Directives.UNRESOLVED_REFERENCE in module.directives) {
|
||||
return
|
||||
}
|
||||
|
||||
val actual = "Resolved to:\n$resolvedTo"
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
|
||||
private fun findReferencesAtCaret(mainKtFile: KtFile, caretPosition: Int): List<KtReference> =
|
||||
mainKtFile.findReferenceAt(caretPosition)?.unwrapMultiReferences().orEmpty().filterIsInstance<KtReference>()
|
||||
|
||||
private fun KtAnalysisSession.checkReferenceResultForValidity(
|
||||
module: TestModule,
|
||||
testServices: TestServices,
|
||||
resolvedTo: List<KtSymbol>
|
||||
) {
|
||||
if (Directives.UNRESOLVED_REFERENCE in module.directives) {
|
||||
testServices.assertions.assertTrue(resolvedTo.isEmpty()) {
|
||||
"Reference should be unresolved, but was resolved to ${renderResolvedTo(resolvedTo)}"
|
||||
}
|
||||
} else {
|
||||
testServices.assertions.assertTrue(resolvedTo.isNotEmpty()) { "Unresolved reference" }
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtAnalysisSession.renderResolvedTo(symbols: List<KtSymbol>) =
|
||||
symbols.map { renderResolveResult(it) }
|
||||
.sorted()
|
||||
.withIndex()
|
||||
.joinToString(separator = "\n") { "${it.index}: ${it.value}" }
|
||||
|
||||
|
||||
private fun KtAnalysisSession.renderResolveResult(symbol: KtSymbol): String {
|
||||
return buildString {
|
||||
symbolContainerFqName(symbol)?.let { fqName ->
|
||||
append("(in $fqName) ")
|
||||
}
|
||||
append(symbol.render(renderingOptions))
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")// KtAnalysisSession receiver
|
||||
private fun KtAnalysisSession.symbolContainerFqName(symbol: KtSymbol): String? {
|
||||
if (symbol is KtPackageSymbol || symbol is KtValueParameterSymbol) return null
|
||||
val nonLocalFqName = when (symbol) {
|
||||
is KtConstructorSymbol -> symbol.containingClassIdIfNonLocal?.asSingleFqName()
|
||||
is KtCallableSymbol -> symbol.callableIdIfNonLocal?.asSingleFqName()?.parent()
|
||||
is KtClassLikeSymbol -> symbol.classIdIfNonLocal?.asSingleFqName()?.parent()
|
||||
else -> null
|
||||
}
|
||||
when (nonLocalFqName) {
|
||||
null -> Unit
|
||||
FqName.ROOT -> return "ROOT"
|
||||
else -> return nonLocalFqName.asString()
|
||||
}
|
||||
val container = (symbol as? KtSymbolWithKind)?.getContainingSymbol() ?: return null
|
||||
val parents = generateSequence(container) { it.getContainingSymbol() }
|
||||
return "<local>: " + parents.joinToString(separator = ".") { (it as? KtNamedSymbol)?.name?.asString() ?: "<no name>" }
|
||||
}
|
||||
|
||||
private object Directives : SimpleDirectivesContainer() {
|
||||
val UNRESOLVED_REFERENCE by directive(
|
||||
"Reference should be unresolved",
|
||||
)
|
||||
}
|
||||
|
||||
private val renderingOptions = KtDeclarationRendererOptions.DEFAULT.copy(
|
||||
modifiers = RendererModifier.DEFAULT - RendererModifier.ANNOTATIONS
|
||||
)
|
||||
|
||||
private fun PsiReference.unwrapMultiReferences(): List<PsiReference> = when (this) {
|
||||
is KtReference -> listOf(this)
|
||||
is PsiMultiReference -> references.flatMap { it.unwrapMultiReferences() }
|
||||
else -> error("Unexpected reference $this")
|
||||
}
|
||||
}
|
||||
+1126
File diff suppressed because it is too large
Load Diff
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtNamedSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
object SymbolByFqName {
|
||||
fun getSymbolDataFromFile(filePath: Path): SymbolData {
|
||||
val testFileText = FileUtil.loadFile(filePath.toFile())
|
||||
val identifier = testFileText.lineSequence().first { line ->
|
||||
SymbolData.identifiers.any { identifier ->
|
||||
line.startsWith(identifier) || line.startsWith("// $identifier")
|
||||
}
|
||||
}
|
||||
return SymbolData.create(identifier.removePrefix("// "))
|
||||
}
|
||||
|
||||
fun textWithRenderedSymbolData(filePath: String, rendered: String): String = buildString {
|
||||
val testFileText = FileUtil.loadFile(File(filePath))
|
||||
val fileTextWithoutSymbolsData = testFileText.substringBeforeLast(SYMBOLS_TAG).trimEnd()
|
||||
appendLine(fileTextWithoutSymbolsData)
|
||||
appendLine()
|
||||
appendLine(SYMBOLS_TAG)
|
||||
append(rendered)
|
||||
}
|
||||
|
||||
|
||||
private const val SYMBOLS_TAG = "// SYMBOLS:"
|
||||
}
|
||||
|
||||
sealed class SymbolData {
|
||||
abstract fun KtAnalysisSession.toSymbols(): List<KtSymbol>
|
||||
|
||||
data class ClassData(val classId: ClassId) : SymbolData() {
|
||||
override fun KtAnalysisSession.toSymbols(): List<KtSymbol> {
|
||||
val symbol = classId.getCorrespondingToplevelClassOrObjectSymbol() ?: error("Class $classId is not found")
|
||||
return listOf(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
data class CallableData(val callableId: CallableId) : SymbolData() {
|
||||
override fun KtAnalysisSession.toSymbols(): List<KtSymbol> {
|
||||
val classId = callableId.classId
|
||||
val symbols = if (classId == null) {
|
||||
callableId.packageName.getContainingCallableSymbolsWithName(callableId.callableName).toList()
|
||||
} else {
|
||||
val classSymbol =
|
||||
classId.getCorrespondingToplevelClassOrObjectSymbol()
|
||||
?: error("Class $classId is not found")
|
||||
classSymbol.getDeclaredMemberScope().getCallableSymbols()
|
||||
.filter { (it as? KtNamedSymbol)?.name == callableId.callableName }
|
||||
.toList()
|
||||
}
|
||||
if (symbols.isEmpty()) {
|
||||
error("No callable with fqName $callableId found")
|
||||
}
|
||||
return symbols
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val identifiers = arrayOf("callable:", "class:")
|
||||
|
||||
fun create(data: String): SymbolData = when {
|
||||
data.startsWith("class:") -> ClassData(ClassId.fromString(data.removePrefix("class:").trim()))
|
||||
data.startsWith("callable:") -> {
|
||||
val fullName = data.removePrefix("callable:").trim()
|
||||
val name = if ('.' in fullName) fullName.substringAfterLast(".") else fullName.substringAfterLast('/')
|
||||
val (packageName, className) = run {
|
||||
val packageNameWithClassName = fullName.dropLast(name.length + 1)
|
||||
when {
|
||||
'.' in fullName ->
|
||||
packageNameWithClassName.substringBeforeLast('/') to packageNameWithClassName.substringAfterLast('/')
|
||||
else -> packageNameWithClassName to null
|
||||
}
|
||||
}
|
||||
CallableData(CallableId(FqName(packageName.replace('/', '.')), className?.let { FqName(it) }, Name.identifier(name)))
|
||||
}
|
||||
else -> error("Invalid symbol")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
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
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractExpectedExpressionTypeTest : AbstractHLApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val expressionAtCaret = testServices.expressionMarkerProvider.getElementOfTypAtCaret(ktFile) as KtExpression
|
||||
|
||||
val actualExpectedTypeText: String? = executeOnPooledThreadInReadAction {
|
||||
analyse(ktFile) {
|
||||
expressionAtCaret.getExpectedType()?.asStringForDebugging()
|
||||
}
|
||||
}
|
||||
|
||||
val actual = buildString {
|
||||
appendLine("expression: ${expressionAtCaret.text}")
|
||||
appendLine("expected type: $actualExpectedTypeText")
|
||||
}
|
||||
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
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
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractHLExpressionTypeTest : AbstractHLApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val expression = testServices.expressionMarkerProvider.getSelectedElement(ktFile) as KtExpression
|
||||
val type = executeOnPooledThreadInReadAction {
|
||||
analyse(expression) { expression.getKtType()?.render() }
|
||||
}
|
||||
val actual = buildString {
|
||||
appendLine("expression: ${expression.text}")
|
||||
appendLine("type: $type")
|
||||
}
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleModuleTest
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractHLImportOptimizerTest : AbstractHLApiSingleModuleTest() {
|
||||
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.first { it.name == "main.kt" }
|
||||
val unusedImports = analyse(mainKtFile) { analyseImports(mainKtFile).unusedImports }
|
||||
|
||||
val unusedImportPaths = unusedImports
|
||||
.map { it.importPath ?: error("Import $it should have an import path, instead was ${it.text}") }
|
||||
.sortedBy { it.toString() } // for stable results
|
||||
|
||||
val actualUnusedImports = buildString {
|
||||
unusedImportPaths.forEach(::appendLine)
|
||||
}
|
||||
|
||||
val expectedUnusedImports = testDataFileSibling(".imports")
|
||||
|
||||
testServices.assertions.assertEqualsToFile(expectedUnusedImports, actualUnusedImports)
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleModuleTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.parentsOfType
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtTypeRendererOptions
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtFunctionSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSyntheticJavaPropertySymbol
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractOverriddenDeclarationProviderTest : AbstractHLApiSingleModuleTest() {
|
||||
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||
val declaration = testServices.expressionMarkerProvider.getElementOfTypAtCaret<KtDeclaration>(ktFiles.first())
|
||||
|
||||
val actual = executeOnPooledThreadInReadAction {
|
||||
analyse(ktFiles.first()) {
|
||||
val symbol = declaration.getSymbol() as KtCallableSymbol
|
||||
val allOverriddenSymbols = symbol.getAllOverriddenSymbols().map { renderSignature(it) }
|
||||
val directlyOverriddenSymbols = symbol.getDirectlyOverriddenSymbols().map { renderSignature(it) }
|
||||
buildString {
|
||||
appendLine("ALL:")
|
||||
allOverriddenSymbols.forEach { appendLine(" $it") }
|
||||
appendLine("DIRECT:")
|
||||
directlyOverriddenSymbols.forEach { appendLine(" $it") }
|
||||
}
|
||||
}
|
||||
}
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
|
||||
private fun KtAnalysisSession.renderSignature(symbol: KtCallableSymbol): String = buildString {
|
||||
append(getPath(symbol))
|
||||
if (symbol is KtFunctionSymbol) {
|
||||
append("(")
|
||||
symbol.valueParameters.forEachIndexed { index, parameter ->
|
||||
append(parameter.name.identifier)
|
||||
append(": ")
|
||||
append(parameter.annotatedType.type.render(KtTypeRendererOptions.SHORT_NAMES))
|
||||
if (index != symbol.valueParameters.lastIndex) {
|
||||
append(", ")
|
||||
}
|
||||
}
|
||||
append(")")
|
||||
}
|
||||
append(": ")
|
||||
append(symbol.annotatedType.type.render(KtTypeRendererOptions.SHORT_NAMES))
|
||||
}
|
||||
|
||||
private fun getPath(symbol: KtCallableSymbol): String = when (symbol) {
|
||||
is KtSyntheticJavaPropertySymbol -> symbol.callableIdIfNonLocal?.toString()!!
|
||||
else -> {
|
||||
val ktDeclaration = symbol.psi as KtDeclaration
|
||||
ktDeclaration
|
||||
.parentsOfType<KtDeclaration>(withSelf = true)
|
||||
.map { it.name ?: "<no name>" }
|
||||
.toList()
|
||||
.asReversed()
|
||||
.joinToString(separator = ".")
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtDeclarationRendererOptions
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtTypeRendererOptions
|
||||
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
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractRendererTest : AbstractHLApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val options = KtDeclarationRendererOptions.DEFAULT.copy(
|
||||
approximateTypes = true,
|
||||
renderContainingDeclarations = true,
|
||||
typeRendererOptions = KtTypeRendererOptions.SHORT_NAMES
|
||||
)
|
||||
|
||||
val actual = executeOnPooledThreadInReadAction {
|
||||
buildString {
|
||||
ktFile.declarations.forEach {
|
||||
analyse(it) {
|
||||
append(it.getSymbol().render(options))
|
||||
appendLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".rendered"), actual)
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleModuleTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtCall
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtDelegatedConstructorCallKind
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtErrorCallTarget
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtSuccessCallTarget
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import kotlin.reflect.KProperty1
|
||||
import kotlin.reflect.full.memberProperties
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
import kotlin.reflect.jvm.javaGetter
|
||||
|
||||
abstract class AbstractResolveCallTest : AbstractHLApiSingleModuleTest() {
|
||||
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||
val ktFile = ktFiles.first()
|
||||
val expression = testServices.expressionMarkerProvider.getSelectedElement(ktFile)
|
||||
|
||||
val actual = executeOnPooledThreadInReadAction {
|
||||
analyse(ktFile) {
|
||||
resolveCall(expression)?.stringRepresentation()
|
||||
}
|
||||
} ?: "null"
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
|
||||
private fun KtAnalysisSession.resolveCall(element: PsiElement): KtCall? = when (element) {
|
||||
is KtCallElement -> element.resolveCall()
|
||||
is KtBinaryExpression -> element.resolveCall()
|
||||
is KtUnaryExpression -> element.resolveCall()
|
||||
is KtArrayAccessExpression -> element.resolveCall()
|
||||
is KtSimpleNameExpression -> element.resolveAccessorCall()
|
||||
is KtValueArgument -> resolveCall(element.getArgumentExpression()!!)
|
||||
else -> error("Selected element type (${element::class.simpleName}) is not supported for resolveCall()")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun KtCall.stringRepresentation(): String {
|
||||
fun KtType.render() = asStringForDebugging().replace('/', '.')
|
||||
fun Any.stringValue(): String = when (this) {
|
||||
is KtFunctionLikeSymbol -> buildString {
|
||||
append(
|
||||
when (this@stringValue) {
|
||||
is KtFunctionSymbol -> callableIdIfNonLocal ?: name
|
||||
is KtConstructorSymbol -> "<constructor>"
|
||||
is KtPropertyGetterSymbol -> callableIdIfNonLocal ?: "<getter>"
|
||||
is KtPropertySetterSymbol -> callableIdIfNonLocal ?: "<setter>"
|
||||
else -> error("unexpected symbol kind in KtCall: ${this@stringValue::class.java}")
|
||||
}
|
||||
)
|
||||
append("(")
|
||||
(this@stringValue as? KtFunctionSymbol)?.receiverType?.let { receiver ->
|
||||
append("<receiver>: ${receiver.type.render()}")
|
||||
if (valueParameters.isNotEmpty()) append(", ")
|
||||
}
|
||||
valueParameters.joinTo(this) { it.stringValue() }
|
||||
append(")")
|
||||
append(": ${annotatedType.type.render()}")
|
||||
}
|
||||
is KtValueParameterSymbol -> "${if (isVararg) "vararg " else ""}$name: ${annotatedType.type.render()}"
|
||||
is KtSuccessCallTarget -> symbol.stringValue()
|
||||
is KtErrorCallTarget -> "ERR<${this.diagnostic.defaultMessage}, [${candidates.joinToString { it.stringValue() }}]>"
|
||||
is Boolean -> toString()
|
||||
is Map<*, *> -> entries.joinToString(prefix = "{ ", postfix = " }") { (k, v) -> "${k?.stringValue()} -> (${v?.stringValue()})" }
|
||||
is KtExpression -> this.text
|
||||
is KtDelegatedConstructorCallKind -> toString()
|
||||
else -> error("unexpected parameter type ${this::class}")
|
||||
}
|
||||
|
||||
val callInfoClass = this::class
|
||||
return buildString {
|
||||
append(callInfoClass.simpleName!!)
|
||||
append(":\n")
|
||||
val propertyByName = callInfoClass.memberProperties.associateBy(KProperty1<*, *>::name)
|
||||
callInfoClass.primaryConstructor!!.parameters.joinTo(this, separator = "\n") { parameter ->
|
||||
val value = propertyByName[parameter.name]!!.javaGetter!!(this@stringRepresentation)?.stringValue()
|
||||
"${parameter.name!!} = $value"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/components/expectedExpressionType")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ExpectedExpressionTypeTestGenerated extends AbstractExpectedExpressionTypeTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInExpectedExpressionType() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/expectedExpressionType"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionExpressionBody.kt")
|
||||
public void testFunctionExpressionBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionExpressionBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionExpressionBodyBlockExpression.kt")
|
||||
public void testFunctionExpressionBodyBlockExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionExpressionBodyBlockExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionExpressionBodyQualified.kt")
|
||||
public void testFunctionExpressionBodyQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionExpressionBodyQualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionExpressionBodyWithTypeFromRHS.kt")
|
||||
public void testFunctionExpressionBodyWithTypeFromRHS() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionExpressionBodyWithTypeFromRHS.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionExpressionBodyWithoutExplicitType.kt")
|
||||
public void testFunctionExpressionBodyWithoutExplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionExpressionBodyWithoutExplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionLambdaParam.kt")
|
||||
public void testFunctionLambdaParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionLambdaParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionNamedlParam.kt")
|
||||
public void testFunctionNamedlParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionNamedlParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionParamWithTypeParam.kt")
|
||||
public void testFunctionParamWithTypeParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionParamWithTypeParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionPositionalParam.kt")
|
||||
public void testFunctionPositionalParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionPositionalParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionPositionalParamQualified.kt")
|
||||
public void testFunctionPositionalParamQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/functionPositionalParamQualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifCondition.kt")
|
||||
public void testIfCondition() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/ifCondition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConditionQualified.kt")
|
||||
public void testIfConditionQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/ifConditionQualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("infixFunctionAsRegularCallParam.kt")
|
||||
public void testInfixFunctionAsRegularCallParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/infixFunctionAsRegularCallParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("infixFunctionParam.kt")
|
||||
public void testInfixFunctionParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/infixFunctionParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("infixFunctionParamQualified.kt")
|
||||
public void testInfixFunctionParamQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/infixFunctionParamQualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithExplicitTypeFromVariable.kt")
|
||||
public void testLambdaWithExplicitTypeFromVariable() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/lambdaWithExplicitTypeFromVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithoutReturnNorExplicitType.kt")
|
||||
public void testLambdaWithoutReturnNorExplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/lambdaWithoutReturnNorExplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDeclaration.kt")
|
||||
public void testPropertyDeclaration() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/propertyDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDeclarationQualified.kt")
|
||||
public void testPropertyDeclarationQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/propertyDeclarationQualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDeclarationWithSafeCast.kt")
|
||||
public void testPropertyDeclarationWithSafeCast() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/propertyDeclarationWithSafeCast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDeclarationWithTypeCast.kt")
|
||||
public void testPropertyDeclarationWithTypeCast() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/propertyDeclarationWithTypeCast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDeclarationWithTypeFromRHS.kt")
|
||||
public void testPropertyDeclarationWithTypeFromRHS() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/propertyDeclarationWithTypeFromRHS.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDeclarationWithoutExplicitType.kt")
|
||||
public void testPropertyDeclarationWithoutExplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/propertyDeclarationWithoutExplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnFromFunction.kt")
|
||||
public void testReturnFromFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/returnFromFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnFromFunctionQualifiedReceiver.kt")
|
||||
public void testReturnFromFunctionQualifiedReceiver() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/returnFromFunctionQualifiedReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnFromFunctionQualifiedSelector.kt")
|
||||
public void testReturnFromFunctionQualifiedSelector() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/returnFromFunctionQualifiedSelector.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnFromLambda.kt")
|
||||
public void testReturnFromLambda() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/returnFromLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sam.kt")
|
||||
public void testSam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/sam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samAsArgument.kt")
|
||||
public void testSamAsArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/samAsArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samAsConstructorArgument.kt")
|
||||
public void testSamAsConstructorArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/samAsConstructorArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samAsReturn.kt")
|
||||
public void testSamAsReturn() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/samAsReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samWithExplicitTypeFromProperty.kt")
|
||||
public void testSamWithExplicitTypeFromProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/samWithExplicitTypeFromProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samWithTypeCast.kt")
|
||||
public void testSamWithTypeCast() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/samWithTypeCast.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("variableAssignment.kt")
|
||||
public void testVariableAssignment() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/variableAssignment.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("variableAssignmentQualified.kt")
|
||||
public void testVariableAssignmentQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/variableAssignmentQualified.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whileCondition.kt")
|
||||
public void testWhileCondition() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/whileCondition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whileConditionQualified.kt")
|
||||
public void testWhileConditionQualified() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expectedExpressionType/whileConditionQualified.kt");
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/components/expressionType")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class HLExpressionTypeTestGenerated extends AbstractHLExpressionTypeTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInExpressionType() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/expressionType"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignmentExpressionTarget.kt")
|
||||
public void testAssignmentExpressionTarget() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/assignmentExpressionTarget.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryExpression.kt")
|
||||
public void testBinaryExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/binaryExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("breakExpression.kt")
|
||||
public void testBreakExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/breakExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forExpression.kt")
|
||||
public void testForExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/forExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCall.kt")
|
||||
public void testFunctionCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/functionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inParens.kt")
|
||||
public void testInParens() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/inParens.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("insideStringTemplate.kt")
|
||||
public void testInsideStringTemplate() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/insideStringTemplate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("insideStringTemplateWithBinrary.kt")
|
||||
public void testInsideStringTemplateWithBinrary() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/insideStringTemplateWithBinrary.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intLiteral.kt")
|
||||
public void testIntLiteral() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/intLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExpression.kt")
|
||||
public void testNonExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/nonExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("property.kt")
|
||||
public void testProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/property.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnExpression.kt")
|
||||
public void testReturnExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/returnExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringLiteral.kt")
|
||||
public void testStringLiteral() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/stringLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whileExpression.kt")
|
||||
public void testWhileExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/expressionType/whileExpression.kt");
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/components/importOptimizer")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class HLImportOptimizerTestGenerated extends AbstractHLImportOptimizerTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInImportOptimizer() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/importOptimizer"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedAliasedTypeImport.kt")
|
||||
public void testUnusedAliasedTypeImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/unusedAliasedTypeImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedFunctionImports.kt")
|
||||
public void testUnusedFunctionImports() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/unusedFunctionImports.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unusedInvokeOperatorImport.kt")
|
||||
public void testUnusedInvokeOperatorImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/unusedInvokeOperatorImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedAliasedFunctionReference.kt")
|
||||
public void testUsedAliasedFunctionReference() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/usedAliasedFunctionReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedAliasedTypeImport.kt")
|
||||
public void testUsedAliasedTypeImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/usedAliasedTypeImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedFunctionImport.kt")
|
||||
public void testUsedFunctionImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/usedFunctionImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedInvokeOperatorAliasedImport.kt")
|
||||
public void testUsedInvokeOperatorAliasedImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/usedInvokeOperatorAliasedImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedInvokeOperatorExplicitImport.kt")
|
||||
public void testUsedInvokeOperatorExplicitImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/usedInvokeOperatorExplicitImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedInvokeOperatorImport.kt")
|
||||
public void testUsedInvokeOperatorImport() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/usedInvokeOperatorImport.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ReferencesWithErrors {
|
||||
@Test
|
||||
public void testAllFilesPresentInReferencesWithErrors() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedConstructor_invalidArguments.kt")
|
||||
public void testUsedConstructor_invalidArguments() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors/usedConstructor_invalidArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedConstructor_missingCall.kt")
|
||||
public void testUsedConstructor_missingCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors/usedConstructor_missingCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedExtensionFunction_invalidArguments.kt")
|
||||
public void testUsedExtensionFunction_invalidArguments() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors/usedExtensionFunction_invalidArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedExtensionProperty_invalidReceiver.kt")
|
||||
public void testUsedExtensionProperty_invalidReceiver() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors/usedExtensionProperty_invalidReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedInvokeOperator_invalidArguments.kt")
|
||||
public void testUsedInvokeOperator_invalidArguments() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors/usedInvokeOperator_invalidArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("usedTypeImport_missingGeneric.kt")
|
||||
public void testUsedTypeImport_missingGeneric() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/importOptimizer/referencesWithErrors/usedTypeImport_missingGeneric.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/components/overridenDeclarations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class OverriddenDeclarationProviderTestGenerated extends AbstractOverriddenDeclarationProviderTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInOverridenDeclarations() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/overridenDeclarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inLocalClass.kt")
|
||||
public void testInLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/inLocalClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inOtherFile.kt")
|
||||
public void testInOtherFile() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/inOtherFile.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intersectionOverride.kt")
|
||||
public void testIntersectionOverride() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intersectionOverride2.kt")
|
||||
public void testIntersectionOverride2() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaAccessors.kt")
|
||||
public void testJavaAccessors() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/javaAccessors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleInterfaces.kt")
|
||||
public void testMultipleInterfaces() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/multipleInterfaces.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sequenceOfOverrides.kt")
|
||||
public void testSequenceOfOverrides() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/sequenceOfOverrides.kt");
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/components/declarationRenderer")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class RendererTestGenerated extends AbstractRendererTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInDeclarationRenderer() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/declarationRenderer"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotation.kt")
|
||||
public void testAnnotation() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/annotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("complexTypes.kt")
|
||||
public void testComplexTypes() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/complexTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorInObject.kt")
|
||||
public void testConstructorInObject() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/constructorInObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
||||
public void testConstructorOfAnonymousObject() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/constructorOfAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegates.kt")
|
||||
public void testDelegates() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/delegates.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("derivedClass.kt")
|
||||
public void testDerivedClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/derivedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyAnonymousObject.kt")
|
||||
public void testEmptyAnonymousObject() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/emptyAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/enums.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enums2.kt")
|
||||
public void testEnums2() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/enums2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectActual.kt")
|
||||
public void testExpectActual() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/expectActual.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("F.kt")
|
||||
public void testF() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/F.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypes.kt")
|
||||
public void testFunctionTypes() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/functionTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericFunctions.kt")
|
||||
public void testGenericFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/genericFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/genericProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intersectionType.kt")
|
||||
public void testIntersectionType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/intersectionType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/nestedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NestedOfAliasedType.kt")
|
||||
public void testNestedOfAliasedType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/NestedOfAliasedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NestedSuperType.kt")
|
||||
public void testNestedSuperType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/NestedSuperType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noPrimaryConstructor.kt")
|
||||
public void testNoPrimaryConstructor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/noPrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleClass.kt")
|
||||
public void testSimpleClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/simpleClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFun.kt")
|
||||
public void testSimpleFun() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/simpleFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleTypeAlias.kt")
|
||||
public void testSimpleTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/simpleTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAliasWithGeneric.kt")
|
||||
public void testTypeAliasWithGeneric() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/typeAliasWithGeneric.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsNested.kt")
|
||||
public void testTypeParameterVsNested() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/typeParameterVsNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameters.kt")
|
||||
public void testTypeParameters() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/typeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/vararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("where.kt")
|
||||
public void testWhere() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/components/declarationRenderer/where.kt");
|
||||
}
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.components;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/analysisSession/resolveCall")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ResolveCallTestGenerated extends AbstractResolveCallTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInResolveCall() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/analysisSession/resolveCall"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedConstructorCall_super.kt")
|
||||
public void testDelegatedConstructorCall_super() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/delegatedConstructorCall_super.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedConstructorCall_super_unresolved.kt")
|
||||
public void testDelegatedConstructorCall_super_unresolved() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/delegatedConstructorCall_super_unresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedConstructorCall_this.kt")
|
||||
public void testDelegatedConstructorCall_this() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/delegatedConstructorCall_this.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedConstructorCall_this_unresolved.kt")
|
||||
public void testDelegatedConstructorCall_this_unresolved() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/delegatedConstructorCall_this_unresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallInTheSameFile.kt")
|
||||
public void testFunctionCallInTheSameFile() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionCallInTheSameFile.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallWithLambdaArgument.kt")
|
||||
public void testFunctionCallWithLambdaArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionCallWithLambdaArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallWithNamedArgument.kt")
|
||||
public void testFunctionCallWithNamedArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionCallWithNamedArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallWithNonTrailingLambdaArgument.kt")
|
||||
public void testFunctionCallWithNonTrailingLambdaArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionCallWithNonTrailingLambdaArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallWithSpreadArgument.kt")
|
||||
public void testFunctionCallWithSpreadArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionCallWithSpreadArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallWithVarargArgument.kt")
|
||||
public void testFunctionCallWithVarargArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionCallWithVarargArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionWithReceiverCall.kt")
|
||||
public void testFunctionWithReceiverCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionWithReceiverCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionWithReceiverSafeCall.kt")
|
||||
public void testFunctionWithReceiverSafeCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/functionWithReceiverSafeCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitConstructorDelegationCall.kt")
|
||||
public void testImplicitConstructorDelegationCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/implicitConstructorDelegationCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitConstuctorCall.kt")
|
||||
public void testImplicitConstuctorCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/implicitConstuctorCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitJavaConstuctorCall.kt")
|
||||
public void testImplicitJavaConstuctorCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/implicitJavaConstuctorCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedGet.kt")
|
||||
public void testIndexedGet() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedGetWithNotEnoughArgs.kt")
|
||||
public void testIndexedGetWithNotEnoughArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedGetWithNotEnoughArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedGetWithTooManyArgs.kt")
|
||||
public void testIndexedGetWithTooManyArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedGetWithTooManyArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedSet.kt")
|
||||
public void testIndexedSet() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedSetWithNotEnoughArgs.kt")
|
||||
public void testIndexedSetWithNotEnoughArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedSetWithNotEnoughArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedSetWithTooManyArgs.kt")
|
||||
public void testIndexedSetWithTooManyArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedSetWithTooManyArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaFunctionCall.kt")
|
||||
public void testJavaFunctionCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/javaFunctionCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaPropertyGetter.kt")
|
||||
public void testJavaPropertyGetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/javaPropertyGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaPropertyNestedGetter.kt")
|
||||
public void testJavaPropertyNestedGetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/javaPropertyNestedGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaPropertySetter.kt")
|
||||
public void testJavaPropertySetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/javaPropertySetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaPropertySetterIncomplete.kt")
|
||||
public void testJavaPropertySetterIncomplete() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/javaPropertySetterIncomplete.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinPropertyGetter.kt")
|
||||
public void testKotlinPropertyGetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/kotlinPropertyGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinPropertyNestedGetter.kt")
|
||||
public void testKotlinPropertyNestedGetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/kotlinPropertyNestedGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinPropertySetter.kt")
|
||||
public void testKotlinPropertySetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/kotlinPropertySetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("resolveCallInSuperConstructorParam.kt")
|
||||
public void testResolveCallInSuperConstructorParam() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/resolveCallInSuperConstructorParam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleCallWithNonMatchingArgs.kt")
|
||||
public void testSimpleCallWithNonMatchingArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/simpleCallWithNonMatchingArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedSuperReference.kt")
|
||||
public void testUnresolvedSuperReference() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/unresolvedSuperReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("variableAsFunction.kt")
|
||||
public void testVariableAsFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/variableAsFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("variableAsFunctionLikeCall.kt")
|
||||
public void testVariableAsFunctionLikeCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/variableAsFunctionLikeCall.kt");
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.scopes
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.DebugSymbolRenderer
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractFileScopeTest : AbstractHLApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val actual = executeOnPooledThreadInReadAction {
|
||||
analyse(ktFile) {
|
||||
val symbol = ktFile.getFileSymbol()
|
||||
val scope = symbol.getFileScope()
|
||||
with(DebugSymbolRenderer) {
|
||||
val renderedSymbol = renderExtra(symbol)
|
||||
val callableNames = scope.getPossibleCallableNames()
|
||||
val renderedCallables = scope.getCallableSymbols().map { renderExtra(it) }
|
||||
val classifierNames = scope.getPossibleClassifierNames()
|
||||
val renderedClassifiers = scope.getClassifierSymbols().map { renderExtra(it) }
|
||||
|
||||
"FILE SYMBOL:\n" + renderedSymbol +
|
||||
"\nCALLABLE NAMES:\n" + callableNames.joinToString(prefix = "[", postfix = "]\n", separator = ", ") +
|
||||
"\nCALLABLE SYMBOLS:\n" + renderedCallables.joinToString(separator = "\n") +
|
||||
"\nCLASSIFIER NAMES:\n" + classifierNames.joinToString(prefix = "[", postfix = "]\n", separator = ", ") +
|
||||
"\nCLASSIFIER SYMBOLS:\n" + renderedClassifiers.joinToString(separator = "\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.scopes
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.SymbolByFqName
|
||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.AbstractSymbolByFqNameTest
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractMemberScopeByFqNameTest : AbstractSymbolByFqNameTest() {
|
||||
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): List<KtSymbol> {
|
||||
val symbolData = SymbolByFqName.getSymbolDataFromFile(testDataPath)
|
||||
val symbols = with(symbolData) { toSymbols() }
|
||||
val classSymbol = symbols.singleOrNull() as? KtClassOrObjectSymbol
|
||||
?: error("Should be a single class symbol, but $symbols found")
|
||||
return classSymbol.getMemberScope().getAllSymbols().toList()
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.scopes;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/fileScopeTest")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FileScopeTestGenerated extends AbstractFileScopeTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInFileScopeTest() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/fileScopeTest"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFileScope.kt")
|
||||
public void testSimpleFileScope() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/fileScopeTest/simpleFileScope.kt");
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.scopes;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/memberScopeByFqName")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class MemberScopeByFqNameTestGenerated extends AbstractMemberScopeByFqNameTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInMemberScopeByFqName() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/memberScopeByFqName"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Int.kt")
|
||||
public void testInt() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/memberScopeByFqName/Int.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("java.lang.String.kt")
|
||||
public void testJava_lang_String() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/memberScopeByFqName/java.lang.String.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlin.Function2.kt")
|
||||
public void testKotlin_Function2() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/memberScopeByFqName/kotlin.Function2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("MutableList.kt")
|
||||
public void testMutableList() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/memberScopeByFqName/MutableList.kt");
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.SymbolByFqName
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractSymbolByFqNameTest : AbstractSymbolTest() {
|
||||
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): List<KtSymbol> {
|
||||
val symbolData = SymbolByFqName.getSymbolDataFromFile(testDataPath)
|
||||
return with(symbolData) { toSymbols() }
|
||||
}
|
||||
|
||||
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||
super.configureTest(builder)
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+JvmEnvironmentConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractSymbolByPsiTest : AbstractSymbolTest() {
|
||||
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): List<KtSymbol> {
|
||||
return ktFile.collectDescendantsOfType<KtDeclaration> { it.isValidForSymbolCreation }.map { declaration ->
|
||||
declaration.getSymbol()
|
||||
}
|
||||
}
|
||||
|
||||
private val KtDeclaration.isValidForSymbolCreation
|
||||
get() =
|
||||
when (this) {
|
||||
is KtParameter -> !this.isFunctionTypeParameter
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractSymbolByReferenceTest : AbstractSymbolTest() {
|
||||
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): List<KtSymbol> {
|
||||
val referenceExpression = testServices.expressionMarkerProvider.getElementOfTypAtCaret<KtNameReferenceExpression>(ktFile)
|
||||
return listOfNotNull(referenceExpression.mainReference.resolveToSymbol())
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinModificationTrackerFactory
|
||||
import org.jetbrains.kotlin.analysis.api.fir.analyseOnPooledThreadInReadAction
|
||||
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.DebugSymbolRenderer
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractSymbolTest : AbstractHLApiSingleFileTest() {
|
||||
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||
super.configureTest(builder)
|
||||
with(builder) {
|
||||
useDirectives(SymbolTestDirectives)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): List<KtSymbol>
|
||||
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val createPointers = SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE !in module.directives
|
||||
val pointersWithRendered = analyseOnPooledThreadInReadAction(ktFile) {
|
||||
collectSymbols(ktFile, testServices).map { symbol ->
|
||||
PointerWithRenderedSymbol(
|
||||
if (createPointers) symbol.createPointer() else null,
|
||||
with(DebugSymbolRenderer) { renderExtra(symbol) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compareResults(pointersWithRendered, testServices)
|
||||
|
||||
doOutOfBlockModification(ktFile)
|
||||
|
||||
|
||||
if (createPointers) {
|
||||
restoreSymbolsInOtherReadActionAndCompareResults(ktFile, pointersWithRendered, testServices)
|
||||
}
|
||||
}
|
||||
|
||||
private fun compareResults(
|
||||
pointersWithRendered: List<PointerWithRenderedSymbol>,
|
||||
testServices: TestServices,
|
||||
) {
|
||||
val actual = pointersWithRendered.joinToString(separator = "\n") { it.rendered }
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
|
||||
private fun restoreSymbolsInOtherReadActionAndCompareResults(
|
||||
ktFile: KtFile,
|
||||
pointersWithRendered: List<PointerWithRenderedSymbol>,
|
||||
testServices: TestServices,
|
||||
) {
|
||||
val restored = analyseOnPooledThreadInReadAction(ktFile) {
|
||||
pointersWithRendered.map { (pointer, expectedRender) ->
|
||||
val restored = pointer!!.restoreSymbol()
|
||||
?: error("Symbol $expectedRender was not restored")
|
||||
with(DebugSymbolRenderer) { renderExtra(restored) }
|
||||
}
|
||||
}
|
||||
val actual = restored.joinToString(separator = "\n")
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
|
||||
private fun doOutOfBlockModification(ktFile: KtFile) {
|
||||
ServiceManager.getService(ktFile.project, KotlinModificationTrackerFactory::class.java)
|
||||
.incrementModificationsCount()
|
||||
}
|
||||
}
|
||||
|
||||
private object SymbolTestDirectives : SimpleDirectivesContainer() {
|
||||
val DO_NOT_CHECK_SYMBOL_RESTORE by directive(
|
||||
description = "Symbol restoring for some symbols in current test is not supported yet",
|
||||
applicability = DirectiveApplicability.Global
|
||||
)
|
||||
}
|
||||
|
||||
private data class PointerWithRenderedSymbol(val pointer: KtSymbolPointer<*>?, val rendered: String)
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/symbols/symbolByFqName")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SymbolByFqNameTestGenerated extends AbstractSymbolByFqNameTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInSymbolByFqName() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/symbols/symbolByFqName"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("class.kt")
|
||||
public void testClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/class.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classFromJdk.kt")
|
||||
public void testClassFromJdk() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/classFromJdk.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/enumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileWalkDirectionEnum.kt")
|
||||
public void testFileWalkDirectionEnum() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/fileWalkDirectionEnum.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("iterator.kt")
|
||||
public void testIterator() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/iterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("listOf.kt")
|
||||
public void testListOf() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/listOf.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunction.kt")
|
||||
public void testMemberFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/memberFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunctionWithOverloads.kt")
|
||||
public void testMemberFunctionWithOverloads() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/memberFunctionWithOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByFqName/nestedClass.kt");
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/symbols/symbolByPsi")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SymbolByPsiTestGenerated extends AbstractSymbolByPsiTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInSymbolByPsi() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/symbols/symbolByPsi"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations.kt")
|
||||
public void testAnnotations() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/annotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousObject.kt")
|
||||
public void testAnonymousObject() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/anonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("backingField.kt")
|
||||
public void testBackingField() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/backingField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("class.kt")
|
||||
public void testClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/class.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classMembes.kt")
|
||||
public void testClassMembes() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/classMembes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classPrimaryConstructor.kt")
|
||||
public void testClassPrimaryConstructor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/classPrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classSecondaryConstructors.kt")
|
||||
public void testClassSecondaryConstructors() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/classSecondaryConstructors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classWithTypeParams.kt")
|
||||
public void testClassWithTypeParams() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/classWithTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/deprecated.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/enum.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumValueMember.kt")
|
||||
public void testEnumValueMember() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/enumValueMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/extensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/function.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionWithTypeParams.kt")
|
||||
public void testFunctionWithTypeParams() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/functionWithTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitConstructorDelegationCall.kt")
|
||||
public void testImplicitConstructorDelegationCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/implicitConstructorDelegationCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitReturn.kt")
|
||||
public void testImplicitReturn() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/implicitReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitReturnInLambda.kt")
|
||||
public void testImplicitReturnInLambda() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/implicitReturnInLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmName.kt")
|
||||
public void testJvmName() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/jvmName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localDeclarations.kt")
|
||||
public void testLocalDeclarations() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/localDeclarations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunctions.kt")
|
||||
public void testMemberFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/memberFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberProperties.kt")
|
||||
public void testMemberProperties() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/memberProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("outerAndInnerClasses.kt")
|
||||
public void testOuterAndInnerClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/outerAndInnerClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunctions.kt")
|
||||
public void testTopLevelFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/topLevelFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelProperties.kt")
|
||||
public void testTopLevelProperties() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/topLevelProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAlias.kt")
|
||||
public void testTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/typeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAnnotations.kt")
|
||||
public void testTypeAnnotations() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/typeAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("varargFunctions.kt")
|
||||
public void testVarargFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/varargFunctions.kt");
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.symbols;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/testData/symbols/symbolByReference")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SymbolByReferenceTestGenerated extends AbstractSymbolByReferenceTest {
|
||||
@Test
|
||||
@TestMetadata("accessorField.kt")
|
||||
public void testAccessorField() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByReference/accessorField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInSymbolByReference() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/symbols/symbolByReference"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorViaTypeAlias.kt")
|
||||
public void testConstructorViaTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByReference/constructorViaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConstructor.kt")
|
||||
public void testSamConstructor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByReference/samConstructor.kt");
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.test.framework
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractHLApiSingleFileTest : AbstractHLApiSingleModuleTest() {
|
||||
final override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||
val singleFile = ktFiles.single()
|
||||
doTestByFileStructure(singleFile, module, testServices)
|
||||
}
|
||||
|
||||
protected abstract fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.test.framework
|
||||
|
||||
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 AbstractHLApiSingleModuleTest : AbstractHLApiTest() {
|
||||
final override fun doTestByFileStructure(ktFiles: List<KtFile>, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val singleModule = moduleStructure.modules.single()
|
||||
doTestByFileStructure(ktFiles, singleModule, testServices)
|
||||
}
|
||||
|
||||
protected abstract fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.test.framework
|
||||
|
||||
import com.intellij.mock.MockApplication
|
||||
import com.intellij.mock.MockProject
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiTest
|
||||
import org.jetbrains.kotlin.analysis.api.InvalidWayOfUsingAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSessionProvider
|
||||
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSessionProvider
|
||||
import org.jetbrains.kotlin.idea.references.HLApiReferenceProviderService
|
||||
import org.jetbrains.kotlin.idea.references.KotlinFirReferenceContributor
|
||||
import org.jetbrains.kotlin.idea.references.KotlinReferenceProviderContributor
|
||||
import org.jetbrains.kotlin.psi.KotlinReferenceProvidersService
|
||||
|
||||
abstract class AbstractHLApiTest : AbstractLowLevelApiTest() {
|
||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||
override fun registerServicesForProject(project: MockProject) {
|
||||
super.registerServicesForProject(project)
|
||||
project.registerService(KtAnalysisSessionProvider::class.java, KtFirAnalysisSessionProvider::class.java)
|
||||
}
|
||||
|
||||
override fun registerApplicationServices(application: MockApplication) {
|
||||
super.registerApplicationServices(application)
|
||||
if (application.getServiceIfCreated(KotlinReferenceProvidersService::class.java) != null) return
|
||||
application.registerService(KotlinReferenceProvidersService::class.java, HLApiReferenceProviderService::class.java)
|
||||
application.registerService(KotlinReferenceProviderContributor::class.java, KotlinFirReferenceContributor::class.java)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.util.Computable
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.DuplicatedFirSourceElementsException
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.analyse
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import java.io.File
|
||||
|
||||
|
||||
inline fun <T> runReadAction(crossinline runnable: () -> T): T {
|
||||
return ApplicationManager.getApplication().runReadAction(Computable { runnable() })
|
||||
}
|
||||
|
||||
fun <R> executeOnPooledThreadInReadAction(action: () -> R): R =
|
||||
ApplicationManager.getApplication().executeOnPooledThread<R> { runReadAction(action) }.get()
|
||||
|
||||
inline fun <R> analyseOnPooledThreadInReadAction(context: KtElement, crossinline action: KtAnalysisSession.() -> R): R =
|
||||
executeOnPooledThreadInReadAction {
|
||||
analyse(context) { action() }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Temporary
|
||||
* @see org.jetbrains.kotlin.analysis.low.level.api.fir.DuplicatedFirSourceElementsException.IS_ENABLED
|
||||
*/
|
||||
inline fun <T> withPossiblyDisabledDuplicatedFirSourceElementsException(fileText: String, action: () -> T): T {
|
||||
val isDisabled = InTextDirectivesUtils.isDirectiveDefined(fileText, "IGNORE_DUPLICATED_FIR_SOURCE_EXCEPTION")
|
||||
|
||||
@Suppress("LiftReturnOrAssignment")
|
||||
if (isDisabled) {
|
||||
val wasEnabled = DuplicatedFirSourceElementsException.IS_ENABLED
|
||||
DuplicatedFirSourceElementsException.IS_ENABLED = false
|
||||
try {
|
||||
return action()
|
||||
} finally {
|
||||
DuplicatedFirSourceElementsException.IS_ENABLED = wasEnabled
|
||||
}
|
||||
} else {
|
||||
return action()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user