use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.
the class ProjectViewManagerImpl method reloadProjectView.
@Nullable
@Override
public ProjectViewSet reloadProjectView(BlazeContext context, WorkspacePathResolver workspacePathResolver) {
BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings();
assert importSettings != null;
assert importSettings.getProjectViewFile() != null;
File projectViewFile = new File(importSettings.getProjectViewFile());
ProjectViewParser parser = new ProjectViewParser(context, workspacePathResolver);
parser.parseProjectView(projectViewFile);
boolean success = !context.hasErrors();
if (success) {
ProjectViewSet projectViewSet = parser.getResult();
File file = getCacheFile(project, importSettings);
try {
SerializationUtil.saveToDisk(file, projectViewSet);
} catch (IOException e) {
logger.error(e);
}
this.projectViewSet = projectViewSet;
}
return success ? projectViewSet : null;
}
use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.
the class CPrefetchFileSourceTest method parseProjectView.
private ProjectViewSet parseProjectView(String... contents) {
ProjectViewParser projectViewParser = new ProjectViewParser(new BlazeContext(), new WorkspacePathResolverImpl(workspaceRoot));
projectViewParser.parseProjectView(Joiner.on("\n").join(contents));
return projectViewParser.getResult();
}
use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser 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.projectview.parser.ProjectViewParser in project intellij by bazelbuild.
the class BlazeSyncIntegrationTestCase method setProjectView.
protected void setProjectView(String... contents) {
ProjectViewParser projectViewParser = new ProjectViewParser(context, new WorkspacePathResolverImpl(workspaceRoot));
projectViewParser.parseProjectView(Joiner.on("\n").join(contents));
ProjectViewSet result = projectViewParser.getResult();
assertThat(result.getProjectViewFiles()).isNotEmpty();
errorCollector.assertNoIssues();
setProjectViewSet(result);
}
use of com.google.idea.blaze.base.projectview.parser.ProjectViewParser in project intellij by bazelbuild.
the class ProjectViewUi method parseProjectView.
public ProjectViewSet parseProjectView(final List<IssueOutput> issues) {
final String projectViewText = projectViewEditor.getDocument().getText();
final OutputSink<IssueOutput> issueCollector = output -> {
issues.add(output);
return OutputSink.Propagation.Continue;
};
return Scope.root(context -> {
context.addOutputSink(IssueOutput.class, issueCollector);
ProjectViewParser projectViewParser = new ProjectViewParser(context, workspacePathResolver);
projectViewParser.parseProjectView(projectViewText);
return projectViewParser.getResult();
});
}
Aggregations