diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java index 9ac53f437de3..aaf4ae106d31 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java @@ -430,6 +430,13 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { HighlightInfo info = assertOneElement(fileLevel); assertEquals("top level", info.getDescription()); + type("\n\n"); + doHighlighting(); + fileLevel = + ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(ourProject)).getFileLevelHighlights(getProject(), getFile()); + info = assertOneElement(fileLevel); + assertEquals("top level", info.getDescription()); + type("//xxx"); //disable top level annotation List warnings = doHighlighting(HighlightSeverity.WARNING); assertEmpty(warnings); diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index 123263a566c8..6a1b527dbeb6 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -167,7 +167,9 @@ public class UpdateHighlightersUtil { ApplicationManager.getApplication().assertIsDispatchThread(); final DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(project); - codeAnalyzer.cleanFileLevelHighlights(project, group, psiFile); + if (startOffset == 0 && endOffset == document.getTextLength()) { + codeAnalyzer.cleanFileLevelHighlights(project, group, psiFile); + } final MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true); assertMarkupConsistent(markup, project);