use of com.google.idea.blaze.base.settings.Blaze.BuildSystem in project intellij by bazelbuild.
the class BlazeEditProjectViewControl method modifyInitialProjectView.
private static String modifyInitialProjectView(BuildSystem buildSystem, String initialProjectViewText, WorkspacePathResolver workspacePathResolver) {
BlazeContext context = new BlazeContext();
ProjectViewParser projectViewParser = new ProjectViewParser(context, workspacePathResolver);
projectViewParser.parseProjectView(initialProjectViewText);
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
if (projectViewFile == null) {
return initialProjectViewText;
}
ProjectView projectView = projectViewFile.projectView;
// Sort default value providers to match the section order
List<SectionKey> sectionKeys = Sections.getParsers().stream().map(SectionParser::getSectionKey).collect(toList());
List<ProjectViewDefaultValueProvider> defaultValueProviders = Lists.newArrayList(ProjectViewDefaultValueProvider.EP_NAME.getExtensions());
defaultValueProviders.sort(Comparator.comparingInt(val -> sectionKeys.indexOf(val.getSectionKey())));
for (ProjectViewDefaultValueProvider defaultValueProvider : defaultValueProviders) {
projectView = defaultValueProvider.addProjectViewDefaultValue(buildSystem, projectViewSet, projectView);
}
return ProjectViewParser.projectViewToString(projectView);
}
use of com.google.idea.blaze.base.settings.Blaze.BuildSystem in project intellij by bazelbuild.
the class BlazeVcsHandler method vcsHandlerForProject.
@Nullable
static BlazeVcsHandler vcsHandlerForProject(Project project) {
BuildSystem buildSystem = Blaze.getBuildSystem(project);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
for (BlazeVcsHandler candidate : BlazeVcsHandler.EP_NAME.getExtensions()) {
if (candidate.handlesProject(buildSystem, workspaceRoot)) {
return candidate;
}
}
return null;
}
use of com.google.idea.blaze.base.settings.Blaze.BuildSystem in project intellij by bazelbuild.
the class BlazeNewProjectBuilder method commit.
/**
* Commits the project. May report errors.
*/
public void commit() throws BlazeProjectCommitException {
this.workspaceRoot = workspaceOption.getWorkspaceRoot();
workspaceOption.commit();
projectViewOption.commit();
BuildSystem buildSystem = workspaceOption.getBuildSystemForWorkspace();
writeWorkspaceHistory(buildSystem, workspaceRoot.toString());
if (!StringUtil.isEmpty(projectDataDirectory)) {
File projectDataDir = new File(projectDataDirectory);
if (!projectDataDir.exists()) {
if (!projectDataDir.mkdirs()) {
throw new BlazeProjectCommitException("Unable to create the project directory: " + projectDataDirectory);
}
}
}
try {
logger.assertTrue(projectViewFile != null);
ProjectViewStorageManager.getInstance().writeProjectView(ProjectViewParser.projectViewToString(projectView), projectViewFile);
} catch (IOException e) {
throw new BlazeProjectCommitException("Could not create project view file", e);
}
}
use of com.google.idea.blaze.base.settings.Blaze.BuildSystem in project intellij by bazelbuild.
the class BlazeInfo method createMockBlazeInfo.
/**
* Creates a mock blaze info with the minimum information required for syncing.
*/
@VisibleForTesting
public static BlazeInfo createMockBlazeInfo(String outputBase, String executionRoot, String blazeBin, String blazeGenFiles) {
BuildSystem buildSystem = BuildSystem.Bazel;
ImmutableMap.Builder<String, String> blazeInfoMap = ImmutableMap.<String, String>builder().put(OUTPUT_BASE_KEY, outputBase).put(EXECUTION_ROOT_KEY, executionRoot).put(blazeBinKey(buildSystem), blazeBin).put(blazeGenfilesKey(buildSystem), blazeGenFiles);
return new BlazeInfo(buildSystem, blazeInfoMap.build());
}
use of com.google.idea.blaze.base.settings.Blaze.BuildSystem in project intellij by bazelbuild.
the class PartialSyncAction method getTargets.
private static List<TargetExpression> getTargets(Project project, @Nullable VirtualFile virtualFile) {
if (virtualFile == null) {
return ImmutableList.of();
}
List<TargetExpression> targets = Lists.newArrayList();
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
SourceToTargetMap.getInstance(project);
if (!virtualFile.isDirectory()) {
targets.addAll(SourceToTargetMap.getInstance(project).getTargetsToBuildForSourceFile(new File(virtualFile.getPath())));
}
if (targets.isEmpty()) {
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet != null) {
BuildSystem buildSystem = Blaze.getBuildSystem(project);
ImportRoots importRoots = ImportRoots.builder(workspaceRoot, buildSystem).add(projectViewSet).build();
BuildTargetFinder buildTargetFinder = new BuildTargetFinder(project, workspaceRoot, importRoots);
TargetExpression targetExpression = buildTargetFinder.findTargetForFile(new File(virtualFile.getPath()));
if (targetExpression != null) {
targets.add(targetExpression);
}
}
}
return targets;
}
Aggregations