Do not throw exception analyzing imports in KtCodeFragments

This commit is contained in:
Natalia Ukhorskaya
2015-12-02 15:07:01 +03:00
parent 08c29b7325
commit 49e484d796
2 changed files with 6 additions and 1 deletions
@@ -97,6 +97,8 @@ public fun ImplicitReceiver.asExpression(resolutionScope: LexicalScope, psiFacto
}
public fun KtImportDirective.targetDescriptors(resolutionFacade: ResolutionFacade = this.getResolutionFacade()): Collection<DeclarationDescriptor> {
// For codeFragments imports are created in dummy file
if (this.getContainingKtFile().doNotAnalyze != null) return emptyList()
val nameExpression = importedReference?.getQualifiedElementSelector() as? KtSimpleNameExpression ?: return emptyList()
return nameExpression.mainReference.resolveToDescriptors(resolutionFacade.analyze(nameExpression))
}