diff --git a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/getModuleInfo.kt b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/getModuleInfo.kt index e1d38cdb574..d16f62aed03 100644 --- a/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/getModuleInfo.kt +++ b/idea/idea-analysis/src/org/jetbrains/jet/plugin/caches/resolve/getModuleInfo.kt @@ -33,12 +33,7 @@ fun PsiElement.getModuleInfo(): IdeaModuleInfo { return NotUnderContentRootModuleInfo } - if (this is KotlinLightElement<*, *>) - 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()}") + if (this is KotlinLightElement<*, *>) return this.getModuleInfoForLightElement() val containingJetFile = (this as? JetElement)?.getContainingFile() as? JetFile 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 containingFile = getContainingFile() ?: return logAndReturnDefault("Analyzing element of type $javaClass with no containing file\nText:\n${getText()}")