[FIR] Reorganize modules of raw fir builders
This commit is contained in:
+7
-6
@@ -256,8 +256,9 @@ extra["compilerModules"] = arrayOf(
|
|||||||
":compiler:fir:cones",
|
":compiler:fir:cones",
|
||||||
":compiler:fir:resolve",
|
":compiler:fir:resolve",
|
||||||
":compiler:fir:tree",
|
":compiler:fir:tree",
|
||||||
":compiler:fir:psi2fir",
|
":compiler:fir:raw-fir:common",
|
||||||
":compiler:fir:lightTree",
|
":compiler:fir:raw-fir:psi2fir",
|
||||||
|
":compiler:fir:raw-fir:light-tree2fir",
|
||||||
":compiler:fir:fir2ir",
|
":compiler:fir:fir2ir",
|
||||||
":compiler:fir:fir2ir:jvm-backend",
|
":compiler:fir:fir2ir:jvm-backend",
|
||||||
":compiler:fir:java",
|
":compiler:fir:java",
|
||||||
@@ -554,16 +555,16 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
register("firCompilerTest") {
|
register("firCompilerTest") {
|
||||||
dependsOn(":compiler:fir:psi2fir:test")
|
dependsOn(":compiler:fir:raw-fir:psi2fir:test")
|
||||||
|
dependsOn(":compiler:fir:raw-fir:light-tree2fir:test")
|
||||||
dependsOn(":compiler:fir:analysis-tests:test")
|
dependsOn(":compiler:fir:analysis-tests:test")
|
||||||
dependsOn(":compiler:fir:fir2ir:test")
|
dependsOn(":compiler:fir:fir2ir:test")
|
||||||
dependsOn(":compiler:fir:lightTree:test")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
register("firAllTest") {
|
register("firAllTest") {
|
||||||
dependsOn(
|
dependsOn(
|
||||||
":compiler:fir:psi2fir:test",
|
":compiler:fir:raw-fir:psi2fir:test",
|
||||||
":compiler:fir:lightTree:test",
|
":compiler:fir:raw-fir:light-tree2fir:test",
|
||||||
":compiler:fir:analysis-tests:test",
|
":compiler:fir:analysis-tests:test",
|
||||||
":compiler:fir:fir2ir:test",
|
":compiler:fir:fir2ir:test",
|
||||||
":idea:idea-fir:test"
|
":idea:idea-fir:test"
|
||||||
|
|||||||
@@ -45,11 +45,10 @@ dependencies {
|
|||||||
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
|
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
|
||||||
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
|
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
|
||||||
testCompile(projectTests(":compiler:tests-common"))
|
testCompile(projectTests(":compiler:tests-common"))
|
||||||
testCompile(projectTests(":compiler:fir:psi2fir"))
|
testCompile(projectTests(":compiler:fir:raw-fir:psi2fir"))
|
||||||
|
testCompile(projectTests(":compiler:fir:raw-fir:light-tree2fir"))
|
||||||
testCompile(projectTests(":compiler:fir:fir2ir"))
|
testCompile(projectTests(":compiler:fir:fir2ir"))
|
||||||
testCompile(projectTests(":compiler:fir:analysis-tests"))
|
testCompile(projectTests(":compiler:fir:analysis-tests"))
|
||||||
testCompile(projectTests(":compiler:fir:analysis-tests"))
|
|
||||||
testCompile(projectTests(":compiler:fir:lightTree"))
|
|
||||||
testCompile(projectTests(":compiler:visualizer"))
|
testCompile(projectTests(":compiler:visualizer"))
|
||||||
testCompile(projectTests(":generators:test-generator"))
|
testCompile(projectTests(":generators:test-generator"))
|
||||||
testCompile(project(":compiler:ir.ir2cfg"))
|
testCompile(project(":compiler:ir.ir2cfg"))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ dependencies {
|
|||||||
compile(project(":native:frontend.native"))
|
compile(project(":native:frontend.native"))
|
||||||
compile(commonDep("org.fusesource.jansi", "jansi"))
|
compile(commonDep("org.fusesource.jansi", "jansi"))
|
||||||
compile(commonDep("org.jline", "jline"))
|
compile(commonDep("org.jline", "jline"))
|
||||||
compile(project(":compiler:fir:psi2fir"))
|
compile(project(":compiler:fir:raw-fir:psi2fir"))
|
||||||
compile(project(":compiler:fir:resolve"))
|
compile(project(":compiler:fir:resolve"))
|
||||||
compile(project(":compiler:fir:jvm"))
|
compile(project(":compiler:fir:jvm"))
|
||||||
compile(project(":compiler:fir:java"))
|
compile(project(":compiler:fir:java"))
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2018 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("jps-compatible")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile(project(":compiler:psi"))
|
||||||
|
compile(project(":core:descriptors"))
|
||||||
|
compile(project(":compiler:fir:tree"))
|
||||||
|
|
||||||
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
||||||
|
|
||||||
|
Platform[192].orHigher {
|
||||||
|
testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
testRuntimeOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
"main" { projectDefault() }
|
||||||
|
"test" { none() }
|
||||||
|
}
|
||||||
|
|
||||||
|
projectTest(parallel = true) {
|
||||||
|
workingDir = rootDir
|
||||||
|
}
|
||||||
+1
-101
@@ -17,8 +17,6 @@ import org.jetbrains.kotlin.fir.declarations.builder.buildPropertyAccessor
|
|||||||
import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
|
import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.builder.*
|
import org.jetbrains.kotlin.fir.expressions.builder.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock
|
||||||
@@ -42,7 +40,6 @@ import org.jetbrains.kotlin.fir.types.impl.FirImplicitKPropertyTypeRef
|
|||||||
import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirQualifierPartImpl
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
@@ -195,68 +192,6 @@ fun FirExpression.generateLazyLogicalOperation(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun KtWhenCondition.toFirWhenCondition(
|
|
||||||
subject: FirWhenSubject,
|
|
||||||
convert: KtExpression?.(String) -> FirExpression,
|
|
||||||
toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef,
|
|
||||||
): FirExpression {
|
|
||||||
val baseSource = this.toFirSourceElement()
|
|
||||||
val firSubjectExpression = buildWhenSubjectExpression {
|
|
||||||
source = baseSource
|
|
||||||
whenSubject = subject
|
|
||||||
}
|
|
||||||
return when (this) {
|
|
||||||
is KtWhenConditionWithExpression -> {
|
|
||||||
buildOperatorCall {
|
|
||||||
source = expression?.toFirSourceElement()
|
|
||||||
operation = FirOperation.EQ
|
|
||||||
argumentList = buildBinaryArgumentList(
|
|
||||||
firSubjectExpression, expression.convert("No expression in condition with expression")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is KtWhenConditionInRange -> {
|
|
||||||
val firRange = rangeExpression.convert("No range in condition with range")
|
|
||||||
firRange.generateContainsOperation(
|
|
||||||
firSubjectExpression,
|
|
||||||
isNegated,
|
|
||||||
rangeExpression?.toFirSourceElement(),
|
|
||||||
operationReference.toFirSourceElement()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
is KtWhenConditionIsPattern -> {
|
|
||||||
buildTypeOperatorCall {
|
|
||||||
source = typeReference?.toFirSourceElement()
|
|
||||||
operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS
|
|
||||||
conversionTypeRef = typeReference.toFirOrErrorTypeRef()
|
|
||||||
argumentList = buildUnaryArgumentList(firSubjectExpression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
buildErrorExpression(baseSource, ConeSimpleDiagnostic("Unsupported when condition: ${this.javaClass}", DiagnosticKind.Syntax))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun Array<KtWhenCondition>.toFirWhenCondition(
|
|
||||||
baseSource: FirSourceElement?,
|
|
||||||
subject: FirWhenSubject,
|
|
||||||
convert: KtExpression?.(String) -> FirExpression,
|
|
||||||
toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef,
|
|
||||||
): FirExpression {
|
|
||||||
var firCondition: FirExpression? = null
|
|
||||||
for (condition in this) {
|
|
||||||
val firConditionElement = condition.toFirWhenCondition(subject, convert, toFirOrErrorTypeRef)
|
|
||||||
firCondition = when (firCondition) {
|
|
||||||
null -> firConditionElement
|
|
||||||
else -> firCondition.generateLazyLogicalOperation(
|
|
||||||
firConditionElement, false, baseSource,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return firCondition!!
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FirExpression.generateContainsOperation(
|
fun FirExpression.generateContainsOperation(
|
||||||
argument: FirExpression,
|
argument: FirExpression,
|
||||||
inverted: Boolean,
|
inverted: Boolean,
|
||||||
@@ -339,42 +274,7 @@ fun generateResolvedAccessExpression(source: FirSourceElement?, variable: FirVar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun generateDestructuringBlock(
|
|
||||||
session: FirSession,
|
|
||||||
multiDeclaration: KtDestructuringDeclaration,
|
|
||||||
container: FirVariable<*>,
|
|
||||||
tmpVariable: Boolean,
|
|
||||||
extractAnnotationsTo: KtAnnotated.(FirAnnotationContainerBuilder) -> Unit,
|
|
||||||
toFirOrImplicitTypeRef: KtTypeReference?.() -> FirTypeRef,
|
|
||||||
): FirExpression {
|
|
||||||
return buildBlock {
|
|
||||||
source = multiDeclaration.toFirSourceElement()
|
|
||||||
if (tmpVariable) {
|
|
||||||
statements += container
|
|
||||||
}
|
|
||||||
val isVar = multiDeclaration.isVar
|
|
||||||
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
|
||||||
val entrySource = entry.toFirSourceElement()
|
|
||||||
val name = entry.nameAsSafeName
|
|
||||||
statements += buildProperty {
|
|
||||||
source = entrySource
|
|
||||||
this.session = session
|
|
||||||
returnTypeRef = entry.typeReference.toFirOrImplicitTypeRef()
|
|
||||||
this.name = name
|
|
||||||
initializer = buildComponentCall {
|
|
||||||
source = entrySource
|
|
||||||
explicitReceiver = generateResolvedAccessExpression(entrySource, container)
|
|
||||||
componentIndex = index + 1
|
|
||||||
}
|
|
||||||
this.isVar = isVar
|
|
||||||
isLocal = true
|
|
||||||
status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
|
||||||
symbol = FirPropertySymbol(name)
|
|
||||||
entry.extractAnnotationsTo(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun generateTemporaryVariable(
|
fun generateTemporaryVariable(
|
||||||
session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null,
|
session: FirSession, source: FirSourceElement?, name: Name, initializer: FirExpression, typeRef: FirTypeRef? = null,
|
||||||
+2
-4
@@ -15,9 +15,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:psi"))
|
compile(project(":compiler:fir:raw-fir:common"))
|
||||||
compile(project(":compiler:fir:tree"))
|
|
||||||
compile(project(":compiler:fir:psi2fir"))
|
|
||||||
|
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
||||||
|
|
||||||
@@ -27,7 +25,7 @@ dependencies {
|
|||||||
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
|
testCompileOnly(project(":kotlin-test:kotlin-test-jvm"))
|
||||||
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
|
testCompileOnly(project(":kotlin-test:kotlin-test-junit"))
|
||||||
testCompile(projectTests(":compiler:tests-common"))
|
testCompile(projectTests(":compiler:tests-common"))
|
||||||
testCompile(projectTests(":compiler:fir:psi2fir"))
|
testCompile(projectTests(":compiler:fir:raw-fir:psi2fir"))
|
||||||
|
|
||||||
testCompileOnly(project(":kotlin-reflect-api"))
|
testCompileOnly(project(":kotlin-reflect-api"))
|
||||||
testRuntime(project(":kotlin-reflect"))
|
testRuntime(project(":kotlin-reflect"))
|
||||||
+57
-57
@@ -16,7 +16,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("compiler/fir/psi2fir/testData/rawBuilder")
|
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2FirConverterTestCase {
|
public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2FirConverterTestCase {
|
||||||
@@ -25,10 +25,10 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInRawBuilder() throws Exception {
|
public void testAllFilesPresentInRawBuilder() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/fir/psi2fir/testData/rawBuilder/declarations")
|
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Declarations extends AbstractLightTree2FirConverterTestCase {
|
public static class Declarations extends AbstractLightTree2FirConverterTestCase {
|
||||||
@@ -37,121 +37,121 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
public void testAllFilesPresentInDeclarations() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("annotation.kt")
|
@TestMetadata("annotation.kt")
|
||||||
public void testAnnotation() throws Exception {
|
public void testAnnotation() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/annotation.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("complexTypes.kt")
|
@TestMetadata("complexTypes.kt")
|
||||||
public void testComplexTypes() throws Exception {
|
public void testComplexTypes() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("constructorInObject.kt")
|
@TestMetadata("constructorInObject.kt")
|
||||||
public void testConstructorInObject() throws Exception {
|
public void testConstructorInObject() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("derivedClass.kt")
|
@TestMetadata("derivedClass.kt")
|
||||||
public void testDerivedClass() throws Exception {
|
public void testDerivedClass() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("enums.kt")
|
@TestMetadata("enums.kt")
|
||||||
public void testEnums() throws Exception {
|
public void testEnums() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("enums2.kt")
|
@TestMetadata("enums2.kt")
|
||||||
public void testEnums2() throws Exception {
|
public void testEnums2() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/enums2.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("expectActual.kt")
|
@TestMetadata("expectActual.kt")
|
||||||
public void testExpectActual() throws Exception {
|
public void testExpectActual() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("F.kt")
|
@TestMetadata("F.kt")
|
||||||
public void testF() throws Exception {
|
public void testF() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/F.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/F.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("functionTypes.kt")
|
@TestMetadata("functionTypes.kt")
|
||||||
public void testFunctionTypes() throws Exception {
|
public void testFunctionTypes() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("genericFunctions.kt")
|
@TestMetadata("genericFunctions.kt")
|
||||||
public void testGenericFunctions() throws Exception {
|
public void testGenericFunctions() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("genericProperty.kt")
|
@TestMetadata("genericProperty.kt")
|
||||||
public void testGenericProperty() throws Exception {
|
public void testGenericProperty() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("nestedClass.kt")
|
@TestMetadata("nestedClass.kt")
|
||||||
public void testNestedClass() throws Exception {
|
public void testNestedClass() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("NestedOfAliasedType.kt")
|
@TestMetadata("NestedOfAliasedType.kt")
|
||||||
public void testNestedOfAliasedType() throws Exception {
|
public void testNestedOfAliasedType() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("NestedSuperType.kt")
|
@TestMetadata("NestedSuperType.kt")
|
||||||
public void testNestedSuperType() throws Exception {
|
public void testNestedSuperType() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("noPrimaryConstructor.kt")
|
@TestMetadata("noPrimaryConstructor.kt")
|
||||||
public void testNoPrimaryConstructor() throws Exception {
|
public void testNoPrimaryConstructor() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleClass.kt")
|
@TestMetadata("simpleClass.kt")
|
||||||
public void testSimpleClass() throws Exception {
|
public void testSimpleClass() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleFun.kt")
|
@TestMetadata("simpleFun.kt")
|
||||||
public void testSimpleFun() throws Exception {
|
public void testSimpleFun() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleTypeAlias.kt")
|
@TestMetadata("simpleTypeAlias.kt")
|
||||||
public void testSimpleTypeAlias() throws Exception {
|
public void testSimpleTypeAlias() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("typeAliasWithGeneric.kt")
|
@TestMetadata("typeAliasWithGeneric.kt")
|
||||||
public void testTypeAliasWithGeneric() throws Exception {
|
public void testTypeAliasWithGeneric() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("typeParameterVsNested.kt")
|
@TestMetadata("typeParameterVsNested.kt")
|
||||||
public void testTypeParameterVsNested() throws Exception {
|
public void testTypeParameterVsNested() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("typeParameters.kt")
|
@TestMetadata("typeParameters.kt")
|
||||||
public void testTypeParameters() throws Exception {
|
public void testTypeParameters() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("where.kt")
|
@TestMetadata("where.kt")
|
||||||
public void testWhere() throws Exception {
|
public void testWhere() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/declarations/where.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/fir/psi2fir/testData/rawBuilder/expressions")
|
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Expressions extends AbstractLightTree2FirConverterTestCase {
|
public static class Expressions extends AbstractLightTree2FirConverterTestCase {
|
||||||
@@ -160,152 +160,152 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInExpressions() throws Exception {
|
public void testAllFilesPresentInExpressions() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("annotated.kt")
|
@TestMetadata("annotated.kt")
|
||||||
public void testAnnotated() throws Exception {
|
public void testAnnotated() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("arrayAccess.kt")
|
@TestMetadata("arrayAccess.kt")
|
||||||
public void testArrayAccess() throws Exception {
|
public void testArrayAccess() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("arrayAssignment.kt")
|
@TestMetadata("arrayAssignment.kt")
|
||||||
public void testArrayAssignment() throws Exception {
|
public void testArrayAssignment() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("branches.kt")
|
@TestMetadata("branches.kt")
|
||||||
public void testBranches() throws Exception {
|
public void testBranches() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/branches.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/branches.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("callableReferences.kt")
|
@TestMetadata("callableReferences.kt")
|
||||||
public void testCallableReferences() throws Exception {
|
public void testCallableReferences() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("calls.kt")
|
@TestMetadata("calls.kt")
|
||||||
public void testCalls() throws Exception {
|
public void testCalls() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/calls.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("classReference.kt")
|
@TestMetadata("classReference.kt")
|
||||||
public void testClassReference() throws Exception {
|
public void testClassReference() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/classReference.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/classReference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("collectionLiterals.kt")
|
@TestMetadata("collectionLiterals.kt")
|
||||||
public void testCollectionLiterals() throws Exception {
|
public void testCollectionLiterals() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("destructuring.kt")
|
@TestMetadata("destructuring.kt")
|
||||||
public void testDestructuring() throws Exception {
|
public void testDestructuring() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("for.kt")
|
@TestMetadata("for.kt")
|
||||||
public void testFor() throws Exception {
|
public void testFor() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/for.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("genericCalls.kt")
|
@TestMetadata("genericCalls.kt")
|
||||||
public void testGenericCalls() throws Exception {
|
public void testGenericCalls() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("in.kt")
|
@TestMetadata("in.kt")
|
||||||
public void testIn() throws Exception {
|
public void testIn() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/in.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/in.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("inBrackets.kt")
|
@TestMetadata("inBrackets.kt")
|
||||||
public void testInBrackets() throws Exception {
|
public void testInBrackets() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("init.kt")
|
@TestMetadata("init.kt")
|
||||||
public void testInit() throws Exception {
|
public void testInit() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/init.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/init.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("lambda.kt")
|
@TestMetadata("lambda.kt")
|
||||||
public void testLambda() throws Exception {
|
public void testLambda() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaAndAnonymousFunction.kt")
|
@TestMetadata("lambdaAndAnonymousFunction.kt")
|
||||||
public void testLambdaAndAnonymousFunction() throws Exception {
|
public void testLambdaAndAnonymousFunction() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("locals.kt")
|
@TestMetadata("locals.kt")
|
||||||
public void testLocals() throws Exception {
|
public void testLocals() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/locals.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("modifications.kt")
|
@TestMetadata("modifications.kt")
|
||||||
public void testModifications() throws Exception {
|
public void testModifications() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/modifications.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/modifications.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("namedArgument.kt")
|
@TestMetadata("namedArgument.kt")
|
||||||
public void testNamedArgument() throws Exception {
|
public void testNamedArgument() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("nullability.kt")
|
@TestMetadata("nullability.kt")
|
||||||
public void testNullability() throws Exception {
|
public void testNullability() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/nullability.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/nullability.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("qualifierWithTypeArguments.kt")
|
@TestMetadata("qualifierWithTypeArguments.kt")
|
||||||
public void testQualifierWithTypeArguments() throws Exception {
|
public void testQualifierWithTypeArguments() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleReturns.kt")
|
@TestMetadata("simpleReturns.kt")
|
||||||
public void testSimpleReturns() throws Exception {
|
public void testSimpleReturns() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("super.kt")
|
@TestMetadata("super.kt")
|
||||||
public void testSuper() throws Exception {
|
public void testSuper() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/super.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/super.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("these.kt")
|
@TestMetadata("these.kt")
|
||||||
public void testThese() throws Exception {
|
public void testThese() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/these.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/these.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("try.kt")
|
@TestMetadata("try.kt")
|
||||||
public void testTry() throws Exception {
|
public void testTry() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/try.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/try.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("typeOperators.kt")
|
@TestMetadata("typeOperators.kt")
|
||||||
public void testTypeOperators() throws Exception {
|
public void testTypeOperators() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("unary.kt")
|
@TestMetadata("unary.kt")
|
||||||
public void testUnary() throws Exception {
|
public void testUnary() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/unary.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("variables.kt")
|
@TestMetadata("variables.kt")
|
||||||
public void testVariables() throws Exception {
|
public void testVariables() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/variables.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/variables.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("while.kt")
|
@TestMetadata("while.kt")
|
||||||
public void testWhile() throws Exception {
|
public void testWhile() throws Exception {
|
||||||
runTest("compiler/fir/psi2fir/testData/rawBuilder/expressions/while.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-4
@@ -9,10 +9,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(":compiler:psi"))
|
compile(project(":compiler:fir:raw-fir:common"))
|
||||||
compile(project(":core:descriptors"))
|
|
||||||
compile(project(":compiler:fir:tree"))
|
|
||||||
compile(project(":compiler:ir.tree"))
|
|
||||||
|
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) }
|
||||||
|
|
||||||
+122
@@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* 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.fir.builder
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||||
|
import org.jetbrains.kotlin.fir.FirWhenSubject
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.builder.buildProperty
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||||
|
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||||
|
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.builder.*
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
|
import org.jetbrains.kotlin.fir.toFirSourceElement
|
||||||
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
|
||||||
|
internal fun KtWhenCondition.toFirWhenCondition(
|
||||||
|
subject: FirWhenSubject,
|
||||||
|
convert: KtExpression?.(String) -> FirExpression,
|
||||||
|
toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef,
|
||||||
|
): FirExpression {
|
||||||
|
val baseSource = this.toFirSourceElement()
|
||||||
|
val firSubjectExpression = buildWhenSubjectExpression {
|
||||||
|
source = baseSource
|
||||||
|
whenSubject = subject
|
||||||
|
}
|
||||||
|
return when (this) {
|
||||||
|
is KtWhenConditionWithExpression -> {
|
||||||
|
buildOperatorCall {
|
||||||
|
source = expression?.toFirSourceElement()
|
||||||
|
operation = FirOperation.EQ
|
||||||
|
argumentList = buildBinaryArgumentList(
|
||||||
|
firSubjectExpression, expression.convert("No expression in condition with expression")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is KtWhenConditionInRange -> {
|
||||||
|
val firRange = rangeExpression.convert("No range in condition with range")
|
||||||
|
firRange.generateContainsOperation(
|
||||||
|
firSubjectExpression,
|
||||||
|
isNegated,
|
||||||
|
rangeExpression?.toFirSourceElement(),
|
||||||
|
operationReference.toFirSourceElement()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
is KtWhenConditionIsPattern -> {
|
||||||
|
buildTypeOperatorCall {
|
||||||
|
source = typeReference?.toFirSourceElement()
|
||||||
|
operation = if (isNegated) FirOperation.NOT_IS else FirOperation.IS
|
||||||
|
conversionTypeRef = typeReference.toFirOrErrorTypeRef()
|
||||||
|
argumentList = buildUnaryArgumentList(firSubjectExpression)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
buildErrorExpression(baseSource, ConeSimpleDiagnostic("Unsupported when condition: ${this.javaClass}", DiagnosticKind.Syntax))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Array<KtWhenCondition>.toFirWhenCondition(
|
||||||
|
baseSource: FirSourceElement?,
|
||||||
|
subject: FirWhenSubject,
|
||||||
|
convert: KtExpression?.(String) -> FirExpression,
|
||||||
|
toFirOrErrorTypeRef: KtTypeReference?.() -> FirTypeRef,
|
||||||
|
): FirExpression {
|
||||||
|
var firCondition: FirExpression? = null
|
||||||
|
for (condition in this) {
|
||||||
|
val firConditionElement = condition.toFirWhenCondition(subject, convert, toFirOrErrorTypeRef)
|
||||||
|
firCondition = when (firCondition) {
|
||||||
|
null -> firConditionElement
|
||||||
|
else -> firCondition.generateLazyLogicalOperation(
|
||||||
|
firConditionElement, false, baseSource,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return firCondition!!
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun generateDestructuringBlock(
|
||||||
|
session: FirSession,
|
||||||
|
multiDeclaration: KtDestructuringDeclaration,
|
||||||
|
container: FirVariable<*>,
|
||||||
|
tmpVariable: Boolean,
|
||||||
|
extractAnnotationsTo: KtAnnotated.(FirAnnotationContainerBuilder) -> Unit,
|
||||||
|
toFirOrImplicitTypeRef: KtTypeReference?.() -> FirTypeRef,
|
||||||
|
): FirExpression {
|
||||||
|
return buildBlock {
|
||||||
|
source = multiDeclaration.toFirSourceElement()
|
||||||
|
if (tmpVariable) {
|
||||||
|
statements += container
|
||||||
|
}
|
||||||
|
val isVar = multiDeclaration.isVar
|
||||||
|
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
||||||
|
val entrySource = entry.toFirSourceElement()
|
||||||
|
val name = entry.nameAsSafeName
|
||||||
|
statements += buildProperty {
|
||||||
|
source = entrySource
|
||||||
|
this.session = session
|
||||||
|
returnTypeRef = entry.typeReference.toFirOrImplicitTypeRef()
|
||||||
|
this.name = name
|
||||||
|
initializer = buildComponentCall {
|
||||||
|
source = entrySource
|
||||||
|
explicitReceiver = generateResolvedAccessExpression(entrySource, container)
|
||||||
|
componentIndex = index + 1
|
||||||
|
}
|
||||||
|
this.isVar = isVar
|
||||||
|
isLocal = true
|
||||||
|
status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||||
|
symbol = FirPropertySymbol(name)
|
||||||
|
entry.extractAnnotationsTo(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user