use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.
the class PsiDocumentManagerBase method finishCommitInWriteAction.
protected boolean finishCommitInWriteAction(@NotNull final Document document, @NotNull final List<Processor<Document>> finishProcessors, final boolean synchronously) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myProject.isDisposed())
return false;
assert !(document instanceof DocumentWindow);
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
if (virtualFile != null) {
getSmartPointerManager().fastenBelts(virtualFile);
}
FileViewProvider viewProvider = getCachedViewProvider(document);
myIsCommitInProgress = true;
boolean success = true;
try {
if (viewProvider != null) {
success = commitToExistingPsi(document, finishProcessors, synchronously, virtualFile, viewProvider);
} else {
handleCommitWithoutPsi(document);
}
} catch (Throwable e) {
forceReload(virtualFile, viewProvider);
LOG.error(e);
} finally {
if (success) {
myUncommittedDocuments.remove(document);
}
myIsCommitInProgress = false;
}
return success;
}
use of com.intellij.injected.editor.DocumentWindow in project intellij-community by JetBrains.
the class SingleRootFileViewProvider method checkLengthConsistency.
private void checkLengthConsistency() {
Document document = getCachedDocument();
if (document instanceof DocumentWindow) {
return;
}
if (document != null && ((PsiDocumentManagerBase) PsiDocumentManager.getInstance(myManager.getProject())).getSynchronizer().isInSynchronization(document)) {
return;
}
List<FileElement> knownTreeRoots = getKnownTreeRoots();
if (knownTreeRoots.isEmpty())
return;
int fileLength = myContent.getTextLength();
for (FileElement fileElement : knownTreeRoots) {
int nodeLength = fileElement.getTextLength();
if (nodeLength != fileLength) {
PsiUtilCore.ensureValid(fileElement.getPsi());
List<Attachment> attachments = ContainerUtil.newArrayList(new Attachment(myVirtualFile.getNameWithoutExtension() + ".tree.txt", fileElement.getText()), new Attachment(myVirtualFile.getNameWithoutExtension() + ".file.txt", myContent.toString()));
if (document != null) {
attachments.add(new Attachment(myVirtualFile.getNameWithoutExtension() + ".document.txt", document.getText()));
}
// exceptions here should be assigned to peter
LOG.error("Inconsistent " + fileElement.getElementType() + " tree in " + this + "; nodeLength=" + nodeLength + "; fileLength=" + fileLength, attachments.toArray(Attachment.EMPTY_ARRAY));
}
}
}
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;
}
Aggregations