injection assertions: compare psi with committed document text

This commit is contained in:
peter
2016-04-01 11:13:01 +02:00
parent 7a3ccdacf6
commit 3868ac3443
@@ -214,7 +214,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
addToResults(new Place(shreds), null);
return;
}
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(myProject);
Place place = new Place(shreds);
DocumentWindowImpl documentWindow = new DocumentWindowImpl(myHostDocument, isOneLineEditor, place);
@@ -237,7 +237,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
assert parsedNode instanceof FileElement : "Parsed to "+parsedNode+" instead of FileElement";
String documentText = documentWindow.getText();
String documentText = documentManager.getLastCommittedDocument(documentWindow).getText();
assert ((FileElement)parsedNode).textMatches(outChars) : exceptionContext("Before patch: doc:\n'" + documentText + "'\n---PSI:\n'" + parsedNode.getText() + "'\n---chars:\n'"+outChars+"'");
viewProvider.setPatchingLeaves(true);
@@ -362,7 +362,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
return node;
}
private void assertEverythingIsAllright(PsiDocumentManager documentManager, DocumentWindowImpl documentWindow, PsiFile psiFile) {
private void assertEverythingIsAllright(PsiDocumentManagerBase documentManager, DocumentWindowImpl documentWindow, PsiFile psiFile) {
boolean isAncestor = false;
for (PsiLanguageInjectionHost.Shred shred : shreds) {
PsiLanguageInjectionHost host = shred.getHost();
@@ -372,14 +372,15 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
InjectedFileViewProvider injectedFileViewProvider = (InjectedFileViewProvider)psiFile.getViewProvider();
assert injectedFileViewProvider.isValid() : "Invalid view provider: "+injectedFileViewProvider;
assert psiFile.textMatches(documentWindow.getText()) : "Document window text mismatch";
DocumentEx frozenWindow = documentManager.getLastCommittedDocument(documentWindow);
assert psiFile.textMatches(frozenWindow.getText()) : "Document window text mismatch";
assert injectedFileViewProvider.getDocument() == documentWindow : "Provider document mismatch";
assert documentManager.getCachedDocument(psiFile) == documentWindow : "Cached document mismatch";
assert Comparing.equal(psiFile.getVirtualFile(), injectedFileViewProvider.getVirtualFile()) : "Virtual file mismatch: " +
psiFile.getVirtualFile() +
"; " +
injectedFileViewProvider.getVirtualFile();
PsiDocumentManagerBase.checkConsistency(psiFile, documentWindow);
PsiDocumentManagerBase.checkConsistency(psiFile, frozenWindow);
}
void addToResults(Place place, PsiFile psiFile, MultiHostRegistrarImpl from) {