Search in sources :

Example 1 with YarnProjectBuilder

use of org.eclipse.n4js.tests.codegen.WorkspaceBuilder.YarnProjectBuilder in project n4js by eclipse.

the class XtSetupParser method parseWorkspace.

private static XtWorkspace parseWorkspace(TokenStream tokens, File xtFile, String xtFileContent) {
    WorkspaceBuilder builder = new WorkspaceBuilder(new BuilderInfo());
    YarnProjectBuilder yarnProjectBuilder = builder.addYarnProject(TestWorkspaceManager.YARN_TEST_PROJECT);
    LOOP: while (tokens.hasNext()) {
        switch(tokens.next()) {
            case "Project":
            case "JavaProject":
                parseProject(tokens, xtFile, xtFileContent, yarnProjectBuilder);
                break;
            case "}":
                break LOOP;
            default:
                Preconditions.checkState(false, ERROR + "Unexpected token in Workspace: " + tokens.lookLast() + " in file " + xtFile.getPath());
        }
    }
    XtWorkspace xtWorkspace = builder.build(new XtWorkspace());
    if (xtWorkspace.getProjects().size() == 1 && xtWorkspace.getProjects().get(0) instanceof YarnWorkspaceProject && ((YarnWorkspaceProject) xtWorkspace.getProjects().get(0)).getMemberProjects().size() == 1) {
        YarnWorkspaceProject yarnWorkspaceProject = (YarnWorkspaceProject) xtWorkspace.getProjects().get(0);
        if (yarnWorkspaceProject.getMemberProjects().size() == 1) {
            Project project = yarnWorkspaceProject.getMemberProjects().iterator().next();
            xtWorkspace.clearProjects();
            xtWorkspace.addProject(project);
        }
    }
    xtWorkspace.moduleNameOfXtFile = ((BuilderInfo) builder.builderInfo).moduleNameOfXtFile;
    return xtWorkspace;
}
Also used : WorkspaceBuilder(org.eclipse.n4js.tests.codegen.WorkspaceBuilder) YarnProjectBuilder(org.eclipse.n4js.tests.codegen.WorkspaceBuilder.YarnProjectBuilder) YarnWorkspaceProject(org.eclipse.n4js.tests.codegen.YarnWorkspaceProject) Project(org.eclipse.n4js.tests.codegen.Project) YarnWorkspaceProject(org.eclipse.n4js.tests.codegen.YarnWorkspaceProject)

Example 2 with YarnProjectBuilder

use of org.eclipse.n4js.tests.codegen.WorkspaceBuilder.YarnProjectBuilder in project n4js by eclipse.

the class XtSetupParser method parseProject.

private static void parseProject(TokenStream tokens, File xtFile, String xtFileContent, YarnProjectBuilder yarnProjectBuilder) {
    String projectName = tokens.expectNameInQuotes();
    ProjectBuilder prjBuilder = yarnProjectBuilder.addProject(projectName);
    parseContainerRest(tokens, xtFile, xtFileContent, prjBuilder, ".", "Project");
}
Also used : ProjectBuilder(org.eclipse.n4js.tests.codegen.WorkspaceBuilder.ProjectBuilder) YarnProjectBuilder(org.eclipse.n4js.tests.codegen.WorkspaceBuilder.YarnProjectBuilder)

Aggregations

YarnProjectBuilder (org.eclipse.n4js.tests.codegen.WorkspaceBuilder.YarnProjectBuilder)2 Project (org.eclipse.n4js.tests.codegen.Project)1 WorkspaceBuilder (org.eclipse.n4js.tests.codegen.WorkspaceBuilder)1 ProjectBuilder (org.eclipse.n4js.tests.codegen.WorkspaceBuilder.ProjectBuilder)1 YarnWorkspaceProject (org.eclipse.n4js.tests.codegen.YarnWorkspaceProject)1