[Analysis API] Support compiler plugins in code fragments

Compiler plugins are currently only supported in source modules.
This commit makes them also available in code fragments with source
context.
This commit is contained in:
Yan Zhulanow
2023-11-07 17:26:01 +09:00
committed by Space Team
parent 5179462632
commit c7aedd932c
11 changed files with 134 additions and 12 deletions
@@ -0,0 +1,8 @@
@org.jetbrains.kotlin.fir.plugin.AllOpen
class Foo {
fun call() {}
}
class Bar : Foo() {}
Bar().call()
@@ -0,0 +1,59 @@
MODULE_FRAGMENT
FILE fqName:<root> fileName:fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> () returnType:kotlin.Unit
EXPRESSION_BODY
BLOCK type=kotlin.Unit origin=null
CLASS CLASS name:Foo modality:OPEN visibility:local superTypes:[kotlin.Any]
annotations:
AllOpen
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment.run.Foo
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment.run.Foo [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Foo modality:OPEN visibility:local superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:call visibility:public modality:OPEN <> ($this:<root>.CodeFragment.run.Foo) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.CodeFragment.run.Foo
BLOCK_BODY
CLASS CLASS name:Bar modality:FINAL visibility:local superTypes:[<root>.CodeFragment.run.Foo]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment.run.Bar
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment.run.Bar [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.CodeFragment.run.Foo'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:local superTypes:[<root>.CodeFragment.run.Foo]'
FUN FAKE_OVERRIDE name:call visibility:public modality:OPEN <> ($this:<root>.CodeFragment.run.Foo) returnType:kotlin.Unit [fake_override]
overridden:
public open fun call (): kotlin.Unit declared in <root>.CodeFragment.run.Foo
$this: VALUE_PARAMETER name:<this> type:<root>.CodeFragment.run.Foo
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.CodeFragment.run.Foo
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.CodeFragment.run.Foo
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.CodeFragment.run.Foo
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CALL 'public open fun call (): kotlin.Unit [fake_override] declared in <root>.CodeFragment.run.Bar' type=kotlin.Unit origin=null
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.CodeFragment.run.Bar' type=<root>.CodeFragment.run.Bar origin=null
@@ -0,0 +1,5 @@
// WITH_FIR_TEST_COMPILER_PLUGIN
fun test() {
<caret>val x = 0
}
@@ -0,0 +1,23 @@
public final class CodeFragment$run$Bar {
// source: 'fragment.kt'
enclosing method CodeFragment.run()V
inner (local) class CodeFragment$run$Bar Bar
inner (local) class CodeFragment$run$Foo Foo
public method <init>(): void
}
public class CodeFragment$run$Foo {
// source: 'fragment.kt'
enclosing method CodeFragment.run()V
inner (local) class CodeFragment$run$Foo Foo
public method <init>(): void
public method call(): void
}
public final class CodeFragment {
// source: 'fragment.kt'
inner (local) class CodeFragment$run$Bar Bar
inner (local) class CodeFragment$run$Foo Foo
public method <init>(): void
public final static method run(): void
}