Add log info when roots are changed
Make it clear how `project roots have changed` are triggered by the Bazel plugin. See for more context.
@@ -33,6 +33,7 @@ import com.google.idea.blaze.base.vcs.VcsSyncListener;
import com.google.idea.common.util.Transactions;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.AdditionalLibraryRootsProvider;
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
@@ -50,6 +51,8 @@ import javax.annotation.Nullable;
* updates individual {@link VirtualFile} entries in response to VFS events.
*/
public class ExternalLibraryManager implements Disposable {
+
+ private static final Logger logger = Logger.getInstance(ExternalLibraryManager.class);
private final Project project;
private volatile boolean duringBlazeSync;
private volatile ImmutableMap<
@@ -135,10 +138,13 @@ public class ExternalLibraryManager implements Disposable {
manager.initialize(blazeProjectData);
manager.duringBlazeSync = false;
if (!manager.libraries.isEmpty()) {
+ // TODO(b/192431174): Consider not triggering `project roots have changed` events.
+ logger.info(
+ "External libraries have been attached to the project. Triggering a `project roots"
+ + " have changed` event so the external libraries can be indexed.");
Transactions.submitWriteActionTransaction(
manager,
() ->
- // notify that roots changed so the external libraries can be indexed
ProjectRootManagerEx.getInstanceEx(project)
.makeRootsChange(() -> {}, /* fileTypes= */ false, /* fireEvents= */ true));
}
