use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class LexerEditorHighlighter method doSetText.
private void doSetText(final CharSequence text) {
if (Comparing.equal(myText, text))
return;
myText = ImmutableCharSequence.asImmutable(text);
final TokenProcessor processor = createTokenProcessor(0);
final int textLength = text.length();
myLexer.start(text, 0, textLength, myInitialState);
mySegments.removeAll();
int i = 0;
while (true) {
final IElementType tokenType = myLexer.getTokenType();
if (tokenType == null)
break;
int data = packData(tokenType, myLexer.getState());
processor.addToken(i, myLexer.getTokenStart(), myLexer.getTokenEnd(), data, tokenType);
i++;
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, textLength);
}
});
}
}
Aggregations