Search in sources :

Example 1 with Outlet

use of org.eclipse.xpand2.output.Outlet in project xtext-eclipse by eclipse.

the class XtextAntlrIDEAGeneratorFragment method generate.

@Override
protected void generate(final Grammar grammar, final List<Object> parameters, final Xtend2ExecutionContext ctx) {
    this._xtextIDEAGeneratorExtensions.installOutlets(ctx, this.ideaProjectPath, this.encoding, this.getNaming().getLineDelimiter());
    final Object options = IterableExtensions.<Object>head(parameters);
    if ((options instanceof AntlrOptions)) {
        this._psiAntlrGrammarGenerator.generate(grammar, ((AntlrOptions) options), ctx);
        final Outlet srcGenOutlet = this._xtextIDEAGeneratorExtensions.getSrcGenOutlet(ctx);
        final String srcGenPath = srcGenOutlet.getPath();
        final String encoding = srcGenOutlet.getFileEncoding();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append(srcGenPath);
        _builder.append("/");
        String _asPath = this._naming.asPath(this._psiAntlrGrammarGenerator.getGrammarFileName(grammar));
        _builder.append(_asPath);
        _builder.append(".g");
        final String absoluteGrammarFileName = _builder.toString();
        this.addAntlrParam("-fo");
        this.addAntlrParam(absoluteGrammarFileName.substring(0, absoluteGrammarFileName.lastIndexOf("/")));
        this.getAntlrTool().runWithEncodingAndParams(absoluteGrammarFileName, encoding, this.getAntlrParams());
        final Charset charset = Charset.forName(encoding);
        this.simplifyUnorderedGroupPredicatesIfRequired(grammar, absoluteGrammarFileName, charset);
        this.splitParserAndLexerIfEnabled(absoluteGrammarFileName, charset);
        this.suppressWarnings(absoluteGrammarFileName, charset);
        this.normalizeLineDelimiters(absoluteGrammarFileName, charset);
        this.normalizeTokens(absoluteGrammarFileName, charset);
    }
}
Also used : Outlet(org.eclipse.xpand2.output.Outlet) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Charset(java.nio.charset.Charset) AntlrOptions(org.eclipse.xtext.generator.parser.antlr.AntlrOptions)

Example 2 with Outlet

use of org.eclipse.xpand2.output.Outlet in project xtext-eclipse by eclipse.

the class XtextIDEAGeneratorExtensions method installOutlet.

protected void installOutlet(final Xtend2ExecutionContext it, final String pathIdeaPluginProject, final String outletName, final String projectPath, final String encoding, final boolean overwrite, final String defaultOutletName, final String lineDelimiter) {
    Outlet _outlet = this.getOutlet(it, outletName);
    boolean _tripleNotEquals = (_outlet != null);
    if (_tripleNotEquals) {
        return;
    }
    final Outlet outlet = new Outlet(outletName);
    outlet.setName(outletName);
    outlet.setOverwrite(overwrite);
    String _xifexpression = null;
    if ((encoding != null)) {
        _xifexpression = encoding;
    } else {
        _xifexpression = this.getOutlet(it, defaultOutletName).getFileEncoding();
    }
    outlet.setFileEncoding(_xifexpression);
    String _xifexpression_1 = null;
    if ((pathIdeaPluginProject != null)) {
        _xifexpression_1 = (pathIdeaPluginProject + projectPath);
    } else {
        _xifexpression_1 = this.getOutlet(it, defaultOutletName).getPath();
    }
    outlet.setPath(_xifexpression_1);
    NewlineNormalizer _newlineNormalizer = new NewlineNormalizer(lineDelimiter);
    outlet.addPostprocessor(_newlineNormalizer);
    it.getXpandExecutionContext().getOutput().addOutlet(outlet);
}
Also used : NewlineNormalizer(org.eclipse.xtext.generator.NewlineNormalizer) Outlet(org.eclipse.xpand2.output.Outlet)

Example 3 with Outlet

use of org.eclipse.xpand2.output.Outlet in project statecharts by Yakindu.

the class Beautifier method format.

/**
 * Format code with PostProcessor (XPand style).
 */
public CharSequence format(String fileName, CharSequence code) {
    // create fileHandle with dummy outlet.
    File file = new File(fileName);
    FileHandle fileHandle = new FileHandleImpl(new Outlet(), file);
    fileHandle.setBuffer(code);
    // call postProcessor for formatting the code.
    csharpBeautifier.beforeWriteAndClose(fileHandle);
    // return formatted results.
    return fileHandle.getBuffer();
}
Also used : FileHandle(org.eclipse.xpand2.output.FileHandle) FileHandleImpl(org.eclipse.xpand2.output.FileHandleImpl) Outlet(org.eclipse.xpand2.output.Outlet) File(java.io.File)

Example 4 with Outlet

use of org.eclipse.xpand2.output.Outlet in project xtext-eclipse by eclipse.

the class IdeaPluginGenerator method addOutlet.

public void addOutlet(final Output output, final String outletName, final boolean overwrite, final String path) {
    String _encoding = this.getEncoding();
    final Outlet outlet = new Outlet(false, _encoding, outletName, overwrite, path);
    String _lineDelimiter = this.getNaming().getLineDelimiter();
    NewlineNormalizer _newlineNormalizer = new NewlineNormalizer(_lineDelimiter);
    outlet.addPostprocessor(_newlineNormalizer);
    output.addOutlet(outlet);
}
Also used : NewlineNormalizer(org.eclipse.xtext.generator.NewlineNormalizer) Outlet(org.eclipse.xpand2.output.Outlet)

Example 5 with Outlet

use of org.eclipse.xpand2.output.Outlet in project dsl-devkit by dsldevkit.

the class LanguageConstantsFragment method addMetamodelSrcGenOutlet.

/**
 * Ensures that METAMODEL_SRC_GEN_OUTLET outlet is defined for the execution context.
 * Unless specific outlets were specified for this fragment default outlets are created.
 *
 * @param grammar
 *          the grammar
 * @param ctx
 *          the Xpand execution context
 */
protected void addMetamodelSrcGenOutlet(final Grammar grammar, final XpandExecutionContext ctx) {
    Outlet outlet = metamodelSrcGenOulet;
    if (outlet == null) {
        // $NON-NLS-1$//$NON-NLS-2$
        final String path = "../" + getNaming().basePackageRuntime(grammar) + "/src-gen";
        outlet = new Outlet(false, ISO_8859_1, METAMODEL_SRC_GEN_OUTLET, true, path);
    }
    ctx.getOutput().addOutlet(outlet);
}
Also used : Outlet(org.eclipse.xpand2.output.Outlet)

Aggregations

Outlet (org.eclipse.xpand2.output.Outlet)7 OutputImpl (org.eclipse.xpand2.output.OutputImpl)2 NewlineNormalizer (org.eclipse.xtext.generator.NewlineNormalizer)2 File (java.io.File)1 Charset (java.nio.charset.Charset)1 ArrayList (java.util.ArrayList)1 Application (org.applause.lang.applauseDsl.Application)1 IFolder (org.eclipse.core.resources.IFolder)1 EObject (org.eclipse.emf.ecore.EObject)1 XpandExecutionContextImpl (org.eclipse.xpand2.XpandExecutionContextImpl)1 XpandFacade (org.eclipse.xpand2.XpandFacade)1 FileHandle (org.eclipse.xpand2.output.FileHandle)1 FileHandleImpl (org.eclipse.xpand2.output.FileHandleImpl)1 JavaBeautifier (org.eclipse.xpand2.output.JavaBeautifier)1 JavaBeansMetaModel (org.eclipse.xtend.type.impl.java.JavaBeansMetaModel)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 AntlrOptions (org.eclipse.xtext.generator.parser.antlr.AntlrOptions)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1