use of com.google.idea.blaze.base.projectview.section.SectionKey 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);
}
Aggregations