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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations