Do not highlight kts files outside source roots if not all definitions are initialized
^KT-20521 Fixed ^KT-21420 Fixed
This commit is contained in:
+20
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.highlighter
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.NotUnderContentRootModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getModuleInfo
|
||||
import org.jetbrains.kotlin.idea.core.script.scriptDependencies
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.psi.KtCodeFragment
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -26,9 +27,16 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
object KotlinHighlightingUtil {
|
||||
fun shouldHighlight(psiElement: PsiElement): Boolean {
|
||||
val ktFile = psiElement.containingFile as? KtFile ?: return false
|
||||
return ktFile is KtCodeFragment && ktFile.context != null ||
|
||||
ktFile.isScript() ||
|
||||
ProjectRootsUtil.isInProjectOrLibraryContent(ktFile) && ktFile.getModuleInfo() !is NotUnderContentRootModuleInfo
|
||||
|
||||
if (ktFile is KtCodeFragment && ktFile.context != null) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (ktFile.isScript()) {
|
||||
return ktFile.virtualFile.scriptDependencies != null
|
||||
}
|
||||
|
||||
return ProjectRootsUtil.isInProjectOrLibraryContent(ktFile) && ktFile.getModuleInfo() !is NotUnderContentRootModuleInfo
|
||||
}
|
||||
|
||||
fun shouldHighlightErrors(psiElement: PsiElement): Boolean {
|
||||
@@ -36,6 +44,14 @@ object KotlinHighlightingUtil {
|
||||
if (ktFile.isCompiled) {
|
||||
return false
|
||||
}
|
||||
return (ktFile is KtCodeFragment && ktFile.context != null) || ktFile.isScript() || ProjectRootsUtil.isInProjectSource(ktFile)
|
||||
if (ktFile is KtCodeFragment && ktFile.context != null) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (ktFile.isScript()) {
|
||||
return ktFile.virtualFile.scriptDependencies != null
|
||||
}
|
||||
|
||||
return ProjectRootsUtil.isInProjectSource(ktFile)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user