Search in sources :

Example 11 with N4HeadlessCompiler

use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.

the class ScenarioTest method testScenario04BuildSingleProjectsWithManyProjectsOnPath.

/**
 * Testing compiling only a single project.
 */
@Test
public void testScenario04BuildSingleProjectsWithManyProjectsOnPath() throws N4JSCompileException {
    N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
    File root = new File(workspace, "scenario04");
    List<File> pProjectRoots = // 
    Arrays.asList(// A, NotAProject
    new File(root, "wsp1"), // B,D
    new File(root, "nest/wsp2"), // C
    new File(root, "wsp3"), // E,H
    new File(root, "nest/nest/wsp4"), // F
    new File(root, "nest/wsp5"), // G
    new File(root, "wsp6"));
    List<File> toCompile = // 
    Arrays.asList(// requires B and A to be loaded.
    new File(root, "nest/wsp2/D"));
    hlc.compileProjects(pProjectRoots, toCompile);
    assertNotExists(root, "wsp1/A/src-gen/packA/A.js");
    assertNotExists(root, "nest/wsp2/B/src-gen/packB/B.js");
    assertNotExists(root, "wsp3/C/src-gen/packC/C.js");
    // Only those both should be available
    assertExists(root, "nest/wsp2/D/src-gen/packD/D.js");
    assertExists(root, "nest/wsp2/D/src-gen/packD/D2.js");
    assertNotExists(root, "nest/nest/wsp4/E/src-gen/packE/E.js");
    assertNotExists(root, "nest/nest/wsp4/E/src-gen/packE/E2.js");
    assertNotExists(root, "nest/wsp5/F/src-gen/packF/F.js");
    assertNotExists(root, "wsp6/G/src-gen/packG/G.js");
    assertNotExists(root, "nest/nest/wsp4/H/src-gen/packH/H.js");
}
Also used : N4HeadlessCompiler(org.eclipse.n4js.generator.headless.N4HeadlessCompiler) File(java.io.File) Test(org.junit.Test)

Example 12 with N4HeadlessCompiler

use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.

the class ScenarioTest method testScenario10BuildSingleFileWithProjectRootAndDependency.

/**
 */
@Test
public void testScenario10BuildSingleFileWithProjectRootAndDependency() throws N4JSCompileException {
    N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
    File root = new File(workspace, "scenario10");
    List<File> toCompile = // 
    Arrays.asList(// requires nothing
    new File(root, "nest/wsp2/D/src/packD/D2.n4js"));
    List<File> wspRoots = // 
    Arrays.asList(new File(root, "nest/wsp2"), new File(root, "wsp1"));
    hlc.compileSingleFiles(wspRoots, toCompile);
    assertExists(root, "nest/wsp2/D/src-gen/packD/D2.js");
    // those should be available
    assertNotExists(root, "wsp1/A/src-gen/packA/A.js");
    assertNotExists(root, "nest/wsp2/B/src-gen/packB/B.js");
    assertNotExists(root, "nest/wsp2/B/src-gen/packB/B2.js");
    assertNotExists(root, "nest/wsp2/D/src-gen/packD/D.js");
}
Also used : N4HeadlessCompiler(org.eclipse.n4js.generator.headless.N4HeadlessCompiler) File(java.io.File) Test(org.junit.Test)

Example 13 with N4HeadlessCompiler

use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.

the class ScenarioTest method testScenario03brokenN4jsSyntax.

/**
 * Broken source-file will result in compile-error.
 */
@Test(expected = N4JSCompileException.class)
public void testScenario03brokenN4jsSyntax() throws N4JSCompileException {
    N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
    File root = new File(workspace, "scenario03");
    List<File> pProjectRoots = // 
    Arrays.asList(// A
    new File(root, "wsp1"));
    hlc.compileAllProjects(pProjectRoots);
}
Also used : N4HeadlessCompiler(org.eclipse.n4js.generator.headless.N4HeadlessCompiler) File(java.io.File) Test(org.junit.Test)

Example 14 with N4HeadlessCompiler

use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.

the class HeadlessCompilerFactory method createCompilerWithProperties.

/**
 * Construct a {@link N4HeadlessCompiler} with configuration based on the provided properties.
 *
 * @param properties
 *            preferences.
 */
public static N4HeadlessCompiler createCompilerWithProperties(Properties properties) {
    Injector localinjector = new N4JSHeadlessStandaloneSetup(properties).createInjectorAndDoEMFRegistration();
    N4HeadlessCompiler instance = localinjector.getInstance(N4HeadlessCompiler.class);
    HeadlessExtensionRegistrationHelper headlessExtensionRegistrationHelper = localinjector.getInstance(HeadlessExtensionRegistrationHelper.class);
    headlessExtensionRegistrationHelper.registerExtensions();
    return instance;
}
Also used : Injector(com.google.inject.Injector) N4JSHeadlessStandaloneSetup(org.eclipse.n4js.generator.headless.N4JSHeadlessStandaloneSetup) N4HeadlessCompiler(org.eclipse.n4js.generator.headless.N4HeadlessCompiler) HeadlessExtensionRegistrationHelper(org.eclipse.n4js.hlc.base.HeadlessExtensionRegistrationHelper)

Aggregations

N4HeadlessCompiler (org.eclipse.n4js.generator.headless.N4HeadlessCompiler)14 File (java.io.File)13 Test (org.junit.Test)12 N4JSCompileException (org.eclipse.n4js.generator.headless.N4JSCompileException)2 Injector (com.google.inject.Injector)1 IssueCollector (org.eclipse.n4js.generator.headless.IssueCollector)1 N4JSHeadlessStandaloneSetup (org.eclipse.n4js.generator.headless.N4JSHeadlessStandaloneSetup)1 HeadlessExtensionRegistrationHelper (org.eclipse.n4js.hlc.base.HeadlessExtensionRegistrationHelper)1