Search in sources :

Example 1 with BlazeCommandRunConfigurationHandlerProvider

use of com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider in project intellij by bazelbuild.

the class BlazeCommandRunConfiguration method updateHandler.

private void updateHandler() {
    BlazeCommandRunConfigurationHandlerProvider handlerProvider = BlazeCommandRunConfigurationHandlerProvider.findHandlerProvider(targetKind);
    updateHandlerIfDifferentProvider(handlerProvider);
}
Also used : BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider)

Example 2 with BlazeCommandRunConfigurationHandlerProvider

use of com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider in project intellij by bazelbuild.

the class BlazeCommandRunConfiguration method readExternal.

@Override
public void readExternal(Element element) throws InvalidDataException {
    sanitizeCorruptedDefaultRunConfiguration(element);
    super.readExternal(element);
    element = element.clone();
    String keepInSyncString = element.getAttributeValue(KEEP_IN_SYNC_TAG);
    keepInSync = keepInSyncString != null ? Boolean.parseBoolean(keepInSyncString) : null;
    // Target is persisted as a tag to permit multiple targets in the future.
    Element targetElement = element.getChild(TARGET_TAG);
    if (targetElement != null && !Strings.isNullOrEmpty(targetElement.getTextTrim())) {
        targetPattern = targetElement.getTextTrim();
        targetKind = Kind.fromString(targetElement.getAttributeValue(KIND_ATTR));
    }
    // Because BlazeProjectData is not available when configurations are loading,
    // we can't call setTarget and have it find the appropriate handler provider.
    // So instead, we use the stored provider ID.
    String providerId = element.getAttributeValue(HANDLER_ATTR);
    BlazeCommandRunConfigurationHandlerProvider handlerProvider = BlazeCommandRunConfigurationHandlerProvider.getHandlerProvider(providerId);
    if (handlerProvider != null) {
        updateHandlerIfDifferentProvider(handlerProvider);
    }
    element.removeAttribute(KIND_ATTR);
    element.removeAttribute(HANDLER_ATTR);
    element.removeChildren(TARGET_TAG);
    element.removeAttribute(KEEP_IN_SYNC_TAG);
    // remove legacy attribute, if present
    element.removeAttribute(TARGET_TAG);
    this.elementState = element;
    handler.getState().readExternal(elementState);
}
Also used : BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider) Element(org.jdom.Element)

Example 3 with BlazeCommandRunConfigurationHandlerProvider

use of com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider in project intellij by bazelbuild.

the class BlazeJavaRunProfileStateTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager());
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    ExperimentService experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    applicationServices.register(BlazeUserSettings.class, new BlazeUserSettings());
    projectServices.register(FastBuildService.class, new DisabledFastBuildService());
    projectServices.register(ProjectViewManager.class, new MockProjectViewManager());
    ExtensionPointImpl<TargetFinder> targetFinderEp = registerExtensionPoint(TargetFinder.EP_NAME, TargetFinder.class);
    targetFinderEp.registerExtension(new MockTargetFinder());
    ExtensionPointImpl<JavaLikeLanguage> javaLikeEp = registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class);
    javaLikeEp.registerExtension(new JavaLikeLanguage.Java());
    registerExtensionPoint(BuildFlagsProvider.EP_NAME, BuildFlagsProvider.class);
    ExtensionPointImpl<BlazeCommandRunConfigurationHandlerProvider> handlerProviderEp = registerExtensionPoint(BlazeCommandRunConfigurationHandlerProvider.EP_NAME, BlazeCommandRunConfigurationHandlerProvider.class);
    handlerProviderEp.registerExtension(new BlazeJavaRunConfigurationHandlerProvider());
    handlerProviderEp.registerExtension(new BlazeCommandGenericRunConfigurationHandlerProvider());
    ExtensionPointImpl<BuildSystemProvider> buildSystemProviderExtensionPoint = registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
    BuildSystemProvider buildSystemProvider = mock(BuildSystemProvider.class);
    when(buildSystemProvider.getBinaryPath()).thenReturn("/usr/bin/blaze");
    buildSystemProviderExtensionPoint.registerExtension(buildSystemProvider);
    configuration = new BlazeCommandRunConfigurationType().getFactory().createTemplateConfiguration(project);
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BlazeCommandGenericRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandGenericRunConfigurationHandlerProvider) TargetFinder(com.google.idea.blaze.base.run.targetfinder.TargetFinder) BlazeCommandRunConfigurationType(com.google.idea.blaze.base.run.BlazeCommandRunConfigurationType) BlazeUserSettings(com.google.idea.blaze.base.settings.BlazeUserSettings) ExperimentService(com.google.idea.common.experiments.ExperimentService) MockExperimentService(com.google.idea.common.experiments.MockExperimentService)

Example 4 with BlazeCommandRunConfigurationHandlerProvider

use of com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider in project intellij by bazelbuild.

the class TestRecorderBlazeCommandRunConfigurationTest method doSetup.

@Before
public final void doSetup() {
    runManager = RunManagerImpl.getInstanceImpl(getProject());
    // Without BlazeProjectData, the configuration editor is always disabled.
    BlazeProjectDataManager mockProjectDataManager = new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder(workspaceRoot).build());
    registerProjectService(BlazeProjectDataManager.class, mockProjectDataManager);
    BlazeCommandRunConfigurationHandlerProvider mockHandler = new MockBlazeAndroidBinaryRunConfigurationHandlerProvider();
    ExtensionPoint<BlazeCommandRunConfigurationHandlerProvider> ep = Extensions.getRootArea().getExtensionPoint(BlazeCommandRunConfigurationHandlerProvider.EP_NAME);
    ep.registerExtension(mockHandler, LoadingOrder.FIRST);
    Disposer.register(getTestRootDisposable(), () -> ep.unregisterExtension(mockHandler));
    MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
    builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind(Kind.ANDROID_BINARY).setLabel("//label:android_binary_rule").build()).addTarget(TargetIdeInfo.builder().setKind(Kind.ANDROID_TEST).setLabel("//label:android_test_rule").build()).build());
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
}
Also used : BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Before(org.junit.Before)

Example 5 with BlazeCommandRunConfigurationHandlerProvider

use of com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider in project intellij by bazelbuild.

the class BlazeCommandRunConfigurationTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(UISettings.class, new UISettings());
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager());
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    ExtensionPointImpl<TargetFinder> targetFinderEp = registerExtensionPoint(TargetFinder.EP_NAME, TargetFinder.class);
    targetFinderEp.registerExtension(new MockTargetFinder());
    ExtensionPointImpl<BlazeCommandRunConfigurationHandlerProvider> handlerProviderEp = registerExtensionPoint(BlazeCommandRunConfigurationHandlerProvider.EP_NAME, BlazeCommandRunConfigurationHandlerProvider.class);
    handlerProviderEp.registerExtension(new MockBlazeCommandRunConfigurationHandlerProvider());
    this.configuration = this.type.getFactory().createTemplateConfiguration(project);
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) TargetFinder(com.google.idea.blaze.base.run.targetfinder.TargetFinder) UISettings(com.intellij.ide.ui.UISettings) BlazeCommandRunConfigurationHandlerProvider(com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider)

Aggregations

BlazeCommandRunConfigurationHandlerProvider (com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationHandlerProvider)5 TargetFinder (com.google.idea.blaze.base.run.targetfinder.TargetFinder)2 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)2 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)2 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)1 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)1 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)1 BlazeCommandRunConfigurationType (com.google.idea.blaze.base.run.BlazeCommandRunConfigurationType)1 BlazeCommandGenericRunConfigurationHandlerProvider (com.google.idea.blaze.base.run.confighandler.BlazeCommandGenericRunConfigurationHandlerProvider)1 BlazeUserSettings (com.google.idea.blaze.base.settings.BlazeUserSettings)1 BlazeProjectDataManager (com.google.idea.blaze.base.sync.data.BlazeProjectDataManager)1 JavaLikeLanguage (com.google.idea.blaze.java.sync.source.JavaLikeLanguage)1 ExperimentService (com.google.idea.common.experiments.ExperimentService)1 UISettings (com.intellij.ide.ui.UISettings)1 Element (org.jdom.Element)1 Before (org.junit.Before)1