use of com.intellij.psi.impl.PsiDocumentManagerImpl in project intellij-community by JetBrains.
the class PsiChangeHandler method queueElement.
private void queueElement(@NotNull PsiElement child, final boolean whitespaceOptimizationAllowed, @NotNull PsiTreeChangeEvent event) {
ApplicationManager.getApplication().assertIsDispatchThread();
PsiFile file = event.getFile();
if (file == null)
file = child.getContainingFile();
if (file == null) {
myFileStatusMap.markAllFilesDirty(child);
return;
}
if (!child.isValid())
return;
PsiDocumentManagerImpl pdm = (PsiDocumentManagerImpl) PsiDocumentManager.getInstance(myProject);
Document document = pdm.getCachedDocument(file);
if (document != null) {
if (pdm.getSynchronizer().getTransaction(document) == null) {
// content reload, language level change or some other big change
myFileStatusMap.markAllFilesDirty(child);
return;
}
List<Pair<PsiElement, Boolean>> toUpdate = changedElements.get(document);
if (toUpdate == null) {
toUpdate = new SmartList<>();
changedElements.put(document, toUpdate);
}
toUpdate.add(Pair.create(child, whitespaceOptimizationAllowed));
}
}
use of com.intellij.psi.impl.PsiDocumentManagerImpl in project intellij-community by JetBrains.
the class FormattingDocumentModelImpl method getDocumentToBeUsedFor.
@Nullable
public static Document getDocumentToBeUsedFor(final PsiFile file) {
final Project project = file.getProject();
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (document == null)
return null;
if (PsiDocumentManager.getInstance(project).isUncommited(document))
return null;
PsiToDocumentSynchronizer synchronizer = ((PsiDocumentManagerImpl) PsiDocumentManager.getInstance(project)).getSynchronizer();
if (synchronizer.isDocumentAffectedByTransactions(document))
return null;
return document;
}
use of com.intellij.psi.impl.PsiDocumentManagerImpl in project intellij-community by JetBrains.
the class LightPlatformTestCase method clearUncommittedDocuments.
public static void clearUncommittedDocuments(@NotNull Project project) {
PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl) PsiDocumentManager.getInstance(project);
documentManager.clearUncommittedDocuments();
ProjectManagerImpl projectManager = (ProjectManagerImpl) ProjectManager.getInstance();
if (projectManager.isDefaultProjectInitialized()) {
Project defaultProject = projectManager.getDefaultProject();
((PsiDocumentManagerImpl) PsiDocumentManager.getInstance(defaultProject)).clearUncommittedDocuments();
}
}
Aggregations