Search in sources :

Example 1 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class AddSourceToProjectHelper method findBlazePackagePath.

@Nullable
private static WorkspacePath findBlazePackagePath(Project project, WorkspacePath source) {
    WorkspacePathResolver pathResolver = WorkspacePathResolverProvider.getInstance(project).getPathResolver();
    if (pathResolver == null) {
        return null;
    }
    BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
    while (source != null) {
        if (provider.findBuildFileInDirectory(pathResolver.resolveToFile(source)) != null) {
            return source;
        }
        source = source.getParent();
    }
    return null;
}
Also used : BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) Nullable(javax.annotation.Nullable)

Example 2 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class BuildTargetFinderTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(FileOperationProvider.class, fileOperationProvider);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    applicationServices.register(BlazeImportSettingsManager.class, mock(BlazeImportSettingsManager.class));
    ExtensionPoint<BuildSystemProvider> extensionPoint = registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
    extensionPoint.registerExtension(new BazelBuildSystemProvider());
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)

Example 3 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider 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 BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class GenerateFromBuildFileSelectProjectViewOption method chooseWorkspacePath.

private void chooseWorkspacePath() {
    BuildSystemProvider buildSystem = BuildSystemProvider.getBuildSystemProvider(builder.getBuildSystem());
    assert buildSystem != null;
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false).withShowHiddenFiles(// Show root project view file
    true).withHideIgnored(false).withTitle("Select BUILD File").withDescription("Select a BUILD file to synthesize a project view from.").withFileFilter(virtualFile -> buildSystem.isBuildFile(virtualFile.getName()));
    FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
    WorkspacePathResolver workspacePathResolver = builder.getWorkspaceOption().getWorkspacePathResolver();
    File fileBrowserRoot = builder.getWorkspaceOption().getFileBrowserRoot();
    File startingLocation = fileBrowserRoot;
    String buildFilePath = getBuildFilePath();
    if (!buildFilePath.isEmpty() && WorkspacePath.isValid(buildFilePath)) {
        // If the user has typed part of the path then clicked the '...', try to start from the
        // partial state
        buildFilePath = StringUtil.trimEnd(buildFilePath, '/');
        if (WorkspacePath.isValid(buildFilePath)) {
            File fileLocation = workspacePathResolver.resolveToFile(new WorkspacePath(buildFilePath));
            if (fileLocation.exists() && FileUtil.isAncestor(fileBrowserRoot, fileLocation, true)) {
                startingLocation = fileLocation;
            }
        }
    }
    VirtualFile toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(startingLocation.getPath());
    VirtualFile[] files = chooser.choose(null, toSelect);
    if (files.length == 0) {
        return;
    }
    VirtualFile file = files[0];
    if (!FileUtil.isAncestor(fileBrowserRoot.getPath(), file.getPath(), true)) {
        Messages.showErrorDialog(String.format("You must choose a BUILD file under %s.", fileBrowserRoot.getPath()), "Cannot Use BUILD File");
        return;
    }
    String newWorkspacePath = FileUtil.getRelativePath(fileBrowserRoot, new File(file.getPath()));
    buildFilePathField.setText(newWorkspacePath);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) FileChooserDialog(com.intellij.openapi.fileChooser.FileChooserDialog)

Example 5 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class BlazeConfigurationResolverTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(BlazeExecutor.class, new MockBlazeExecutor());
    CPPEnvironmentAdapter.registerForTest(applicationServices.getPicoContainer());
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    compilerVersionChecker = new MockCompilerVersionChecker("1234");
    applicationServices.register(CompilerVersionChecker.class, compilerVersionChecker);
    applicationServices.register(ProgressManager.class, new ProgressManagerImpl());
    applicationServices.register(VirtualFileManager.class, mock(VirtualFileManager.class));
    mockFileSystem = mock(LocalFileSystem.class);
    applicationServices.register(VirtualFileSystemProvider.class, mock(VirtualFileSystemProvider.class));
    when(VirtualFileSystemProvider.getInstance().getSystem()).thenReturn(mockFileSystem);
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager());
    BuildSystemProvider buildSystemProvider = new BazelBuildSystemProvider();
    registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class).registerExtension(buildSystemProvider);
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(new BlazeImportSettings("", "", "", "", buildSystemProvider.buildSystem()));
    context.addOutputSink(IssueOutput.class, errorCollector);
    resolver = new BlazeConfigurationResolver(project);
    resolverResult = BlazeConfigurationResolverResult.empty(project);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) VirtualFileSystemProvider(com.google.idea.blaze.base.io.VirtualFileSystemProvider) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor)

Aggregations

BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)13 File (java.io.File)6 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)5 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)4 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)4 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)4 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)4 Nullable (javax.annotation.Nullable)3 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 VirtualFileSystemProvider (com.google.idea.blaze.base.io.VirtualFileSystemProvider)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)2 ProgressManagerImpl (com.intellij.openapi.progress.impl.ProgressManagerImpl)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Futures (com.google.common.util.concurrent.Futures)1