use of org.eclipse.xtext.generator.trace.LocationData in project xtext-core by eclipse.
the class GeneratorNodePerformanceTest method testBasicCreationAndProcessingPerformance.
@Test
public void testBasicCreationAndProcessingPerformance() {
LocationData root = loc(0);
CompositeGeneratorNode node = exts.appendNewLine(exts.append(exts.trace(root), "notindented"));
for (int i = 0; i < GeneratorNodePerformanceTest.numberOfLines; i++) {
exts.appendNewLine(exts.append(exts.indent(exts.appendNewLine(exts.append(exts.trace(exts.indent(node), loc(1)), "indented1"))), "indented2"));
}
exts.append(exts.appendNewLine(node), "dedented");
GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
GeneratorNodeProcessor.Result result = processor.process(node);
String resultAsString = null;
if (result != null) {
resultAsString = result.toString();
}
Assert.assertFalse(Strings.isNullOrEmpty(resultAsString));
}
use of org.eclipse.xtext.generator.trace.LocationData in project xtext-core by eclipse.
the class GeneratorNodeTest method testBasicCreationAndProcessing.
@Test
public void testBasicCreationAndProcessing() {
final LocationData root = this.loc(0);
CompositeGeneratorNode node = this.exts.appendNewLine(this.exts.append(this.exts.trace(root), "notindented"));
this.exts.append(this.exts.appendNewLine(this.exts.append(this.exts.trace(this.exts.indent(node), this.loc(1)), "indented1")), "indented2");
this.exts.append(this.exts.appendNewLine(node), "dedented");
final GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
final GeneratorNodeProcessor.Result result = processor.process(node);
StringConcatenation _builder = new StringConcatenation();
_builder.append("notindented");
_builder.newLine();
_builder.append(" ");
_builder.append("indented1");
_builder.newLine();
_builder.append(" ");
_builder.append("indented2");
_builder.newLine();
_builder.append("dedented");
this.assertEquals(_builder.toString(), result.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("CompletableTraceRegion [myOffset=0, myLength=44, useForDebugging=false] associations={");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("LocationData [TextRegionWithLineInformation [0:100][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder_1.newLine();
_builder_1.append("} nestedRegions={");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("CompletableTraceRegion [myOffset=14, myLength=21, useForDebugging=false] associations={");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("LocationData [TextRegionWithLineInformation [1:99][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
this.assertEquals(_builder_1.toString(), result.getTraceRegion().toString());
}
use of org.eclipse.xtext.generator.trace.LocationData 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.xtext.generator.trace.LocationData 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());
}
use of org.eclipse.xtext.generator.trace.LocationData in project xtext-core by eclipse.
the class TracingSugar method location.
/**
* @param obj
* the EObject containing the feature
* @param feature
* the EStructuralFeature to trace
* @param idx
* the index of the value to trace, in case the feature contains a list, should be <code>-1</code>
* otherwise.
*
* @return ILocationData covering the <code>fullTextRegion</code> of the given feature in the given EObject.
*/
public ILocationData location(EObject obj, EStructuralFeature feature, int idx) {
ITextRegion region = locationProvider.getFullTextRegion(obj, feature, idx);
SourceRelativeURI uri = traceURIConverter.getURIForTrace(obj.eResource());
return new LocationData((ITextRegionWithLineInformation) region, uri);
}
Aggregations