[LL API] Remove incorrect ways to get modules/sessions
^KT-57559 Fixed
This commit is contained in:
+1
-9
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.api
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirResolveSessionService
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.getKtModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider
|
||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
@@ -19,14 +19,6 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
/**
|
||||
* Returns [LLFirResolveSession] which corresponds to containing module
|
||||
*/
|
||||
fun KtElement.getFirResolveSession(): LLFirResolveSession {
|
||||
val project = project
|
||||
return getKtModule(project).getFirResolveSession(project)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [LLFirResolveSession] which corresponds to containing module
|
||||
*/
|
||||
|
||||
+1
-25
@@ -33,28 +33,4 @@ public abstract class ProjectStructureProvider {
|
||||
return getInstance(element.project).getModule(element, contextualModule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given [PsiElement] get a [KtModule] to which [PsiElement] belongs.
|
||||
* @param project [Project] which contains current [PsiElement]. `PsiElement.project` may be a heavy operation as it includes PSI tree traversal. So, when a [Project] is already available, it is better to pass it explicitly
|
||||
*/
|
||||
public fun PsiElement.getKtModule(project: Project = this.project): KtModule =
|
||||
project.getService(ProjectStructureProvider::class.java)
|
||||
.getModule(this, null)
|
||||
|
||||
/**
|
||||
* For a given [PsiElement] get a [KtModule] to which [PsiElement] belongs.
|
||||
* @return [KtModule] of type [M] if `result <: M`, [java.lang.ClassCastException] otherwise
|
||||
* @param project [Project] which contains current [PsiElement]. `PsiElement.project` may be a heavy operation as it includes PSI tree traversal. So, when a [Project] is already available, it is better to pass it explicitly
|
||||
*/
|
||||
public inline fun <reified M : KtModule> PsiElement.getKtModuleOfType(project: Project = this.project): M =
|
||||
getKtModule(project) as M
|
||||
|
||||
/**
|
||||
* For a given [PsiElement] get a [KtModule] to which [PsiElement] belongs.
|
||||
* @return [KtModule] of type [M] if `result <: M`, `null` otherwise
|
||||
* @param project [Project] which contains current [PsiElement]. `PsiElement.project` may be a heavy operation as it includes PSI tree traversal. So, when a [Project] is already available, it is better to pass it explicitly
|
||||
*/
|
||||
public inline fun <reified M : KtModule> PsiElement.getKtModuleOfTypeSafe(project: Project = this.project): M? =
|
||||
getKtModule(project) as? M
|
||||
}
|
||||
Reference in New Issue
Block a user