From cbf1c1e29dc4946d9ac90f98cc31df99d5cc145b Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 1 May 2014 08:26:45 +0200 Subject: [PATCH] ensure pushers are run before initial indexing, don't rely on chance --- .../impl/PushedFilePropertiesUpdater.java | 35 ++++++++++--------- .../FileBasedIndexProjectHandler.java | 3 ++ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java index 758d836cf402..4a24e34022e6 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java @@ -79,10 +79,6 @@ public class PushedFilePropertiesUpdater { StartupManager.getInstance(project).registerPreStartupActivity(new Runnable() { @Override public void run() { - long l = System.currentTimeMillis(); - pushAll(myPushers); - LOG.info("File properties pushed in " + (System.currentTimeMillis() - l) + " ms"); - final MessageBusConnection connection = bus.connect(); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override @@ -121,23 +117,28 @@ public class PushedFilePropertiesUpdater { doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex()); } })); - for (final FilePropertyPusher pusher : myPushers) { - pusher.initExtra(project, bus, new FilePropertyPusher.Engine() { - @Override - public void pushAll() { - PushedFilePropertiesUpdater.this.pushAll(pusher); - } - - @Override - public void pushRecursively(VirtualFile file, Project project) { - PushedFilePropertiesUpdater.this.schedulePushRecursively(file, pusher); - } - }); - } } }); } + public void initializeProperties() { + pushAll(myPushers); + + for (final FilePropertyPusher pusher : myPushers) { + pusher.initExtra(myProject, myProject.getMessageBus(), new FilePropertyPusher.Engine() { + @Override + public void pushAll() { + PushedFilePropertiesUpdater.this.pushAll(pusher); + } + + @Override + public void pushRecursively(VirtualFile file, Project project) { + PushedFilePropertiesUpdater.this.schedulePushRecursively(file, pusher); + } + }); + } + } + private void schedulePushRecursively(final VirtualFile dir, final FilePropertyPusher... pushers) { if (pushers.length == 0) return; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java index c79aca0c1aaf..2ece1842ecac 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -32,6 +32,7 @@ import com.intellij.openapi.roots.ContentIterator; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.roots.impl.ProjectRootManagerComponent; +import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; @@ -72,6 +73,8 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple startupManager.registerPreStartupActivity(new Runnable() { @Override public void run() { + PushedFilePropertiesUpdater.getInstance(project).initializeProperties(); + // dumb mode should start before post-startup activities // only when queueTask is called from UI thread, we can guarantee that // when the method returns, the application has entered dumb mode