Skip to content

Commit

Permalink
Add EP to extend external modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gchandu25 committed Jun 9, 2024
1 parent 82e447d commit c9d51b0
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.ModuleValidator"
interface="com.google.idea.blaze.base.sync.projectstructure.ModuleValidator"/>

</extensionPoints>

Expand Down
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())
&& (ModuleValidator.EP_NAME.getExtensionList().isEmpty() || !ModuleValidator.EP_NAME.getExtensionList().stream().anyMatch(n -> n.hasOtherContentRoot(module)))) {
orphanModules.add(module);
}
}
if (orphanModules.size() > 0) {
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;

/**
* Finds if the module is an orphan module, to be not shown in project tree view.
*/
public interface ModuleValidator {
ExtensionPointName<ModuleValidator> EP_NAME =
ExtensionPointName.create("com.google.idea.blaze.base.sync.projectstructure.ModuleValidator");

boolean isOrphanModule(Module module);
}

0 comments on commit c9d51b0

Please sign in to comment.