Skip to content

Commit

Permalink
fixed ijwb integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch committed Oct 9, 2024
1 parent 5bbb03a commit 4ba4f85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.nio.file.Paths;
import java.util.Map;

class SyncAspectTemplateProvider implements SyncListener {
public class SyncAspectTemplateProvider implements SyncListener {
private final Map<LanguageClass, String> supportedLanguageAspectTemplate = Map.of(
LanguageClass.JAVA, "java_info.template.bzl",
LanguageClass.GENERIC, "java_info.template.bzl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.google.idea.blaze.base.sync.aspects.BlazeIdeInterface;
import com.google.idea.blaze.base.sync.aspects.BuildResult;
import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup;
import com.google.idea.blaze.base.sync.aspects.strategy.SyncAspectTemplateProvider;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.blaze.base.sync.projectview.LanguageSupport;
import com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings;
Expand Down Expand Up @@ -120,6 +121,8 @@ public void doSetup() throws Throwable {
projectViewManager = new MockProjectViewManager(getProject());
ServiceHelper.registerExtension(
BlazeVcsHandlerProvider.EP_NAME, new MockBlazeVcsHandlerProvider(), thisClassDisposable);
ServiceHelper.unregisterExtension(
SyncListener.EP_NAME, SyncAspectTemplateProvider.class, thisClassDisposable);
blazeInfoData = new MockBlazeInfoRunner();
blazeModData = new MockBlazeModRunner();
blazeIdeInterface = new MockBlazeIdeInterface();
Expand Down
13 changes: 13 additions & 0 deletions testing/src/com/google/idea/testing/ServiceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ public static <T> void registerExtension(
ep.registerExtension(instance, parentDisposable);
}

public static <T> void unregisterExtension(
ExtensionPointName<T> name, Class<? extends T> clazz, Disposable parentDisposable) {
final var ep = name.getPoint();
for (final var extension : name.getExtensions()) {
if (!extension.getClass().equals(clazz)) {
continue;
}

ep.unregisterExtension(extension);
Disposer.register(parentDisposable, () -> ep.registerExtension(extension));
}
}

public static <T> void registerProjectExtension(
Project project, ExtensionPointName<T> name, T instance, Disposable parentDisposable) {
ExtensionPoint<T> ep = project.getExtensionArea().getExtensionPoint(name);
Expand Down

0 comments on commit 4ba4f85

Please sign in to comment.