Search in sources :

Example 16 with DumbAwareRunnable

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);
            }
        });
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable)

Aggregations

DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)16 ToolWindow (com.intellij.openapi.wm.ToolWindow)3 Notification (com.intellij.notification.Notification)2 NotificationListener (com.intellij.notification.NotificationListener)2 Application (com.intellij.openapi.application.Application)2 Project (com.intellij.openapi.project.Project)2 FileStatusListener (com.intellij.openapi.vcs.FileStatusListener)2 DependencyOnPlugin (com.intellij.externalDependencies.DependencyOnPlugin)1 ProjectExternalDependency (com.intellij.externalDependencies.ProjectExternalDependency)1 UISettings (com.intellij.ide.ui.UISettings)1 Editor (com.intellij.openapi.editor.Editor)1 EditorColorsListener (com.intellij.openapi.editor.colors.EditorColorsListener)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)1 ExternalSystemSettingsListenerAdapter (com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter)1 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)1 Library (com.intellij.openapi.roots.libraries.Library)1 Balloon (com.intellij.openapi.ui.popup.Balloon)1 JBPopupAdapter (com.intellij.openapi.ui.popup.JBPopupAdapter)1 LightweightWindowEvent (com.intellij.openapi.ui.popup.LightweightWindowEvent)1