use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.
the class BlazeResolveConfigurationEquivalenceTest 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());
applicationServices.register(CompilerVersionChecker.class, new MockCompilerVersionChecker("1234"));
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(PsiManager.class, new MockPsiManager(project));
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);
}
use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.
the class DeprecatedLoadQuickFix method findContainingPackage.
@Nullable
private static File findContainingPackage(Project project, File file) {
BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
file = file.getParentFile();
while (file != null) {
File buildFile = provider.findBuildFileInDirectory(file);
if (buildFile != null) {
return file;
}
file = file.getParentFile();
}
return null;
}
use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.
the class GenerateFromBuildFileSelectProjectViewOption method validate.
@Override
public BlazeValidationResult validate() {
String buildFilePath = getBuildFilePath();
if (buildFilePath.isEmpty()) {
return BlazeValidationResult.failure("BUILD file field cannot be empty.");
}
if (!WorkspacePath.isValid(buildFilePath)) {
return BlazeValidationResult.failure("Invalid BUILD file path: specify a path relative to the workspace root.");
}
WorkspacePathResolver workspacePathResolver = builder.getWorkspaceOption().getWorkspacePathResolver();
File file = workspacePathResolver.resolveToFile(new WorkspacePath(buildFilePath));
if (!file.exists()) {
return BlazeValidationResult.failure("BUILD file does not exist.");
}
if (file.isDirectory()) {
return BlazeValidationResult.failure("Specified path is a directory, not a file");
}
BuildSystemProvider buildSystemProvider = BuildSystemProvider.getBuildSystemProvider(builder.getBuildSystem());
checkState(buildSystemProvider != null);
if (!buildSystemProvider.isBuildFile(file.getName())) {
return BlazeValidationResult.failure("File must be a BUILD file.");
}
return BlazeValidationResult.success();
}
use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.
the class WorkspaceHelper method deriveLabel.
private static Label deriveLabel(Project project, Workspace workspace, WorkspacePath workspacePath) {
BuildSystemProvider provider = Blaze.getBuildSystemProvider(project);
File file = workspace.root.fileForPath(workspacePath);
if (provider.isBuildFile(file.getName())) {
return Label.create(workspace.externalWorkspaceName, workspace.root.workspacePathFor(file.getParentFile()), TargetName.create("__pkg__"));
}
WorkspacePath packagePath = getPackagePath(provider, workspace.root, workspacePath);
if (packagePath == null) {
return null;
}
TargetName targetName = TargetName.createIfValid(FileUtil.getRelativePath(workspace.root.fileForPath(packagePath), file));
return targetName != null ? Label.create(workspace.externalWorkspaceName, packagePath, targetName) : null;
}
use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.
the class BlazeKotlinSyncPluginTest method initTest.
@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
super.initTest(applicationServices, projectServices);
ExtensionPointImpl<BuildSystemProvider> buildSystems = registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
buildSystems.registerExtension(new BazelBuildSystemProvider());
ExtensionPointImpl<BlazeSyncPlugin> syncPlugins = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
syncPlugins.registerExtension(new BlazeJavaSyncPlugin());
syncPlugins.registerExtension(new BlazeKotlinSyncPlugin());
context = new BlazeContext();
context.addOutputSink(IssueOutput.class, errorCollector);
}
Aggregations