[kotlin] KTIJ-34510 Fix file level highlighting check

(cherry picked from commit 90beb591188217cb36904e85dee95f19ebf27b5f)

GitOrigin-RevId: 5b8e463a80fa7a84cd2f90aae01c3ddca6140449
This commit is contained in:
Vladimir Dolzhenko
2025-10-31 20:54:21 +00:00
committed by intellij-monorepo-bot
parent 777d5dd826
commit de81d39bc1
2 changed files with 9 additions and 3 deletions
@@ -112,8 +112,14 @@ fun createCodeMetaInfo(obj: Any, renderConfiguration: AbstractCodeMetaInfoRender
}
is HighlightInfo -> {
val codeMetaInfo: CodeMetaInfo = when(renderConfiguration) {
is HighlightingConfiguration -> HighlightingCodeMetaInfo(renderConfiguration, obj)
is FileLevelHighlightingConfiguration -> FileLevelHighlightingCodeMetaInfo(renderConfiguration, obj)
is HighlightingConfiguration -> {
if (obj.isFileLevelAnnotation) return emptyList()
HighlightingCodeMetaInfo(renderConfiguration, obj)
}
is FileLevelHighlightingConfiguration -> {
if (!obj.isFileLevelAnnotation) return emptyList()
FileLevelHighlightingCodeMetaInfo(renderConfiguration, obj)
}
else -> error(errorMessage())
}
@@ -1,4 +1,4 @@
<!FILE_LEVEL_HIGHLIGHTING, HIGHLIGHTING("severity='WEAK WARNING'; descr='Package directive does not match the file location'")!><!HIGHLIGHTING("severity='ERROR'; descr='Expecting a top level declaration'")!>x<!>
<!FILE_LEVEL_HIGHLIGHTING!><!HIGHLIGHTING("severity='ERROR'; descr='Expecting a top level declaration'")!>x<!>
// TOOL: org.jetbrains.kotlin.idea.k2.codeinsight.inspections.PackageDirectoryMismatchInspection
// IGNORE_K1
// IMPLICIT_PACKAGE_PREFIX: "foo"