FIR IDE: move low level api test sources to the analysis directory
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.low.level.api.fir
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
||||
import org.jetbrains.kotlin.fir.builder.BodyBuildingMode
|
||||
import org.jetbrains.kotlin.fir.builder.PsiHandlingMode
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirLazyBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirLazyExpression
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.FirLazyBodiesCalculator
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.providers.firIdeProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractFirLazyBodiesCalculatorTest : AbstractLowLevelApiSingleFileTest() {
|
||||
|
||||
private val lazyChecker = object : FirVisitorVoid() {
|
||||
override fun visitElement(element: FirElement) {
|
||||
TestCase.assertFalse("${FirLazyBlock::class.qualifiedName} should not present in the tree", element is FirLazyBlock)
|
||||
TestCase.assertFalse("${FirLazyExpression::class.qualifiedName} should not present in the tree", element is FirLazyExpression)
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
resolveWithClearCaches(ktFile) { resolveState ->
|
||||
val session = resolveState.rootModuleSession
|
||||
val provider = session.firIdeProvider.kotlinScopeProvider
|
||||
|
||||
val laziedFirFile = RawFirBuilder(
|
||||
session,
|
||||
provider,
|
||||
psiMode = PsiHandlingMode.IDE,
|
||||
bodyBuildingMode = BodyBuildingMode.LAZY_BODIES
|
||||
).buildFirFile(ktFile)
|
||||
|
||||
FirLazyBodiesCalculator.calculateLazyBodies(laziedFirFile)
|
||||
laziedFirFile.accept(lazyChecker)
|
||||
|
||||
val fullFirFile = RawFirBuilder(
|
||||
session,
|
||||
provider,
|
||||
psiMode = PsiHandlingMode.IDE,
|
||||
bodyBuildingMode = BodyBuildingMode.NORMAL
|
||||
).buildFirFile(ktFile)
|
||||
|
||||
val laziedFirFileDump = StringBuilder().also { FirRenderer(it).visitFile(laziedFirFile) }.toString()
|
||||
val fullFirFileDump = StringBuilder().also { FirRenderer(it).visitFile(fullFirFile) }.toString()
|
||||
|
||||
TestCase.assertEquals(laziedFirFileDump, fullFirFileDump)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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.low.level.api.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.realPsi
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.withFirDeclaration
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.ResolveType
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
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.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import org.junit.jupiter.api.parallel.Execution
|
||||
import org.junit.jupiter.api.parallel.ExecutionMode
|
||||
|
||||
/**
|
||||
* Test that we do not resolve declarations we do not need & do not build bodies for them
|
||||
*/
|
||||
@Execution(ExecutionMode.SAME_THREAD)
|
||||
abstract class AbstractFirLazyDeclarationResolveTest : AbstractLowLevelApiSingleFileTest() {
|
||||
|
||||
private fun FirFile.findResolveMe(): FirDeclaration {
|
||||
val visitor = object : FirVisitorVoid() {
|
||||
var result: FirDeclaration? = null
|
||||
override fun visitElement(element: FirElement) {
|
||||
if (result != null) return
|
||||
val declaration = element.realPsi as? KtDeclaration
|
||||
if (element is FirDeclaration && declaration != null && declaration.name == "resolveMe") {
|
||||
result = element
|
||||
return
|
||||
}
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
|
||||
}
|
||||
accept(visitor)
|
||||
return visitor.result ?: error("declaration with name `resolveMe` was not found")
|
||||
}
|
||||
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val rendererOption = FirRenderer.RenderMode.WithDeclarationAttributes.copy(renderDeclarationResolvePhase = true)
|
||||
val resultBuilder = StringBuilder()
|
||||
resolveWithClearCaches(ktFile) { firModuleResolveState ->
|
||||
check(firModuleResolveState is FirModuleResolveStateImpl)
|
||||
val declarationToResolve = firModuleResolveState
|
||||
.getOrBuildFirFile(ktFile)
|
||||
.findResolveMe()
|
||||
for (currentPhase in FirResolvePhase.values()) {
|
||||
if (currentPhase.pluginPhase || currentPhase == FirResolvePhase.SEALED_CLASS_INHERITORS) continue
|
||||
declarationToResolve.withFirDeclaration(firModuleResolveState, currentPhase) {
|
||||
val firFile = firModuleResolveState.getOrBuildFirFile(ktFile)
|
||||
resultBuilder.append("\n${currentPhase.name}:\n")
|
||||
resultBuilder.append(firFile.render(rendererOption))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (resolveType in ResolveType.values()) {
|
||||
resolveWithClearCaches(ktFile) { firModuleResolveState ->
|
||||
check(firModuleResolveState is FirModuleResolveStateImpl)
|
||||
val declarationToResolve = firModuleResolveState
|
||||
.getOrBuildFirFile(ktFile)
|
||||
.findResolveMe()
|
||||
|
||||
when (resolveType) {
|
||||
ResolveType.CallableReturnType,
|
||||
ResolveType.CallableBodyResolve,
|
||||
ResolveType.CallableContracts -> if (declarationToResolve !is FirCallableDeclaration) return@resolveWithClearCaches
|
||||
ResolveType.ClassSuperTypes -> if (declarationToResolve !is FirClassLikeDeclaration) return@resolveWithClearCaches
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
declarationToResolve.withFirDeclaration(resolveType, firModuleResolveState) {
|
||||
val firFile = firModuleResolveState.getOrBuildFirFile(ktFile)
|
||||
resultBuilder.append("\n${resolveType.name}:\n")
|
||||
resultBuilder.append(firFile.render(rendererOption))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resolveWithClearCaches(ktFile) { firModuleResolveState ->
|
||||
check(firModuleResolveState is FirModuleResolveStateImpl)
|
||||
val firFile = firModuleResolveState.getOrBuildFirFile(ktFile)
|
||||
firFile.withFirDeclaration(firModuleResolveState, FirResolvePhase.BODY_RESOLVE) {
|
||||
resultBuilder.append("\nFILE RAW TO BODY:\n")
|
||||
resultBuilder.append(firFile.render(rendererOption))
|
||||
}
|
||||
}
|
||||
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), resultBuilder.toString())
|
||||
}
|
||||
|
||||
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||
super.configureTest(builder)
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+JvmEnvironmentConfigurationDirectives.WITH_STDLIB
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+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.low.level.api.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LowLevelFirApiFacadeForResolveOnAir
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtAnnotated
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtFileAnnotationList
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.util.findElementByCommentPrefix
|
||||
|
||||
abstract class AbstractFirOnAirResolveTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
fun fixUpAnnotations(element: KtElement): KtElement = when (element) {
|
||||
is KtAnnotated -> element.annotationEntries.firstOrNull() ?: element
|
||||
is KtFileAnnotationList -> element.annotationEntries.first()
|
||||
else -> element
|
||||
}
|
||||
|
||||
val place = (ktFile.findElementByCommentPrefix("/*PLACE*/") as KtElement).let(::fixUpAnnotations)
|
||||
val onAir = (ktFile.findElementByCommentPrefix("/*ONAIR*/") as KtElement).let(::fixUpAnnotations)
|
||||
|
||||
check(place::class == onAir::class)
|
||||
|
||||
resolveWithClearCaches(ktFile) { resolveState ->
|
||||
check(resolveState is FirModuleResolveStateImpl)
|
||||
val firElement = LowLevelFirApiFacadeForResolveOnAir.onAirResolveElement(resolveState, place, onAir)
|
||||
val rendered = firElement.render(FirRenderer.RenderMode.WithResolvePhases)
|
||||
KotlinTestUtils.assertEqualsToFile(testDataFileSibling(".txt"), rendered)
|
||||
}
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.low.level.api.fir
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirImport
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFir
|
||||
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.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractGetOrBuildFirTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun configureTest(builder: TestConfigurationBuilder) {
|
||||
super.configureTest(builder)
|
||||
with(builder) {
|
||||
useDirectives(Directives)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val selectedElement = getElementOfType(ktFile, moduleStructure, testServices) as KtElement
|
||||
|
||||
val actual = resolveWithClearCaches(ktFile) { state ->
|
||||
val fir = selectedElement.getOrBuildFir(state)
|
||||
"""|KT element: ${selectedElement::class.simpleName}
|
||||
|FIR element: ${fir?.let { it::class.simpleName }}
|
||||
|
|
||||
|FIR element rendered:
|
||||
|${render(fir)}""".trimMargin()
|
||||
}
|
||||
testServices.assertions.assertEqualsToFile(testDataFileSibling(".txt"), actual)
|
||||
}
|
||||
|
||||
private fun getElementOfType(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices): PsiElement {
|
||||
val selectedElement = testServices.expressionMarkerProvider.getSelectedElement(ktFile)
|
||||
val expectedType = moduleStructure.allDirectives[Directives.LOOK_UP_FOR_ELEMENT_OF_TYPE].firstOrNull() ?: return selectedElement
|
||||
@Suppress("UNCHECKED_CAST") val expectedClass = Class.forName(expectedType) as Class<PsiElement>
|
||||
if (expectedClass.isInstance(selectedElement)) return selectedElement
|
||||
|
||||
return listOfNotNull(
|
||||
PsiTreeUtil.getChildOfType(selectedElement, expectedClass),
|
||||
).single { it.textRange == selectedElement.textRange }
|
||||
}
|
||||
|
||||
private fun render(firElement: FirElement?): String = when (firElement) {
|
||||
null -> "null"
|
||||
is FirImport -> "import ${firElement.importedFqName}"
|
||||
else -> firElement.render(renderingMode)
|
||||
}
|
||||
|
||||
private val renderingMode = FirRenderer.RenderMode.Normal.copy(
|
||||
renderPackageDirective = true,
|
||||
)
|
||||
|
||||
private object Directives : SimpleDirectivesContainer() {
|
||||
val LOOK_UP_FOR_ELEMENT_OF_TYPE by stringDirective("LOOK_UP_FOR_ELEMENT_OF_TYPE")
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.low.level.api.fir
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.builder.PsiHandlingMode
|
||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
|
||||
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionFactory
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDeclarationDesignation
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.RawFirNonLocalDeclarationBuilder
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import kotlin.io.path.readText
|
||||
|
||||
abstract class AbstractPartialRawFirBuilderTestCase : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val fileText = testDataPath.readText()
|
||||
val functionName = InTextDirectivesUtils.findStringWithPrefixes(fileText, FUNCTION_DIRECTIVE)
|
||||
val propertyName = InTextDirectivesUtils.findStringWithPrefixes(fileText, PROPERTY_DIRECTIVE)
|
||||
|
||||
when {
|
||||
functionName != null -> testFunctionPartialBuilding(ktFile, functionName)
|
||||
propertyName != null -> testPropertyPartialBuilding(ktFile, propertyName)
|
||||
else -> testServices.assertions.fail { "No '$FUNCTION_DIRECTIVE' or '$PROPERTY_DIRECTIVE' directives found!" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun testFunctionPartialBuilding(ktFile: KtFile, nameToFind: String) {
|
||||
testPartialBuilding(
|
||||
ktFile
|
||||
) { file -> file.findDescendantOfType<KtNamedFunction> { it.name == nameToFind }!! }
|
||||
}
|
||||
|
||||
private fun testPropertyPartialBuilding(ktFile: KtFile, nameToFind: String) {
|
||||
testPartialBuilding(
|
||||
ktFile
|
||||
) { file -> file.findDescendantOfType<KtProperty> { it.name == nameToFind }!! }
|
||||
}
|
||||
|
||||
private class DesignationBuilder(private val elementToBuild: KtDeclaration) : FirVisitorVoid() {
|
||||
private val path = mutableListOf<FirDeclaration>()
|
||||
var resultDesignation: FirDeclarationDesignation? = null
|
||||
private set
|
||||
|
||||
override fun visitElement(element: FirElement) {
|
||||
if (resultDesignation != null) return
|
||||
when (element) {
|
||||
is FirSimpleFunction, is FirProperty -> {
|
||||
if (element.psi == elementToBuild) {
|
||||
val originalDeclaration = element as FirDeclaration
|
||||
resultDesignation = FirDeclarationDesignation(path, originalDeclaration)
|
||||
} else {
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
}
|
||||
is FirRegularClass -> {
|
||||
path.add(element)
|
||||
element.acceptChildren(this)
|
||||
if (resultDesignation == null) {
|
||||
path.removeLast()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun <T : KtElement> testPartialBuilding(
|
||||
file: KtFile,
|
||||
findPsiElement: (KtFile) -> T
|
||||
) {
|
||||
val elementToBuild = findPsiElement(file) as KtDeclaration
|
||||
|
||||
val scopeProvider = object : FirScopeProvider() {
|
||||
override fun getUseSiteMemberScope(klass: FirClass, useSiteSession: FirSession, scopeSession: ScopeSession): FirTypeScope =
|
||||
error("Should not be called")
|
||||
|
||||
override fun getStaticMemberScopeForCallables(
|
||||
klass: FirClass,
|
||||
useSiteSession: FirSession,
|
||||
scopeSession: ScopeSession
|
||||
): FirScope =
|
||||
error("Should not be called")
|
||||
|
||||
override fun getNestedClassifierScope(klass: FirClass, useSiteSession: FirSession, scopeSession: ScopeSession): FirScope =
|
||||
error("Should not be called")
|
||||
}
|
||||
|
||||
val session = FirSessionFactory.createEmptySession()
|
||||
val firBuilder = RawFirBuilder(session, scopeProvider, PsiHandlingMode.IDE)
|
||||
val original = firBuilder.buildFirFile(file)
|
||||
|
||||
val designationBuilder = DesignationBuilder(elementToBuild)
|
||||
original.accept(designationBuilder)
|
||||
val designation = designationBuilder.resultDesignation
|
||||
TestCase.assertTrue(designation != null)
|
||||
|
||||
val firElement = RawFirNonLocalDeclarationBuilder.buildWithReplacement(
|
||||
session = session,
|
||||
scopeProvider = scopeProvider,
|
||||
designation!!,
|
||||
elementToBuild,
|
||||
null
|
||||
)
|
||||
|
||||
val firDump = firElement.render(FirRenderer.RenderMode.WithFqNames)
|
||||
KotlinTestUtils.assertEqualsToFile(testDataFileSibling(".txt"), firDump)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val FUNCTION_DIRECTIVE = "// FUNCTION: "
|
||||
private const val PROPERTY_DIRECTIVE = "// PROPERTY: "
|
||||
}
|
||||
}
|
||||
+472
@@ -0,0 +1,472 @@
|
||||
/*
|
||||
* 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.low.level.api.fir;
|
||||
|
||||
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("compiler/fir/raw-fir/psi2fir/testData/rawBuilder")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirLazyBodiesCalculatorTestGenerated extends AbstractFirLazyBodiesCalculatorTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInRawBuilder() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Declarations {
|
||||
@Test
|
||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotation.kt")
|
||||
public void testAnnotation() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsOnNullableParenthesizedTypes.kt")
|
||||
public void testAnnotationsOnNullableParenthesizedTypes() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationsOnNullableParenthesizedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsOnParenthesizedTypes.kt")
|
||||
public void testAnnotationsOnParenthesizedTypes() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationsOnParenthesizedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("complexTypes.kt")
|
||||
public void testComplexTypes() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorInObject.kt")
|
||||
public void testConstructorInObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
||||
public void testConstructorOfAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegates.kt")
|
||||
public void testDelegates() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/delegates.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("derivedClass.kt")
|
||||
public void testDerivedClass() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyAnonymousObject.kt")
|
||||
public void testEmptyAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enums2.kt")
|
||||
public void testEnums2() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("expectActual.kt")
|
||||
public void testExpectActual() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("external.kt")
|
||||
public void testExternal() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("F.kt")
|
||||
public void testF() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/F.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypes.kt")
|
||||
public void testFunctionTypes() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericFunctions.kt")
|
||||
public void testGenericFunctions() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initBlockWithDeclarations.kt")
|
||||
public void testInitBlockWithDeclarations() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NestedOfAliasedType.kt")
|
||||
public void testNestedOfAliasedType() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NestedSuperType.kt")
|
||||
public void testNestedSuperType() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noPrimaryConstructor.kt")
|
||||
public void testNoPrimaryConstructor() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleClass.kt")
|
||||
public void testSimpleClass() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFun.kt")
|
||||
public void testSimpleFun() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleTypeAlias.kt")
|
||||
public void testSimpleTypeAlias() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("splitModifierList.kt")
|
||||
public void testSplitModifierList() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/splitModifierList.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionTypes.kt")
|
||||
public void testSuspendFunctionTypes() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/suspendFunctionTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAliasWithGeneric.kt")
|
||||
public void testTypeAliasWithGeneric() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsNested.kt")
|
||||
public void testTypeParameterVsNested() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameters.kt")
|
||||
public void testTypeParameters() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("where.kt")
|
||||
public void testWhere() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Contracts {
|
||||
@Test
|
||||
public void testAllFilesPresentInContracts() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class NewSyntax {
|
||||
@Test
|
||||
public void testAllFilesPresentInNewSyntax() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionWithBothOldAndNewSyntaxContractDescription.kt")
|
||||
public void testFunctionWithBothOldAndNewSyntaxContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/functionWithBothOldAndNewSyntaxContractDescription.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAccessorsContractDescription.kt")
|
||||
public void testPropertyAccessorsContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/propertyAccessorsContractDescription.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctionsContractDescription.kt")
|
||||
public void testSimpleFunctionsContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/simpleFunctionsContractDescription.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class OldSyntax {
|
||||
@Test
|
||||
public void testAllFilesPresentInOldSyntax() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contractDescription.kt")
|
||||
public void testContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax/contractDescription.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Expressions {
|
||||
@Test
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotated.kt")
|
||||
public void testAnnotated() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("arrayAccess.kt")
|
||||
public void testArrayAccess() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("arrayAssignment.kt")
|
||||
public void testArrayAssignment() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("branches.kt")
|
||||
public void testBranches() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/branches.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callableReferences.kt")
|
||||
public void testCallableReferences() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("calls.kt")
|
||||
public void testCalls() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classReference.kt")
|
||||
public void testClassReference() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/classReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("collectionLiterals.kt")
|
||||
public void testCollectionLiterals() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("destructuring.kt")
|
||||
public void testDestructuring() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("for.kt")
|
||||
public void testFor() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericCalls.kt")
|
||||
public void testGenericCalls() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("in.kt")
|
||||
public void testIn() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/in.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inBrackets.kt")
|
||||
public void testInBrackets() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("init.kt")
|
||||
public void testInit() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/init.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labelForInfix.kt")
|
||||
public void testLabelForInfix() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/labelForInfix.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaAndAnonymousFunction.kt")
|
||||
public void testLambdaAndAnonymousFunction() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localDeclarationWithExpression.kt")
|
||||
public void testLocalDeclarationWithExpression() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/localDeclarationWithExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("locals.kt")
|
||||
public void testLocals() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("modifications.kt")
|
||||
public void testModifications() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/modifications.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("namedArgument.kt")
|
||||
public void testNamedArgument() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullability.kt")
|
||||
public void testNullability() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/nullability.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierWithTypeArguments.kt")
|
||||
public void testQualifierWithTypeArguments() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleReturns.kt")
|
||||
public void testSimpleReturns() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("super.kt")
|
||||
public void testSuper() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/super.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("these.kt")
|
||||
public void testThese() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/these.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("try.kt")
|
||||
public void testTry() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/try.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeOperators.kt")
|
||||
public void testTypeOperators() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unary.kt")
|
||||
public void testUnary() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("variables.kt")
|
||||
public void testVariables() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/variables.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("while.kt")
|
||||
public void testWhile() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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.low.level.api.fir;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/lazyResolve")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirLazyDeclarationResolveTestGenerated extends AbstractFirLazyDeclarationResolveTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInLazyResolve() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationParameters.kt")
|
||||
public void testAnnotationParameters() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/annotationParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations.kt")
|
||||
public void testAnnotations() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/annotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classMembers.kt")
|
||||
public void testClassMembers() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/classMembers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegates.kt")
|
||||
public void testDelegates() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/delegates.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionWithParameter.kt")
|
||||
public void testFunctionWithParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/functionWithParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localDeclaration.kt")
|
||||
public void testLocalDeclaration() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/localDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/localFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("parameterOfLocalSetter.kt")
|
||||
public void testParameterOfLocalSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/parameterOfLocalSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("parameterOfNonLocalSetter.kt")
|
||||
public void testParameterOfNonLocalSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/parameterOfNonLocalSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyWithGetter.kt")
|
||||
public void testPropertyWithGetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyWithGetterAndSetter.kt")
|
||||
public void testPropertyWithGetterAndSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithGetterAndSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyWithInitializer.kt")
|
||||
public void testPropertyWithInitializer() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/propertyWithInitializer.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("secondaryConstructor.kt")
|
||||
public void testSecondaryConstructor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/secondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superTypes.kt")
|
||||
public void testSuperTypes() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/superTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superTypesLoop.kt")
|
||||
public void testSuperTypesLoop() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/superTypesLoop.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunctions.kt")
|
||||
public void testTopLevelFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunctionsWithExpressionBodyAndExplicitType.kt")
|
||||
public void testTopLevelFunctionsWithExpressionBodyAndExplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunctionsWithImplicitType.kt")
|
||||
public void testTopLevelFunctionsWithImplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/topLevelFunctionsWithImplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterOfLocalFunction.kt")
|
||||
public void testTypeParameterOfLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfLocalFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterOfNonLocalFunction.kt")
|
||||
public void testTypeParameterOfNonLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfNonLocalFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterOfTopFunction.kt")
|
||||
public void testTypeParameterOfTopFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfTopFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterOfTopSetter.kt")
|
||||
public void testTypeParameterOfTopSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/lazyResolve/typeParameterOfTopSetter.kt");
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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.low.level.api.fir;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/onAirResolve")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirOnAirResolveTestGenerated extends AbstractFirOnAirResolveTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInOnAirResolve() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classInClass.kt")
|
||||
public void testClassInClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/classInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileAnnotation.kt")
|
||||
public void testFileAnnotation() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/fileAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("identifierInContext.kt")
|
||||
public void testIdentifierInContext() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/identifierInContext.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inParameter.kt")
|
||||
public void testInParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/inParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incompleteIdentifier.kt")
|
||||
public void testIncompleteIdentifier() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/incompleteIdentifier.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/localClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/localFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("loopConstruction.kt")
|
||||
public void testLoopConstruction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/loopConstruction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberInClass.kt")
|
||||
public void testMemberInClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/memberInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberPropertyInClass.kt")
|
||||
public void testMemberPropertyInClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/memberPropertyInClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberWithOverride.kt")
|
||||
public void testMemberWithOverride() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/memberWithOverride.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("onAirTypesResolve.kt")
|
||||
public void testOnAirTypesResolve() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/onAirTypesResolve.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("replacementInHeader.kt")
|
||||
public void testReplacementInHeader() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInHeader.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("replacementInsidePropertyBody.kt")
|
||||
public void testReplacementInsidePropertyBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInsidePropertyBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("replacementInsidePropertyBody2.kt")
|
||||
public void testReplacementInsidePropertyBody2() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInsidePropertyBody2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAlias.kt")
|
||||
public void testTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
+662
@@ -0,0 +1,662 @@
|
||||
/*
|
||||
* 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.low.level.api.fir;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/getOrBuildFir")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class GetOrBuildFirTestGenerated extends AbstractGetOrBuildFirTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInGetOrBuildFir() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Annotations {
|
||||
@Test
|
||||
public void testAllFilesPresentInAnnotations() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationApplicationArgument.kt")
|
||||
public void testAnnotationApplicationArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations/annotationApplicationArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationApplicationArgumentList.kt")
|
||||
public void testAnnotationApplicationArgumentList() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations/annotationApplicationArgumentList.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationApplicationCallExpression.kt")
|
||||
public void testAnnotationApplicationCallExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations/annotationApplicationCallExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationApplicationVarargArgument.kt")
|
||||
public void testAnnotationApplicationVarargArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations/annotationApplicationVarargArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationApplicationWithArguments.kt")
|
||||
public void testAnnotationApplicationWithArguments() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations/annotationApplicationWithArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileAnnotation.kt")
|
||||
public void testFileAnnotation() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/annotations/fileAnnotation.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Calls {
|
||||
@Test
|
||||
public void testAllFilesPresentInCalls() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callArgument.kt")
|
||||
public void testCallArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/callArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("calllTypeArguments.kt")
|
||||
public void testCalllTypeArguments() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/calllTypeArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorDelegationSuperCall.kt")
|
||||
public void testConstructorDelegationSuperCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/constructorDelegationSuperCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorDelegationThisCall.kt")
|
||||
public void testConstructorDelegationThisCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/constructorDelegationThisCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionCallArgumentList.kt")
|
||||
public void testFunctionCallArgumentList() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/functionCallArgumentList.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invokeCallArgumentList.kt")
|
||||
public void testInvokeCallArgumentList() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/invokeCallArgumentList.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifiedCallSelector.kt")
|
||||
public void testQualifiedCallSelector() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/qualifiedCallSelector.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifiedWholeCall.kt")
|
||||
public void testQualifiedWholeCall() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/calls/qualifiedWholeCall.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/declarations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Declarations {
|
||||
@Test
|
||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDelegate.kt")
|
||||
public void testPropertyDelegate() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/declarations/propertyDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDelegateExpression.kt")
|
||||
public void testPropertyDelegateExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/declarations/propertyDelegateExpression.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Expressions {
|
||||
@Test
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("arrayAccessExpression.kt")
|
||||
public void testArrayAccessExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/arrayAccessExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("asExpression.kt")
|
||||
public void testAsExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/asExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryExpression.kt")
|
||||
public void testBinaryExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/binaryExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryExpressionOperator.kt")
|
||||
public void testBinaryExpressionOperator() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/binaryExpressionOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("blockExpression.kt")
|
||||
public void testBlockExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/blockExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boolLiteral.kt")
|
||||
public void testBoolLiteral() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/boolLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classAccessExpression.kt")
|
||||
public void testClassAccessExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/classAccessExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forExpression.kt")
|
||||
public void testForExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/forExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forExpressionRange.kt")
|
||||
public void testForExpressionRange() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/forExpressionRange.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forExpressionVariable.kt")
|
||||
public void testForExpressionVariable() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/forExpressionVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifExpression.kt")
|
||||
public void testIfExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/ifExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intLiteral.kt")
|
||||
public void testIntLiteral() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/intLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("isExpression.kt")
|
||||
public void testIsExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/isExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaExpression.kt")
|
||||
public void testLambdaExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/lambdaExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objectLiteralExpression.kt")
|
||||
public void testObjectLiteralExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/objectLiteralExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("parenthesizedExpression.kt")
|
||||
public void testParenthesizedExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/parenthesizedExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyReferenceExpression.kt")
|
||||
public void testPropertyReferenceExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/propertyReferenceExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringLiteral.kt")
|
||||
public void testStringLiteral() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/stringLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringTemplateExpressionEntry.kt")
|
||||
public void testStringTemplateExpressionEntry() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/stringTemplateExpressionEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("throwExpression.kt")
|
||||
public void testThrowExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/throwExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryExpression.kt")
|
||||
public void testTryExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/tryExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unraryExpression.kt")
|
||||
public void testUnraryExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/unraryExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unraryExpressionOperator.kt")
|
||||
public void testUnraryExpressionOperator() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/unraryExpressionOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpression.kt")
|
||||
public void testWhenExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/whenExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whileExpression.kt")
|
||||
public void testWhileExpression() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/whileExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wholeStringTemplate.kt")
|
||||
public void testWholeStringTemplate() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/expressions/wholeStringTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class InImport {
|
||||
@Test
|
||||
public void testAllFilesPresentInInImport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("firstImportNamePart.kt")
|
||||
public void testFirstImportNamePart() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport/firstImportNamePart.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importList.kt")
|
||||
public void testImportList() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport/importList.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("middleImportNamePart.kt")
|
||||
public void testMiddleImportNamePart() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport/middleImportNamePart.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifiedImportNamePart.kt")
|
||||
public void testQualifiedImportNamePart() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport/qualifiedImportNamePart.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wholeImportDirective.kt")
|
||||
public void testWholeImportDirective() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport/wholeImportDirective.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wholeImportName.kt")
|
||||
public void testWholeImportName() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inImport/wholeImportName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class InPackage {
|
||||
@Test
|
||||
public void testAllFilesPresentInInPackage() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("firstPackageNamePart.kt")
|
||||
public void testFirstPackageNamePart() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage/firstPackageNamePart.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("middlePackageNamePart.kt")
|
||||
public void testMiddlePackageNamePart() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage/middlePackageNamePart.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifiedPackageNamePart.kt")
|
||||
public void testQualifiedPackageNamePart() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage/qualifiedPackageNamePart.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wholePackageDirective.kt")
|
||||
public void testWholePackageDirective() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage/wholePackageDirective.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wholePackageName.kt")
|
||||
public void testWholePackageName() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/inPackage/wholePackageName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/qualifiedExpressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class QualifiedExpressions {
|
||||
@Test
|
||||
public void testAllFilesPresentInQualifiedExpressions() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/qualifiedExpressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("firstPartOfQualifiedCallWithNestedClasses.kt")
|
||||
public void testFirstPartOfQualifiedCallWithNestedClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/qualifiedExpressions/firstPartOfQualifiedCallWithNestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lastPartOfQualifiedCallWithNestedClasses.kt")
|
||||
public void testLastPartOfQualifiedCallWithNestedClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/qualifiedExpressions/lastPartOfQualifiedCallWithNestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("middlePartOfQualifiedCallWithNestedClasses.kt")
|
||||
public void testMiddlePartOfQualifiedCallWithNestedClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/qualifiedExpressions/middlePartOfQualifiedCallWithNestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifiedPartOfQualifiedCallWithNestedClasses.kt")
|
||||
public void testQualifiedPartOfQualifiedCallWithNestedClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/qualifiedExpressions/qualifiedPartOfQualifiedCallWithNestedClasses.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Types {
|
||||
@Test
|
||||
public void testAllFilesPresentInTypes() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/functionalType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalTypeArgument.kt")
|
||||
public void testFunctionalTypeArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/functionalTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidTypeArgumentsCount.kt")
|
||||
public void testInvalidTypeArgumentsCount() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/invalidTypeArgumentsCount.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidTypeArgumentsCountArgument.kt")
|
||||
public void testInvalidTypeArgumentsCountArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/invalidTypeArgumentsCountArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidTypeArgumentsCountFirstArgument.kt")
|
||||
public void testInvalidTypeArgumentsCountFirstArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/invalidTypeArgumentsCountFirstArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidTypeArgumentsCountLastArgument.kt")
|
||||
public void testInvalidTypeArgumentsCountLastArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/invalidTypeArgumentsCountLastArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedTypeArgument.kt")
|
||||
public void testNestedTypeArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/nestedTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableType.kt")
|
||||
public void testNullableType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/nullableType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableTypeWithooutQuestionMark.kt")
|
||||
public void testNullableTypeWithooutQuestionMark() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/nullableTypeWithooutQuestionMark.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeArgument.kt")
|
||||
public void testTypeArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/typeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedTypeArgumentResolvedTypeConsturctor.kt")
|
||||
public void testUnresolvedTypeArgumentResolvedTypeConsturctor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/unresolvedTypeArgumentResolvedTypeConsturctor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedTypeConsturctorResolvedNestedTypeArgument.kt")
|
||||
public void testUnresolvedTypeConsturctorResolvedNestedTypeArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/unresolvedTypeConsturctorResolvedNestedTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedTypeConsturctorResolvedTypeArgument.kt")
|
||||
public void testUnresolvedTypeConsturctorResolvedTypeArgument() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/unresolvedTypeConsturctorResolvedTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wholeType.kt")
|
||||
public void testWholeType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/types/wholeType.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class WholeDeclaration {
|
||||
@Test
|
||||
public void testAllFilesPresentInWholeDeclaration() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classTypeParemeter.kt")
|
||||
public void testClassTypeParemeter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/classTypeParemeter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/enumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypeParemeter.kt")
|
||||
public void testFunctionTypeParemeter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/functionTypeParemeter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionValueParameter.kt")
|
||||
public void testFunctionValueParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/functionValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("getter.kt")
|
||||
public void testGetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/getter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/localClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/localFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localProperty.kt")
|
||||
public void testLocalProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/localProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunction.kt")
|
||||
public void testMemberFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/memberFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberProperty.kt")
|
||||
public void testMemberProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/memberProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberTypeAlias.kt")
|
||||
public void testMemberTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/memberTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/nestedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primaryConstructorValValueParameter.kt")
|
||||
public void testPrimaryConstructorValValueParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/primaryConstructorValValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primaryConstructorValueParameter.kt")
|
||||
public void testPrimaryConstructorValueParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/primaryConstructorValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("secondaryConstructorValueParameter.kt")
|
||||
public void testSecondaryConstructorValueParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/secondaryConstructorValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("setter.kt")
|
||||
public void testSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/setter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelClass.kt")
|
||||
public void testTopLevelClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/topLevelClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/topLevelProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelTypelTypeAlias.kt")
|
||||
public void testTopLevelTypelTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/getOrBuildFir/wholeDeclaration/topLevelTypelTypeAlias.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.low.level.api.fir;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/partialRawBuilder")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class PartialRawFirBuilderTestCaseGenerated extends AbstractPartialRawFirBuilderTestCase {
|
||||
@Test
|
||||
public void testAllFilesPresentInPartialRawBuilder() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/localFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunction.kt")
|
||||
public void testMemberFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/memberFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberProperty.kt")
|
||||
public void testMemberProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/memberProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("paramemtersCatching.kt")
|
||||
public void testParamemtersCatching() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/paramemtersCatching.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunction.kt")
|
||||
public void testSimpleFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/simpleFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleVal.kt")
|
||||
public void testSimpleVal() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/simpleVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleVar.kt")
|
||||
public void testSimpleVar() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/partialRawBuilder/simpleVar.kt");
|
||||
}
|
||||
}
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.compiler.based
|
||||
|
||||
import com.intellij.mock.MockProject
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.psi.PsiElementFinder
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.ProjectScope
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinDeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinModificationTrackerFactory
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinModuleInfoProvider
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinPackageProviderFactory
|
||||
import org.jetbrains.kotlin.analysis.providers.impl.KotlinStaticDeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.analysis.providers.impl.KotlinStaticModificationTrackerFactory
|
||||
import org.jetbrains.kotlin.analysis.providers.impl.KotlinStaticPackageProviderFactory
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
import org.jetbrains.kotlin.asJava.KotlinAsJavaSupport
|
||||
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
|
||||
import org.jetbrains.kotlin.cli.jvm.config.jvmModularRoots
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.DependencyListForCliModule
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.SealedClassInheritorsProvider
|
||||
import org.jetbrains.kotlin.fir.deserialization.ModuleDataProvider
|
||||
import org.jetbrains.kotlin.fir.session.FirModuleInfoBasedModuleData
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.*
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.*
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.SealedClassInheritorsProviderTestImpl
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.transformers.FirLazyTransformerForIDE
|
||||
import org.jetbrains.kotlin.idea.frontend.api.InvalidWayOfUsingAnalysisSession
|
||||
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSessionProvider
|
||||
import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSessionProvider
|
||||
import org.jetbrains.kotlin.light.classes.symbol.IDEKotlinAsJavaFirSupport
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
import org.jetbrains.kotlin.test.TestConfiguration
|
||||
import org.jetbrains.kotlin.test.bind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.builders.testConfiguration
|
||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
|
||||
import org.jetbrains.kotlin.test.frontend.fir.getAnalyzerServices
|
||||
import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
|
||||
abstract class AbstractCompilerBasedTest : AbstractKotlinCompilerTest() {
|
||||
private var _disposable: Disposable? = null
|
||||
protected val disposable: Disposable get() = _disposable!!
|
||||
|
||||
@BeforeEach
|
||||
private fun intiDisposable(testInfo: TestInfo) {
|
||||
_disposable = Disposer.newDisposable("disposable for ${testInfo.displayName}")
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
private fun disposeDisposable() {
|
||||
_disposable?.let { Disposer.dispose(it) }
|
||||
_disposable = null
|
||||
}
|
||||
|
||||
final override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.FIR
|
||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
|
||||
configureTest()
|
||||
defaultConfiguration(this)
|
||||
|
||||
useAdditionalService(::TestModuleInfoProvider)
|
||||
usePreAnalysisHandlers(::ModuleRegistrarPreAnalysisHandler.bind(disposable))
|
||||
}
|
||||
|
||||
open fun TestConfigurationBuilder.configureTest() {}
|
||||
|
||||
|
||||
inner class LowLevelFirFrontendFacade(
|
||||
testServices: TestServices
|
||||
) : FrontendFacade<FirOutputArtifact>(testServices, FrontendKinds.FIR) {
|
||||
|
||||
override val directiveContainers: List<DirectivesContainer>
|
||||
get() = listOf(FirDiagnosticsDirectives)
|
||||
|
||||
override fun analyze(module: TestModule): FirOutputArtifact {
|
||||
val moduleInfoProvider = testServices.moduleInfoProvider
|
||||
val moduleInfo = moduleInfoProvider.getModuleInfo(module.name)
|
||||
|
||||
val project = testServices.compilerConfigurationProvider.getProject(module)
|
||||
val resolveState = createResolveStateForNoCaching(moduleInfo, project)
|
||||
|
||||
val allFirFiles = moduleInfo.testFilesToKtFiles.map { (testFile, psiFile) ->
|
||||
testFile to psiFile.getOrBuildFirFile(resolveState)
|
||||
}.toMap()
|
||||
|
||||
val diagnosticCheckerFilter = if (FirDiagnosticsDirectives.WITH_EXTENDED_CHECKERS in module.directives) {
|
||||
DiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS
|
||||
} else DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS
|
||||
|
||||
val analyzerFacade = LowLevelFirAnalyzerFacade(resolveState, allFirFiles, diagnosticCheckerFilter)
|
||||
return LowLevelFirOutputArtifact(resolveState.rootModuleSession, analyzerFacade)
|
||||
}
|
||||
}
|
||||
|
||||
override fun runTest(filePath: String) {
|
||||
val configuration = testConfiguration(filePath, configuration)
|
||||
if (ignoreTest(filePath, configuration)) {
|
||||
return
|
||||
}
|
||||
val oldEnableDeepEnsure = FirLazyTransformerForIDE.enableDeepEnsure
|
||||
try {
|
||||
FirLazyTransformerForIDE.enableDeepEnsure = true
|
||||
super.runTest(filePath)
|
||||
} finally {
|
||||
FirLazyTransformerForIDE.enableDeepEnsure = oldEnableDeepEnsure
|
||||
}
|
||||
}
|
||||
|
||||
private fun ignoreTest(filePath: String, configuration: TestConfiguration): Boolean {
|
||||
val modules = configuration.moduleStructureExtractor.splitTestDataByModules(filePath, configuration.directives)
|
||||
|
||||
if (modules.modules.none { it.files.any { it.isKtFile } }) {
|
||||
return true // nothing to highlight
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestModuleInfoProvider(private val testServices: TestServices) : TestService {
|
||||
private val cache = mutableMapOf<String, TestModuleSourceInfo>()
|
||||
|
||||
fun registerModuleInfo(testModule: TestModule, ktFiles: Map<TestFile, KtFile>) {
|
||||
cache[testModule.name] = TestModuleSourceInfo(testModule, ktFiles, testServices)
|
||||
}
|
||||
|
||||
fun getModuleInfoByKtFile(ktFile: KtFile): TestModuleSourceInfo =
|
||||
cache.values.first { moduleSourceInfo ->
|
||||
ktFile in moduleSourceInfo.ktFiles
|
||||
}
|
||||
|
||||
fun getModuleInfo(moduleName: String): TestModuleSourceInfo =
|
||||
cache.getValue(moduleName)
|
||||
}
|
||||
|
||||
val TestServices.moduleInfoProvider: TestModuleInfoProvider by TestServices.testServiceAccessor()
|
||||
|
||||
class ModuleRegistrarPreAnalysisHandler(
|
||||
testServices: TestServices,
|
||||
private val parentDisposable: Disposable
|
||||
) : PreAnalysisHandler(testServices) {
|
||||
|
||||
private val moduleInfoProvider = testServices.moduleInfoProvider
|
||||
|
||||
override fun preprocessModuleStructure(moduleStructure: TestModuleStructure) {
|
||||
// todo rework after all modules will have the same Project instance
|
||||
val ktFilesByModule = moduleStructure.modules.associateWith { testModule ->
|
||||
val project = testServices.compilerConfigurationProvider.getProject(testModule)
|
||||
testServices.sourceFileProvider.getKtFilesForSourceFiles(testModule.files, project)
|
||||
}
|
||||
|
||||
val allKtFiles = ktFilesByModule.values.flatMap { it.values.toList() }
|
||||
|
||||
ktFilesByModule.forEach { (testModule, ktFiles) ->
|
||||
val project = testServices.compilerConfigurationProvider.getProject(testModule)
|
||||
moduleInfoProvider.registerModuleInfo(testModule, ktFiles)
|
||||
|
||||
val configurator = FirModuleResolveStateConfiguratorForSingleModuleTestImpl(
|
||||
project,
|
||||
testServices,
|
||||
parentDisposable
|
||||
)
|
||||
(project as MockProject).registerTestServices(configurator, allKtFiles, testServices)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestModuleSourceInfo(
|
||||
val testModule: TestModule,
|
||||
val testFilesToKtFiles: Map<TestFile, KtFile>,
|
||||
testServices: TestServices,
|
||||
) : ModuleInfo, ModuleSourceInfoBase {
|
||||
private val moduleInfoProvider = testServices.moduleInfoProvider
|
||||
|
||||
val ktFiles = testFilesToKtFiles.values.toSet()
|
||||
val moduleData = FirModuleInfoBasedModuleData(this)
|
||||
|
||||
override val name: Name
|
||||
get() = Name.identifier(testModule.name)
|
||||
|
||||
override fun dependencies(): List<ModuleInfo> =
|
||||
testModule.allDependencies
|
||||
.map { moduleInfoProvider.getModuleInfo(it.moduleName) }
|
||||
|
||||
override val expectedBy: List<ModuleInfo>
|
||||
get() = testModule.dependsOnDependencies
|
||||
.map { moduleInfoProvider.getModuleInfo(it.moduleName) }
|
||||
|
||||
override fun modulesWhoseInternalsAreVisible(): Collection<ModuleInfo> =
|
||||
testModule.friendDependencies
|
||||
.map { moduleInfoProvider.getModuleInfo(it.moduleName) }
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = testModule.targetPlatform
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = testModule.targetPlatform.getAnalyzerServices()
|
||||
}
|
||||
|
||||
|
||||
class FirModuleResolveStateConfiguratorForSingleModuleTestImpl(
|
||||
private val project: Project,
|
||||
testServices: TestServices,
|
||||
private val parentDisposable: Disposable,
|
||||
) : FirModuleResolveStateConfigurator() {
|
||||
private val compilerConfigurationProvider = testServices.compilerConfigurationProvider
|
||||
private val librariesScope = ProjectScope.getLibrariesScope(project)//todo incorrect?
|
||||
private val sealedClassInheritorsProvider = SealedClassInheritorsProviderTestImpl()
|
||||
|
||||
override fun createPackagePartsProvider(moduleInfo: ModuleSourceInfoBase, scope: GlobalSearchScope): PackagePartProvider {
|
||||
require(moduleInfo is TestModuleSourceInfo)
|
||||
val factory = compilerConfigurationProvider.getPackagePartProviderFactory(moduleInfo.testModule)
|
||||
return factory(scope)
|
||||
}
|
||||
|
||||
|
||||
override fun createModuleDataProvider(moduleInfo: ModuleSourceInfoBase): ModuleDataProvider {
|
||||
require(moduleInfo is TestModuleSourceInfo)
|
||||
val configuration = compilerConfigurationProvider.getCompilerConfiguration(moduleInfo.testModule)
|
||||
return DependencyListForCliModule.build(
|
||||
moduleInfo.name,
|
||||
moduleInfo.platform,
|
||||
moduleInfo.analyzerServices
|
||||
) {
|
||||
dependencies(configuration.jvmModularRoots.map { it.toPath() })
|
||||
dependencies(configuration.jvmClasspathRoots.map { it.toPath() })
|
||||
|
||||
friendDependencies(configuration[JVMConfigurationKeys.FRIEND_PATHS] ?: emptyList())
|
||||
|
||||
sourceDependencies(moduleInfo.moduleData.dependencies)
|
||||
sourceFriendsDependencies(moduleInfo.moduleData.friendDependencies)
|
||||
sourceDependsOnDependencies(moduleInfo.moduleData.dependsOnDependencies)
|
||||
}.moduleDataProvider
|
||||
}
|
||||
|
||||
override fun getLanguageVersionSettings(moduleInfo: ModuleSourceInfoBase): LanguageVersionSettings {
|
||||
require(moduleInfo is TestModuleSourceInfo)
|
||||
return moduleInfo.testModule.languageVersionSettings
|
||||
}
|
||||
|
||||
override fun getModuleSourceScope(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope {
|
||||
require(moduleInfo is TestModuleSourceInfo)
|
||||
return TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, moduleInfo.testFilesToKtFiles.values)
|
||||
}
|
||||
|
||||
override fun createScopeForModuleLibraries(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope {
|
||||
return librariesScope
|
||||
}
|
||||
|
||||
override fun createSealedInheritorsProvider(): SealedClassInheritorsProvider {
|
||||
return sealedClassInheritorsProvider
|
||||
}
|
||||
|
||||
override fun configureSourceSession(session: FirSession) {
|
||||
}
|
||||
}
|
||||
|
||||
fun MockProject.registerTestServices(
|
||||
configurator: FirModuleResolveStateConfiguratorForSingleModuleTestImpl,
|
||||
allKtFiles: List<KtFile>,
|
||||
testServices: TestServices,
|
||||
) {
|
||||
registerService(
|
||||
FirModuleResolveStateConfigurator::class.java,
|
||||
configurator
|
||||
)
|
||||
registerService(FirIdeResolveStateService::class.java)
|
||||
registerService(
|
||||
KotlinModificationTrackerFactory::class.java,
|
||||
KotlinStaticModificationTrackerFactory::class.java
|
||||
)
|
||||
registerService(KotlinDeclarationProviderFactory::class.java, KotlinStaticDeclarationProviderFactory(allKtFiles))
|
||||
registerService(KotlinPackageProviderFactory::class.java, KotlinStaticPackageProviderFactory(allKtFiles))
|
||||
registerService(KotlinModuleInfoProvider::class.java, TestKotlinModuleInfoProvider(testServices))
|
||||
reRegisterJavaElementFinder(this)
|
||||
}
|
||||
|
||||
private class TestKotlinModuleInfoProvider(testServices: TestServices): KotlinModuleInfoProvider() {
|
||||
private val moduleInfoProvider = testServices.moduleInfoProvider
|
||||
override fun getModuleInfo(element: KtElement): ModuleInfo {
|
||||
val containingFile = element.containingKtFile
|
||||
return moduleInfoProvider.getModuleInfoByKtFile(containingFile)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||
private fun reRegisterJavaElementFinder(project: Project) {
|
||||
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
|
||||
with(project as MockProject) {
|
||||
picoContainer.registerComponentInstance(
|
||||
KtAnalysisSessionProvider::class.qualifiedName,
|
||||
KtFirAnalysisSessionProvider(this)
|
||||
)
|
||||
picoContainer.unregisterComponent(KotlinAsJavaSupport::class.qualifiedName)
|
||||
picoContainer.registerComponentInstance(
|
||||
KotlinAsJavaSupport::class.qualifiedName,
|
||||
IDEKotlinAsJavaFirSupport(project)
|
||||
)
|
||||
}
|
||||
@Suppress("DEPRECATION")
|
||||
PsiElementFinder.EP.getPoint(project).registerExtension(JavaElementFinder(project))
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global
|
||||
|
||||
object FirIdeDirectives : SimpleDirectivesContainer() {
|
||||
val FIR_IDE_IGNORE by directive(
|
||||
description = "Test is ignored in FIR IDE",
|
||||
applicability = Global
|
||||
)
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.test.WrappedException
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
import org.jetbrains.kotlin.test.utils.removeDirectiveFromFile
|
||||
|
||||
class IdeTestIgnoreHandler(testServices: TestServices) : AfterAnalysisChecker(testServices) {
|
||||
companion object {
|
||||
private val isTeamCityBuild: Boolean = System.getenv("TEAMCITY_VERSION") != null
|
||||
}
|
||||
|
||||
override val directiveContainers: List<DirectivesContainer>
|
||||
get() = listOf(FirIdeDirectives)
|
||||
|
||||
override fun check(failedAssertions: List<WrappedException>) {
|
||||
if (!isFirIdeIgnoreDirectivePresent()) return
|
||||
if (failedAssertions.isNotEmpty()) return
|
||||
val testDataFile = testServices.moduleStructure.originalTestDataFiles.first()
|
||||
|
||||
if (!isTeamCityBuild) {
|
||||
testDataFile.removeDirectiveFromFile(FirIdeDirectives.FIR_IDE_IGNORE)
|
||||
}
|
||||
|
||||
val message = if (isTeamCityBuild) {
|
||||
"Please remove // ${FirIdeDirectives.FIR_IDE_IGNORE} from the test source"
|
||||
} else {
|
||||
"Removed // ${FirIdeDirectives.FIR_IDE_IGNORE} from the test source"
|
||||
}
|
||||
throw TestWithFirIdeIgnoreAnnotationPassesException(
|
||||
"""
|
||||
Test pass in FIR IDE
|
||||
$message
|
||||
Please re-run the test now
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
|
||||
return if (isFirIdeIgnoreDirectivePresent())
|
||||
failedAssertions.filter{ it.cause is TestWithFirIdeIgnoreAnnotationPassesException }
|
||||
else failedAssertions
|
||||
}
|
||||
|
||||
private fun isFirIdeIgnoreDirectivePresent(): Boolean {
|
||||
val moduleStructure = testServices.moduleStructure
|
||||
return FirIdeDirectives.FIR_IDE_IGNORE in moduleStructure.allDirectives
|
||||
}
|
||||
}
|
||||
|
||||
fun TestConfigurationBuilder.addIdeTestIgnoreHandler() {
|
||||
/* IdeTestIgnoreHandler should be executed after FirFailingTestSuppressor,
|
||||
otherwise IdeTestIgnoreHandler will suppress exceptions and FirFailingTestSuppressor will throw error
|
||||
saying that file .fir.fail exists but test passes
|
||||
*/
|
||||
forTestsMatching("*") {
|
||||
useAfterAnalysisCheckers(
|
||||
::IdeTestIgnoreHandler
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class TestWithFirIdeIgnoreAnnotationPassesException(override val message: String) : IllegalStateException()
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.fir.analysis.AbstractFirAnalyzerFacade
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrResult
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.psi
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirSealedClassInheritorsProcessor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirModuleResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.collectDiagnosticsForFile
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.resolvedFirToPhase
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi2ir.generators.GeneratorExtensions
|
||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
|
||||
class LowLevelFirAnalyzerFacade(
|
||||
val resolveState: FirModuleResolveState,
|
||||
val allFirFiles: Map<TestFile, FirFile>,
|
||||
private val diagnosticCheckerFilter: DiagnosticCheckerFilter,
|
||||
) : AbstractFirAnalyzerFacade() {
|
||||
override val scopeSession: ScopeSession get() = shouldNotBeCalled()
|
||||
|
||||
override fun runCheckers(): Map<FirFile, List<FirDiagnostic>> {
|
||||
findSealedInheritors()
|
||||
return allFirFiles.values.associateWith { firFile ->
|
||||
val ktFile = firFile.psi as KtFile
|
||||
val diagnostics = ktFile.collectDiagnosticsForFile(resolveState, diagnosticCheckerFilter)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
diagnostics.toList() as List<FirDiagnostic>
|
||||
}
|
||||
}
|
||||
|
||||
private fun findSealedInheritors() {
|
||||
allFirFiles.values.forEach {
|
||||
it.resolvedFirToPhase(FirResolvePhase.SUPER_TYPES, resolveState)
|
||||
}
|
||||
val sealedProcessor = FirSealedClassInheritorsProcessor(allFirFiles.values.first().moduleData.session, ScopeSession())
|
||||
sealedProcessor.process(allFirFiles.values)
|
||||
}
|
||||
|
||||
override fun runResolution(): List<FirFile> = shouldNotBeCalled()
|
||||
override fun convertToIr(extensions: GeneratorExtensions): Fir2IrResult = shouldNotBeCalled()
|
||||
}
|
||||
|
||||
private fun shouldNotBeCalled(): Nothing = error("Should not be called for LL test")
|
||||
+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.low.level.api.fir.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
|
||||
class LowLevelFirOutputArtifact(
|
||||
override val session: FirSession,
|
||||
override val firAnalyzerFacade: LowLevelFirAnalyzerFacade,
|
||||
) : FirOutputArtifact() {
|
||||
override val allFirFiles: Map<TestFile, FirFile>
|
||||
get() = firAnalyzerFacade.allFirFiles
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.diagnostic
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirRealSourceElementKind
|
||||
import org.jetbrains.kotlin.fir.SessionConfiguration
|
||||
import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollectorVisitor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.SessionHolderImpl
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.collectDiagnosticsForFile
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFir
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirOfType
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics.BeforeElementDiagnosticCollectionHandler
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics.SingleNonLocalDeclarationDiagnosticRetriever
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics.fir.PersistentCheckerContextFactory
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.renderWithClassName
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.resolveWithClearCaches
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
/**
|
||||
* Check that every declaration is visited exactly one time during diagnostic collection
|
||||
*/
|
||||
abstract class AbstractDiagnosticTraversalCounterTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val handler = BeforeElementTestDiagnosticCollectionHandler()
|
||||
resolveWithClearCaches(
|
||||
ktFile,
|
||||
configureSession = {
|
||||
@OptIn(SessionConfiguration::class)
|
||||
register(BeforeElementDiagnosticCollectionHandler::class, handler)
|
||||
}
|
||||
) { resolveState ->
|
||||
// we should get diagnostics before we resolve the whole file by ktFile.getOrBuildFir
|
||||
ktFile.collectDiagnosticsForFile(resolveState, DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS)
|
||||
|
||||
val firFile = ktFile.getOrBuildFirOfType<FirFile>(resolveState)
|
||||
|
||||
val errorElements = collectErrorElements(firFile, handler)
|
||||
|
||||
if (errorElements.isNotEmpty()) {
|
||||
val zeroElements = errorElements.filter { it.second == 0 }
|
||||
val nonZeroElements = errorElements.filter { it.second > 1 }
|
||||
val message = buildString {
|
||||
if (zeroElements.isNotEmpty()) {
|
||||
appendLine(
|
||||
""" |The following elements were not visited
|
||||
|${zeroElements.joinToString(separator = "\n\n") { it.first.source?.kind.toString() + " <> " + it.first.renderWithClassName() }}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
if (nonZeroElements.isNotEmpty()) {
|
||||
appendLine(
|
||||
""" |The following elements were visited more than one time
|
||||
|${nonZeroElements.joinToString(separator = "\n\n") { it.second.toString() + " times " + it.first.source?.kind.toString() + " <> " + it.first.renderWithClassName() }}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
testServices.assertions.fail { message }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun collectErrorElements(
|
||||
firFile: FirElement,
|
||||
handler: BeforeElementTestDiagnosticCollectionHandler
|
||||
): List<Pair<FirElement, Int>> {
|
||||
val errorElements = mutableListOf<Pair<FirElement, Int>>()
|
||||
val nonDuplicatingElements = findNonDuplicatingFirElements(firFile).filter { element ->
|
||||
when {
|
||||
element is FirTypeRef && element.source?.kind != FirRealSourceElementKind -> {
|
||||
// AbstractDiagnosticCollectorVisitor do not visit such elements
|
||||
false
|
||||
}
|
||||
element.source?.kind == FirRealSourceElementKind -> true
|
||||
SingleNonLocalDeclarationDiagnosticRetriever.shouldDiagnosticsAlwaysBeCheckedOn(element) -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
firFile.accept(object : FirVisitorVoid() {
|
||||
override fun visitElement(element: FirElement) {
|
||||
if (element !in nonDuplicatingElements) return
|
||||
val visitedTimes = handler.visitedTimes[element] ?: 0
|
||||
if (visitedTimes != 1) {
|
||||
errorElements += element to visitedTimes
|
||||
}
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
})
|
||||
return errorElements
|
||||
}
|
||||
|
||||
|
||||
private fun findNonDuplicatingFirElements(
|
||||
firFile: FirElement,
|
||||
): Set<FirElement> {
|
||||
val elementUsageCount = mutableMapOf<FirElement, Int>()
|
||||
val sessionHolder = SessionHolderImpl((firFile as FirDeclaration).moduleData.session, ScopeSession())
|
||||
val visitor = object : AbstractDiagnosticCollectorVisitor(
|
||||
PersistentCheckerContextFactory.createEmptyPersistenceCheckerContext(sessionHolder)
|
||||
) {
|
||||
override fun visitNestedElements(element: FirElement) {
|
||||
element.acceptChildren(this, null)
|
||||
}
|
||||
|
||||
override fun checkElement(element: FirElement) {
|
||||
elementUsageCount.compute(element) { _, count -> (count ?: 0) + 1 }
|
||||
}
|
||||
}
|
||||
|
||||
firFile.accept(visitor, null)
|
||||
return elementUsageCount.filterValues { it == 1 }.keys
|
||||
}
|
||||
|
||||
|
||||
class BeforeElementTestDiagnosticCollectionHandler : BeforeElementDiagnosticCollectionHandler() {
|
||||
val visitedTimes = mutableMapOf<FirElement, Int>()
|
||||
override fun beforeCollectingForElement(element: FirElement) {
|
||||
if (!visitedTimes.containsKey(element)) {
|
||||
visitedTimes[element] = 1
|
||||
} else {
|
||||
visitedTimes.compute(element) { _, count -> (count ?: 0) + 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.diagnostic
|
||||
|
||||
import org.jetbrains.kotlin.fir.SessionConfiguration
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStack
|
||||
import org.jetbrains.kotlin.fir.resolve.SessionHolderImpl
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.FirModuleResolveStateImpl
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getDiagnostics
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics.BeforeElementDiagnosticCollectionHandler
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics.fir.PersistenceContextCollector
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.FileStructureElement
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.NonReanalyzableDeclarationStructureElement
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.ReanalyzableStructureElement
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.RootStructureElement
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.name
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.resolveWithClearCaches
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.services.AssertionsService
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
|
||||
abstract class AbstractFirContextCollectionTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val handler = BeforeElementTestDiagnosticCollectionHandler(testServices.assertions)
|
||||
resolveWithClearCaches(
|
||||
ktFile,
|
||||
configureSession = {
|
||||
@OptIn(SessionConfiguration::class)
|
||||
register(BeforeElementDiagnosticCollectionHandler::class, handler)
|
||||
}
|
||||
) { resolveState ->
|
||||
check(resolveState is FirModuleResolveStateImpl)
|
||||
|
||||
val fileStructure = resolveState.fileStructureCache.getFileStructure(ktFile, resolveState.rootModuleSession.cache)
|
||||
val allStructureElements = fileStructure.getAllStructureElements()
|
||||
|
||||
handler.elementsToCheckContext = allStructureElements.map { it.getFirDeclaration() }
|
||||
handler.firFile = ktFile.getOrBuildFirFile(resolveState)
|
||||
|
||||
ktFile.getDiagnostics(resolveState, DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FileStructureElement.getFirDeclaration(): FirDeclaration = when (this) {
|
||||
is NonReanalyzableDeclarationStructureElement -> fir
|
||||
is ReanalyzableStructureElement<*, *> -> firSymbol.fir
|
||||
is RootStructureElement -> firFile
|
||||
}
|
||||
|
||||
|
||||
private class BeforeElementTestDiagnosticCollectionHandler(
|
||||
private val assertions: AssertionsService
|
||||
) :
|
||||
BeforeElementDiagnosticCollectionHandler() {
|
||||
lateinit var elementsToCheckContext: List<FirDeclaration>
|
||||
lateinit var firFile: FirFile
|
||||
|
||||
override fun beforeGoingNestedDeclaration(declaration: FirDeclaration, context: CheckerContext) {
|
||||
if (declaration is FirFile) {
|
||||
return
|
||||
}
|
||||
if (declaration in elementsToCheckContext) {
|
||||
val collectedContext = PersistenceContextCollector.collectContext(
|
||||
SessionHolderImpl.createWithEmptyScopeSession(declaration.moduleData.session),
|
||||
firFile,
|
||||
declaration
|
||||
)
|
||||
compareStructurally(context, collectedContext)
|
||||
}
|
||||
}
|
||||
|
||||
private fun compareStructurally(expected: CheckerContext, actual: CheckerContext) {
|
||||
assertions.assertEquals(expected.implicitReceiverStack.asString(), actual.implicitReceiverStack.asString())
|
||||
assertions.assertEquals(expected.containingDeclarations.asString(), actual.containingDeclarations.asString())
|
||||
}
|
||||
|
||||
private fun ImplicitReceiverStack.asString() =
|
||||
joinToString { it.boundSymbol.name() }
|
||||
|
||||
private fun List<FirDeclaration>.asString() =
|
||||
joinToString(transform = FirDeclaration::name)
|
||||
}
|
||||
}
|
||||
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.diagnostic;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/diagnosticTraversalCounter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DiagnosticTraversalCounterTestGenerated extends AbstractDiagnosticTraversalCounterTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInDiagnosticTraversalCounter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/constructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declarationsInPropertyInit.kt")
|
||||
public void testDeclarationsInPropertyInit() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/declarationsInPropertyInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClass.kt")
|
||||
public void testEnumClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/enumClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClassWithBody.kt")
|
||||
public void testEnumClassWithBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/enumClassWithBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType.kt")
|
||||
public void testFunctionalType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/functionalType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initBlock.kt")
|
||||
public void testInitBlock() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/initBlock.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/lambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localDeclarationsInAccessor.kt")
|
||||
public void testLocalDeclarationsInAccessor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/localDeclarationsInAccessor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunctionWithImplicitType.kt")
|
||||
public void testLocalFunctionWithImplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/localFunctionWithImplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localUnitFunction.kt")
|
||||
public void testLocalUnitFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/localUnitFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberFunctions.kt")
|
||||
public void testMemberFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/memberFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberProperties.kt")
|
||||
public void testMemberProperties() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/memberProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberTypeAlias.kt")
|
||||
public void testMemberTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/memberTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleTopLevelClasses.kt")
|
||||
public void testMultipleTopLevelClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/multipleTopLevelClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleTopLevelFunctionsWithImplicitTypes.kt")
|
||||
public void testMultipleTopLevelFunctionsWithImplicitTypes() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/multipleTopLevelFunctionsWithImplicitTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleTopLevelUnitFunctions.kt")
|
||||
public void testMultipleTopLevelUnitFunctions() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/multipleTopLevelUnitFunctions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClases.kt")
|
||||
public void testNestedClases() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/nestedClases.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasesWithFun.kt")
|
||||
public void testNestedClasesWithFun() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/nestedClasesWithFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAccessors.kt")
|
||||
public void testPropertyAccessors() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/propertyAccessors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyWithGetterAndSetter.kt")
|
||||
public void testPropertyWithGetterAndSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/propertyWithGetterAndSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("secondaryConstructor.kt")
|
||||
public void testSecondaryConstructor() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/secondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAlias.kt")
|
||||
public void testTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/diagnosticTraversalCounter/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.diagnostic;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/fileStructure")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirContextCollectionTestGenerated extends AbstractFirContextCollectionTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInFileStructure() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("class.kt")
|
||||
public void testClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/class.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classMemberProperty.kt")
|
||||
public void testClassMemberProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/classMemberProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declarationsInPropertyInit.kt")
|
||||
public void testDeclarationsInPropertyInit() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/declarationsInPropertyInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClass.kt")
|
||||
public void testEnumClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/enumClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClassWithBody.kt")
|
||||
public void testEnumClassWithBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/enumClassWithBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initBlock.kt")
|
||||
public void testInitBlock() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/initBlock.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/localClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFun.kt")
|
||||
public void testLocalFun() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/localFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localProperty.kt")
|
||||
public void testLocalProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/localProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberTypeAlias.kt")
|
||||
public void testMemberTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/memberTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/nestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAccessors.kt")
|
||||
public void testPropertyAccessors() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/propertyAccessors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelExpressionBodyFunWithType.kt")
|
||||
public void testTopLevelExpressionBodyFunWithType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelExpressionBodyFunWithType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelExpressionBodyFunWithoutType.kt")
|
||||
public void testTopLevelExpressionBodyFunWithoutType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelExpressionBodyFunWithoutType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunWithType.kt")
|
||||
public void testTopLevelFunWithType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelFunWithType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelUnitFun.kt")
|
||||
public void testTopLevelUnitFun() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelUnitFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAlias.kt")
|
||||
public void testTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
+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.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.AbstractCompilerBasedTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.addIdeTestIgnoreHandler
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
|
||||
import org.jetbrains.kotlin.test.runners.baseFirSpecDiagnosticTestConfiguration
|
||||
|
||||
abstract class AbstractDiagnosisCompilerTestDataSpecTest : AbstractCompilerBasedTest() {
|
||||
override fun TestConfigurationBuilder.configureTest() {
|
||||
baseFirDiagnosticTestConfiguration(frontendFacade = ::LowLevelFirFrontendFacade)
|
||||
baseFirSpecDiagnosticTestConfiguration()
|
||||
addIdeTestIgnoreHandler()
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.AbstractCompilerBasedTest
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.addIdeTestIgnoreHandler
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
|
||||
|
||||
abstract class AbstractDiagnosisCompilerTestDataTest : AbstractCompilerBasedTest() {
|
||||
override fun TestConfigurationBuilder.configureTest() {
|
||||
baseFirDiagnosticTestConfiguration(frontendFacade = ::LowLevelFirFrontendFacade)
|
||||
addIdeTestIgnoreHandler()
|
||||
}
|
||||
}
|
||||
+5677
File diff suppressed because it is too large
Load Diff
+37087
File diff suppressed because it is too large
Load Diff
+7622
File diff suppressed because it is too large
Load Diff
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.file.structure
|
||||
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.FirModuleResolveStateImpl
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
val fileStructure = ktFile.getFileStructure()
|
||||
val allStructureElements = fileStructure.getAllStructureElements(ktFile)
|
||||
val declarationToStructureElement = allStructureElements.associateBy { it.psi }
|
||||
|
||||
val elementToComment = mutableMapOf<PsiElement, String>()
|
||||
ktFile.forEachDescendantOfType<KtDeclaration> { ktDeclaration ->
|
||||
val structureElement = declarationToStructureElement[ktDeclaration] ?: return@forEachDescendantOfType
|
||||
val comment = structureElement.createComment()
|
||||
when (ktDeclaration) {
|
||||
is KtClassOrObject -> {
|
||||
val lBrace = ktDeclaration.body?.lBrace
|
||||
if (lBrace != null) {
|
||||
elementToComment[lBrace] = comment
|
||||
} else {
|
||||
elementToComment[ktDeclaration] = comment
|
||||
}
|
||||
}
|
||||
is KtFunction -> {
|
||||
val lBrace = ktDeclaration.bodyBlockExpression?.lBrace
|
||||
if (lBrace != null) {
|
||||
elementToComment[lBrace] = comment
|
||||
} else {
|
||||
elementToComment[ktDeclaration] = comment
|
||||
}
|
||||
}
|
||||
is KtProperty -> {
|
||||
val initializerOrTypeReference = ktDeclaration.initializer ?: ktDeclaration.typeReference
|
||||
if (initializerOrTypeReference != null) {
|
||||
elementToComment[initializerOrTypeReference] = comment
|
||||
} else {
|
||||
elementToComment[ktDeclaration] = comment
|
||||
}
|
||||
}
|
||||
is KtTypeAlias -> {
|
||||
elementToComment[ktDeclaration.getTypeReference()!!] = comment
|
||||
}
|
||||
else -> error("Unsupported declaration $ktDeclaration")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val text = buildString {
|
||||
ktFile.accept(object : PsiElementVisitor() {
|
||||
override fun visitElement(element: PsiElement) {
|
||||
if (element is LeafPsiElement) {
|
||||
append(element.text)
|
||||
}
|
||||
element.acceptChildren(this)
|
||||
elementToComment[element]?.let {
|
||||
append(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitComment(comment: PsiComment) {}
|
||||
})
|
||||
}
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(testDataPath, text)
|
||||
}
|
||||
|
||||
private fun FileStructureElement.createComment(): String {
|
||||
return """/* ${this::class.simpleName!!} */"""
|
||||
}
|
||||
|
||||
private fun KtFile.getFileStructure(): FileStructure {
|
||||
val moduleResolveState = getResolveState() as FirModuleResolveStateImpl
|
||||
return moduleResolveState.fileStructureCache.getFileStructure(
|
||||
ktFile = this,
|
||||
moduleFileCache = moduleResolveState.rootModuleSession.cache
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private fun FileStructure.getAllStructureElements(ktFile: KtFile): Collection<FileStructureElement> = buildSet {
|
||||
ktFile.forEachDescendantOfType<KtElement> { ktElement ->
|
||||
add(getStructureElementFor(ktElement))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.file.structure;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/fileStructure")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FileStructureTestGenerated extends AbstractFileStructureTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInFileStructure() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("class.kt")
|
||||
public void testClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/class.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classMemberProperty.kt")
|
||||
public void testClassMemberProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/classMemberProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declarationsInPropertyInit.kt")
|
||||
public void testDeclarationsInPropertyInit() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/declarationsInPropertyInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClass.kt")
|
||||
public void testEnumClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/enumClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClassWithBody.kt")
|
||||
public void testEnumClassWithBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/enumClassWithBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initBlock.kt")
|
||||
public void testInitBlock() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/initBlock.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/localClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFun.kt")
|
||||
public void testLocalFun() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/localFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localProperty.kt")
|
||||
public void testLocalProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/localProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberTypeAlias.kt")
|
||||
public void testMemberTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/memberTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/nestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAccessors.kt")
|
||||
public void testPropertyAccessors() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/propertyAccessors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelExpressionBodyFunWithType.kt")
|
||||
public void testTopLevelExpressionBodyFunWithType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelExpressionBodyFunWithType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelExpressionBodyFunWithoutType.kt")
|
||||
public void testTopLevelExpressionBodyFunWithoutType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelExpressionBodyFunWithoutType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelFunWithType.kt")
|
||||
public void testTopLevelFunWithType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelFunWithType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelUnitFun.kt")
|
||||
public void testTopLevelUnitFun() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/topLevelUnitFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeAlias.kt")
|
||||
public void testTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/fileStructure/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.low.level.api.fir
|
||||
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analysis.providers.getModuleInfo
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousInitializerSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFileSymbol
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirModuleResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.FirIdeSession
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
internal fun Project.allModules() = ModuleManager.getInstance(this).modules.toList()
|
||||
|
||||
|
||||
internal fun FirElement.renderWithClassName(renderMode: FirRenderer.RenderMode = FirRenderer.RenderMode.Normal): String =
|
||||
"${this::class.simpleName} `${render(renderMode)}`"
|
||||
|
||||
|
||||
internal fun FirBasedSymbol<*>.name(): String = when (this) {
|
||||
is FirCallableSymbol<*> -> callableId.callableName.asString()
|
||||
is FirClassLikeSymbol<*> -> classId.shortClassName.asString()
|
||||
is FirAnonymousInitializerSymbol -> "<init>"
|
||||
is FirFileSymbol -> "<FILE>"
|
||||
else -> error("unknown symbol ${this::class.simpleName}")
|
||||
}
|
||||
|
||||
internal fun FirDeclaration.name(): String = symbol.name()
|
||||
|
||||
internal inline fun <R> resolveWithClearCaches(
|
||||
context: KtElement,
|
||||
noinline configureSession: FirIdeSession.() -> Unit = {},
|
||||
action: (FirModuleResolveState) -> R,
|
||||
): R {
|
||||
val resolveState = createResolveStateForNoCaching(context.getModuleInfo(), context.project, configureSession)
|
||||
return action(resolveState)
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirOfType
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.resolveWithClearCaches
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractInnerDeclarationsResolvePhaseTest : AbstractLowLevelApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
resolveWithClearCaches(ktFile) { resolveState ->
|
||||
val firFile = ktFile.getOrBuildFirOfType<FirFile>(resolveState)
|
||||
val actual = firFile.render(FirRenderer.RenderMode.WithResolvePhases)
|
||||
KotlinTestUtils.assertEqualsToFile(testDataFileSibling(".fir.txt"), actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.resolve;
|
||||
|
||||
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/idea-fir-low-level-api/testdata/innerDeclarationsResolve")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class InnerDeclarationsResolvePhaseTestGenerated extends AbstractInnerDeclarationsResolvePhaseTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInInnerDeclarationsResolve() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annonymousClass.kt")
|
||||
public void testAnnonymousClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/annonymousClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("class.kt")
|
||||
public void testClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/class.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constructorParameter.kt")
|
||||
public void testConstructorParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/constructorParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/enum.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("funWithoutTypes.kt")
|
||||
public void testFunWithoutTypes() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/funWithoutTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionValueParameter.kt")
|
||||
public void testFunctionValueParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/functionValueParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionWithImplicitType.kt")
|
||||
public void testFunctionWithImplicitType() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/functionWithImplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaInImplicitFunBody.kt")
|
||||
public void testLambdaInImplicitFunBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/lambdaInImplicitFunBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaInImplicitPropertyBody.kt")
|
||||
public void testLambdaInImplicitPropertyBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/lambdaInImplicitPropertyBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdasInWithBodyFunction.kt")
|
||||
public void testLambdasInWithBodyFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/lambdasInWithBodyFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/localClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyWithGetterAndSetter.kt")
|
||||
public void testPropertyWithGetterAndSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/propertyWithGetterAndSetter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyWithSetter.kt")
|
||||
public void testPropertyWithSetter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/innerDeclarationsResolve/propertyWithSetter.kt");
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.test.base
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractLowLevelApiSingleFileTest : AbstractLowLevelApiSingleModuleTest() {
|
||||
final override fun doTestByFileStructure(ktFiles: List<KtFile>, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
doTestByFileStructure(ktFiles.single(), moduleStructure, testServices)
|
||||
}
|
||||
|
||||
abstract fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices)
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.test.base
|
||||
|
||||
abstract class AbstractLowLevelApiSingleModuleTest : AbstractLowLevelApiTest()
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.test.base
|
||||
|
||||
import com.intellij.mock.MockApplication
|
||||
import com.intellij.mock.MockProject
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.testFramework.TestDataFile
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinModuleInfoProvider
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.ModuleRegistrarPreAnalysisHandler
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.TestModuleInfoProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.moduleInfoProvider
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.TestInfrastructureInternals
|
||||
import org.jetbrains.kotlin.test.bind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.builders.testConfiguration
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.model.ResultingArtifact
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.io.path.nameWithoutExtension
|
||||
|
||||
abstract class AbstractLowLevelApiTest : TestWithDisposable() {
|
||||
private lateinit var testInfo: KotlinTestInfo
|
||||
|
||||
@OptIn(TestInfrastructureInternals::class)
|
||||
private val configure: TestConfigurationBuilder.() -> Unit = {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.FIR
|
||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
||||
dependencyKind = DependencyKind.Source
|
||||
}
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JvmEnvironmentConfigurator,
|
||||
)
|
||||
assertions = JUnit5Assertions
|
||||
useAdditionalService<TemporaryDirectoryManager>(::TemporaryDirectoryManagerImpl)
|
||||
|
||||
useDirectives(*AbstractKotlinCompilerTest.defaultDirectiveContainers.toTypedArray())
|
||||
useDirectives(JvmEnvironmentConfigurationDirectives)
|
||||
|
||||
useSourcePreprocessor(::ExpressionMarkersSourceFilePreprocessor)
|
||||
useAdditionalService { ExpressionMarkerProvider() }
|
||||
useAdditionalService(::TestModuleInfoProvider)
|
||||
usePreAnalysisHandlers(::ModuleRegistrarPreAnalysisHandler.bind(disposable))
|
||||
configureTest(this)
|
||||
|
||||
startingArtifactFactory = { ResultingArtifact.Source() }
|
||||
this.testInfo = this@AbstractLowLevelApiTest.testInfo
|
||||
}
|
||||
|
||||
protected lateinit var testDataPath: Path
|
||||
|
||||
protected fun testDataFileSibling(extension: String): Path {
|
||||
val extensionWithDot = "." + extension.removePrefix(".")
|
||||
return testDataPath.resolveSibling(testDataPath.nameWithoutExtension + extensionWithDot)
|
||||
}
|
||||
|
||||
open fun configureTest(builder: TestConfigurationBuilder) {}
|
||||
|
||||
protected fun runTest(@TestDataFile path: String) {
|
||||
testDataPath = Paths.get(path)
|
||||
val testConfiguration = testConfiguration(path, configure)
|
||||
Disposer.register(disposable, testConfiguration.rootDisposable)
|
||||
val testServices = testConfiguration.testServices
|
||||
val moduleStructure = testConfiguration.moduleStructureExtractor.splitTestDataByModules(
|
||||
path,
|
||||
testConfiguration.directives,
|
||||
).also { testModuleStructure ->
|
||||
testConfiguration.testServices.register(TestModuleStructure::class, testModuleStructure)
|
||||
testConfiguration.preAnalysisHandlers.forEach { preprocessor ->
|
||||
preprocessor.preprocessModuleStructure(testModuleStructure)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val singleModule = moduleStructure.modules.single()
|
||||
val project = testServices.compilerConfigurationProvider.getProject(singleModule)
|
||||
val moduleInfoProvider = testServices.moduleInfoProvider
|
||||
|
||||
val moduleInfo = moduleInfoProvider.getModuleInfo(singleModule.name)
|
||||
|
||||
with(project as MockProject) {
|
||||
registerServicesForProject(this)
|
||||
}
|
||||
|
||||
registerApplicationServices()
|
||||
|
||||
doTestByFileStructure(
|
||||
moduleInfo.testFilesToKtFiles.filter { (testFile, _) -> !testFile.isAdditional }.values.toList(),
|
||||
moduleStructure,
|
||||
testServices
|
||||
)
|
||||
}
|
||||
|
||||
private fun registerApplicationServices() {
|
||||
val application = ApplicationManager.getApplication() as MockApplication
|
||||
KotlinCoreEnvironment.underApplicationLock {
|
||||
registerApplicationServices(application)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun registerServicesForProject(project: MockProject) {}
|
||||
|
||||
protected open fun registerApplicationServices(application: MockApplication) {}
|
||||
|
||||
protected abstract fun doTestByFileStructure(ktFiles: List<KtFile>, moduleStructure: TestModuleStructure, testServices: TestServices)
|
||||
|
||||
@BeforeEach
|
||||
fun initTestInfo(testInfo: TestInfo) {
|
||||
this.testInfo = KotlinTestInfo(
|
||||
className = testInfo.testClass.orElseGet(null)?.name ?: "_undefined_",
|
||||
methodName = testInfo.testMethod.orElseGet(null)?.name ?: "_testUndefined_",
|
||||
tags = testInfo.tags
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun String.indexOfOrNull(substring: String) =
|
||||
indexOf(substring).takeIf { it >= 0 }
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.test.base
|
||||
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.annotations.PrivateForInline
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.parentOfType
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.elementsInRange
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
import org.jetbrains.kotlin.test.services.SourceFilePreprocessor
|
||||
import org.jetbrains.kotlin.test.services.TestService
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
internal class ExpressionMarkersSourceFilePreprocessor(testServices: TestServices) : SourceFilePreprocessor(testServices) {
|
||||
override fun process(file: TestFile, content: String): String {
|
||||
val withSelectedProcessed = processSelectedExpression(file, content)
|
||||
return processCaretExpression(file, withSelectedProcessed)
|
||||
}
|
||||
|
||||
private fun processSelectedExpression(file: TestFile, content: String): String {
|
||||
val startCaretPosition = content.indexOfOrNull(TAGS.OPENING_EXPRESSION_TAG) ?: return content
|
||||
|
||||
val endCaretPosition = content.indexOfOrNull(TAGS.CLOSING_EXPRESSION_TAG)
|
||||
?: error("${TAGS.CLOSING_EXPRESSION_TAG} was not found in the file")
|
||||
|
||||
check(startCaretPosition < endCaretPosition)
|
||||
testServices.expressionMarkerProvider.addSelectedExpression(
|
||||
file,
|
||||
TextRange.create(startCaretPosition, endCaretPosition - TAGS.OPENING_EXPRESSION_TAG.length)
|
||||
)
|
||||
return content
|
||||
.replace(TAGS.OPENING_EXPRESSION_TAG, "")
|
||||
.replace(TAGS.CLOSING_EXPRESSION_TAG, "")
|
||||
}
|
||||
|
||||
private fun processCaretExpression(file: TestFile, content: String): String {
|
||||
val startCaretPosition = content.indexOfOrNull(TAGS.CARET) ?: return content
|
||||
|
||||
testServices.expressionMarkerProvider.addCaret(file, startCaretPosition)
|
||||
return content
|
||||
.replace(TAGS.CARET, "")
|
||||
}
|
||||
|
||||
object TAGS {
|
||||
const val OPENING_EXPRESSION_TAG = "<expr>"
|
||||
const val CLOSING_EXPRESSION_TAG = "</expr>"
|
||||
const val CARET = "<caret>"
|
||||
}
|
||||
}
|
||||
|
||||
class ExpressionMarkerProvider : TestService {
|
||||
private val selected = mutableMapOf<String, TextRange>()
|
||||
|
||||
@PrivateForInline
|
||||
val atCaret = mutableMapOf<String, Int>()
|
||||
|
||||
fun addSelectedExpression(file: TestFile, range: TextRange) {
|
||||
selected[file.relativePath] = range
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
fun addCaret(file: TestFile, caret: Int) {
|
||||
atCaret[file.relativePath] = caret
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
fun getCaretPosition(file: KtFile): Int {
|
||||
return atCaret[file.name]
|
||||
?: error("No caret found in file")
|
||||
}
|
||||
|
||||
inline fun <reified P : KtElement> getElementOfTypAtCaret(file: KtFile): P {
|
||||
val offset = getCaretPosition(file)
|
||||
return file.findElementAt(offset)
|
||||
?.parentOfType<P>()
|
||||
?: error("No expression found at caret")
|
||||
}
|
||||
|
||||
|
||||
fun getSelectedElement(file: KtFile): KtElement {
|
||||
val range = selected[file.name]
|
||||
?: error("No selected expression found in file")
|
||||
val elements = file.elementsInRange(range).trimWhitespaces()
|
||||
if (elements.size != 1) {
|
||||
error("Expected one element at rage but found ${elements.size} [${elements.joinToString { it::class.simpleName + ": " + it.text }}]")
|
||||
}
|
||||
return elements.single() as KtElement
|
||||
}
|
||||
|
||||
private fun List<PsiElement>.trimWhitespaces(): List<PsiElement> =
|
||||
dropWhile { it is PsiWhiteSpace }
|
||||
.dropLastWhile { it is PsiWhiteSpace }
|
||||
}
|
||||
|
||||
val TestServices.expressionMarkerProvider: ExpressionMarkerProvider by TestServices.testServiceAccessor()
|
||||
+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.low.level.api.fir.test.base
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.SealedClassInheritorsProvider
|
||||
import org.jetbrains.kotlin.fir.declarations.SealedClassInheritorsProviderInternals
|
||||
import org.jetbrains.kotlin.fir.declarations.sealedInheritorsAttr
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
internal class SealedClassInheritorsProviderTestImpl : SealedClassInheritorsProvider() {
|
||||
@OptIn(SealedClassInheritorsProviderInternals::class)
|
||||
override fun getSealedClassInheritors(firClass: FirRegularClass): List<ClassId> {
|
||||
return firClass.sealedInheritorsAttr ?: emptyList()
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.low.level.api.fir.test.base
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
|
||||
abstract class TestWithDisposable {
|
||||
private var _disposable: Disposable? = null
|
||||
protected val disposable: Disposable get() = _disposable!!
|
||||
|
||||
@BeforeEach
|
||||
private fun intiDisposable(testInfo: TestInfo) {
|
||||
_disposable = Disposer.newDisposable("disposable for ${testInfo.displayName}")
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
private fun disposeDisposable() {
|
||||
_disposable?.let { Disposer.dispose(it) }
|
||||
_disposable = null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user