track modification stamp to restart the lexer in order to avoid unexpected lexer assertions from edited code (EA-30079, EA-43510 ) review+ CR-IC

This commit is contained in:
Maxim.Mossienko
2013-02-18 17:53:56 +01:00
parent 8674192975
commit 0eb2b7fecd
@@ -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<RangeMarker> 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;