Search in sources :

Example 1 with AbstractSubGenerator

use of org.eclipse.n4js.generator.AbstractSubGenerator in project n4js by eclipse.

the class XpectN4JSES5GeneratorHelper method compile.

/**
 * Compiles provided Script. Can replace backslashes with single quote (for windows command line issues)
 *
 * @param depRoot
 *            script to transpile
 * @param options
 *            the {@link GeneratorOption}s to use during compilation.
 * @param replaceQuotes
 *            should replace quotes (only for windows)
 * @return string representation of compilation result
 */
public String compile(Script depRoot, GeneratorOption[] options, boolean replaceQuotes) {
    final Resource resource = depRoot.eResource();
    EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
    final AbstractSubGenerator generator = getGeneratorForResource(resource);
    String compileResultStr = generator.getCompileResultAsText(depRoot, options);
    if (replaceQuotes) {
        // Windows Node.js has problems with " as it interprets it as ending of script to execute
        compileResultStr = compileResultStr.replace("\"", "'");
    }
    return compileResultStr;
}
Also used : AbstractSubGenerator(org.eclipse.n4js.generator.AbstractSubGenerator) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)1 AbstractSubGenerator (org.eclipse.n4js.generator.AbstractSubGenerator)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1