This commit is contained in:
Alexey Kudravtsev
2012-01-26 13:24:51 +04:00
parent 50bffafe2b
commit 2a554d19e0
3 changed files with 13 additions and 9 deletions
@@ -86,8 +86,7 @@ class InjectedSelfElementInfo extends SelfElementInfo {
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(hostFile.getProject());
Document document = documentManager.getDocument(hostFile);
if (document != null && documentManager.isUncommited(document)) {
List<DocumentWindow> documents = InjectedLanguageUtil.getCachedInjectedDocuments(hostFile);
for (DocumentWindow documentWindow : documents) {
for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(hostFile)) {
PsiFile injected = documentManager.getPsiFile(documentWindow);
if (injected != null) {
visitor.visit(injected, Collections.<PsiLanguageInjectionHost.Shred>emptyList());
@@ -143,7 +143,9 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme
RangeMarker rangeMarker = documentWindow.getHostRanges()[0];
PsiElement element = rangeMarker.isValid() ? hostPsiFile.findElementAt(rangeMarker.getStartOffset()) : null;
if (element == null) {
injected.remove(documentWindow);
synchronized (PsiLock.LOCK) {
injected.remove(documentWindow);
}
return true;
}
final DocumentWindow[] stillInjectedDocument = {null};
@@ -155,12 +157,14 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme
PsiDocumentManagerImpl.checkConsistency(injectedPsi, stillInjectedDocument[0]);
}
});
if (stillInjectedDocument[0] == null) {
injected.remove(documentWindow);
}
else if (stillInjectedDocument[0] != documentWindow) {
injected.remove(documentWindow);
injected.add(stillInjectedDocument[0]);
synchronized (PsiLock.LOCK) {
if (stillInjectedDocument[0] == null) {
injected.remove(documentWindow);
}
else if (stillInjectedDocument[0] != documentWindow) {
injected.remove(documentWindow);
injected.add(stillInjectedDocument[0]);
}
}
return true;
@@ -385,6 +385,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
TreeUtil.clearCaches((TreeElement)parsedNode);
}
// under com.intellij.psi.PsiLock.LOCK
private static PsiFile registerDocument(final DocumentWindowImpl documentWindow,
final PsiFile injectedPsi,
final Place shreds,