From 0eb2b7fecd2df87a14707478c5c41831dc0f8f95 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 18 Feb 2013 17:51:56 +0100 Subject: [PATCH] track modification stamp to restart the lexer in order to avoid unexpected lexer assertions from edited code (EA-30079, EA-43510 ) review+ CR-IC --- .../usageView/src/com/intellij/usages/ChunkExtractor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/usageView/src/com/intellij/usages/ChunkExtractor.java b/platform/usageView/src/com/intellij/usages/ChunkExtractor.java index f364ea67cfae..4419596eab98 100644 --- a/platform/usageView/src/com/intellij/usages/ChunkExtractor.java +++ b/platform/usageView/src/com/intellij/usages/ChunkExtractor.java @@ -62,6 +62,7 @@ public class ChunkExtractor { private final EditorColorsScheme myColorsScheme; private final Document myDocument; + private long myDocumentStamp; private final SyntaxHighlighter myHighlighter; private final Lexer myLexer; @@ -121,6 +122,7 @@ public class ChunkExtractor { myHighlighter = highlighter == null ? new PlainSyntaxHighlighter() : highlighter; myLexer = myHighlighter.getHighlightingLexer(); myLexer.start(myDocument.getCharsSequence()); + myDocumentStamp = myDocument.getModificationStamp(); } public static int getStartOffset(final List rangeMarkers) { @@ -183,8 +185,9 @@ public class ChunkExtractor { int i = StringUtil.indexOf(chars, '\n', start, end); if (i != -1) end = i; - if (lexer.getTokenStart() > start) { + if (lexer.getTokenStart() > start || myDocumentStamp != myDocument.getModificationStamp()) { lexer.start(chars); + myDocumentStamp = myDocument.getModificationStamp(); } boolean isBeginning = true;