From cd179d8971a6e87c61aaff4c0de2a822afc185a3 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Fri, 17 Jun 2011 14:34:25 +0400 Subject: [PATCH] IDEA-68357 IDEA unresponsive with large MXML files Don't using highlighter iterator for determining target markup model range to process on typing. Reason: the highlighter doesn't know about injected context, hence, its lexer-based iterator considers all injected code as a single big token (CDATA in our case). Subsequent markup model processing for such a large range causes unnecessary CPU consuming. That is the reason why we use actual document change-based region and process only highlighters that overlap with it. --- .../daemon/impl/UpdateHighlightersUtil.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index aae461f1f862..7b22704798cf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -28,10 +28,8 @@ import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.ex.DocumentEx; -import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; -import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.editor.impl.RangeMarkerTree; import com.intellij.openapi.editor.impl.RedBlackTree; import com.intellij.openapi.editor.markup.*; @@ -591,18 +589,11 @@ public class UpdateHighlightersUtil { final MarkupModel markup = document.getMarkupModel(project); assertMarkupConsistent(markup, project); - int offset = e.getOffset(); Editor[] editors = EditorFactory.getInstance().getEditors(document, project); - if (editors.length == 0) return; - Editor editor = editors[0]; // use any editor - just to fetch SelectInEditorManager - HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(Math.max(0, offset - 1)); - if (iterator.atEnd()) return; - final int start = iterator.getStart(); - while (iterator.getEnd() < e.getOffset() + Math.max(e.getOldLength(), e.getNewLength())) { - iterator.advance(); - if (iterator.atEnd()) return; - } - final int end = iterator.getEnd(); + if (editors.length <= 0) return; + + final int start = e.getOffset(); + final int end = start + Math.max(e.getOldLength(), e.getNewLength()); final boolean[] highlightersChanged = {false}; final List removed = new ArrayList();