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);
}
});
}
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;
}
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;
}
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();
}
}
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();
}
Aggregations