FIR IDE: do not use IJ test infrastructure in frontend-api-fir tests
This commit is contained in:
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDE_IGNORE
|
||||
// FILE: K1.kt
|
||||
class KSub : J1()
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDE_IGNORE
|
||||
// FILE: K1.kt
|
||||
class K2: <!CYCLIC_INHERITANCE_HIERARCHY!>J1<!>() {
|
||||
class Q : <!UNRESOLVED_REFERENCE!>Nested<!>()
|
||||
|
||||
@@ -6,12 +6,17 @@
|
||||
package org.jetbrains.kotlin.test
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
abstract class Assertions {
|
||||
fun assertEqualsToFile(expectedFile: File, actual: String, sanitizer: (String) -> String = { it }) {
|
||||
assertEqualsToFile(expectedFile, actual, sanitizer) { "Actual data differs from file content" }
|
||||
}
|
||||
|
||||
fun assertEqualsToFile(expectedFile: Path, actual: String, sanitizer: (String) -> String = { it }) {
|
||||
assertEqualsToFile(expectedFile.toFile(), actual, sanitizer)
|
||||
}
|
||||
|
||||
abstract fun assertEqualsToFile(
|
||||
expectedFile: File,
|
||||
actual: String,
|
||||
|
||||
@@ -17,6 +17,7 @@ dependencies {
|
||||
testCompile(projectTests(":compiler:tests-common"))
|
||||
testCompile(projectTests(":compiler:tests-spec"))
|
||||
testCompile(projectTests(":idea:idea-frontend-fir:idea-fir-low-level-api"))
|
||||
testCompile(projectTests(":idea:idea-frontend-fir"))
|
||||
testCompile(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
||||
testApiJUnit5()
|
||||
}
|
||||
|
||||
+54
@@ -6,6 +6,16 @@
|
||||
package org.jetbrains.kotlin.generators.tests.frontend.api
|
||||
|
||||
import org.jetbrains.kotlin.generators.util.TestGeneratorUtil
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.components.AbstractExpectedExpressionTypeTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.components.AbstractHLExpressionTypeTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.components.AbstractOverriddenDeclarationProviderTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.components.AbstractRendererTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.fir.AbstractResolveCallTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.scopes.AbstractFileScopeTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.scopes.AbstractMemberScopeByFqNameTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByFqNameTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByPsiTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByReferenceTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyBodiesCalculatorTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyDeclarationResolveTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirOnAirResolveTest
|
||||
@@ -26,6 +36,50 @@ fun main(args: Array<String>) {
|
||||
|
||||
|
||||
generateTestGroupSuiteWithJUnit5(args) {
|
||||
|
||||
testGroup("idea/idea-frontend-fir/tests", "idea/idea-frontend-fir/testData") {
|
||||
testClass<AbstractResolveCallTest> {
|
||||
model("analysisSession/resolveCall")
|
||||
}
|
||||
|
||||
testClass<AbstractMemberScopeByFqNameTest> {
|
||||
model("memberScopeByFqName")
|
||||
}
|
||||
|
||||
testClass<AbstractFileScopeTest> {
|
||||
model("fileScopeTest", extension = "kt")
|
||||
}
|
||||
|
||||
testClass<AbstractSymbolByPsiTest> {
|
||||
model("symbols/symbolByPsi")
|
||||
}
|
||||
|
||||
testClass<AbstractSymbolByFqNameTest> {
|
||||
model("symbols/symbolByFqName")
|
||||
}
|
||||
|
||||
// todo
|
||||
// testClass<AbstractSymbolByReferenceTest> {
|
||||
// model("symbols/symbolByReference")
|
||||
// }
|
||||
|
||||
testClass<AbstractExpectedExpressionTypeTest> {
|
||||
model("components/expectedExpressionType")
|
||||
}
|
||||
|
||||
testClass<AbstractOverriddenDeclarationProviderTest> {
|
||||
model("components/overridenDeclarations")
|
||||
}
|
||||
|
||||
testClass<AbstractHLExpressionTypeTest> {
|
||||
model("components/expressionType")
|
||||
}
|
||||
|
||||
testClass<AbstractRendererTest> {
|
||||
model("components/declarationRenderer")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/idea-frontend-fir/idea-fir-low-level-api/tests", "compiler/fir/raw-fir/psi2fir/testData") {
|
||||
testClass<AbstractFirLazyBodiesCalculatorTest> {
|
||||
model("rawBuilder", testMethod = "doTest")
|
||||
|
||||
-69
@@ -70,7 +70,6 @@ import org.jetbrains.kotlin.idea.editor.AbstractMultiLineStringIndentTest
|
||||
import org.jetbrains.kotlin.idea.editor.backspaceHandler.AbstractBackspaceHandlerTest
|
||||
import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest
|
||||
import org.jetbrains.kotlin.idea.filters.AbstractKotlinExceptionFilterTest
|
||||
import org.jetbrains.kotlin.idea.fir.AbstractKtDeclarationAndFirDeclarationEqualityChecker
|
||||
import org.jetbrains.kotlin.idea.fir.asJava.classes.AbstractFirClassLoadingTest
|
||||
import org.jetbrains.kotlin.idea.fir.asJava.classes.AbstractFirLightClassTest
|
||||
import org.jetbrains.kotlin.idea.fir.asJava.classes.AbstractFirLightFacadeClassTest
|
||||
@@ -86,29 +85,13 @@ import org.jetbrains.kotlin.idea.fir.highlighter.AbstractFirHighlightingTest
|
||||
import org.jetbrains.kotlin.idea.fir.inspections.AbstractHLInspectionTest
|
||||
import org.jetbrains.kotlin.idea.fir.inspections.AbstractHLLocalInspectionTest
|
||||
import org.jetbrains.kotlin.idea.fir.intentions.AbstractHLIntentionTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.*
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostic.compiler.based.AbstractDiagnosisCompilerTestDataSpecTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostic.compiler.based.AbstractDiagnosisCompilerTestDataTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.AbstractFileStructureTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.resolve.AbstractInnerDeclarationsResolvePhaseTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.sessions.AbstractSessionsInvalidationTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.trackers.AbstractProjectWideOutOfBlockKotlinModificationTrackerTest
|
||||
import org.jetbrains.kotlin.idea.fir.quickfix.AbstractHighLevelQuickFixMultiFileTest
|
||||
import org.jetbrains.kotlin.idea.fir.quickfix.AbstractHighLevelQuickFixTest
|
||||
import org.jetbrains.kotlin.idea.fir.resolve.AbstractFirReferenceResolveTest
|
||||
import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest
|
||||
import org.jetbrains.kotlin.idea.frontend.api.components.*
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.fir.AbstractResolveCallTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.scopes.AbstractFileScopeTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.scopes.AbstractMemberScopeByFqNameTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractMemoryLeakInSymbolsTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByFqNameTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByPsiTest
|
||||
import org.jetbrains.kotlin.idea.fir.frontend.api.symbols.AbstractSymbolByReferenceTest
|
||||
import org.jetbrains.kotlin.idea.fir.inspections.AbstractFe10BindingIntentionTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostic.AbstractDiagnosticTraversalCounterTest
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostic.AbstractFirContextCollectionTest
|
||||
//import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.AbstractFileStructureAndOutOfBlockModificationTrackerConsistencyTest
|
||||
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest
|
||||
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyWithLibTest
|
||||
import org.jetbrains.kotlin.idea.highlighter.*
|
||||
@@ -995,59 +978,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/idea-frontend-fir/tests", "idea/idea-frontend-fir/testData") {
|
||||
testClass<AbstractKtDeclarationAndFirDeclarationEqualityChecker> {
|
||||
model("ktDeclarationAndFirDeclarationEqualityChecker")
|
||||
}
|
||||
|
||||
testClass<AbstractResolveCallTest> {
|
||||
model("analysisSession/resolveCall")
|
||||
}
|
||||
|
||||
testClass<AbstractMemberScopeByFqNameTest> {
|
||||
model("memberScopeByFqName")
|
||||
}
|
||||
|
||||
testClass<AbstractFileScopeTest> {
|
||||
model("fileScopeTest", extension = "kt")
|
||||
}
|
||||
|
||||
testClass<AbstractSymbolByPsiTest> {
|
||||
model("symbols/symbolByPsi")
|
||||
}
|
||||
|
||||
testClass<AbstractSymbolByFqNameTest> {
|
||||
model("symbols/symbolByFqName")
|
||||
}
|
||||
|
||||
testClass<AbstractSymbolByReferenceTest> {
|
||||
model("symbols/symbolByReference")
|
||||
}
|
||||
|
||||
testClass<AbstractMemoryLeakInSymbolsTest> {
|
||||
model("symbolMemoryLeak")
|
||||
}
|
||||
|
||||
testClass<AbstractReturnExpressionTargetTest> {
|
||||
model("components/returnExpressionTarget")
|
||||
}
|
||||
|
||||
testClass<AbstractExpectedExpressionTypeTest> {
|
||||
model("components/expectedExpressionType")
|
||||
}
|
||||
|
||||
testClass<AbstractOverriddenDeclarationProviderTest> {
|
||||
model("components/overridenDeclarations")
|
||||
}
|
||||
|
||||
testClass<AbstractHLExpressionTypeTest> {
|
||||
model("components/expressionType")
|
||||
}
|
||||
|
||||
testClass<AbstractRendererTest> {
|
||||
model("components/declarationRenderer")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testGroup("idea/idea-frontend-fir/fir-low-level-api-ide-impl/tests", "idea/idea-frontend-fir/idea-fir-low-level-api/testdata") {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.idea.fir
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.LightPlatformTestCase
|
||||
import org.jetbrains.kotlin.idea.caches.project.LibraryModificationTracker
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.KotlinOutOfBlockModificationTrackerFactory
|
||||
import org.jetbrains.kotlin.idea.frontend.api.InvalidWayOfUsingAnalysisSession
|
||||
import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSessionProvider
|
||||
import org.jetbrains.kotlin.idea.frontend.api.analyse
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import java.io.File
|
||||
|
||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||
fun Project.invalidateCaches(context: KtElement?) {
|
||||
LibraryModificationTracker.getInstance(this).incModificationCount()
|
||||
service<KotlinOutOfBlockModificationTrackerFactory>().incrementModificationsCount()
|
||||
service<KtAnalysisSessionProvider>().clearCaches()
|
||||
if (context != null) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread {
|
||||
runReadAction { analyse(context) { } }
|
||||
}.get()
|
||||
}
|
||||
}
|
||||
|
||||
fun addExternalTestFiles(testDataFilePath: String) {
|
||||
File(testDataFilePath).getExternalFiles().forEach(::addFile)
|
||||
}
|
||||
|
||||
private fun addFile(file: File) {
|
||||
addFile(FileUtil.loadFile(file, /* convertLineSeparators = */true), file.name)
|
||||
}
|
||||
|
||||
private fun File.getExternalFiles(): List<File> {
|
||||
val directory = parentFile
|
||||
val externalFileName = "${nameWithoutExtension}.external"
|
||||
return directory.listFiles { _, name ->
|
||||
name == "$externalFileName.kt" || name == "$externalFileName.java"
|
||||
}!!.filterNotNull()
|
||||
}
|
||||
|
||||
|
||||
private fun addFile(text: String, fileName: String) {
|
||||
runWriteAction {
|
||||
val virtualDir = LightPlatformTestCase.getSourceRoot()!!
|
||||
val virtualFile = virtualDir.createChildData(null, fileName)
|
||||
virtualFile.getOutputStream(null)!!.writer().use { it.write(text) }
|
||||
}
|
||||
}
|
||||
+4
@@ -12,6 +12,7 @@ import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Computable
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.idea.frontend.api.tokens.AlwaysAccessibleValidityTokenFactory
|
||||
import org.jetbrains.kotlin.idea.frontend.api.tokens.ReadActionConfinementValidityTokenFactory
|
||||
import org.jetbrains.kotlin.idea.frontend.api.tokens.ValidityTokenFactory
|
||||
@@ -65,6 +66,9 @@ abstract class KtAnalysisSessionProvider : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
abstract fun clearCaches()
|
||||
|
||||
override fun dispose() {}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -18,19 +18,35 @@ dependencies {
|
||||
compile(project(":compiler:light-classes"))
|
||||
compile(intellijCoreDep())
|
||||
|
||||
testCompile(project(":idea:idea-fir"))
|
||||
testCompile(intellijDep())
|
||||
testCompile(intellijCoreDep())
|
||||
testCompile(toolsJar())
|
||||
testCompile(project(":kotlin-reflect"))
|
||||
testCompile(projectTests(":idea"))
|
||||
testCompile(projectTests(":idea:idea-frontend-fir:idea-fir-low-level-api"))
|
||||
testCompile(projectTests(":compiler:tests-common"))
|
||||
testCompile(projectTests(":idea:idea-test-framework"))
|
||||
testCompile(projectTests(":compiler:test-infrastructure-utils"))
|
||||
testCompile(projectTests(":compiler:test-infrastructure"))
|
||||
testCompile(projectTests(":compiler:tests-common-new"))
|
||||
testCompile(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(projectTests(":idea:idea-frontend-independent"))
|
||||
testCompile(toolsJar())
|
||||
testApiJUnit5()
|
||||
|
||||
// compile(intellijPluginDep("java"))
|
||||
testRuntimeOnly(intellijDep()) {
|
||||
includeJars(
|
||||
"jps-model",
|
||||
"extensions",
|
||||
"util",
|
||||
"platform-api",
|
||||
"platform-impl",
|
||||
"idea",
|
||||
"guava",
|
||||
"trove4j",
|
||||
"asm-all",
|
||||
"log4j",
|
||||
"jdom",
|
||||
"streamex",
|
||||
"bootstrap",
|
||||
"jna",
|
||||
rootProject = rootProject
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -38,19 +54,15 @@ sourceSets {
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
projectTest {
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
val useFirIdeaPlugin = kotlinBuildProperties.useFirIdeaPlugin
|
||||
doFirst {
|
||||
if (!useFirIdeaPlugin) {
|
||||
error("Test task in the module should be executed with -Pidea.fir.plugin=true")
|
||||
}
|
||||
}
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
testsJar()
|
||||
|
||||
|
||||
val generatorClasspath by configurations.creating
|
||||
|
||||
dependencies {
|
||||
|
||||
+4
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
import org.jetbrains.kotlin.analyzer.SdkInfoBase
|
||||
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.dependenciesWithoutSelf
|
||||
import org.jetbrains.kotlin.fir.deserialization.ModuleDataProvider
|
||||
@@ -99,4 +100,7 @@ class FirModuleResolveStateConfiguratorIdeImpl(private val project: Project) : F
|
||||
override fun getModuleInfoFor(element: KtElement): ModuleInfo {
|
||||
return element.getModuleInfo()
|
||||
}
|
||||
|
||||
override fun configureSourceSession(session: FirSession) {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ class KotlinFirOutOfBlockModificationTrackerFactory(private val project: Project
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
fun incrementModificationsCount() {
|
||||
override fun incrementModificationsCount() {
|
||||
project.service<KotlinFirModificationTrackerService>().increaseModificationCountForAllModules()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ dependencies {
|
||||
testCompile(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testApiJUnit5()
|
||||
testCompile(project(":kotlin-reflect"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
+6
@@ -7,14 +7,18 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.api
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElementFinder
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
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.java.FirJavaElementFinder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.DeclarationProvider
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.KtPackageProvider
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.sessions.FirIdeSourcesSession
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
@@ -28,6 +32,8 @@ abstract class FirModuleResolveStateConfigurator {
|
||||
abstract fun createScopeForModuleLibraries(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope
|
||||
abstract fun createSealedInheritorsProvider(): SealedClassInheritorsProvider
|
||||
abstract fun getModuleInfoFor(element: KtElement): ModuleInfo
|
||||
|
||||
abstract fun configureSourceSession(session: FirSession)
|
||||
}
|
||||
|
||||
val Project.stateConfigurator: FirModuleResolveStateConfigurator
|
||||
|
||||
+4
@@ -9,6 +9,7 @@ import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
|
||||
@@ -17,6 +18,9 @@ abstract class KotlinOutOfBlockModificationTrackerFactory {
|
||||
abstract fun createProjectWideOutOfBlockModificationTracker(): ModificationTracker
|
||||
abstract fun createModuleWithoutDependenciesOutOfBlockModificationTracker(moduleInfo: ModuleSourceInfoBase): ModificationTracker
|
||||
abstract fun createLibraryOutOfBlockModificationTracker(): ModificationTracker
|
||||
|
||||
@TestOnly
|
||||
abstract fun incrementModificationsCount()
|
||||
}
|
||||
|
||||
fun Project.createProjectWideOutOfBlockModificationTracker() =
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ private object CheckersFactory {
|
||||
useExtendedCheckers: Boolean
|
||||
): List<AbstractDiagnosticCollectorComponent> {
|
||||
val moduleInfo = session.moduleData.moduleSourceInfo
|
||||
val platform = moduleInfo.platform.componentPlatforms.single()
|
||||
val platform = moduleInfo.platform.componentPlatforms.first()
|
||||
val declarationCheckers = createDeclarationCheckers(useExtendedCheckers, platform)
|
||||
val expressionCheckers = createExpressionCheckers(useExtendedCheckers)
|
||||
val typeCheckers = createTypeCheckers(useExtendedCheckers)
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.idea.fir.low.level.api.sessions
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElementFinder
|
||||
import org.jetbrains.kotlin.analyzer.LibraryModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
@@ -17,6 +18,7 @@ import org.jetbrains.kotlin.fir.backend.jvm.FirJvmTypeMapper
|
||||
import org.jetbrains.kotlin.fir.caches.FirCachesFactory
|
||||
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
|
||||
import org.jetbrains.kotlin.fir.declarations.SealedClassInheritorsProvider
|
||||
import org.jetbrains.kotlin.fir.java.FirJavaElementFinder
|
||||
import org.jetbrains.kotlin.fir.java.JavaSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.java.deserialization.KotlinDeserializedJvmSymbolsProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.FirProvider
|
||||
@@ -78,7 +80,6 @@ internal object FirIdeSessionFactory {
|
||||
val session = FirIdeSourcesSession(dependentModules, project, searchScope, firBuilder, builtinTypes)
|
||||
sessionsCache[moduleInfo] = session
|
||||
|
||||
|
||||
return session.apply session@{
|
||||
val moduleData = FirModuleInfoBasedModuleData(moduleInfo).apply { bindSession(this@session) }
|
||||
registerModuleData(moduleData)
|
||||
@@ -155,8 +156,8 @@ internal object FirIdeSessionFactory {
|
||||
registerExtendedCommonCheckers()
|
||||
}
|
||||
}.configure()
|
||||
|
||||
configureSession?.invoke(this)
|
||||
project.stateConfigurator.configureSourceSession(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+123
-101
@@ -9,18 +9,23 @@ import com.intellij.mock.MockProject
|
||||
import com.intellij.psi.PsiElementFinder
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.ProjectScope
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider
|
||||
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.CompilerConfiguration
|
||||
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.analysis.FirAnalyzerFacade
|
||||
import org.jetbrains.kotlin.fir.declarations.SealedClassInheritorsProvider
|
||||
import org.jetbrains.kotlin.fir.deserialization.ModuleDataProvider
|
||||
import org.jetbrains.kotlin.fir.java.FirJavaElementFinder
|
||||
import org.jetbrains.kotlin.fir.session.FirModuleInfoBasedModuleData
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.*
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.*
|
||||
@@ -74,23 +79,6 @@ abstract class FrontendApiTestWithTestdata : AbstractKotlinCompilerTest() {
|
||||
open fun TestConfigurationBuilder.configureTest() {}
|
||||
|
||||
|
||||
private class TestModuleInfo(
|
||||
val testModule: TestModule,
|
||||
) : ModuleInfo, ModuleSourceInfoBase {
|
||||
override val name: Name get() = Name.identifier(testModule.name)
|
||||
|
||||
override fun dependencies(): List<ModuleInfo> {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = testModule.targetPlatform
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = testModule.targetPlatform.getAnalyzerServices()
|
||||
}
|
||||
|
||||
|
||||
inner class LowLevelFirFrontendFacade(
|
||||
testServices: TestServices
|
||||
) : FrontendFacade<FirOutputArtifact>(testServices, FrontendKinds.FIR) {
|
||||
@@ -101,105 +89,29 @@ abstract class FrontendApiTestWithTestdata : AbstractKotlinCompilerTest() {
|
||||
get() = listOf(FirDiagnosticsDirectives)
|
||||
|
||||
override fun analyze(module: TestModule): FirOutputArtifact {
|
||||
val moduleInfoProvider = testServices.firModuleInfoProvider
|
||||
val compilerConfigurationProvider = testServices.compilerConfigurationProvider
|
||||
|
||||
val project = compilerConfigurationProvider.getProject(module)
|
||||
|
||||
val project = testServices.compilerConfigurationProvider.getProject(module)
|
||||
val ktFiles = testServices.sourceFileProvider.getKtFilesForSourceFiles(module.files, project)
|
||||
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
|
||||
|
||||
val ktFiles = testServices.sourceFileProvider.getKtFilesForSourceFiles(module.files, project)
|
||||
|
||||
val languageVersionSettings = module.languageVersionSettings
|
||||
val packagePartProviderFactory = compilerConfigurationProvider.getPackagePartProviderFactory(module)
|
||||
|
||||
val configuration = compilerConfigurationProvider.getCompilerConfiguration(module)
|
||||
|
||||
val librariesScope = ProjectScope.getLibrariesScope(project)
|
||||
val sourcesScope = TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, ktFiles.values)
|
||||
val moduleInfo = TestModuleInfo(module)
|
||||
moduleInfoProvider.registerModuleData(module, FirModuleInfoBasedModuleData(moduleInfo))
|
||||
|
||||
|
||||
val configurator = object : FirModuleResolveStateConfigurator() {
|
||||
private val sealedClassInheritorsProvider = SealedClassInheritorsProviderTestImpl()
|
||||
|
||||
override fun createPackagePartsProvider(scope: GlobalSearchScope): PackagePartProvider {
|
||||
return packagePartProviderFactory.invoke(scope)
|
||||
}
|
||||
|
||||
override fun createModuleDataProvider(moduleInfo: ModuleSourceInfoBase): ModuleDataProvider {
|
||||
require(moduleInfo is TestModuleInfo)
|
||||
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(moduleInfoProvider.getRegularDependentSourceModules(module))
|
||||
sourceFriendsDependencies(moduleInfoProvider.getDependentFriendSourceModules(module))
|
||||
sourceDependsOnDependencies(moduleInfoProvider.getDependentDependsOnSourceModules(module))
|
||||
}.moduleDataProvider
|
||||
}
|
||||
|
||||
override fun getLanguageVersionSettings(moduleInfo: ModuleSourceInfoBase): LanguageVersionSettings {
|
||||
return languageVersionSettings
|
||||
}
|
||||
|
||||
override fun getModuleSourceScope(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope {
|
||||
return sourcesScope
|
||||
}
|
||||
|
||||
override fun createScopeForModuleLibraries(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope {
|
||||
return librariesScope
|
||||
}
|
||||
|
||||
override fun createSealedInheritorsProvider(): SealedClassInheritorsProvider {
|
||||
return sealedClassInheritorsProvider
|
||||
}
|
||||
|
||||
override fun getModuleInfoFor(element: KtElement): ModuleInfo {
|
||||
return moduleInfo
|
||||
}
|
||||
}
|
||||
testServices.firModuleInfoProvider.registerModuleData(module, FirModuleInfoBasedModuleData(moduleInfo))
|
||||
val configurator = FirModuleResolveStateConfiguratorForSingleModuleTestImpl(testServices, module, ktFiles, moduleInfo)
|
||||
|
||||
with(project as MockProject) {
|
||||
registerService(
|
||||
FirModuleResolveStateConfigurator::class.java,
|
||||
configurator
|
||||
)
|
||||
registerService(FirIdeResolveStateService::class.java)
|
||||
registerService(
|
||||
KotlinOutOfBlockModificationTrackerFactory::class.java,
|
||||
KotlinOutOfBlockModificationTrackerFactoryTestImpl::class.java
|
||||
)
|
||||
registerService(KtDeclarationProviderFactory::class.java, object : KtDeclarationProviderFactory() {
|
||||
override fun createDeclarationProvider(searchScope: GlobalSearchScope): DeclarationProvider {
|
||||
return DeclarationProviderTestImpl(searchScope, ktFiles.values)
|
||||
}
|
||||
})
|
||||
registerService(KtPackageProviderFactory::class.java, object : KtPackageProviderFactory() {
|
||||
override fun createPackageProvider(searchScope: GlobalSearchScope): KtPackageProvider {
|
||||
return KtPackageProviderTestImpl(searchScope, ktFiles.values)
|
||||
}
|
||||
})
|
||||
registerTestServices(configurator, ktFiles)
|
||||
}
|
||||
|
||||
|
||||
val resolveState = createResolveStateForNoCaching(moduleInfo, project) { configureSession() }
|
||||
return getArtifact(module, testServices, ktFiles, resolveState)
|
||||
?: FirOutputArtifactImpl(
|
||||
resolveState.rootModuleSession,
|
||||
emptyMap(),
|
||||
FirAnalyzerFacade(resolveState.rootModuleSession, languageVersionSettings)
|
||||
FirAnalyzerFacade(resolveState.rootModuleSession, configurator.getLanguageVersionSettings(moduleInfo))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected open fun FirIdeSession.configureSession() {}
|
||||
|
||||
protected abstract fun getArtifact(
|
||||
@@ -234,4 +146,114 @@ abstract class FrontendApiTestWithTestdata : AbstractKotlinCompilerTest() {
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestModuleInfo(
|
||||
val testModule: TestModule,
|
||||
) : ModuleInfo, ModuleSourceInfoBase {
|
||||
override val name: Name get() = Name.identifier(testModule.name)
|
||||
|
||||
override fun dependencies(): List<ModuleInfo> {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = testModule.targetPlatform
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = testModule.targetPlatform.getAnalyzerServices()
|
||||
}
|
||||
|
||||
|
||||
class FirModuleResolveStateConfiguratorForSingleModuleTestImpl(
|
||||
private val testServices: TestServices,
|
||||
private val testModule: TestModule,
|
||||
private val ktFiles: Map<TestFile, KtFile>,
|
||||
private val moduleInfo: ModuleInfo,
|
||||
) : FirModuleResolveStateConfigurator() {
|
||||
val moduleInfoProvider = testServices.firModuleInfoProvider
|
||||
val compilerConfigurationProvider = testServices.compilerConfigurationProvider
|
||||
|
||||
val project = compilerConfigurationProvider.getProject(testModule)
|
||||
|
||||
val languageVersionSettings = testModule.languageVersionSettings
|
||||
val packagePartProviderFactory = compilerConfigurationProvider.getPackagePartProviderFactory(testModule)
|
||||
|
||||
val configuration = compilerConfigurationProvider.getCompilerConfiguration(testModule)
|
||||
|
||||
val librariesScope = ProjectScope.getLibrariesScope(project)
|
||||
val sourcesScope = TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, ktFiles.values)
|
||||
|
||||
private val sealedClassInheritorsProvider = SealedClassInheritorsProviderTestImpl()
|
||||
|
||||
override fun createPackagePartsProvider(scope: GlobalSearchScope): PackagePartProvider {
|
||||
return packagePartProviderFactory.invoke(scope)
|
||||
}
|
||||
|
||||
override fun createModuleDataProvider(moduleInfo: ModuleSourceInfoBase): ModuleDataProvider {
|
||||
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(moduleInfoProvider.getRegularDependentSourceModules(testModule))
|
||||
sourceFriendsDependencies(moduleInfoProvider.getDependentFriendSourceModules(testModule))
|
||||
sourceDependsOnDependencies(moduleInfoProvider.getDependentDependsOnSourceModules(testModule))
|
||||
}.moduleDataProvider
|
||||
}
|
||||
|
||||
override fun getLanguageVersionSettings(moduleInfo: ModuleSourceInfoBase): LanguageVersionSettings {
|
||||
return languageVersionSettings
|
||||
}
|
||||
|
||||
override fun getModuleSourceScope(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope {
|
||||
return sourcesScope
|
||||
}
|
||||
|
||||
override fun createScopeForModuleLibraries(moduleInfo: ModuleSourceInfoBase): GlobalSearchScope {
|
||||
return librariesScope
|
||||
}
|
||||
|
||||
override fun createSealedInheritorsProvider(): SealedClassInheritorsProvider {
|
||||
return sealedClassInheritorsProvider
|
||||
}
|
||||
|
||||
override fun getModuleInfoFor(element: KtElement): ModuleInfo {
|
||||
return moduleInfo
|
||||
}
|
||||
|
||||
override fun configureSourceSession(session: FirSession) {
|
||||
@Suppress("IncorrectParentDisposable")
|
||||
PsiElementFinder.EP.getPoint(project).registerExtension(FirJavaElementFinder(session, project), project)
|
||||
}
|
||||
}
|
||||
|
||||
fun MockProject.registerTestServices(
|
||||
configurator: FirModuleResolveStateConfiguratorForSingleModuleTestImpl,
|
||||
ktFiles: Map<TestFile, KtFile>
|
||||
) {
|
||||
registerService(
|
||||
FirModuleResolveStateConfigurator::class.java,
|
||||
configurator
|
||||
)
|
||||
registerService(FirIdeResolveStateService::class.java)
|
||||
registerService(
|
||||
KotlinOutOfBlockModificationTrackerFactory::class.java,
|
||||
KotlinOutOfBlockModificationTrackerFactoryTestImpl::class.java
|
||||
)
|
||||
registerService(KtDeclarationProviderFactory::class.java, object : KtDeclarationProviderFactory() {
|
||||
override fun createDeclarationProvider(searchScope: GlobalSearchScope): DeclarationProvider {
|
||||
return DeclarationProviderTestImpl(searchScope, ktFiles.values)
|
||||
}
|
||||
})
|
||||
registerService(KtPackageProviderFactory::class.java, object : KtPackageProviderFactory() {
|
||||
override fun createPackageProvider(searchScope: GlobalSearchScope): KtPackageProvider {
|
||||
return KtPackageProviderTestImpl(searchScope, ktFiles.values)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+27
-10
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
|
||||
@@ -26,21 +27,37 @@ internal class DeclarationProviderTestImpl(
|
||||
filesInScope.asSequence()
|
||||
.filter { it.packageFqName == packageFqName }
|
||||
|
||||
|
||||
override fun getClassByClassId(classId: ClassId): KtClassOrObject? =
|
||||
filesByPackage(classId.packageFqName).firstNotNullOfOrNull { file ->
|
||||
file.findDescendantOfType { ktClass ->
|
||||
override fun getClassesByClassId(classId: ClassId): Collection<KtClassOrObject> =
|
||||
filesByPackage(classId.packageFqName).flatMap { file ->
|
||||
file.collectDescendantsOfType<KtClassOrObject> { ktClass ->
|
||||
ktClass.getClassId() == classId
|
||||
}
|
||||
}
|
||||
}.toList()
|
||||
|
||||
|
||||
override fun getTypeAliasByClassId(classId: ClassId): KtTypeAlias? =
|
||||
filesByPackage(classId.packageFqName).firstNotNullOfOrNull { file ->
|
||||
file.findDescendantOfType { typeAlias ->
|
||||
override fun getTypeAliasesByClassId(classId: ClassId): Collection<KtTypeAlias> =
|
||||
filesByPackage(classId.packageFqName).flatMap { file ->
|
||||
file.collectDescendantsOfType<KtTypeAlias> { typeAlias ->
|
||||
typeAlias.getClassId() == classId
|
||||
}
|
||||
}
|
||||
}.toList()
|
||||
|
||||
override fun getTypeAliasNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
filesByPackage(packageFqName)
|
||||
.flatMap { it.declarations }
|
||||
.filterIsInstance<KtTypeAlias>()
|
||||
.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
|
||||
override fun getPropertyNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
filesByPackage(packageFqName)
|
||||
.flatMap { it.declarations }
|
||||
.filterIsInstance<KtProperty>()
|
||||
.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
|
||||
override fun getFunctionsNamesInPackage(packageFqName: FqName): Set<Name> =
|
||||
filesByPackage(packageFqName)
|
||||
.flatMap { it.declarations }
|
||||
.filterIsInstance<KtNamedFunction>()
|
||||
.mapNotNullTo(mutableSetOf()) { it.nameAsName }
|
||||
|
||||
override fun getTopLevelProperties(callableId: CallableId): Collection<KtProperty> =
|
||||
filesByPackage(callableId.packageName)
|
||||
|
||||
+9
-1
@@ -7,13 +7,14 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.test.base
|
||||
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import com.intellij.openapi.util.SimpleModificationTracker
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.KotlinOutOfBlockModificationTrackerFactory
|
||||
|
||||
internal class KotlinOutOfBlockModificationTrackerFactoryTestImpl : KotlinOutOfBlockModificationTrackerFactory() {
|
||||
private val projectWide = SimpleModificationTracker()
|
||||
private val library = SimpleModificationTracker()
|
||||
private val forModule = mutableMapOf<ModuleSourceInfoBase, ModificationTracker>()
|
||||
private val forModule = mutableMapOf<ModuleSourceInfoBase, SimpleModificationTracker>()
|
||||
|
||||
override fun createProjectWideOutOfBlockModificationTracker(): ModificationTracker {
|
||||
return projectWide
|
||||
@@ -27,4 +28,11 @@ internal class KotlinOutOfBlockModificationTrackerFactoryTestImpl : KotlinOutOfB
|
||||
override fun createLibraryOutOfBlockModificationTracker(): ModificationTracker {
|
||||
return library
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
override fun incrementModificationsCount() {
|
||||
projectWide.incModificationCount()
|
||||
library.incModificationCount()
|
||||
forModule.values.forEach { it.incModificationCount() }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -41,7 +41,7 @@ class KtFirAnalysisSessionProvider(private val project: Project) : KtAnalysisSes
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
fun clearCaches() {
|
||||
override fun clearCaches() {
|
||||
cache.clear()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
fun function(a: Int) {}
|
||||
|
||||
fun call() {
|
||||
<selection>function(1)</selection>
|
||||
<expr>function(1)</expr>
|
||||
}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = /function(a: kotlin.Int): kotlin.Unit
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = /function(a: kotlin.Int): kotlin.Unit
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
fun String.function(a: Int) {}
|
||||
|
||||
fun call() {
|
||||
"str".<selection>function(1)</selection>
|
||||
"str".<expr>function(1)</expr>
|
||||
}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = /function(<receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = /function(<receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
fun String.function(a: Int) {}
|
||||
|
||||
fun call() {
|
||||
"str"?.<selection>function(1)</selection>
|
||||
"str"?.<expr>function(1)</expr>
|
||||
}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = /function(<receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = /function(<receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class A
|
||||
|
||||
fun call() {
|
||||
val a = <selection>A()</selection>
|
||||
val a = <expr>A()</expr>
|
||||
}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = <constructor>(): A
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = <constructor>(): A
|
||||
idea/idea-frontend-fir/testData/analysisSession/resolveCall/implicitJavaConstuctorCall.external.java
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
class A {
|
||||
|
||||
}
|
||||
+5
-2
@@ -1,6 +1,9 @@
|
||||
|
||||
// FILE: call.kt
|
||||
fun call() {
|
||||
val a = <selection>A()</selection>
|
||||
val a = <expr>A()</expr>
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
class A {}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = <constructor>(): A
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = <constructor>(): A
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
class JavaClass {
|
||||
void javaMethod() {}
|
||||
}
|
||||
+7
-1
@@ -1,6 +1,12 @@
|
||||
// FILE: call.kt
|
||||
fun call() {
|
||||
val javaClass = JavaClass()
|
||||
javaClass.<selection>javaMethod()</selection>
|
||||
javaClass.<expr>javaMethod()</expr>
|
||||
}
|
||||
|
||||
// FILE: JavaClass.java
|
||||
class JavaClass {
|
||||
void javaMethod() {}
|
||||
}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = /JavaClass.javaMethod(): kotlin.Unit
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = /JavaClass.javaMethod(): kotlin.Unit
|
||||
Vendored
+1
-1
@@ -2,6 +2,6 @@ infix fun <A, B> A.to(other: B) = this
|
||||
|
||||
open class A<T>(x: T)
|
||||
|
||||
class B : A(<selection>1 to 2</selection>)
|
||||
class B : A(<expr>1 to 2</expr>)
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = /to(<receiver>: A, other: B): A
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = /to(<receiver>: A, other: B): A
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun x() {
|
||||
<selection>foo(1)</selection>
|
||||
<expr>foo(1)</expr>
|
||||
}
|
||||
|
||||
fun foo(){}
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = ERR<Too many arguments for public final fun /foo(): R|kotlin/Unit|, [/foo(): kotlin.Unit]>
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fun call(x: (Int) -> String) {
|
||||
<selection>x(1)</selection>
|
||||
<expr>x(1)</expr>
|
||||
}
|
||||
|
||||
// CALL: KtFunctionalTypeVariableCall: target = x: kotlin.Function1<kotlin.Int, kotlin.String>, targetFunction = kotlin/Function1.invoke(p1: kotlin.Int): kotlin.String
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionalTypeVariableCall: target = x: kotlin.Function1<kotlin.Int, kotlin.String>, targetFunction = kotlin/Function1.invoke(p1: kotlin.Int): kotlin.String
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
operator fun Int.invoke(): String {}
|
||||
|
||||
fun call(x: kotlin.int) {
|
||||
<selection>x()</selection>
|
||||
<expr>x()</expr>
|
||||
}
|
||||
|
||||
// CALL: KtFunctionCall: targetFunction = /invoke(<receiver>: kotlin.Int): kotlin.String
|
||||
+1
@@ -0,0 +1 @@
|
||||
KtFunctionCall: targetFunction = /invoke(<receiver>: kotlin.Int): kotlin.String
|
||||
@@ -0,0 +1,2 @@
|
||||
open class A
|
||||
class B : A
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
abstract class A {
|
||||
abstract class Nested
|
||||
}
|
||||
typealias TA = A
|
||||
class B : TA {
|
||||
class NestedInB : A.Nested
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
abstract class My {
|
||||
abstract class NestedOne : My {
|
||||
abstract class NestedTwo : My.NestedOne
|
||||
}
|
||||
}
|
||||
class Your : My {
|
||||
class NestedThree : My.NestedOne
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
@Target(allowedTargets = NOT_CONST_EXPRESSION) annotation class base
|
||||
@base annotation class derived
|
||||
@base class correct {
|
||||
constructor(@base x: Int)
|
||||
@base val x: Int
|
||||
@base constructor()
|
||||
}
|
||||
@base enum class My {
|
||||
FIRST,
|
||||
SECOND,
|
||||
}
|
||||
@base fun foo(@base y: @base Int): Int {
|
||||
@base fun bar(@base z: @base Int): Int
|
||||
@base val local: Int
|
||||
}
|
||||
@base val z: Int
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class C<T, out S> {
|
||||
inner class D<R, in P>
|
||||
}
|
||||
interface Test {
|
||||
val x: C<out CharSequence, *>.D<in List<*>, *>
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
object A {
|
||||
constructor()
|
||||
}
|
||||
enum class B {
|
||||
X,
|
||||
}
|
||||
class C {
|
||||
companion object {
|
||||
constructor()
|
||||
}
|
||||
}
|
||||
val anonObject: Any
|
||||
idea/idea-frontend-fir/testData/components/declarationRenderer/constructorOfAnonymousObject.rendered
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
interface IFace<T> {
|
||||
fun getStatus(arg: T): Boolean
|
||||
}
|
||||
class Some
|
||||
private fun resolve(): IFace<Some> {
|
||||
object : IFace<Some> {
|
||||
constructor()
|
||||
override fun getStatus(arg: Some): Boolean
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
interface MyRwProperty<in T, V> {
|
||||
operator fun setValue(thisRef: T, property: Any, value: V)
|
||||
operator fun getValue(thisRef: T, property: Any): V
|
||||
}
|
||||
val x: Int
|
||||
get()
|
||||
val delegate: MyRwProperty<Any?, Int>
|
||||
val value: Int
|
||||
get()
|
||||
var variable: Int
|
||||
get()
|
||||
set(value: Int)
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
open class Base<T> {
|
||||
constructor(x: T)
|
||||
val x: T
|
||||
}
|
||||
class Derived<T : Any> : Base<T> {
|
||||
constructor(x: T)
|
||||
}
|
||||
fun <T : Any> create(x: T): Derived<T>
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
val x: Any
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
enum class Order {
|
||||
FIRST,
|
||||
SECOND,
|
||||
THIRD,
|
||||
}
|
||||
enum class Planet {
|
||||
MERCURY,
|
||||
VENERA,
|
||||
EARTH,
|
||||
constructor(m: Double, r: Double)
|
||||
val m: Double
|
||||
internal val r: Double
|
||||
val g: Double
|
||||
abstract fun sayHello()
|
||||
companion object {
|
||||
const val G: Double
|
||||
}
|
||||
}
|
||||
enum class PseudoInsn {
|
||||
FIX_STACK_BEFORE_JUMP,
|
||||
FAKE_ALWAYS_TRUE_IFEQ,
|
||||
FAKE_ALWAYS_FALSE_IFEQ,
|
||||
SAVE_STACK_BEFORE_TRY,
|
||||
RESTORE_STACK_IN_TRY_CATCH,
|
||||
STORE_NOT_NULL,
|
||||
AS_NOT_NULL,
|
||||
constructor(signature: String = ...)
|
||||
val signature: String
|
||||
fun emit()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
interface Some
|
||||
object O1 : Some
|
||||
object O2 : Some
|
||||
enum class SomeEnum {
|
||||
FIRST,
|
||||
SECOND,
|
||||
constructor(x: Some)
|
||||
val x: Some
|
||||
abstract fun check(y: Some): Boolean
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
expect class MyClass
|
||||
expect fun foo(): String
|
||||
expect val x: Int
|
||||
actual class MyClass
|
||||
actual fun foo(): String
|
||||
actual val x: Int
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun <T> simpleRun(f: (T) -> Unit)
|
||||
fun <T, R> List<T>.simpleMap(f: (T) -> R): R
|
||||
fun <T> simpleWith(t: T, f: T.() -> Unit)
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
interface Any
|
||||
inline fun <reified T : Any> Any.safeAs(): T?
|
||||
abstract class Summator {
|
||||
abstract fun <T> plus(first: T, second: T): T
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun <T> genericFoo(): T
|
||||
val <T> T.generic: T
|
||||
get()
|
||||
+1
@@ -0,0 +1 @@
|
||||
private fun foo(x: Any): Any?
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
abstract class Base {
|
||||
constructor(s: String)
|
||||
val s: String
|
||||
}
|
||||
class Outer {
|
||||
class Derived : Base {
|
||||
constructor(s: String)
|
||||
}
|
||||
object Obj : Base
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
class NoPrimary {
|
||||
val x: String
|
||||
constructor(x: String)
|
||||
constructor()
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface SomeInterface {
|
||||
fun foo(x: Int, y: String): String
|
||||
val bar: Boolean
|
||||
}
|
||||
class SomeClass : SomeInterface {
|
||||
private val baz: Int
|
||||
override fun foo(x: Int, y: String): String
|
||||
override var bar: Boolean
|
||||
get()
|
||||
set(value: Boolean)
|
||||
lateinit var fau: Double
|
||||
}
|
||||
inline class InlineClass
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
fun foo()
|
||||
suspend fun bar()
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
interface B
|
||||
typealias C = B
|
||||
class D : C
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
open class A
|
||||
interface B<S, T : A>
|
||||
typealias C<T> = B<T, A>
|
||||
class D : C<A>
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
interface Some
|
||||
abstract class My<T : Some> {
|
||||
open inner class T
|
||||
abstract val x: My<T>.T
|
||||
abstract fun foo(arg: My<T>.T)
|
||||
abstract val y: My<Some>.T
|
||||
abstract val z: My<Some>.T
|
||||
abstract class Some : My<Some>.T
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface List<out T : Any> {
|
||||
operator fun get(index: Int): T
|
||||
infix fun concat(other: List<T>): List<T>
|
||||
}
|
||||
typealias StringList = List<out String>
|
||||
typealias AnyList = List<*>
|
||||
abstract class AbstractList<out T : Any> : List<T>
|
||||
class SomeList : AbstractList<Int> {
|
||||
override operator fun get(index: Int): Int
|
||||
override infix fun concat(other: List<Int>): List<Int>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
@Target(allowedTargets = NOT_CONST_EXPRESSION) annotation class base
|
||||
fun foo1(vararg ints: Int)
|
||||
fun foo2(@base vararg ints: @base Int)
|
||||
@@ -0,0 +1,3 @@
|
||||
interface A
|
||||
interface B
|
||||
class C<T : A> where T : B
|
||||
Vendored
-2
@@ -1,3 +1 @@
|
||||
fun foo(): String = a<caret>v
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
idea/idea-frontend-fir/testData/components/expectedExpressionType/functionExpressionBodyQualified.kt
Vendored
-1
@@ -1,3 +1,2 @@
|
||||
fun foo(): String = x.a<caret>v
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
-1
@@ -2,4 +2,3 @@ val av = "foo"
|
||||
|
||||
fun foo() = a<caret>v
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
-1
@@ -1,3 +1,2 @@
|
||||
fun foo() = a<caret>v
|
||||
|
||||
// EXPECTED_TYPE: null
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: null
|
||||
-1
@@ -4,4 +4,3 @@ fun x() {
|
||||
|
||||
fun toCall(x: Int, y: String, lambda: (Int) -> String): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/Function1<kotlin/Int, kotlin/String>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/Function1<kotlin/Int, kotlin/String>
|
||||
-1
@@ -6,4 +6,3 @@ fun x() {
|
||||
|
||||
fun toCall(x: Int, y: String, z: Boolean): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/Boolean
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: null
|
||||
Vendored
-1
@@ -6,4 +6,3 @@ fun x() {
|
||||
|
||||
fun <T> toCall(x: T, y: T): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/Int
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
expression: ab
|
||||
expected type: T
|
||||
Vendored
-1
@@ -4,4 +4,3 @@ fun x() {
|
||||
|
||||
fun toCall(x: Int, y: String, z: Boolean): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
-1
@@ -4,4 +4,3 @@ fun x() {
|
||||
|
||||
fun toCall(x: Int, y: String, z: Boolean): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
-1
@@ -2,4 +2,3 @@ fun x() {
|
||||
if(x<caret>y){
|
||||
}
|
||||
|
||||
// EXPECTED_TYPE: kotlin/Boolean
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: xy
|
||||
expected type: kotlin/Boolean
|
||||
-1
@@ -2,4 +2,3 @@ fun x() {
|
||||
if(x.fd<caret>fd){
|
||||
}
|
||||
|
||||
// EXPECTED_TYPE: kotlin/Boolean
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: fdfd
|
||||
expected type: kotlin/Boolean
|
||||
idea/idea-frontend-fir/testData/components/expectedExpressionType/infixFunctionAsRegularCallParam.kt
Vendored
-1
@@ -4,4 +4,3 @@ fun x() {
|
||||
|
||||
infix fun Int.toCall(y: String): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
-1
@@ -4,4 +4,3 @@ fun x() {
|
||||
|
||||
infix fun Int.toCall(y: String): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
Vendored
-1
@@ -4,4 +4,3 @@ fun x() {
|
||||
|
||||
infix fun Int.toCall(y: String): Char = 'a'
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
-1
@@ -2,4 +2,3 @@ class C {
|
||||
var y: String = a<caret>v
|
||||
}
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: kotlin/String
|
||||
Vendored
-1
@@ -2,4 +2,3 @@ class C {
|
||||
var y: String = x.a<caret>v
|
||||
}
|
||||
|
||||
// EXPECTED_TYPE: kotlin/String
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user