use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class AddSourceToProjectHelper method getContext.
/**
* Returns the location context related to a source file to be added to the project.
*/
@Nullable
static LocationContext getContext(Project project, File file) {
BlazeProjectData syncData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (syncData == null) {
return null;
}
WorkspacePath workspacePath = getWorkspacePath(project, file);
if (workspacePath == null || isBuildSystemOutputArtifact(project, workspacePath)) {
return null;
}
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet == null) {
return null;
}
WorkspacePath parent = workspacePath.getParent();
if (parent == null) {
return null;
}
WorkspacePath blazePackage = findBlazePackagePath(project, parent);
return blazePackage != null ? new LocationContext(project, syncData, projectViewSet, file, workspacePath, blazePackage) : null;
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class PrefetchProjectInitializer method prefetchProjectFiles.
private static void prefetchProjectFiles(Project project) {
if (!Blaze.isBlazeProject(project)) {
return;
}
BlazeProjectData projectData = getBlazeProjectData(project);
ProjectViewSet projectViewSet = getProjectViewSet(project);
if (projectViewSet == null) {
return;
}
PrefetchIndexingTask.submitPrefetchingTask(project, PrefetchService.getInstance().prefetchProjectFiles(project, projectViewSet, projectData), "Initial Prefetching");
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class BlazeIssueParserTest method initTest.
@Override
protected void initTest(Container applicationServices, Container projectServices) {
super.initTest(applicationServices, projectServices);
applicationServices.register(ExperimentService.class, new MockExperimentService());
projectViewManager = mock(ProjectViewManager.class);
projectServices.register(ProjectViewManager.class, projectViewManager);
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(new File(".blazeproject"), ProjectView.builder().add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//tests/com/google/a/b/c/d/baz:baz")).add(TargetExpression.fromStringSafe("//package/path:hello4"))).build()).build();
when(projectViewManager.getProjectViewSet()).thenReturn(projectViewSet);
workspaceRoot = new WorkspaceRoot(new File("/root"));
parsers = ImmutableList.of(new BlazeIssueParser.CompileParser(workspaceRoot), new BlazeIssueParser.TracebackParser(), new BlazeIssueParser.BuildParser(), new BlazeIssueParser.SkylarkErrorParser(), new BlazeIssueParser.LinelessBuildParser(), new BlazeIssueParser.ProjectViewLabelParser(projectViewSet), new BlazeIssueParser.InvalidTargetProjectViewPackageParser(projectViewSet, "no such package '(.*)': BUILD file not found on package path"), new BlazeIssueParser.InvalidTargetProjectViewPackageParser(projectViewSet, "no targets found beneath '(.*)'"), new BlazeIssueParser.InvalidTargetProjectViewPackageParser(projectViewSet, "ERROR: invalid target format '(.*)'"), new BlazeIssueParser.FileNotFoundBuildParser(workspaceRoot), BlazeIssueParser.GenericErrorParser.INSTANCE);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class ProjectViewParserTest method testDirectoriesAndTargets.
@Test
public void testDirectoriesAndTargets() throws Exception {
projectViewStorageManager.add(".blazeproject", "directories:", " java/com/google", " java/com/google/android", " -java/com/google/android/notme", "", "targets:", " //java/com/google:all", " //java/com/google/...:all", " -//java/com/google:thistarget");
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
assertThat(projectViewFile).isNotNull();
assertThat(projectViewFile.projectViewFile).isEqualTo(new File(".blazeproject"));
assertThat(projectViewSet.getProjectViewFiles()).containsExactly(projectViewFile);
ProjectView projectView = projectViewFile.projectView;
assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android/notme"), false));
assertThat(projectView.getSectionsOfType(TargetSection.KEY).get(0).items()).containsExactly(TargetExpression.fromStringSafe("//java/com/google:all"), TargetExpression.fromStringSafe("//java/com/google/...:all"), TargetExpression.fromStringSafe("-//java/com/google:thistarget"));
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class ProjectViewParserTest method testCommentsAreParsed.
@Test
public void testCommentsAreParsed() throws Exception {
projectViewStorageManager.add(".blazeproject", "# comment", "directories:", " # another comment", " java/com/google", " # comment", " java/com/google/android", "");
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
ProjectView projectView = projectViewFile.projectView;
assertThat(projectView.getSectionsOfType(TextBlockSection.KEY).get(0).getTextBlock()).isEqualTo(new TextBlock(ImmutableList.of("# comment")));
assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android"), true));
}
Aggregations