This commit is contained in:
Alexey Kudravtsev
2012-08-13 10:08:40 +04:00
parent 7b293c4b8c
commit 2212035291
2 changed files with 18 additions and 13 deletions
@@ -62,7 +62,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
@NotNull private final VirtualFile myVirtualFile;
private final boolean myEventSystemEnabled;
private final boolean myPhysical;
@NotNull private final AtomicReference<PsiFile> myPsiFile = new AtomicReference<PsiFile>();
private final AtomicReference<PsiFile> myPsiFile = new AtomicReference<PsiFile>();
private volatile Content myContent;
private volatile SoftReference<Document> myDocument;
@NotNull private final Language myBaseLanguage;
@@ -178,7 +178,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
public void beforeDocumentChanged() {
final PsiFileImpl psiFile = (PsiFileImpl)getCachedPsi(getBaseLanguage());
if (psiFile != null && psiFile.isContentsLoaded() && getContent()instanceof DocumentContent) {
if (psiFile != null && psiFile.isContentsLoaded() && getContent() instanceof DocumentContent) {
setContent(new PsiFileContent(psiFile, getModificationStamp()));
}
}
@@ -60,6 +60,7 @@ import com.intellij.util.PatchedSoftReference;
import com.intellij.util.PatchedWeakReference;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -145,7 +146,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
if (pointer instanceof FileElement) {
return (FileElement)pointer;
}
else if (pointer instanceof Reference) {
if (pointer instanceof Reference) {
FileElement treeElement = (FileElement)((Reference)pointer).get();
if (treeElement != null) return treeElement;
@@ -185,9 +186,14 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
//return valid;
}
protected boolean isPsiUpToDate(VirtualFile vFile) {
protected boolean isPsiUpToDate(@NotNull VirtualFile vFile) {
final FileViewProvider provider = myManager.findViewProvider(vFile);
return provider.getPsi(getLanguage()) == this || provider.getPsi(provider.getBaseLanguage()) == this;
Language language = getLanguage();
if (provider.getPsi(language) == this) {
return true;
}
Language baseLanguage = provider.getBaseLanguage();
return baseLanguage != language && provider.getPsi(baseLanguage) == this;
}
@Override
@@ -977,14 +983,13 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
if (tree == null) {
IElementType contentElementType = getContentElementType();
if (!(contentElementType instanceof IStubFileElementType)) {
final StringBuilder builder = new StringBuilder();
builder.append("ContentElementType: ").append(contentElementType).append("; file: ").append(this);
builder.append("\n\t").append("Boolean.TRUE.equals(getUserData(BUILDING_STUB)) = ").append(Boolean.TRUE.equals(getUserData(BUILDING_STUB)));
builder.append("\n\t").append("getTreeElementNoLock() = ").append(getTreeElementNoLock());
final VirtualFile vFile = getVirtualFile();
builder.append("\n\t").append("vFile instanceof VirtualFileWithId = ").append(vFile instanceof VirtualFileWithId);
builder.append("\n\t").append("StubUpdatingIndex.canHaveStub(vFile) = ").append(StubTreeLoader.getInstance().canHaveStub(vFile));
LOG.error(builder.toString());
VirtualFile vFile = getVirtualFile();
@NonNls String builder = "ContentElementType: " + contentElementType + "; file: " + this +
"\n\t" + "Boolean.TRUE.equals(getUserData(BUILDING_STUB)) = " + Boolean.TRUE.equals(getUserData(BUILDING_STUB)) +
"\n\t" + "getTreeElementNoLock() = " + getTreeElementNoLock() +
"\n\t" + "vFile instanceof VirtualFileWithId = " + (vFile instanceof VirtualFileWithId) +
"\n\t" + "StubUpdatingIndex.canHaveStub(vFile) = " + StubTreeLoader.getInstance().canHaveStub(vFile);
LOG.error(builder);
}
final StubElement currentStubTree = ((IStubFileElementType)contentElementType).getBuilder().buildStubTree(this);
tree = new StubTree((PsiFileStub)currentStubTree);