Search in sources :

Example 6 with CompositeGeneratorNode

use of org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode in project xtext-core by eclipse.

the class TracingSugarTest method _generateTypeWithDebugging.

@Traced(useForDebugging = true)
public IGeneratorNode _generateTypeWithDebugging(final Type it) {
    ILocationData _location = this._myExtensions.location(it);
    CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location, true);
    this._myExtensions.appendTemplate(_traceNode, __generateTypeWithDebugging(it));
    return _traceNode;
}
Also used : CompositeGeneratorNode(org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode) ILocationData(org.eclipse.xtext.generator.trace.ILocationData) Traced(org.eclipse.xtext.generator.trace.node.Traced)

Example 7 with CompositeGeneratorNode

use of org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode in project xtext-core by eclipse.

the class TracingSugar method generateTracedFile.

/**
 * Convenience extension, to generate traced code.
 */
public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final EObject rootTrace, final StringConcatenationClient code) {
    final CompositeGeneratorNode node = this.trace(rootTrace, code);
    this.generateTracedFile(fsa, path, node);
}
Also used : CompositeGeneratorNode(org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode)

Example 8 with CompositeGeneratorNode

use of org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode in project xtext-core by eclipse.

the class GeneratorNodeTest method testEmptyIndent.

@Test
public void testEmptyIndent() {
    final LocationData root = this.loc(0);
    CompositeGeneratorNode node = this.exts.appendNewLine(this.exts.append(this.exts.trace(root), "Hallo"));
    this.exts.indent(node);
    this.exts.appendNewLine(this.exts.append(node, "noindent"));
    IndentNode _indentNode = new IndentNode("  ", true, true);
    this.exts.append(node, _indentNode);
    this.exts.appendNewLine(this.exts.append(node, "noindent"));
    final GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("Hallo");
    _builder.newLine();
    _builder.append("noindent");
    _builder.newLine();
    _builder.append("noindent");
    _builder.newLine();
    this.assertEquals(_builder.toString(), processor.process(node).toString());
}
Also used : GeneratorNodeProcessor(org.eclipse.xtext.generator.trace.node.GeneratorNodeProcessor) LocationData(org.eclipse.xtext.generator.trace.LocationData) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) CompositeGeneratorNode(org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode) IndentNode(org.eclipse.xtext.generator.trace.node.IndentNode) Test(org.junit.Test)

Example 9 with CompositeGeneratorNode

use of org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode in project xtext-core by eclipse.

the class TemplateNodeTest method assertEquals.

protected void assertEquals(final StringConcatenationClient c) {
    final GeneratorNodeExtensions ext = new GeneratorNodeExtensions();
    final GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
    final CompositeGeneratorNode root = new CompositeGeneratorNode();
    ext.appendTemplate(root, c);
    final GeneratorNodeProcessor.Result result = processor.process(root);
    final StringConcatenation expected = new StringConcatenation();
    expected.append(c);
    final String expectedM = expected.toString().replaceAll(System.lineSeparator(), "\n");
    final String resultM = result.toString().replaceAll(System.lineSeparator(), "\n");
    Assert.assertEquals(expectedM, resultM);
}
Also used : GeneratorNodeProcessor(org.eclipse.xtext.generator.trace.node.GeneratorNodeProcessor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) CompositeGeneratorNode(org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode) GeneratorNodeExtensions(org.eclipse.xtext.generator.trace.node.GeneratorNodeExtensions)

Example 10 with CompositeGeneratorNode

use of org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode in project xtext-core by eclipse.

the class TracingSugarTest method _generateType.

@Traced
public IGeneratorNode _generateType(final Type it) {
    ILocationData _location = this._myExtensions.location(it);
    CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location, false);
    this._myExtensions.appendTemplate(_traceNode, __generateType(it));
    return _traceNode;
}
Also used : CompositeGeneratorNode(org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode) ILocationData(org.eclipse.xtext.generator.trace.ILocationData) Traced(org.eclipse.xtext.generator.trace.node.Traced)

Aggregations

CompositeGeneratorNode (org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode)13 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)6 GeneratorNodeProcessor (org.eclipse.xtext.generator.trace.node.GeneratorNodeProcessor)6 ILocationData (org.eclipse.xtext.generator.trace.ILocationData)5 Traced (org.eclipse.xtext.generator.trace.node.Traced)5 Test (org.junit.Test)5 LocationData (org.eclipse.xtext.generator.trace.LocationData)3 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)2 IndentNode (org.eclipse.xtext.generator.trace.node.IndentNode)2 GeneratorNodeExtensions (org.eclipse.xtext.generator.trace.node.GeneratorNodeExtensions)1 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)1