Commit 5c245f31 authored by Nicolay Mitropolsky's avatar Nicolay Mitropolsky
Browse files

Uast: `findPlugin` workaround for KT-18054

parent 38f189bd
Showing with 5 additions and 1 deletion
+5 -1
......@@ -42,7 +42,11 @@ class UastContext(val project: Project) : UastLanguagePlugin {
get() = UastLanguagePlugin.getInstances()
fun findPlugin(element: PsiElement): UastLanguagePlugin? {
val language = (element.containingFile ?: element).language // because sometimes java elements are used in another files (see Drools)
// we searching for plugin for file because sometimes java elements are used in another languages (see Drools)
val containingFile = element.containingFile?.takeIf {
it !is PsiCompiledFile // Dont trust compiled files because of KT-18054
}
val language = (containingFile ?: element).language
return languagePlugins.firstOrNull { it.language == language }
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment