Search in sources :

Example 81 with DocumentEx

use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.

the class LexerEditorHighlighter method createIterator.

@NotNull
@Override
public HighlighterIterator createIterator(int startOffset) {
    synchronized (this) {
        if (!isInSyncWithDocument()) {
            final Document document = getDocument();
            assert document != null;
            if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate()) {
                // bulk mode failed
                ((DocumentEx) document).setInBulkUpdate(false);
            }
            doSetText(document.getImmutableCharSequence());
        }
        final int latestValidOffset = mySegments.getLastValidOffset();
        return new HighlighterIteratorImpl(startOffset <= latestValidOffset ? startOffset : latestValidOffset);
    }
}
Also used : DocumentEx(com.intellij.openapi.editor.ex.DocumentEx) Document(com.intellij.openapi.editor.Document) NotNull(org.jetbrains.annotations.NotNull)

Example 82 with DocumentEx

use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.

the class StatusBarUpdater method updateStatus.

private void updateStatus() {
    Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
    if (editor == null || !editor.getContentComponent().hasFocus()) {
        return;
    }
    final Document document = editor.getDocument();
    if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate())
        return;
    int offset = editor.getCaretModel().getOffset();
    DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
    HighlightInfo info = ((DaemonCodeAnalyzerImpl) codeAnalyzer).findHighlightByOffset(document, offset, false, MIN);
    String text = info != null && info.getDescription() != null ? info.getDescription() : "";
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(editor.getContentComponent(), myProject);
    if (statusBar != null && !text.equals(statusBar.getInfo())) {
        statusBar.setInfo(text, "updater");
    }
}
Also used : DocumentEx(com.intellij.openapi.editor.ex.DocumentEx) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) Editor(com.intellij.openapi.editor.Editor) Document(com.intellij.openapi.editor.Document) StatusBar(com.intellij.openapi.wm.StatusBar)

Example 83 with DocumentEx

use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.

the class BraceHighlighter method updateBraces.

static void updateBraces(@NotNull final Editor editor, @NotNull final Alarm alarm) {
    final Document document = editor.getDocument();
    if (document instanceof DocumentEx && ((DocumentEx) document).isInBulkUpdate())
        return;
    BraceHighlightingHandler.lookForInjectedAndMatchBracesInOtherThread(editor, alarm, handler -> {
        handler.updateBraces();
        return false;
    });
}
Also used : DocumentEx(com.intellij.openapi.editor.ex.DocumentEx) Document(com.intellij.openapi.editor.Document)

Example 84 with DocumentEx

use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.

the class ApplyChangesState method setDone.

@Override
protected void setDone(boolean done) {
    super.setDone(done);
    if (myResetBulkUpdateState) {
        DocumentEx document = getAffectedDocument(myModel);
        if (document != null) {
            document.setInBulkUpdate(false);
            myResetBulkUpdateState = false;
        }
    }
    if (done) {
        myModel.commitChanges();
    }
}
Also used : DocumentEx(com.intellij.openapi.editor.ex.DocumentEx)

Example 85 with DocumentEx

use of com.intellij.openapi.editor.ex.DocumentEx in project intellij-community by JetBrains.

the class PydevConsoleRunnerImpl method createInterruptAction.

private AnAction createInterruptAction() {
    AnAction anAction = new AnAction() {

        @Override
        public void actionPerformed(final AnActionEvent e) {
            if (myPydevConsoleCommunication.isExecuting() || myPydevConsoleCommunication.isWaitingForInput()) {
                myConsoleView.print("^C", ProcessOutputTypes.SYSTEM);
                myPydevConsoleCommunication.interrupt();
            } else {
                DocumentEx document = myConsoleView.getConsoleEditor().getDocument();
                if (!(document.getTextLength() == 0)) {
                    ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().runUndoTransparentAction(() -> document.deleteString(0, document.getLineEndOffset(document.getLineCount() - 1))));
                }
            }
        }

        @Override
        public void update(final AnActionEvent e) {
            EditorEx consoleEditor = myConsoleView.getConsoleEditor();
            boolean enabled = IJSwingUtilities.hasFocus(consoleEditor.getComponent()) && !consoleEditor.getSelectionModel().hasSelection();
            e.getPresentation().setEnabled(enabled);
        }
    };
    anAction.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.CTRL_MASK, myConsoleView.getConsoleEditor().getComponent());
    anAction.getTemplatePresentation().setVisible(false);
    return anAction;
}
Also used : DocumentEx(com.intellij.openapi.editor.ex.DocumentEx) EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Aggregations

DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)87 Document (com.intellij.openapi.editor.Document)12 NotNull (org.jetbrains.annotations.NotNull)8 RangeMarkerEx (com.intellij.openapi.editor.ex.RangeMarkerEx)7 Project (com.intellij.openapi.project.Project)7 TextRange (com.intellij.openapi.util.TextRange)7 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)7 PsiFile (com.intellij.psi.PsiFile)6 Nullable (org.jetbrains.annotations.Nullable)5 EditorEx (com.intellij.openapi.editor.ex.EditorEx)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 MockVirtualFile (com.intellij.mock.MockVirtualFile)3 FoldRegion (com.intellij.openapi.editor.FoldRegion)3 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)3 DocumentWindow (com.intellij.injected.editor.DocumentWindow)2 DocumentBulkUpdateListener (com.intellij.openapi.editor.ex.DocumentBulkUpdateListener)2 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)2 DocumentMarkupModel (com.intellij.openapi.editor.impl.DocumentMarkupModel)2 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)2 FileDocumentManagerAdapter (com.intellij.openapi.fileEditor.FileDocumentManagerAdapter)2