mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
change p.s.i. for light file on the fly
This commit is contained in:
@@ -41,6 +41,7 @@ import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.file.PsiBinaryFileImpl;
|
||||
import com.intellij.psi.impl.file.PsiLargeFileImpl;
|
||||
import com.intellij.psi.impl.file.impl.FileManager;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.PsiPlainTextFileImpl;
|
||||
import com.intellij.psi.impl.source.tree.FileElement;
|
||||
@@ -134,7 +135,11 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
@Nullable
|
||||
public final PsiFile getPsi(@NotNull Language target) {
|
||||
if (!isPhysical()) {
|
||||
((PsiManagerEx)myManager).getFileManager().setViewProvider(getVirtualFile(), this);
|
||||
FileManager fileManager = ((PsiManagerEx)myManager).getFileManager();
|
||||
VirtualFile virtualFile = getVirtualFile();
|
||||
if (fileManager.findCachedViewProvider(virtualFile) == null) {
|
||||
fileManager.setViewProvider(virtualFile, this);
|
||||
}
|
||||
}
|
||||
return getPsiInner(target);
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
FileViewProvider provider = getViewProvider();
|
||||
final VirtualFile vFile = provider.getVirtualFile();
|
||||
if (!vFile.isValid()) return false;
|
||||
if (!provider.isPhysical()) return true; // "dummy" file
|
||||
if (!provider.isEventSystemEnabled()) return true; // "dummy" file
|
||||
if (myManager.getProject().isDisposed()) return false;
|
||||
return isPsiUpToDate(vFile);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
protected boolean isPsiUpToDate(@NotNull VirtualFile vFile) {
|
||||
final FileViewProvider provider = myManager.findViewProvider(vFile);
|
||||
Language language = getLanguage();
|
||||
if (provider.getPsi(language) == this) {
|
||||
if (provider == null || provider.getPsi(language) == this) { // provider == null in tests
|
||||
return true;
|
||||
}
|
||||
Language baseLanguage = provider.getBaseLanguage();
|
||||
|
||||
Reference in New Issue
Block a user