mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PsiToDocumentSynchronizer shouldn't be the first one to load AST
e.g. for file-level childrenChanged event AST may be missing, and that's OK
This commit is contained in:
@@ -72,7 +72,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
private void checkPsiModificationAllowed(@NotNull final PsiTreeChangeEvent event) {
|
||||
if (!toProcessPsiEvent()) return;
|
||||
final PsiFile psiFile = event.getFile();
|
||||
if (psiFile == null || psiFile.getNode() == null) return;
|
||||
if (!(psiFile instanceof PsiFileEx) || !((PsiFileEx)psiFile).isContentsLoaded()) return;
|
||||
|
||||
final Document document = myPsiDocumentManager.getCachedDocument(psiFile);
|
||||
if (document != null && myPsiDocumentManager.isUncommited(document)) {
|
||||
@@ -91,7 +91,7 @@ public class PsiToDocumentSynchronizer extends PsiTreeChangeAdapter {
|
||||
private void doSync(@NotNull final PsiTreeChangeEvent event, boolean force, @NotNull final DocSyncAction syncAction) {
|
||||
if (!toProcessPsiEvent()) return;
|
||||
final PsiFile psiFile = event.getFile();
|
||||
if (psiFile == null || psiFile.getNode() == null) return;
|
||||
if (!(psiFile instanceof PsiFileEx) || !((PsiFileEx)psiFile).isContentsLoaded()) return;
|
||||
|
||||
final DocumentEx document = getCachedDocument(psiFile, force);
|
||||
if (document == null) return;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.command.impl.UndoManagerImpl;
|
||||
@@ -59,6 +60,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
|
||||
private PsiToDocumentSynchronizer synchronizer;
|
||||
private Document document;
|
||||
private PsiFile psiFile;
|
||||
private FileASTNode fileNode;
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
@@ -96,6 +98,16 @@ public class RangeMarkerTest extends LightPlatformTestCase {
|
||||
synchronizer = documentManager.getSynchronizer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
documentManager = null;
|
||||
synchronizer = null;
|
||||
psiFile = null;
|
||||
fileNode = null;
|
||||
document = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testCreation() throws Exception {
|
||||
RangeMarker marker = createMarker("0123456789", 2, 5);
|
||||
|
||||
@@ -940,6 +952,7 @@ public class RangeMarkerTest extends LightPlatformTestCase {
|
||||
|
||||
private RangeMarkerEx createMarker(String text, final int start, final int end) {
|
||||
psiFile = createFile("x.txt", text);
|
||||
fileNode = psiFile.getNode(); // the node should be loaded, otherwise PsiToDocumentSynchronizer will ignore our commands
|
||||
return createMarker(psiFile, start, end);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user