[LL API] Add some more 'ContextCollector' tests
diff --git a/analysis/low-level-api-fir/testdata/contextCollector/enumValue.kt b/analysis/low-level-api-fir/testdata/contextCollector/enumValue.kt new file mode 100644 index 0000000..b8e051e --- /dev/null +++ b/analysis/low-level-api-fir/testdata/contextCollector/enumValue.kt
@@ -0,0 +1,23 @@ +enum class Direction { + NORTH { + override val code: Int + get() = 1 + }, + + EAST { + override val code: Int + get() = <expr>2</expr> + }, + + SOUTH { + override val code: Int + get() = 3 + }, + + WEST { + override val code: Int + get() = 4 + }; + + abstract val code: Int +} \ No newline at end of file
diff --git a/analysis/low-level-api-fir/testdata/contextCollector/enumValue.txt b/analysis/low-level-api-fir/testdata/contextCollector/enumValue.txt new file mode 100644 index 0000000..20d8600 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/contextCollector/enumValue.txt
@@ -0,0 +1,81 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirDefaultSimpleImportingScope + Element 2 + Scope: FirExplicitStarImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirDefaultSimpleImportingScope + Element 5 + Scope: FirPackageMemberScope + Element 6 + Scope: FirExplicitSimpleImportingScope + Element 7 + Implicit receiver: + FirRegularClassSymbol public final companion object Companion : R|kotlin/Any| + Type: kotlin/Enum.Companion + Element 8 + Scope: FirNestedClassifierScopeWithSubstitution + Classifiers: + FirRegularClassSymbol public final companion object Companion : R|kotlin/Any| + Static scope owner symbol: FirRegularClassSymbol public abstract class Enum<E : R|kotlin/Enum<E>|> : R|kotlin/Comparable<E>|, R|java/io/Serializable| + Element 9 + Scope: FirNameAwareOnlyCallablesScope + Functions + FirNamedFunctionSymbol public final static fun valueOf(value: R|kotlin/String|): R|Direction| + FirNamedFunctionSymbol public final static fun values(): R|kotlin/Array<Direction>| + Properties: + FirEnumEntrySymbol public final static enum entry EAST: R|Direction| = object : R|Direction| + FirEnumEntrySymbol public final static enum entry NORTH: R|Direction| = LAZY_EXPRESSION + FirEnumEntrySymbol public final static enum entry SOUTH: R|Direction| = LAZY_EXPRESSION + FirEnumEntrySymbol public final static enum entry WEST: R|Direction| = LAZY_EXPRESSION + FirPropertySymbol public final static val entries: R|kotlin/enums/EnumEntries<Direction>| + public get(): R|kotlin/enums/EnumEntries<Direction>| + Element 10 + Implicit receiver: + FirAnonymousObjectSymbol object : R|Direction| + Type: <anonymous> + Element 11 + Scope: FirLocalScope + Properties: + FirBackingFieldSymbol private <explicit backing field>: R|kotlin/Int| + Element 12 + Scope: FirLocalScope + +FILE: [ResolvedTo(IMPORTS)] enumValue.kt + public final [ResolvedTo(STATUS)] enum class Direction : R|kotlin/Enum<Direction>| { + private [ResolvedTo(STATUS)] constructor(): R|Direction| { + LAZY_super<R|kotlin/Enum<Direction>|> + } + + public final static [ResolvedTo(STATUS)] enum entry NORTH: R|Direction| = LAZY_EXPRESSION + public final static [ResolvedTo(BODY_RESOLVE)] enum entry EAST: R|Direction| = object : R|Direction| { + private [ResolvedTo(BODY_RESOLVE)] constructor(): R|<anonymous>| { + super<R|Direction|>() + } + + public open override [ResolvedTo(BODY_RESOLVE)] val code: R|kotlin/Int| + public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| { + ^ Int(2) + } + + } + + public final static [ResolvedTo(STATUS)] enum entry SOUTH: R|Direction| = LAZY_EXPRESSION + public final static [ResolvedTo(STATUS)] enum entry WEST: R|Direction| = LAZY_EXPRESSION + public abstract [ResolvedTo(STATUS)] val code: R|kotlin/Int| + public [ResolvedTo(STATUS)] get(): R|kotlin/Int| + + public final static [ResolvedTo(STATUS)] fun values(): R|kotlin/Array<Direction>| { + } + + public final static [ResolvedTo(STATUS)] fun valueOf([ResolvedTo(STATUS)] value: R|kotlin/String|): R|Direction| { + } + + public final static [ResolvedTo(STATUS)] val entries: R|kotlin/enums/EnumEntries<Direction>| + public [ResolvedTo(STATUS)] get(): R|kotlin/enums/EnumEntries<Direction>| + + }
diff --git a/analysis/low-level-api-fir/testdata/contextCollector/file.kt b/analysis/low-level-api-fir/testdata/contextCollector/file.kt new file mode 100644 index 0000000..6c59d4b --- /dev/null +++ b/analysis/low-level-api-fir/testdata/contextCollector/file.kt
@@ -0,0 +1,15 @@ +package <expr>test</expr> + +import java.util.List + +fun test() = List::class + +fun other(): Int { + return "foo".length +} + +class Foo { + fun foo() { + require(other() == 3) + } +} \ No newline at end of file
diff --git a/analysis/low-level-api-fir/testdata/contextCollector/file.txt b/analysis/low-level-api-fir/testdata/contextCollector/file.txt new file mode 100644 index 0000000..fdaa5dc --- /dev/null +++ b/analysis/low-level-api-fir/testdata/contextCollector/file.txt
@@ -0,0 +1,36 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirDefaultSimpleImportingScope + Element 2 + Scope: FirExplicitStarImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirDefaultSimpleImportingScope + Element 5 + Scope: FirPackageMemberScope + Element 6 + Scope: FirExplicitSimpleImportingScope + Import name:List + Qualified name: java.util.List + Is all under: false + +FILE: [ResolvedTo(IMPORTS)] file.kt + public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/reflect/KClass<java/util/List<*>>| { + ^test <getClass>(Q|java/util/List|) + } + public final [ResolvedTo(BODY_RESOLVE)] fun other(): R|kotlin/Int| { + ^other String(foo).R|kotlin/String.length| + } + public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Foo| { + super<R|kotlin/Any|>() + } + + public final [ResolvedTo(BODY_RESOLVE)] fun foo(): R|kotlin/Unit| { + <Unresolved name: require>#(==(R|test/other|(), Int(3))) + } + + }
diff --git a/analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.kt b/analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.kt new file mode 100644 index 0000000..13c153a --- /dev/null +++ b/analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.kt
@@ -0,0 +1,5 @@ +class Foo( + val a: String = "foo" + val b: Int = <expr>a.length</expr>, + val c: Long = (a.length - 1).toLong() +) \ No newline at end of file
diff --git a/analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.txt b/analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.txt new file mode 100644 index 0000000..df64f09 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.txt
@@ -0,0 +1,36 @@ +Tower Data Context: + Element 0 + Scope: FirDefaultStarImportingScope + Element 1 + Scope: FirDefaultSimpleImportingScope + Element 2 + Scope: FirExplicitStarImportingScope + Element 3 + Scope: FirDefaultSimpleImportingScope + Element 4 + Scope: FirDefaultSimpleImportingScope + Element 5 + Scope: FirPackageMemberScope + Element 6 + Scope: FirExplicitSimpleImportingScope + Element 7 + Implicit receiver: + FirRegularClassSymbol public final class Foo : R|kotlin/Any| + Type: Foo + +FILE: [ResolvedTo(IMPORTS)] primaryConstructorParameter.kt + public final [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| { + public [ResolvedTo(STATUS)] constructor([ResolvedTo(STATUS)] a: R|kotlin/String| = LAZY_EXPRESSION, [ResolvedTo(STATUS)] b: R|kotlin/Int| = LAZY_EXPRESSION, [ResolvedTo(STATUS)] c: R|kotlin/Long| = LAZY_EXPRESSION): R|Foo| { + LAZY_super<R|kotlin/Any|> + } + + public final [ResolvedTo(STATUS)] val a: R|kotlin/String| = R|<local>/a| + public [ResolvedTo(STATUS)] get(): R|kotlin/String| + + public final [ResolvedTo(BODY_RESOLVE)] val b: R|kotlin/Int| = R|<local>/b| + public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| + + public final [ResolvedTo(STATUS)] val c: R|kotlin/Long| = R|<local>/c| + public [ResolvedTo(STATUS)] get(): R|kotlin/Long| + + }
diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorTestGenerated.java index 4bf2c2a..2d1e8ba 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/ContextCollectorTestGenerated.java
@@ -37,6 +37,12 @@ } @Test + @TestMetadata("enumValue.kt") + public void testEnumValue() throws Exception { + runTest("analysis/low-level-api-fir/testdata/contextCollector/enumValue.kt"); + } + + @Test @TestMetadata("extensionFunction.kt") public void testExtensionFunction() throws Exception { runTest("analysis/low-level-api-fir/testdata/contextCollector/extensionFunction.kt"); @@ -49,6 +55,12 @@ } @Test + @TestMetadata("file.kt") + public void testFile() throws Exception { + runTest("analysis/low-level-api-fir/testdata/contextCollector/file.kt"); + } + + @Test @TestMetadata("innerClasses.kt") public void testInnerClasses() throws Exception { runTest("analysis/low-level-api-fir/testdata/contextCollector/innerClasses.kt"); @@ -67,6 +79,12 @@ } @Test + @TestMetadata("primaryConstructorParameter.kt") + public void testPrimaryConstructorParameter() throws Exception { + runTest("analysis/low-level-api-fir/testdata/contextCollector/primaryConstructorParameter.kt"); + } + + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("analysis/low-level-api-fir/testdata/contextCollector/simple.kt");