KTIJ-21986 Don't log non-kotlin code fragment context when it's null

This warning shouldn't be logged when the context is null.
This commit is contained in:
Bart van Helvert
2022-06-13 12:12:43 +02:00
committed by teamcity
parent 79ba790b38
commit 7bef560b6b
@@ -83,8 +83,8 @@ abstract class KtCodeFragment(
override fun getContext(): PsiElement? {
if (fakeContextForJavaFile != null) return fakeContextForJavaFile
if (context !is KtElement) {
val logInfoForContextElement = (context as? PsiFile)?.virtualFile?.path ?: context?.getElementTextWithContext()
if (context != null && context !is KtElement) {
val logInfoForContextElement = (context as? PsiFile)?.virtualFile?.path ?: context.getElementTextWithContext()
LOG.warn("CodeFragment with non-kotlin context should have fakeContextForJavaFile set: \noriginalContext = $logInfoForContextElement")
return null
}