Search in sources :

Example 1 with WorkspaceBuilder

use of org.eclipse.n4js.tests.codegen.WorkspaceBuilder 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)

Aggregations

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