[FIR IDE] Add OnAir resolve tests
This commit is contained in:
committed by
TeamCityServer
parent
633e03b710
commit
0569f810cf
@@ -1075,6 +1075,9 @@ fun main(args: Array<String>) {
|
||||
testClass<AbstractFirSealedInheritorsTest> {
|
||||
model("resolveSealed", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractFirOnAirResolveTest> {
|
||||
model("onAirResolve")
|
||||
}
|
||||
testClass<AbstractFirLazyDeclarationResolveTest> {
|
||||
model("lazyResolve")
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class X<T> {
|
||||
class Y<K>
|
||||
open class BASE
|
||||
/*PLACE*/class PLACE
|
||||
}
|
||||
|
||||
/*ONAIR*/inner class ONAIR : BASE() {
|
||||
fun x() = Y<T>()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public final inner [BODY_RESOLVE] class ONAIR<T> : R|X.BASE| {
|
||||
public [BODY_RESOLVE] constructor(): R|X.ONAIR<T>| {
|
||||
super<R|X.BASE|>()
|
||||
}
|
||||
|
||||
public final [BODY_RESOLVE] fun x(): R|X.Y<T>| {
|
||||
^x R|SubstitutionOverride</X.Y.Y>|<R|T|>()
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
fun xxx() {
|
||||
val f = 2
|
||||
val g = "x"
|
||||
/*PLACE*/val x = g
|
||||
}
|
||||
|
||||
fun x() {
|
||||
/*ONAIR*/val y = f
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
[BODY_RESOLVE] lval y: R|kotlin/Int| = R|<local>/f|
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class X {
|
||||
class Y
|
||||
fun x(/*PLACE*/x: Int) {}
|
||||
}
|
||||
|
||||
fun y(/*ONAIR*/y: Y) {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
[BODY_RESOLVE] y: R|X.Y|
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
class B
|
||||
}
|
||||
|
||||
val a: /*PLACE*/A.B.C
|
||||
|
||||
val b: /*ONAIR*/A.B
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
public final [BODY_RESOLVE] val b: R|A.B|
|
||||
[BODY_RESOLVE] public get(): R|A.B|
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun xxx() {
|
||||
val x = 2
|
||||
/*PLACE*/class C
|
||||
}
|
||||
|
||||
|
||||
/*ONAIR*/class E {
|
||||
fun e() = x
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public? final? [BODY_RESOLVE] class E : R|kotlin/Any| {
|
||||
public? [BODY_RESOLVE] constructor(): R|E| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public? final? [BODY_RESOLVE] fun e(): R|kotlin/Int| {
|
||||
^e R|<local>/x|
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun xxx() {
|
||||
val x = 3
|
||||
/*PLACE*/fun lcl() = ""
|
||||
}
|
||||
|
||||
/*ONAIR*/fun x() = x
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
local final [BODY_RESOLVE] fun x(): R|kotlin/Int| {
|
||||
^x R|<local>/x|
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class X
|
||||
fun f(): X {
|
||||
var x = 3
|
||||
val y = 4
|
||||
/*PLACE*/while(true) {}
|
||||
}
|
||||
|
||||
fun g(): X {
|
||||
/*ONAIR*/while (x < 2) {
|
||||
x--
|
||||
val z = y
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
while(CMP(<, R|<local>/x|.R|kotlin/Int.compareTo|(Int(2)))) {
|
||||
[BODY_RESOLVE] lval <unary>: R|kotlin/Int| = R|<local>/x|
|
||||
R|<local>/x| = R|<local>/<unary>|.R|kotlin/Int.dec|()
|
||||
R|<local>/<unary>|
|
||||
[BODY_RESOLVE] lval z: R|kotlin/Int| = R|<local>/y|
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Cls<T, K> {
|
||||
/*PLACE*/fun member<T>(x: Int) = 2
|
||||
}
|
||||
|
||||
/*ONAIR*/fun niewbe<K>(a: Char, b: Double) = "Trololo"
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public final [BODY_RESOLVE] fun <K> niewbe([BODY_RESOLVE] a: R|kotlin/Char|, [BODY_RESOLVE] b: R|kotlin/Double|): R|kotlin/String| {
|
||||
^niewbe String(Trololo)
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
class Cls {
|
||||
/*PLACE*/val memberProperty = 2
|
||||
}
|
||||
|
||||
/*ONAIR*/val niewbe = "Hello"
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
public final [BODY_RESOLVE] val niewbe: R|kotlin/String| = String(Hello)
|
||||
[BODY_RESOLVE] public get(): R|kotlin/String|
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface Base {
|
||||
fun baseMember(): Int
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
/*PLACE*/fun someMember() = "Hello"
|
||||
}
|
||||
|
||||
/*ONAIR*/override fun baseMember() = 3
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public final override [BODY_RESOLVE] fun baseMember(): R|kotlin/Int| {
|
||||
^baseMember Int(3)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
open class X {
|
||||
/*PLACE*/class PLACE
|
||||
}
|
||||
|
||||
/*ONAIR*/class Y {
|
||||
open class BASE : X()
|
||||
class DERIVED : BASE()
|
||||
fun withType(arg: BASE) { }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
public final [BODY_RESOLVE] class Y : R|kotlin/Any| {
|
||||
public [BODY_RESOLVE] constructor(): R|X.Y| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public? open [BODY_RESOLVE] class BASE : R|X| {
|
||||
public? [BODY_RESOLVE] constructor(): R|X.Y.BASE| {
|
||||
super<R|X|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public? final? [BODY_RESOLVE] class DERIVED : R|X.Y.BASE| {
|
||||
public? [BODY_RESOLVE] constructor(): R|X.Y.DERIVED| {
|
||||
super<R|X.Y.BASE|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final [BODY_RESOLVE] fun withType([BODY_RESOLVE] arg: R|X.Y.BASE|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class C<T> {
|
||||
fun x(/*PLACE*/a: Int) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun y(/*ONAIR*/b: T) {
|
||||
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
[BODY_RESOLVE] b: R|T|
|
||||
idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInsidePropertyBody.kt
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
|
||||
val x: Int get() {
|
||||
val qqq = "Hello"
|
||||
/*PLACE*/val x = 42
|
||||
2
|
||||
}
|
||||
|
||||
/*ONAIR*/val z = qqq
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public? final? [BODY_RESOLVE] val z: R|kotlin/String| = R|<local>/qqq|
|
||||
[BODY_RESOLVE] public? get(): R|kotlin/String|
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
var x = 2
|
||||
set(value) {
|
||||
/*PLACE*/val inside = ""
|
||||
}
|
||||
|
||||
/*ONAIR*/val inSetter = value
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public? final? [BODY_RESOLVE] val inSetter: R|kotlin/Int| = R|<local>/value|
|
||||
[BODY_RESOLVE] public? get(): R|kotlin/Int|
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*PLACE*/fun place(): Int {
|
||||
fun xxx() = 2
|
||||
}
|
||||
|
||||
|
||||
/*ONAIR*/fun onAir(): Int {
|
||||
fun yyy() = "hello"
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
public final [BODY_RESOLVE] fun onAir(): R|kotlin/Int| {
|
||||
local final [BODY_RESOLVE] fun yyy(): R|kotlin/String| {
|
||||
^yyy String(hello)
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
|
||||
class X<T, K> {
|
||||
/*PLACE*/private typealias A = List<T>
|
||||
}
|
||||
|
||||
class Y {
|
||||
/*ONAIR*/public typealias B = Set<K>
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
public final [BODY_RESOLVE] typealias B = R|kotlin/collections/Set<K>|
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.low.level.api
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.LowLevelFirApiFacadeForResolveOnAir
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.util.findElementByCommentPrefix
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFirOnAirResolveTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun isFirPlugin(): Boolean = true
|
||||
|
||||
fun doTest(path: String) {
|
||||
val testDataFile = File(path)
|
||||
val ktFile = myFixture.configureByText(testDataFile.name, FileUtil.loadFile(testDataFile)) as KtFile
|
||||
|
||||
val place = ktFile.findElementByCommentPrefix("/*PLACE*/") as KtElement
|
||||
val onAir = ktFile.findElementByCommentPrefix("/*ONAIR*/") as KtElement
|
||||
|
||||
check(place::class == onAir::class)
|
||||
|
||||
resolveWithClearCaches(ktFile) { firModuleResolveState ->
|
||||
check(firModuleResolveState is FirModuleResolveStateImpl)
|
||||
val firElement = LowLevelFirApiFacadeForResolveOnAir.onAirResolveElement(firModuleResolveState, place, onAir)
|
||||
val rendered = firElement.render(FirRenderer.RenderMode.WithResolvePhases)
|
||||
val expectedFileName = testDataFile.name.replace(".kt", ".txt")
|
||||
KotlinTestUtils.assertEqualsToFile(testDataFile.parentFile.resolve(expectedFileName), rendered)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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.low.level.api;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class FirOnAirResolveTestGenerated extends AbstractFirOnAirResolveTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("classInClass.kt")
|
||||
public void testClassInClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/classInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("identifierInContext.kt")
|
||||
public void testIdentifierInContext() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/identifierInContext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inParameter.kt")
|
||||
public void testInParameter() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/inParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("incompleteIdentifier.kt")
|
||||
public void testIncompleteIdentifier() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/incompleteIdentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localClass.kt")
|
||||
public void testLocalClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/localClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/localFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("loopConstruction.kt")
|
||||
public void testLoopConstruction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/loopConstruction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberInClass.kt")
|
||||
public void testMemberInClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/memberInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberPropertyInClass.kt")
|
||||
public void testMemberPropertyInClass() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/memberPropertyInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberWithOverride.kt")
|
||||
public void testMemberWithOverride() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/memberWithOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("onAirTypesResolve.kt")
|
||||
public void testOnAirTypesResolve() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/onAirTypesResolve.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replacementInHeader.kt")
|
||||
public void testReplacementInHeader() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInHeader.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replacementInsidePropertyBody.kt")
|
||||
public void testReplacementInsidePropertyBody() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInsidePropertyBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replacementInsidePropertyBody2.kt")
|
||||
public void testReplacementInsidePropertyBody2() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/replacementInsidePropertyBody2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeAlias.kt")
|
||||
public void testTypeAlias() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/idea-fir-low-level-api/testdata/onAirResolve/typeAlias.kt");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user