Search in sources :

Example 1 with ProjectView

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()));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ImmutableList(com.google.common.collect.ImmutableList) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Section(com.google.idea.blaze.base.projectview.section.Section) SectionParser(com.google.idea.blaze.base.projectview.section.SectionParser)

Example 2 with ProjectView

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));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ProjectView(com.google.idea.blaze.base.projectview.ProjectView)

Example 3 with ProjectView

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());
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager)

Example 4 with ProjectView

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"));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 5 with ProjectView

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"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Aggregations

ProjectView (com.google.idea.blaze.base.projectview.ProjectView)87 Test (org.junit.Test)81 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)55 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)45 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)40 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)33 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)13 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)12 File (java.io.File)12 BlazeScalaImportResult (com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult)9 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)8 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)7 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)6 WorkingSet (com.google.idea.blaze.base.sync.workspace.WorkingSet)5 JavaWorkingSet (com.google.idea.blaze.java.sync.workingset.JavaWorkingSet)5 ImmutableList (com.google.common.collect.ImmutableList)4 GenfilesPath (com.google.idea.blaze.android.projectview.GenfilesPath)4 BlazeAndroidLibrarySource (com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)4