Skip to content

Commit

Permalink
Add EP to extend external modules (#6467)
Browse files Browse the repository at this point in the history
Added an EP to give the feasibility to allow other modules. For example, when maven modules are added into project view bazel sync resets the view as they have different content root. An implementation could be added to allow maven modules to be shown in project tree view.
  • Loading branch information
gchandu25 authored Jun 13, 2024
1 parent ca9c95e commit 56fc692
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions base/src/META-INF/blaze-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@
interface="com.google.idea.blaze.base.qsync.BlazeProjectListenerProvider"/>
<extensionPoint qualifiedName="com.google.idea.blaze.base.qsync.ProjectProtoTransformProvider"
interface="com.google.idea.blaze.base.qsync.ProjectProtoTransformProvider"/>
<extensionPoint qualifiedName="com.google.idea.blaze.base.sync.projectstructure.ExternalModuleProvider"
interface="com.google.idea.blaze.base.sync.projectstructure.ExternalModuleProvider"/>

</extensionPoints>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.google.idea.blaze.base.sync.projectstructure;

import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.module.Module;

/**
* An EP provider for external modules.
*/
public interface ExternalModuleProvider {
ExtensionPointName<ExternalModuleProvider> EP_NAME =
ExtensionPointName.create("com.google.idea.blaze.base.sync.projectstructure.ExternalModuleProvider");

boolean isOwnedByExternalPlugin(Module module);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.intellij.openapi.roots.impl.ModifiableModelCommitter;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;

import java.io.File;
import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -118,8 +119,9 @@ public Module findModule(String moduleName) {
public void commitWithGc(BlazeContext context) {
List<Module> orphanModules = Lists.newArrayList();
for (Module module : ModuleManager.getInstance(project).getModules()) {
if (!modules.containsKey(module.getName())) {
orphanModules.add(module);
if (!modules.containsKey(module.getName())
&& !ExternalModuleProvider.EP_NAME.getExtensionList().stream().anyMatch(n -> n.isOwnedByExternalPlugin(module))) {
orphanModules.add(module);
}
}
if (orphanModules.size() > 0) {
Expand Down

0 comments on commit 56fc692

Please sign in to comment.