Search in sources :

Example 11 with PsiTreeChangeEventImpl

use of com.intellij.psi.impl.PsiTreeChangeEventImpl in project intellij-community by JetBrains.

the class PsiVFSListener method fileDeleted.

@Override
public void fileDeleted(@NotNull final VirtualFileEvent event) {
    final VirtualFile vFile = event.getFile();
    VirtualFile parent = event.getParent();
    final PsiDirectory parentDir = getCachedDirectory(parent);
    final PsiFile psiFile = myFileManager.getCachedPsiFileInner(vFile);
    if (psiFile != null) {
        clearViewProvider(vFile, "PSI fileDeleted");
        if (parentDir != null) {
            ApplicationManager.getApplication().runWriteAction(new ExternalChangeAction() {

                @Override
                public void run() {
                    PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(myManager);
                    treeEvent.setParent(parentDir);
                    treeEvent.setChild(psiFile);
                    myManager.childRemoved(treeEvent);
                }
            });
        } else if (parent != null) {
            handleVfsChangeWithoutPsi(parent);
        }
    } else {
        final PsiDirectory psiDir = myFileManager.getCachedDirectory(vFile);
        if (psiDir != null) {
            myFileManager.removeInvalidFilesAndDirs(false);
            if (parentDir != null) {
                ApplicationManager.getApplication().runWriteAction(new ExternalChangeAction() {

                    @Override
                    public void run() {
                        PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(myManager);
                        treeEvent.setParent(parentDir);
                        treeEvent.setChild(psiDir);
                        myManager.childRemoved(treeEvent);
                    }
                });
            }
        } else if (parent != null) {
            handleVfsChangeWithoutPsi(parent);
        }
    }
}
Also used : PsiTreeChangeEventImpl(com.intellij.psi.impl.PsiTreeChangeEventImpl)

Aggregations

PsiTreeChangeEventImpl (com.intellij.psi.impl.PsiTreeChangeEventImpl)11 ASTNode (com.intellij.lang.ASTNode)1 TextRange (com.intellij.openapi.util.TextRange)1 ChangeInfo (com.intellij.pom.tree.events.ChangeInfo)1 ReplaceChangeInfo (com.intellij.pom.tree.events.ReplaceChangeInfo)1 TreeChange (com.intellij.pom.tree.events.TreeChange)1 ChangeInfoImpl (com.intellij.pom.tree.events.impl.ChangeInfoImpl)1 TreeChangeImpl (com.intellij.pom.tree.events.impl.TreeChangeImpl)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 PsiManagerImpl (com.intellij.psi.impl.PsiManagerImpl)1