Search in sources :

Example 1 with DocumentWindow

use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.

the class SelectInEditorManagerImpl method selectInEditor.

@Override
public void selectInEditor(VirtualFile file, final int startOffset, final int endOffset, final boolean toSelectLine, final boolean toUseNormalSelection) {
    releaseAll();
    final TextRange textRange;
    if (file instanceof VirtualFileWindow) {
        DocumentWindow documentWindow = ((VirtualFileWindow) file).getDocumentWindow();
        textRange = documentWindow.injectedToHost(new TextRange(startOffset, endOffset));
        file = ((VirtualFileWindow) file).getDelegate();
    } else {
        textRange = new ProperTextRange(startOffset, endOffset);
    }
    openEditor(file, endOffset);
    final Editor editor = openEditor(file, textRange.getStartOffset());
    SwingUtilities.invokeLater(() -> {
        if (editor != null && !editor.isDisposed()) {
            doSelect(toUseNormalSelection, editor, toSelectLine, textRange);
        }
    });
}
Also used : DocumentWindow(com.intellij.injected.editor.DocumentWindow) VirtualFileWindow(com.intellij.injected.editor.VirtualFileWindow) ProperTextRange(com.intellij.openapi.util.ProperTextRange) ProperTextRange(com.intellij.openapi.util.ProperTextRange) TextRange(com.intellij.openapi.util.TextRange) Editor(com.intellij.openapi.editor.Editor)

Example 2 with DocumentWindow

use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.

the class EditorActionManagerImpl method getReadonlyFragmentModificationHandler.

@Override
public ReadonlyFragmentModificationHandler getReadonlyFragmentModificationHandler(@NotNull final Document document) {
    final Document doc = document instanceof DocumentWindow ? ((DocumentWindow) document).getDelegate() : document;
    final ReadonlyFragmentModificationHandler docHandler = doc instanceof DocumentImpl ? ((DocumentImpl) doc).getReadonlyFragmentModificationHandler() : null;
    return docHandler == null ? myReadonlyFragmentsHandler : docHandler;
}
Also used : DocumentWindow(com.intellij.injected.editor.DocumentWindow) Document(com.intellij.openapi.editor.Document)

Example 3 with DocumentWindow

use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.

the class EditorFactoryImpl method createEditor.

private Editor createEditor(@NotNull Document document, boolean isViewer, Project project) {
    Document hostDocument = document instanceof DocumentWindow ? ((DocumentWindow) document).getDelegate() : document;
    EditorImpl editor = new EditorImpl(hostDocument, isViewer, project);
    myEditors.add(editor);
    myEditorEventMulticaster.registerEditor(editor);
    myEditorFactoryEventDispatcher.getMulticaster().editorCreated(new EditorFactoryEvent(this, editor));
    if (LOG.isDebugEnabled()) {
        LOG.debug("number of Editors after create: " + myEditors.size());
    }
    return editor;
}
Also used : DocumentWindow(com.intellij.injected.editor.DocumentWindow) EditorFactoryEvent(com.intellij.openapi.editor.event.EditorFactoryEvent) Document(com.intellij.openapi.editor.Document)

Example 4 with DocumentWindow

use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.

the class LightPlatformCodeInsightTestCase method bringRealEditorBack.

protected static void bringRealEditorBack() {
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    if (myEditor instanceof EditorWindow) {
        Document document = ((DocumentWindow) myEditor.getDocument()).getDelegate();
        myFile = PsiDocumentManager.getInstance(getProject()).getPsiFile(document);
        myEditor = ((EditorWindow) myEditor).getDelegate();
        myVFile = myFile.getVirtualFile();
    }
}
Also used : DocumentWindow(com.intellij.injected.editor.DocumentWindow) Document(com.intellij.openapi.editor.Document) EditorWindow(com.intellij.injected.editor.EditorWindow)

Example 5 with DocumentWindow

use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.

the class PsiDocumentManagerBase method getLastCommittedDocument.

@NotNull
public DocumentEx getLastCommittedDocument(@NotNull Document document) {
    if (document instanceof FrozenDocument)
        return (DocumentEx) document;
    if (document instanceof DocumentWindow) {
        DocumentWindow window = (DocumentWindow) document;
        Document delegate = window.getDelegate();
        if (delegate instanceof FrozenDocument)
            return (DocumentEx) window;
        if (!window.isValid()) {
            throw new AssertionError("host committed: " + isCommitted(delegate) + ", window=" + window);
        }
        UncommittedInfo info = myUncommittedInfos.get(delegate);
        DocumentWindow answer = info == null ? null : info.myFrozenWindows.get(document);
        if (answer == null)
            answer = freezeWindow(window);
        if (info != null)
            answer = ConcurrencyUtil.cacheOrGet(info.myFrozenWindows, window, answer);
        return (DocumentEx) answer;
    }
    assert document instanceof DocumentImpl;
    UncommittedInfo info = myUncommittedInfos.get(document);
    return info != null ? info.myFrozen : ((DocumentImpl) document).freeze();
}
Also used : DocumentWindow(com.intellij.injected.editor.DocumentWindow) DocumentEx(com.intellij.openapi.editor.ex.DocumentEx) FrozenDocument(com.intellij.openapi.editor.impl.FrozenDocument) Document(com.intellij.openapi.editor.Document) FrozenDocument(com.intellij.openapi.editor.impl.FrozenDocument) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DocumentWindow (com.intellij.injected.editor.DocumentWindow)42 TextRange (com.intellij.openapi.util.TextRange)18 Document (com.intellij.openapi.editor.Document)17 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)9 Project (com.intellij.openapi.project.Project)8 VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 PsiFile (com.intellij.psi.PsiFile)6 InjectedLanguageManager (com.intellij.lang.injection.InjectedLanguageManager)5 DocumentWindowImpl (com.intellij.injected.editor.DocumentWindowImpl)4 Language (com.intellij.lang.Language)4 Editor (com.intellij.openapi.editor.Editor)4 Segment (com.intellij.openapi.util.Segment)4 PsiFileImpl (com.intellij.psi.impl.source.PsiFileImpl)4 DaemonProgressIndicator (com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator)3 ASTNode (com.intellij.lang.ASTNode)3 com.intellij.psi (com.intellij.psi)3 PsiElement (com.intellij.psi.PsiElement)3 PsiDocumentManagerBase (com.intellij.psi.impl.PsiDocumentManagerBase)3