[LL FIR] extract LLFirResolveTargetWithDedicatedElement
It is required to simplify the logic in the next commit. Also, it drops redundant inheritance from [firFile] and [path] properties ^KT-60728
This commit is contained in:
committed by
Space Team
parent
dc347e2aa6
commit
544341412a
+4
-4
@@ -14,10 +14,10 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
|||||||
* [LLFirResolveTarget] representing a class with all callable members (functions and properties).
|
* [LLFirResolveTarget] representing a class with all callable members (functions and properties).
|
||||||
*/
|
*/
|
||||||
class LLFirClassWithAllCallablesResolveTarget(
|
class LLFirClassWithAllCallablesResolveTarget(
|
||||||
override val firFile: FirFile,
|
firFile: FirFile,
|
||||||
override val path: List<FirRegularClass>,
|
classPath: List<FirRegularClass>,
|
||||||
val target: FirRegularClass,
|
target: FirRegularClass,
|
||||||
) : LLFirResolveTarget() {
|
) : LLFirResolveTargetWithDedicatedElement<FirRegularClass>(firFile, classPath, target) {
|
||||||
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
||||||
action(target)
|
action(target)
|
||||||
forEachCallable(action)
|
forEachCallable(action)
|
||||||
|
|||||||
+4
-4
@@ -14,10 +14,10 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
|||||||
* [LLFirResolveTarget] representing a class with all class members to be resolved (this includes callables, init blocks, and classifiers)
|
* [LLFirResolveTarget] representing a class with all class members to be resolved (this includes callables, init blocks, and classifiers)
|
||||||
*/
|
*/
|
||||||
class LLFirClassWithAllMembersResolveTarget(
|
class LLFirClassWithAllMembersResolveTarget(
|
||||||
override val firFile: FirFile,
|
firFile: FirFile,
|
||||||
override val path: List<FirRegularClass>,
|
classPath: List<FirRegularClass>,
|
||||||
val target: FirRegularClass,
|
target: FirRegularClass,
|
||||||
) : LLFirResolveTarget() {
|
) : LLFirResolveTargetWithDedicatedElement<FirRegularClass>(firFile, classPath, target) {
|
||||||
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
||||||
action(target)
|
action(target)
|
||||||
forEachMember(action)
|
forEachMember(action)
|
||||||
|
|||||||
+5
-5
@@ -11,11 +11,11 @@ import org.jetbrains.kotlin.fir.declarations.FirFile
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||||
|
|
||||||
class LLFirClassWithSpecificMembersResolveTarget(
|
class LLFirClassWithSpecificMembersResolveTarget(
|
||||||
override val firFile: FirFile,
|
firFile: FirFile,
|
||||||
override val path: List<FirRegularClass>,
|
classPath: List<FirRegularClass>,
|
||||||
val target: FirRegularClass,
|
target: FirRegularClass,
|
||||||
val members: List<FirDeclaration>
|
val members: List<FirDeclaration>,
|
||||||
) : LLFirResolveTarget() {
|
) : LLFirResolveTargetWithDedicatedElement<FirRegularClass>(firFile, classPath, target) {
|
||||||
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
||||||
action(target)
|
action(target)
|
||||||
forEachMember(action)
|
forEachMember(action)
|
||||||
|
|||||||
+4
-4
@@ -20,19 +20,19 @@ import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
|||||||
* Specifies the path to the resolve targets and resolve targets themselves.
|
* Specifies the path to the resolve targets and resolve targets themselves.
|
||||||
* Those targets are going to be resolved by [org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.LLFirModuleLazyDeclarationResolver]
|
* Those targets are going to be resolved by [org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.LLFirModuleLazyDeclarationResolver]
|
||||||
*/
|
*/
|
||||||
sealed class LLFirResolveTarget {
|
sealed class LLFirResolveTarget(
|
||||||
/**
|
/**
|
||||||
* [FirFile] where the targets are located
|
* [FirFile] where the targets are located
|
||||||
*/
|
*/
|
||||||
abstract val firFile: FirFile
|
val firFile: FirFile,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of [FirRegularClass] which are the required to go from file to target declarations in the top-down order.
|
* The list of [FirRegularClass] which are the required to go from file to target declarations in the top-down order.
|
||||||
*
|
*
|
||||||
* If resolve target is [FirRegularClass] itself, it's not included into the [path]
|
* If resolve target is [FirRegularClass] itself, it's not included into the [path]
|
||||||
*/
|
*/
|
||||||
abstract val path: List<FirRegularClass>
|
val path: List<FirDeclaration>,
|
||||||
|
) {
|
||||||
/**
|
/**
|
||||||
* Executions the [action] for each target that this [LLFirResolveTarget] represents.
|
* Executions the [action] for each target that this [LLFirResolveTarget] represents.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 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.analysis.low.level.api.fir.api.targets
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirElementWithResolveState
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [LLFirResolveTarget] representing a target with a dedicated main element.
|
||||||
|
* Such resolved is supposed to resolve [target] element and/or its declaration subgraph.
|
||||||
|
*/
|
||||||
|
sealed class LLFirResolveTargetWithDedicatedElement<T : FirElementWithResolveState>(
|
||||||
|
firFile: FirFile,
|
||||||
|
classPath: List<FirRegularClass>,
|
||||||
|
val target: T,
|
||||||
|
) : LLFirResolveTarget(
|
||||||
|
firFile = firFile,
|
||||||
|
path = classPath,
|
||||||
|
)
|
||||||
+4
-5
@@ -13,11 +13,10 @@ import org.jetbrains.kotlin.fir.declarations.*
|
|||||||
* [LLFirResolveTarget] representing single target to resolve. The [target] can be any of [FirElementWithResolveState]
|
* [LLFirResolveTarget] representing single target to resolve. The [target] can be any of [FirElementWithResolveState]
|
||||||
*/
|
*/
|
||||||
class LLFirSingleResolveTarget(
|
class LLFirSingleResolveTarget(
|
||||||
override val firFile: FirFile,
|
firFile: FirFile,
|
||||||
override val path: List<FirRegularClass>,
|
classPath: List<FirRegularClass>,
|
||||||
val target: FirElementWithResolveState,
|
target: FirElementWithResolveState,
|
||||||
) : LLFirResolveTarget() {
|
) : LLFirResolveTargetWithDedicatedElement<FirElementWithResolveState>(firFile, classPath, target) {
|
||||||
|
|
||||||
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
||||||
action(target)
|
action(target)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -14,10 +14,10 @@ import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
|||||||
* All of them are going to be resolved.
|
* All of them are going to be resolved.
|
||||||
*/
|
*/
|
||||||
class LLFirWholeClassResolveTarget(
|
class LLFirWholeClassResolveTarget(
|
||||||
override val firFile: FirFile,
|
firFile: FirFile,
|
||||||
override val path: List<FirRegularClass>,
|
classPath: List<FirRegularClass>,
|
||||||
val target: FirRegularClass,
|
target: FirRegularClass,
|
||||||
) : LLFirResolveTarget() {
|
) : LLFirResolveTargetWithDedicatedElement<FirRegularClass>(firFile, classPath, target) {
|
||||||
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
||||||
action(target)
|
action(target)
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -14,11 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.FirScript
|
|||||||
/**
|
/**
|
||||||
* [LLFirResolveTarget] representing all declarations in file. All of them are going to be resolved.
|
* [LLFirResolveTarget] representing all declarations in file. All of them are going to be resolved.
|
||||||
*/
|
*/
|
||||||
class LLFirWholeFileResolveTarget(
|
class LLFirWholeFileResolveTarget(firFile: FirFile) : LLFirResolveTarget(firFile, emptyList()) {
|
||||||
override val firFile: FirFile,
|
|
||||||
) : LLFirResolveTarget() {
|
|
||||||
override val path: List<FirRegularClass> get() = emptyList()
|
|
||||||
|
|
||||||
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
override fun forEachTarget(action: (FirElementWithResolveState) -> Unit) {
|
||||||
fun goInside(target: FirElementWithResolveState) {
|
fun goInside(target: FirElementWithResolveState) {
|
||||||
action(target)
|
action(target)
|
||||||
|
|||||||
Reference in New Issue
Block a user