Search in sources :

Example 6 with SectionParser

use of com.google.idea.blaze.base.projectview.section.SectionParser in project intellij by bazelbuild.

the class ProjectViewParser method projectViewToString.

public static String projectViewToString(ProjectView projectView) {
    StringBuilder sb = new StringBuilder();
    List<SectionParser> sectionParsers = Sections.getParsers();
    for (Section<?> section : projectView.getSections()) {
        SectionParser sectionParser = sectionParsers.stream().filter(parser -> section.isSectionType(parser.getSectionKey())).findFirst().orElse(null);
        if (sectionParser != null) {
            sectionParser.print(sb, section);
        }
    }
    // Because we split lines we'll always have an extra newline at the end
    if (sb.length() > 0) {
        sb.deleteCharAt(sb.length() - 1);
    }
    return sb.toString();
}
Also used : SectionParser(com.google.idea.blaze.base.projectview.section.SectionParser)

Aggregations

SectionParser (com.google.idea.blaze.base.projectview.section.SectionParser)6 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)2 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)2 ProjectViewFile (com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)2 ScalarSection (com.google.idea.blaze.base.projectview.section.ScalarSection)2 Section (com.google.idea.blaze.base.projectview.section.Section)2 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)2 ImportSection (com.google.idea.blaze.base.projectview.section.sections.ImportSection)2 TargetSection (com.google.idea.blaze.base.projectview.section.sections.TargetSection)2 File (java.io.File)2 Nullable (javax.annotation.Nullable)2 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 HashCode (com.google.common.hash.HashCode)1 Hashing (com.google.common.hash.Hashing)1 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)1 ProjectViewStorageManager (com.google.idea.blaze.base.projectview.ProjectViewStorageManager)1 ProjectViewVerifier (com.google.idea.blaze.base.projectview.ProjectViewVerifier)1 ProjectViewParser (com.google.idea.blaze.base.projectview.parser.ProjectViewParser)1