diagnostics for EA-48865

This commit is contained in:
Dmitry Batrak
2015-11-03 13:34:12 +03:00
parent d82b8fa9b3
commit 5d2906041e
@@ -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);
}
});
}