use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class GeneratorNodeTest method testTemplateProcessing.
@Test
public void testTemplateProcessing() {
final LocationData root = this.loc(0);
CompositeGeneratorNode _trace = this.exts.trace(root);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
StringConcatenationClient _someCodeGen = GeneratorNodeTest.this.someCodeGen(2);
_builder.append(_someCodeGen);
_builder.newLineIfNotEmpty();
}
};
final CompositeGeneratorNode node = this.exts.appendTemplate(_trace, _client);
final GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
final GeneratorNodeProcessor.Result result = processor.process(node);
this.assertEquals(this.someCodeGen_noTrace(2).toString(), result.toString());
StringConcatenation _builder = new StringConcatenation();
_builder.append("CompletableTraceRegion [myOffset=0, myLength=80, useForDebugging=false] associations={");
_builder.newLine();
_builder.append(" ");
_builder.append("LocationData [TextRegionWithLineInformation [0:100][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder.newLine();
_builder.append("} nestedRegions={");
_builder.newLine();
_builder.append(" ");
_builder.append("CompletableTraceRegion [myOffset=7, myLength=5, useForDebugging=false] associations={");
_builder.newLine();
_builder.append(" ");
_builder.append("LocationData [TextRegionWithLineInformation [10:90][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append(" ");
_builder.append("CompletableTraceRegion [myOffset=28, myLength=5, useForDebugging=false] associations={");
_builder.newLine();
_builder.append(" ");
_builder.append("LocationData [TextRegionWithLineInformation [10:90][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append(" ");
_builder.append("CompletableTraceRegion [myOffset=47, myLength=5, useForDebugging=false] associations={");
_builder.newLine();
_builder.append(" ");
_builder.append("LocationData [TextRegionWithLineInformation [11:89][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append(" ");
_builder.append("CompletableTraceRegion [myOffset=68, myLength=5, useForDebugging=false] associations={");
_builder.newLine();
_builder.append(" ");
_builder.append("LocationData [TextRegionWithLineInformation [10:90][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append("}");
this.assertEquals(_builder.toString(), result.getTraceRegion().toString());
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class GeneratorNodeTest method testAppendVariants.
@Test
public void testAppendVariants() {
final CompositeGeneratorNode node = new CompositeGeneratorNode();
StringConcatenation _builder = new StringConcatenation();
_builder.append("* a simple string");
final String string = _builder.toString();
this.exts.append(node, string);
this.exts.appendNewLine(node);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("* a multi-line string concatenation embedding");
_builder_1.newLine();
_builder_1.append(" \t");
_builder_1.append(string, " \t");
_builder_1.newLineIfNotEmpty();
final StringConcatenation stringConcat1 = _builder_1;
this.exts.append(node, stringConcat1);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("* a string concatentation client embedding");
_builder.newLine();
_builder.append(" \t");
_builder.append(stringConcat1, " \t");
_builder.newLineIfNotEmpty();
}
};
final StringConcatenationClient client = _client;
this.exts.append(node, client);
final CompositeGeneratorNode nestedNode = new CompositeGeneratorNode();
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("* I can even embed");
_builder_2.newLine();
_builder_2.append(" \t");
_builder_2.append(client, " \t");
_builder_2.newLineIfNotEmpty();
_builder_2.append(" ");
_builder_2.append("in a string concatenation");
_builder_2.newLine();
final StringConcatenation stringConcat2 = _builder_2;
this.exts.append(nestedNode, stringConcat2);
this.exts.append(node, nestedNode);
final GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append("* a simple string");
_builder_3.newLine();
_builder_3.append("* a multi-line string concatenation embedding");
_builder_3.newLine();
_builder_3.append(" \t");
_builder_3.append("* a simple string");
_builder_3.newLine();
_builder_3.append("* a string concatentation client embedding");
_builder_3.newLine();
_builder_3.append(" \t");
_builder_3.append("* a multi-line string concatenation embedding");
_builder_3.newLine();
_builder_3.append(" \t \t");
_builder_3.append("* a simple string");
_builder_3.newLine();
_builder_3.append("* I can even embed");
_builder_3.newLine();
_builder_3.append(" \t");
_builder_3.append("* a string concatentation client embedding");
_builder_3.newLine();
_builder_3.append(" \t \t");
_builder_3.append("* a multi-line string concatenation embedding");
_builder_3.newLine();
_builder_3.append(" \t \t \t");
_builder_3.append("* a simple string");
_builder_3.newLine();
_builder_3.append(" ");
_builder_3.append("in a string concatenation");
_builder_3.newLine();
this.assertEquals(_builder_3.toString(), processor.process(node).toString());
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class TemplateNodeTest method testNull.
@Test
public void testNull() {
final Object x = null;
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("fooo ");
_builder.append(x);
_builder.append("bar");
_builder.newLineIfNotEmpty();
}
};
this.assertEquals(_client);
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class TemplateNodeTest method testSimpleTemplate_01.
@Test
public void testSimpleTemplate_01() {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
String _multiLineString = TemplateNodeTest.this.multiLineString();
_builder.append(_multiLineString);
_builder.append(" ");
String _multiLineString_1 = TemplateNodeTest.this.multiLineString();
_builder.append(_multiLineString_1);
_builder.newLineIfNotEmpty();
}
};
this.assertEquals(_client);
}
use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.
the class TemplateNodeTest method testNull_02.
@Test
public void testNull_02() {
final Object x = null;
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("fooo");
_builder.newLine();
_builder.append("\t");
_builder.append(x, "\t");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("bar");
_builder.newLine();
}
};
this.assertEquals(_client);
}
Aggregations