use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class ProjectViewParser method parseProjectView.
private void parseProjectView(ParseContext parseContext) {
ImmutableList.Builder<Section<?>> sections = ImmutableList.builder();
List<SectionParser> sectionParsers = Sections.getParsers();
while (!parseContext.atEnd()) {
Section section = null;
for (SectionParser sectionParser : sectionParsers) {
section = sectionParser.parse(this, parseContext);
if (section != null) {
sections.add(section);
break;
}
}
if (section == null) {
if (parseContext.current().indent != 0) {
parseContext.addError(String.format("Invalid indentation on line: '%s'", parseContext.current().text));
skipSection(parseContext);
} else {
parseContext.addError(String.format("Could not parse: '%s'", parseContext.current().text));
parseContext.consume();
// Skip past the entire section
skipSection(parseContext);
}
}
}
ProjectView projectView = new ProjectView(sections.build());
projectViewFiles.add(new ProjectViewSet.ProjectViewFile(projectView, parseContext.getProjectViewFile()));
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class ProjectViewParser method parseProjectView.
public void parseProjectView(String text) {
if (text.isEmpty()) {
ProjectView projectView = new ProjectView(ImmutableList.of());
projectViewFiles.add(new ProjectViewSet.ProjectViewFile(projectView, null));
return;
}
parseProjectView(new ParseContext(context, workspacePathResolver, null, text));
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeBuildServiceTest method initTest.
@Override
protected void initTest(Container applicationServices, Container projectServices) {
BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
importSettingsManager.setImportSettings(new BlazeImportSettings("", "", "", "", Blaze.BuildSystem.Blaze));
projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
applicationServices.register(ExperimentService.class, new MockExperimentService());
ProjectView view = ProjectView.builder().add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//view/target:one")).add(TargetExpression.fromStringSafe("//view/target:two"))).build();
viewSet = ProjectViewSet.builder().add(new File("view/target/.blazeproject"), view).build();
ProjectViewManager viewManager = new MockProjectViewManager(viewSet);
projectServices.register(ProjectViewManager.class, viewManager);
BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
projectServices.register(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
applicationServices.register(BlazeBuildService.class, spy(new BlazeBuildService()));
service = BlazeBuildService.getInstance();
assertThat(service).isNotNull();
// Can't mock BlazeExecutor.submitTask.
doNothing().when(service).buildTargetExpressions(any(), any(), any(), any());
}
use of com.google.idea.blaze.base.projectview.ProjectView 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.ProjectView in project intellij by bazelbuild.
the class ProjectViewParserTest method testPrint.
@Test
public void testPrint() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/com/google/one"))).add(DirectoryEntry.exclude(new WorkspacePath("java/com/google/two")))).add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//java/com/google:one")).add(TargetExpression.fromStringSafe("//java/com/google:two"))).add(ScalarSection.builder(ImportSection.KEY).set(new WorkspacePath("some/file.blazeproject"))).build();
String text = ProjectViewParser.projectViewToString(projectView);
assertThat(text).isEqualTo(Joiner.on('\n').join("directories:", " java/com/google/one", " -java/com/google/two", "targets:", " //java/com/google:one", " //java/com/google:two", "import some/file.blazeproject"));
}
Aggregations