From 2c9b0448a1cdf6e365a836a86302af16146eccf7 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 19 Nov 2014 17:20:03 +0300 Subject: [PATCH] Fix getModuleInfo for elements in code fragments --- .../jet/plugin/caches/resolve/getModuleInfo.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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()}")