Fix getModuleInfo for elements in code fragments
This commit is contained in:
@@ -33,12 +33,7 @@ fun PsiElement.getModuleInfo(): IdeaModuleInfo {
|
|||||||
return NotUnderContentRootModuleInfo
|
return NotUnderContentRootModuleInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this is KotlinLightElement<*, *>)
|
if (this is KotlinLightElement<*, *>) return this.getModuleInfoForLightElement()
|
||||||
return this.getModuleInfoForLightElement()
|
|
||||||
|
|
||||||
if (this is JetCodeFragment)
|
|
||||||
return this.getContext()?.getModuleInfo()
|
|
||||||
?: logAndReturnDefault("Analyzing code fragment of type $javaClass with no context element\nText:\n${getText()}")
|
|
||||||
|
|
||||||
val containingJetFile = (this as? JetElement)?.getContainingFile() as? JetFile
|
val containingJetFile = (this as? JetElement)?.getContainingFile() as? JetFile
|
||||||
val context = containingJetFile?.analysisContext
|
val context = containingJetFile?.analysisContext
|
||||||
@@ -51,6 +46,11 @@ fun PsiElement.getModuleInfo(): IdeaModuleInfo {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (containingJetFile is JetCodeFragment) {
|
||||||
|
return containingJetFile.getContext()?.getModuleInfo()
|
||||||
|
?: logAndReturnDefault("Analyzing code fragment of type ${containingJetFile.javaClass} with no context element\nText:\n${containingJetFile.getText()}")
|
||||||
|
}
|
||||||
|
|
||||||
val project = getProject()
|
val project = getProject()
|
||||||
val containingFile = getContainingFile()
|
val containingFile = getContainingFile()
|
||||||
?: return logAndReturnDefault("Analyzing element of type $javaClass with no containing file\nText:\n${getText()}")
|
?: return logAndReturnDefault("Analyzing element of type $javaClass with no containing file\nText:\n${getText()}")
|
||||||
|
|||||||
Reference in New Issue
Block a user