Search in sources :

Example 1 with PsiDocumentManagerImpl

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));
    }
}
Also used : PsiDocumentManagerImpl(com.intellij.psi.impl.PsiDocumentManagerImpl) Document(com.intellij.openapi.editor.Document) Pair(com.intellij.openapi.util.Pair)

Example 2 with PsiDocumentManagerImpl

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;
}
Also used : Project(com.intellij.openapi.project.Project) PsiToDocumentSynchronizer(com.intellij.psi.impl.PsiToDocumentSynchronizer) PsiDocumentManagerImpl(com.intellij.psi.impl.PsiDocumentManagerImpl) Document(com.intellij.openapi.editor.Document) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PsiDocumentManagerImpl

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();
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsiDocumentManagerImpl(com.intellij.psi.impl.PsiDocumentManagerImpl) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Aggregations

PsiDocumentManagerImpl (com.intellij.psi.impl.PsiDocumentManagerImpl)3 Document (com.intellij.openapi.editor.Document)2 Project (com.intellij.openapi.project.Project)2 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)1 Pair (com.intellij.openapi.util.Pair)1 PsiToDocumentSynchronizer (com.intellij.psi.impl.PsiToDocumentSynchronizer)1 Nullable (org.jetbrains.annotations.Nullable)1