added before event firing
authorAlexey Kudravtsev <cdr@intellij.com>
Wed, 21 Apr 2010 13:12:08 +0000 (17:12 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Thu, 22 Apr 2010 12:28:44 +0000 (16:28 +0400)
platform/lang-api/src/com/intellij/util/FileContentUtil.java
platform/platform-api/src/com/intellij/openapi/vfs/VirtualFile.java

index 5cf631476812dcf1d088d0f9a71f766ef893d295..d627f9c153004ec0b99b5c142ba3253e65d58da7 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiManager;
 import gnu.trove.THashSet;
+import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -42,7 +43,7 @@ import java.util.Set;
  * @author peter
  */
 public class FileContentUtil {
-  public static final String FORCE_RELOAD_REQUESTOR = "FileContentUtil.saveOrReload";
+  @NonNls public static final String FORCE_RELOAD_REQUESTOR = "FileContentUtil.saveOrReload";
 
   private FileContentUtil() {
   }
@@ -67,23 +68,23 @@ public class FileContentUtil {
   }
 
   public static void reparseFiles(@NotNull final Project project, @NotNull final Collection<VirtualFile> files, boolean includeOpenFiles) {
-    final Set<VFilePropertyChangeEvent> list = new THashSet<VFilePropertyChangeEvent>();
+    final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
     for (VirtualFile file : files) {
-      saveOrReload(file, list);
+      saveOrReload(file, events);
     }
     if (includeOpenFiles) {
       for (VirtualFile open : FileEditorManager.getInstance(project).getOpenFiles()) {
         if (!files.contains(open)) {
-          saveOrReload(open, list);
+          saveOrReload(open, events);
         }
       }
     }
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       public void run() {
         ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
-            .before(new ArrayList<VFileEvent>(list));
+            .before(new ArrayList<VFileEvent>(events));
         ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
-            .after(new ArrayList<VFileEvent>(list));
+            .after(new ArrayList<VFileEvent>(events));
       }
     });
   }
index f60217bfd97a6d1f24a5a7b8c6a119795a557676..5f4c0337dda3f52dc9e49cac8fcbe4567250f5b6 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager;
 import com.intellij.openapi.util.*;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.encoding.EncodingManager;
+import com.intellij.openapi.vfs.newvfs.BulkFileListener;
 import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
 import com.intellij.util.Icons;
 import org.jetbrains.annotations.NonNls;
@@ -36,6 +37,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.charset.Charset;
 import java.util.Collections;
+import java.util.List;
 
 /**
  * Represents a file in <code>{@link VirtualFileSystem}</code>. A particular file is represented by the same
@@ -451,7 +453,10 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
           if (isValid() && !application.isDisposed()) {
             application.runWriteAction(new Runnable(){
               public void run() {
-                application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES).after(Collections.singletonList(new VFilePropertyChangeEvent(this, VirtualFile.this, PROP_ENCODING, old, charset, false)));
+                List<VFilePropertyChangeEvent> events = Collections.singletonList(new VFilePropertyChangeEvent(this, VirtualFile.this, PROP_ENCODING, old, charset, false));
+                BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
+                listener.before(events);
+                listener.after(events);
               }
             });
           }