From 5d2906041e4067a2d0f8149511d239dfdb1c09e3 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 2 Nov 2015 19:09:18 +0300 Subject: [PATCH] diagnostics for EA-48865 --- .../openapi/editor/ex/util/LexerEditorHighlighter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java index 5193dc8807ed..8d156ced6cbb 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java @@ -113,7 +113,6 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc ((DocumentEx)document).setInBulkUpdate(false); // bulk mode failed } doSetText(document.getCharsSequence()); - assert isInSyncWithDocument() : "Lexer produced no tokens for non-empty document: " + myLexer; } final int latestValidOffset = mySegments.getLastValidOffset(); @@ -315,7 +314,8 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc private void doSetText(final CharSequence text) { final TokenProcessor processor = createTokenProcessor(0); - myLexer.start(text, 0, text.length(),myInitialState); + final int textLength = text.length(); + myLexer.start(text, 0, textLength, myInitialState); mySegments.removeAll(); int i = 0; while (true) { @@ -328,12 +328,16 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc myLexer.advance(); } processor.finish(); + + if (textLength > 0 && (mySegments.mySegmentCount == 0 || mySegments.myEnds[mySegments.mySegmentCount - 1] != textLength)) { + throw new IllegalStateException("Unexpected termination offset for lexer " + myLexer); + } if(myEditor != null && !ApplicationManager.getApplication().isHeadlessEnvironment()) { UIUtil.invokeLaterIfNeeded(new DumbAwareRunnable() { @Override public void run() { - myEditor.repaint(0, text.length()); + myEditor.repaint(0, textLength); } }); }