mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cls files should become invalid after their view provider removal
This commit is contained in:
@@ -100,6 +100,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
private volatile ClsPackageStatementImpl myPackageStatement = null;
|
||||
private volatile LanguageLevel myLanguageLevel = null;
|
||||
private boolean myIsPhysical = true;
|
||||
private boolean myInvalidated;
|
||||
|
||||
public ClsFileImpl(@NotNull FileViewProvider viewProvider) {
|
||||
this(viewProvider, false);
|
||||
@@ -148,7 +149,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return myIsForDecompiling || getVirtualFile().isValid();
|
||||
return !myInvalidated && (myIsForDecompiling || getVirtualFile().isValid());
|
||||
}
|
||||
|
||||
protected boolean isForDecompiling() {
|
||||
@@ -516,6 +517,11 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
myLanguageLevel = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markInvalidated() {
|
||||
myInvalidated = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInfo(@NotNull Map<String, String> info) {
|
||||
PsiFileImpl.putInfo(this, info);
|
||||
|
||||
@@ -183,8 +183,8 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
if (alreadyCreated == psiFile) {
|
||||
LOG.error(this + ".createFile() must create new file instance but got the same: " + psiFile);
|
||||
}
|
||||
if (psiFile instanceof PsiFileImpl) {
|
||||
((PsiFileImpl)psiFile).markInvalidated();
|
||||
if (psiFile instanceof PsiFileEx) {
|
||||
((PsiFileEx)psiFile).markInvalidated();
|
||||
}
|
||||
psiFile = alreadyCreated;
|
||||
}
|
||||
@@ -526,8 +526,8 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
|
||||
public void forceCachedPsi(@NotNull PsiFile psiFile) {
|
||||
PsiFile prev = myPsiFile.getAndSet(psiFile);
|
||||
if (prev != null && prev != psiFile && prev instanceof PsiFileImpl) {
|
||||
((PsiFileImpl)prev).markInvalidated();
|
||||
if (prev != null && prev != psiFile && prev instanceof PsiFileEx) {
|
||||
((PsiFileEx)prev).markInvalidated();
|
||||
}
|
||||
((PsiManagerEx)myManager).getFileManager().setViewProvider(getVirtualFile(), this);
|
||||
}
|
||||
@@ -572,8 +572,8 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
|
||||
public void markInvalidated() {
|
||||
PsiFile psiFile = getCachedPsi(myBaseLanguage);
|
||||
if (psiFile instanceof PsiFileImpl) {
|
||||
((PsiFileImpl)psiFile).markInvalidated();
|
||||
if (psiFile instanceof PsiFileEx) {
|
||||
((PsiFileEx)psiFile).markInvalidated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface PsiFileEx extends PsiFile{
|
||||
|
||||
boolean isContentsLoaded();
|
||||
void onContentReload();
|
||||
|
||||
void markInvalidated();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFile
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.LightPsiFileImpl");
|
||||
private PsiFile myOriginalFile = null;
|
||||
private boolean myExplicitlySetAsValid = false;
|
||||
private boolean myInvalidated = false;
|
||||
private final FileViewProvider myViewProvider;
|
||||
private final PsiManagerImpl myManager;
|
||||
private final Language myLanguage;
|
||||
@@ -62,6 +63,7 @@ public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFile
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
if (myInvalidated) return false;
|
||||
if (!getViewProvider().isPhysical() || myExplicitlySetAsValid) return true; // "dummy" file
|
||||
return getViewProvider().getVirtualFile().isValid();
|
||||
}
|
||||
@@ -378,4 +380,9 @@ public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFile
|
||||
public PsiElement getContext() {
|
||||
return FileContextUtil.getFileContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markInvalidated() {
|
||||
myInvalidated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user