[LL API] Remove incorrect ways to get modules/sessions
^KT-57559 Fixed
This commit is contained in:
+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