From 08727bf0be9a9e21eb6e21f53fcce0604b9a5210 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 11 Jan 2024 17:34:34 +0900 Subject: [PATCH] [Analysis API] Add more ContextCollector tests inspired by dependentCopy As the on-air analysis is obsolete, related tests are going to be deleted. Here we add cases not yet covered by 'ContextCollector' tests. --- .../superTypeDelegatedToCompanion.copy.txt | 42 +++++++++ .../superTypeDelegatedToCompanion.kt | 7 ++ .../superTypeDelegatedToCompanion.txt | 42 +++++++++ ...elegatedToPrimaryConstructorParam.copy.txt | 29 ++++++ ...rTypeDelegatedToPrimaryConstructorParam.kt | 5 + ...TypeDelegatedToPrimaryConstructorParam.txt | 29 ++++++ .../scripts/insideClassBody.copy.txt | 56 +++++++++++ .../scripts/insideClassBody.kts | 5 + .../scripts/insideClassBody.txt | 56 +++++++++++ .../scripts/lastStatement.copy.txt | 86 +++++++++++++++++ .../scripts/lastStatement.kts | 16 ++++ .../scripts/lastStatement.txt | 86 +++++++++++++++++ .../scriptInsideLastStatement.copy.txt | 92 +++++++++++++++++++ .../scripts/scriptInsideLastStatement.kts | 16 ++++ .../scripts/scriptInsideLastStatement.txt | 92 +++++++++++++++++++ .../scripts/statement.copy.txt | 89 ++++++++++++++++++ .../contextCollector/scripts/statement.kts | 16 ++++ .../contextCollector/scripts/statement.txt | 89 ++++++++++++++++++ ...daryConstructor_superCallArgument.copy.txt | 31 +++++++ .../secondaryConstructor_superCallArgument.kt | 9 ++ ...secondaryConstructor_superCallArgument.txt | 31 +++++++ .../ContextCollectorScriptTestGenerated.java | 24 +++++ .../ContextCollectorSourceTestGenerated.java | 18 ++++ 23 files changed, 966 insertions(+) create mode 100644 analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.kt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.kt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/insideClassBody.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/insideClassBody.kts create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/insideClassBody.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/lastStatement.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/lastStatement.kts create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/lastStatement.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/scriptInsideLastStatement.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/scriptInsideLastStatement.kts create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/scriptInsideLastStatement.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/statement.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/statement.kts create mode 100644 analysis/low-level-api-fir/testData/contextCollector/scripts/statement.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/secondaryConstructor_superCallArgument.copy.txt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/secondaryConstructor_superCallArgument.kt create mode 100644 analysis/low-level-api-fir/testData/contextCollector/secondaryConstructor_superCallArgument.txt diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.copy.txt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.copy.txt new file mode 100644 index 00000000000..07e0853f0a3 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.copy.txt @@ -0,0 +1,42 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final companion object Companion : R|test/MyInterface| + Type: test.MyClass.Companion + Element 7 + Scope: FirNestedClassifierScopeImpl + Classifiers: + FirRegularClassSymbol public final companion object Companion : R|test/MyInterface| + Element 8 + Scope: FirLocalScope + +FILE: [ResolvedTo(IMPORTS)] superTypeDelegatedToCompanion.kt + public final? [ResolvedTo(RAW_FIR)] interface MyInterface : R|kotlin/Any| { + } + public final [ResolvedTo(STATUS)] class MyClass : R|test/MyInterface| { + public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/MyClass| { + super() + } + + private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|test/MyInterface| = Q|test/MyClass.Companion| + + public final companion [ResolvedTo(STATUS)] object Companion : R|test/MyInterface| { + private [ResolvedTo(RAW_FIR)] constructor(): R|test/MyClass.Companion| { + LAZY_super<> + } + + } + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.kt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.kt new file mode 100644 index 00000000000..b52e70145f8 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.kt @@ -0,0 +1,7 @@ +package test + +interface MyInterface + +class MyClass: MyInterface by Companion { + companion object : MyInterface +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.txt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.txt new file mode 100644 index 00000000000..bf16beaabf6 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToCompanion.txt @@ -0,0 +1,42 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Implicit receiver: + FirRegularClassSymbol public final companion object Companion : R|test/MyInterface| + Type: test.MyClass.Companion + Element 7 + Scope: FirNestedClassifierScopeImpl + Classifiers: + FirRegularClassSymbol public final companion object Companion : R|test/MyInterface| + Element 8 + Scope: FirLocalScope + +FILE: [ResolvedTo(IMPORTS)] superTypeDelegatedToCompanion.kt + public abstract [ResolvedTo(STATUS)] interface MyInterface : R|kotlin/Any| { + } + public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class MyClass : R|test/MyInterface| { + public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/MyClass| { + super() + } + + private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|test/MyInterface| = Q|test/MyClass.Companion| + + public final companion [ResolvedTo(STATUS)] object Companion : R|test/MyInterface| { + private [ResolvedTo(STATUS)] constructor(): R|test/MyClass.Companion| { + LAZY_super<> + } + + } + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.copy.txt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.copy.txt new file mode 100644 index 00000000000..0796a2cd968 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.copy.txt @@ -0,0 +1,29 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Scope: FirLocalScope + Properties: + FirValueParameterSymbol param: R|test/MyInterface| + +FILE: [ResolvedTo(IMPORTS)] superTypeDelegatedToPrimaryConstructorParam.kt + public final? [ResolvedTo(RAW_FIR)] interface MyInterface : R|kotlin/Any| { + } + public final [ResolvedTo(STATUS)] class MyClass : R|test/MyInterface| { + public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] param: R|test/MyInterface|): R|test/MyClass| { + super() + } + + private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|test/MyInterface| = R|/param| + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.kt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.kt new file mode 100644 index 00000000000..8f52823e710 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.kt @@ -0,0 +1,5 @@ +package test + +interface MyInterface + +class MyClass(param: MyInterface): MyInterface by param \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.txt b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.txt new file mode 100644 index 00000000000..7bc4fc8099e --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/classHeaderPositions/superTypeDelegatedToPrimaryConstructorParam.txt @@ -0,0 +1,29 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Scope: FirLocalScope + Properties: + FirValueParameterSymbol param: R|test/MyInterface| + +FILE: [ResolvedTo(IMPORTS)] superTypeDelegatedToPrimaryConstructorParam.kt + public abstract [ResolvedTo(STATUS)] interface MyInterface : R|kotlin/Any| { + } + public final [ResolvedTo(ANNOTATION_ARGUMENTS)] class MyClass : R|test/MyInterface| { + public [ResolvedTo(BODY_RESOLVE)] constructor([ResolvedTo(BODY_RESOLVE)] param: R|test/MyInterface|): R|test/MyClass| { + super() + } + + private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|test/MyInterface| = R|/param| + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/scripts/insideClassBody.copy.txt b/analysis/low-level-api-fir/testData/contextCollector/scripts/insideClassBody.copy.txt new file mode 100644 index 00000000000..3c7a01b6b70 --- /dev/null +++ b/analysis/low-level-api-fir/testData/contextCollector/scripts/insideClassBody.copy.txt @@ -0,0 +1,56 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirExplicitStarImportingScope + Element 2 + Scope: FirDefaultSimpleImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirPackageMemberScope + Element 5 + Scope: FirExplicitSimpleImportingScope + Element 6 + Scope: FirScriptDeclarationsScope + Classifiers: + FirRegularClassSymbol public final? class Foo : R|kotlin/Any| + Element 7 + Scope: FirLocalScope + Classifiers: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Properties: + FirPropertySymbol lval args: R|kotlin/Array| + Element 8 + Context receivers: + FirScriptSymbol context(