mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
Merge pull request #468 from eclipse/cd_issue467
[Tracing] Allow to specify UseForDebugging #467
This commit is contained in:
commit
a4a96fd94c
16 changed files with 671 additions and 39 deletions
|
@ -37,10 +37,10 @@ class GeneratorNodeTest {
|
|||
indented2
|
||||
dedented'''.toString, result.toString)
|
||||
assertEquals('''
|
||||
CompletableTraceRegion [myOffset=0, myLength=44] associations={
|
||||
CompletableTraceRegion [myOffset=0, myLength=44, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:100][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=14, myLength=21] associations={
|
||||
CompletableTraceRegion [myOffset=14, myLength=21, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [1:99][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
}
|
||||
}'''.toString, result.traceRegion.toString)
|
||||
|
@ -73,19 +73,19 @@ class GeneratorNodeTest {
|
|||
val result = processor.process(node)
|
||||
assertEquals(someCodeGen_noTrace(2).toString, result.toString)
|
||||
assertEquals('''
|
||||
CompletableTraceRegion [myOffset=0, myLength=80] associations={
|
||||
CompletableTraceRegion [myOffset=0, myLength=80, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:100][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=7, myLength=5] associations={
|
||||
CompletableTraceRegion [myOffset=7, myLength=5, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [10:90][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=28, myLength=5] associations={
|
||||
CompletableTraceRegion [myOffset=28, myLength=5, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [10:90][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=47, myLength=5] associations={
|
||||
CompletableTraceRegion [myOffset=47, myLength=5, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [11:89][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=68, myLength=5] associations={
|
||||
CompletableTraceRegion [myOffset=68, myLength=5, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [10:90][lineNumber=0, endLineNumber=0]][path=foo/mymodel.dsl]
|
||||
}
|
||||
}'''.toString, result.traceRegion.toString)
|
||||
|
|
|
@ -72,29 +72,137 @@ class TracingSugarTest {
|
|||
|
||||
val trace = (generated as ITraceRegionProvider).traceRegion
|
||||
Assert.assertEquals(LineDelimiters.toUnix('''
|
||||
CompletableTraceRegion [myOffset=0, myLength=55] associations={
|
||||
CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=0, myLength=17] associations={
|
||||
CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=6, myLength=6] associations={
|
||||
CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
}
|
||||
CompletableTraceRegion [myOffset=17, myLength=38] associations={
|
||||
CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=23, myLength=3] associations={
|
||||
CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=30, myLength=24] associations={
|
||||
CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=39, myLength=4] associations={
|
||||
CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=46, myLength=6] associations={
|
||||
CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
}
|
||||
}
|
||||
}'''), trace.toString)
|
||||
}
|
||||
|
||||
@Test def void testCodeGenerationWithDebug() {
|
||||
val root = parseHelper.parse(LineDelimiters.toUnix('''
|
||||
type String {}
|
||||
type Foo {
|
||||
String name;
|
||||
}
|
||||
'''))
|
||||
val fsa = new InMemoryFileSystemAccess
|
||||
fsa.generateTracedFile('foo/bar.txt', root, '''
|
||||
«FOR t : root.types»
|
||||
«t._generateTypeWithDebugging»
|
||||
«ENDFOR»
|
||||
''')
|
||||
val generated = fsa.textFiles.get(IFileSystemAccess.DEFAULT_OUTPUT + 'foo/bar.txt')
|
||||
|
||||
// check the generated string is as expected
|
||||
Assert.assertEquals(LineDelimiters.toUnix('''
|
||||
«FOR t : root.types»
|
||||
«t.generateTypeWithDebugging»
|
||||
«ENDFOR»
|
||||
'''), generated.toString)
|
||||
|
||||
val trace = (generated as ITraceRegionProvider).traceRegion
|
||||
Assert.assertEquals(LineDelimiters.toUnix('''
|
||||
CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=true] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
}
|
||||
CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=true] associations={
|
||||
LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
}
|
||||
}
|
||||
}'''), trace.toString)
|
||||
}
|
||||
|
||||
@Test def void testCodeGenerationWithDebug_02() {
|
||||
val root = parseHelper.parse(LineDelimiters.toUnix('''
|
||||
type String {}
|
||||
type Foo {
|
||||
String name;
|
||||
}
|
||||
'''))
|
||||
val fsa = new InMemoryFileSystemAccess
|
||||
fsa.generateTracedFile('foo/bar.txt', root, '''
|
||||
«FOR t : root.types»
|
||||
«t._generateTypeWithDebugging02»
|
||||
«ENDFOR»
|
||||
''')
|
||||
val generated = fsa.textFiles.get(IFileSystemAccess.DEFAULT_OUTPUT + 'foo/bar.txt')
|
||||
|
||||
// check the generated string is as expected
|
||||
Assert.assertEquals(LineDelimiters.toUnix('''
|
||||
«FOR t : root.types»
|
||||
«t.generateTypeWithDebugging»
|
||||
«ENDFOR»
|
||||
'''), generated.toString)
|
||||
|
||||
val trace = (generated as ITraceRegionProvider).traceRegion
|
||||
Assert.assertEquals(LineDelimiters.toUnix('''
|
||||
CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
}
|
||||
CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=true] associations={
|
||||
LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
} nestedRegions={
|
||||
CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=true] associations={
|
||||
LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={
|
||||
LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]
|
||||
}
|
||||
}
|
||||
|
@ -110,10 +218,30 @@ class TracingSugarTest {
|
|||
}
|
||||
'''
|
||||
|
||||
@Traced(useForDebugging=true) def _generateTypeWithDebugging(Type it) '''
|
||||
Class «_name» {
|
||||
«FOR p : properties»
|
||||
«p._generateProperty»
|
||||
«ENDFOR»
|
||||
}
|
||||
'''
|
||||
|
||||
@Traced def _generateTypeWithDebugging02(Type it) '''
|
||||
Class «_name» {
|
||||
«FOR p : properties»
|
||||
«p._generatePropertyWithDebugging»
|
||||
«ENDFOR»
|
||||
}
|
||||
'''
|
||||
|
||||
@Traced def _generateProperty(Property it) '''
|
||||
Property «_name» : «_type[name]»
|
||||
'''
|
||||
|
||||
@Traced(useForDebugging=true) def _generatePropertyWithDebugging(Property it) '''
|
||||
Property «_name(true)» : «_type[name]»
|
||||
'''
|
||||
|
||||
def generateType(Type it) '''
|
||||
Class «name» {
|
||||
«FOR p : properties»
|
||||
|
@ -122,6 +250,14 @@ class TracingSugarTest {
|
|||
}
|
||||
'''
|
||||
|
||||
def generateTypeWithDebugging(Type it) '''
|
||||
Class «name» {
|
||||
«FOR p : properties»
|
||||
«p.generateProperty»
|
||||
«ENDFOR»
|
||||
}
|
||||
'''
|
||||
|
||||
def generateProperty(Property it) '''
|
||||
Property «name» : «type.head.name»
|
||||
'''
|
||||
|
|
|
@ -48,7 +48,7 @@ public class GeneratorNodeTest {
|
|||
_builder.append("dedented");
|
||||
this.assertEquals(_builder.toString(), result.toString());
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
_builder_1.append("CompletableTraceRegion [myOffset=0, myLength=44] associations={");
|
||||
_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]");
|
||||
|
@ -56,7 +56,7 @@ public class GeneratorNodeTest {
|
|||
_builder_1.append("} nestedRegions={");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("CompletableTraceRegion [myOffset=14, myLength=21] associations={");
|
||||
_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]");
|
||||
|
@ -105,7 +105,7 @@ public class GeneratorNodeTest {
|
|||
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] associations={");
|
||||
_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]");
|
||||
|
@ -113,7 +113,7 @@ public class GeneratorNodeTest {
|
|||
_builder.append("} nestedRegions={");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("CompletableTraceRegion [myOffset=7, myLength=5] associations={");
|
||||
_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]");
|
||||
|
@ -122,7 +122,7 @@ public class GeneratorNodeTest {
|
|||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("CompletableTraceRegion [myOffset=28, myLength=5] associations={");
|
||||
_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]");
|
||||
|
@ -131,7 +131,7 @@ public class GeneratorNodeTest {
|
|||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("CompletableTraceRegion [myOffset=47, myLength=5] associations={");
|
||||
_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]");
|
||||
|
@ -140,7 +140,7 @@ public class GeneratorNodeTest {
|
|||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append(" ");
|
||||
_builder.append("CompletableTraceRegion [myOffset=68, myLength=5] associations={");
|
||||
_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]");
|
||||
|
|
|
@ -68,6 +68,14 @@ public class TracingSugarTest {
|
|||
return trace;
|
||||
}
|
||||
|
||||
public IGeneratorNode _name(final Property target, final boolean useForDebugging) {
|
||||
EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
|
||||
ILocationData location = this.location(target, feature, -1);
|
||||
CompositeGeneratorNode trace = this.trace(location, useForDebugging);
|
||||
this.append(trace, target.getName());
|
||||
return trace;
|
||||
}
|
||||
|
||||
public IGeneratorNode _name(final Property target, final Function<String, String> stringProvider) {
|
||||
EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
|
||||
ILocationData location = this.location(target, feature, -1);
|
||||
|
@ -92,6 +100,14 @@ public class TracingSugarTest {
|
|||
return trace;
|
||||
}
|
||||
|
||||
public IGeneratorNode _name(final Type target, final boolean useForDebugging) {
|
||||
EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
|
||||
ILocationData location = this.location(target, feature, -1);
|
||||
CompositeGeneratorNode trace = this.trace(location, useForDebugging);
|
||||
this.append(trace, target.getName());
|
||||
return trace;
|
||||
}
|
||||
|
||||
public IGeneratorNode _name(final Type target, final Function<String, String> stringProvider) {
|
||||
EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
|
||||
ILocationData location = this.location(target, feature, -1);
|
||||
|
@ -116,6 +132,14 @@ public class TracingSugarTest {
|
|||
return trace;
|
||||
}
|
||||
|
||||
public IGeneratorNode _name(final UnresolvedProxyProperty target, final boolean useForDebugging) {
|
||||
EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
|
||||
ILocationData location = this.location(target, feature, -1);
|
||||
CompositeGeneratorNode trace = this.trace(location, useForDebugging);
|
||||
this.append(trace, target.getName());
|
||||
return trace;
|
||||
}
|
||||
|
||||
public IGeneratorNode _name(final UnresolvedProxyProperty target, final Function<String, String> stringProvider) {
|
||||
EStructuralFeature feature = target.eClass().getEStructuralFeature("name");
|
||||
ILocationData location = this.location(target, feature, -1);
|
||||
|
@ -174,7 +198,7 @@ public class TracingSugarTest {
|
|||
Assert.assertEquals(LineDelimiters.toUnix(_builder_1.toString()), generated.toString());
|
||||
final AbstractTraceRegion trace = ((ITraceRegionProvider) generated).getTraceRegion();
|
||||
StringConcatenation _builder_2 = new StringConcatenation();
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=55] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -182,7 +206,7 @@ public class TracingSugarTest {
|
|||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=17] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -191,7 +215,7 @@ public class TracingSugarTest {
|
|||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=6, myLength=6] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -203,7 +227,7 @@ public class TracingSugarTest {
|
|||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=17, myLength=38] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -212,7 +236,7 @@ public class TracingSugarTest {
|
|||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=23, myLength=3] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -221,7 +245,7 @@ public class TracingSugarTest {
|
|||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=30, myLength=24] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -230,7 +254,7 @@ public class TracingSugarTest {
|
|||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=39, myLength=4] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -239,7 +263,263 @@ public class TracingSugarTest {
|
|||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=46, myLength=6] associations={");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append("}");
|
||||
Assert.assertEquals(LineDelimiters.toUnix(_builder_2.toString()), trace.toString());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCodeGenerationWithDebug() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type String {}");
|
||||
_builder.newLine();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("String name;");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final Model root = this.parseHelper.parse(LineDelimiters.toUnix(_builder.toString()));
|
||||
final InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
{
|
||||
EList<Type> _types = root.getTypes();
|
||||
for(final Type t : _types) {
|
||||
IGeneratorNode __generateTypeWithDebugging = TracingSugarTest.this._generateTypeWithDebugging(t);
|
||||
_builder.append(__generateTypeWithDebugging);
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this._myExtensions.generateTracedFile(fsa, "foo/bar.txt", root, _client);
|
||||
final CharSequence generated = fsa.getTextFiles().get((IFileSystemAccess.DEFAULT_OUTPUT + "foo/bar.txt"));
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
{
|
||||
EList<Type> _types = root.getTypes();
|
||||
for(final Type t : _types) {
|
||||
CharSequence _generateTypeWithDebugging = this.generateTypeWithDebugging(t);
|
||||
_builder_1.append(_generateTypeWithDebugging);
|
||||
_builder_1.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(LineDelimiters.toUnix(_builder_1.toString()), generated.toString());
|
||||
final AbstractTraceRegion trace = ((ITraceRegionProvider) generated).getTraceRegion();
|
||||
StringConcatenation _builder_2 = new StringConcatenation();
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=true] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=true] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append("}");
|
||||
Assert.assertEquals(LineDelimiters.toUnix(_builder_2.toString()), trace.toString());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCodeGenerationWithDebug_02() {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type String {}");
|
||||
_builder.newLine();
|
||||
_builder.append("type Foo {");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("String name;");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
final Model root = this.parseHelper.parse(LineDelimiters.toUnix(_builder.toString()));
|
||||
final InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
{
|
||||
EList<Type> _types = root.getTypes();
|
||||
for(final Type t : _types) {
|
||||
IGeneratorNode __generateTypeWithDebugging02 = TracingSugarTest.this._generateTypeWithDebugging02(t);
|
||||
_builder.append(__generateTypeWithDebugging02);
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this._myExtensions.generateTracedFile(fsa, "foo/bar.txt", root, _client);
|
||||
final CharSequence generated = fsa.getTextFiles().get((IFileSystemAccess.DEFAULT_OUTPUT + "foo/bar.txt"));
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
{
|
||||
EList<Type> _types = root.getTypes();
|
||||
for(final Type t : _types) {
|
||||
CharSequence _generateTypeWithDebugging = this.generateTypeWithDebugging(t);
|
||||
_builder_1.append(_generateTypeWithDebugging);
|
||||
_builder_1.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(LineDelimiters.toUnix(_builder_1.toString()), generated.toString());
|
||||
final AbstractTraceRegion trace = ((ITraceRegionProvider) generated).getTraceRegion();
|
||||
StringConcatenation _builder_2 = new StringConcatenation();
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=true] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("} nestedRegions={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=true] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("}");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={");
|
||||
_builder_2.newLine();
|
||||
_builder_2.append(" ");
|
||||
_builder_2.append("LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
|
||||
|
@ -263,19 +543,43 @@ public class TracingSugarTest {
|
|||
@Traced
|
||||
public IGeneratorNode _generateType(final Type it) {
|
||||
ILocationData _location = this._myExtensions.location(it);
|
||||
CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location);
|
||||
CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location, false);
|
||||
this._myExtensions.appendTemplate(_traceNode, __generateType(it));
|
||||
return _traceNode;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Traced
|
||||
public IGeneratorNode _generateTypeWithDebugging02(final Type it) {
|
||||
ILocationData _location = this._myExtensions.location(it);
|
||||
CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location, false);
|
||||
this._myExtensions.appendTemplate(_traceNode, __generateTypeWithDebugging02(it));
|
||||
return _traceNode;
|
||||
}
|
||||
|
||||
@Traced
|
||||
public IGeneratorNode _generateProperty(final Property it) {
|
||||
ILocationData _location = this._myExtensions.location(it);
|
||||
CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location);
|
||||
CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location, false);
|
||||
this._myExtensions.appendTemplate(_traceNode, __generateProperty(it));
|
||||
return _traceNode;
|
||||
}
|
||||
|
||||
@Traced(useForDebugging = true)
|
||||
public IGeneratorNode _generatePropertyWithDebugging(final Property it) {
|
||||
ILocationData _location = this._myExtensions.location(it);
|
||||
CompositeGeneratorNode _traceNode = this._myExtensions.trace(_location, true);
|
||||
this._myExtensions.appendTemplate(_traceNode, __generatePropertyWithDebugging(it));
|
||||
return _traceNode;
|
||||
}
|
||||
|
||||
public CharSequence generateType(final Type it) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("Class ");
|
||||
|
@ -297,6 +601,27 @@ public class TracingSugarTest {
|
|||
return _builder;
|
||||
}
|
||||
|
||||
public CharSequence generateTypeWithDebugging(final Type it) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("Class ");
|
||||
String _name = it.getName();
|
||||
_builder.append(_name);
|
||||
_builder.append(" {");
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
EList<Property> _properties = it.getProperties();
|
||||
for(final Property p : _properties) {
|
||||
_builder.append("\t");
|
||||
CharSequence _generateProperty = this.generateProperty(p);
|
||||
_builder.append(_generateProperty, "\t");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
return _builder;
|
||||
}
|
||||
|
||||
public CharSequence generateProperty(final Property it) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("Property ");
|
||||
|
@ -334,6 +659,56 @@ public class TracingSugarTest {
|
|||
return _client;
|
||||
}
|
||||
|
||||
public StringConcatenationClient __generateTypeWithDebugging(final Type it) {
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
_builder.append("Class ");
|
||||
IGeneratorNode __name = TracingSugarTest.this._myExtensions._name(it);
|
||||
_builder.append(__name);
|
||||
_builder.append(" {");
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
EList<Property> _properties = it.getProperties();
|
||||
for(final Property p : _properties) {
|
||||
_builder.append("\t");
|
||||
IGeneratorNode __generateProperty = TracingSugarTest.this._generateProperty(p);
|
||||
_builder.append(__generateProperty, "\t");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
}
|
||||
};
|
||||
return _client;
|
||||
}
|
||||
|
||||
public StringConcatenationClient __generateTypeWithDebugging02(final Type it) {
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
_builder.append("Class ");
|
||||
IGeneratorNode __name = TracingSugarTest.this._myExtensions._name(it);
|
||||
_builder.append(__name);
|
||||
_builder.append(" {");
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
EList<Property> _properties = it.getProperties();
|
||||
for(final Property p : _properties) {
|
||||
_builder.append("\t");
|
||||
IGeneratorNode __generatePropertyWithDebugging = TracingSugarTest.this._generatePropertyWithDebugging(p);
|
||||
_builder.append(__generatePropertyWithDebugging, "\t");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
}
|
||||
};
|
||||
return _client;
|
||||
}
|
||||
|
||||
public StringConcatenationClient __generateProperty(final Property it) {
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
|
@ -352,4 +727,23 @@ public class TracingSugarTest {
|
|||
};
|
||||
return _client;
|
||||
}
|
||||
|
||||
public StringConcatenationClient __generatePropertyWithDebugging(final Property it) {
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
_builder.append("Property ");
|
||||
IGeneratorNode __name = TracingSugarTest.this._myExtensions._name(it, true);
|
||||
_builder.append(__name);
|
||||
_builder.append(" : ");
|
||||
final Function1<Type, String> _function = (Type it_1) -> {
|
||||
return it_1.getName();
|
||||
};
|
||||
IGeneratorNode __type = TracingSugarTest.this._myExtensions._type(it, _function);
|
||||
_builder.append(__type);
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
};
|
||||
return _client;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -512,7 +512,7 @@ public abstract class AbstractTraceRegion {
|
|||
associatedText = "";
|
||||
else
|
||||
associatedText = " associations={\n " + Joiner.on("\n").join(associated).replace("\n", "\n ") + "\n}";
|
||||
return getClass().getSimpleName() + " [myOffset=" + getMyOffset() + ", myLength=" + getMyLength() + "]"
|
||||
return getClass().getSimpleName() + " [myOffset=" + getMyOffset() + ", myLength=" + getMyLength() + ", useForDebugging="+isUseForDebugging()+"]"
|
||||
+ associatedText + nestedText;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,15 @@ class GeneratorNodeExtensions {
|
|||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a root trace node for the given location
|
||||
*/
|
||||
def CompositeGeneratorNode trace(ILocationData data, boolean useForDebugging) {
|
||||
val result = new TraceNode(data)
|
||||
result.useForDebugging = useForDebugging
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a trace node for the given location, appended as a child on the given parent
|
||||
*/
|
||||
|
@ -37,6 +46,16 @@ class GeneratorNodeExtensions {
|
|||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a trace node for the given location, appended as a child on the given parent
|
||||
*/
|
||||
def CompositeGeneratorNode trace(CompositeGeneratorNode parent, ILocationData data, boolean useForDebugging) {
|
||||
val result = new TraceNode(data)
|
||||
result.useForDebugging = useForDebugging
|
||||
parent.children += result
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an indentation node, using the default indentation string, appended as a child on the given parent
|
||||
*/
|
||||
|
|
|
@ -125,7 +125,7 @@ class GeneratorNodeProcessor {
|
|||
protected def dispatch void doProcess(TraceNode node, Context ctx) {
|
||||
if (node._hasContent(ctx)) {
|
||||
val beforeRegion = ctx.currentRegion
|
||||
val newRegion = new CompletableTraceRegion(false, node.sourceLocation, beforeRegion)
|
||||
val newRegion = new CompletableTraceRegion(node.useForDebugging, node.sourceLocation, beforeRegion)
|
||||
val offset = ctx.contentLength
|
||||
val startLineNumber = ctx.currentLineNumber
|
||||
try {
|
||||
|
|
|
@ -24,4 +24,6 @@ class TraceNode extends CompositeGeneratorNode {
|
|||
this.sourceLocation = sourceLocation
|
||||
}
|
||||
|
||||
boolean useForDebugging
|
||||
|
||||
}
|
|
@ -22,11 +22,13 @@ import org.eclipse.xtext.generator.trace.ILocationData
|
|||
@Active(TracedProcessor)
|
||||
annotation Traced {
|
||||
String tracingSugarFieldName = '_traceExtensions'
|
||||
boolean useForDebugging = false
|
||||
}
|
||||
|
||||
class TracedProcessor extends AbstractMethodProcessor {
|
||||
|
||||
override doTransform(MutableMethodDeclaration annotatedMethod, extension TransformationContext context) {
|
||||
val useForDebugging = annotatedMethod.findAnnotation(Traced.findTypeGlobally).getBooleanValue("useForDebugging")
|
||||
val traceSugar = TracingSugar.newTypeReference
|
||||
val templateClient = StringConcatenationClient.newTypeReference
|
||||
val nodeType = IGeneratorNode.newTypeReference
|
||||
|
@ -55,7 +57,7 @@ class TracedProcessor extends AbstractMethodProcessor {
|
|||
annotatedMethod.returnType = nodeType
|
||||
annotatedMethod.body = '''
|
||||
«ILocationData» _location = this.«field.simpleName».location(«traceParam.simpleName»);
|
||||
«CompositeGeneratorNode» _traceNode = this.«field.simpleName».trace(_location);
|
||||
«CompositeGeneratorNode» _traceNode = this.«field.simpleName».trace(_location, «useForDebugging»);
|
||||
this.«field.simpleName».appendTemplate(_traceNode, _«annotatedMethod.simpleName»(«annotatedMethod.parameters.join(',')[simpleName]»));
|
||||
return _traceNode;
|
||||
'''
|
||||
|
|
|
@ -52,6 +52,18 @@ class TracedAccessorsProcessor extends AbstractClassProcessor {
|
|||
return trace;
|
||||
'''
|
||||
]
|
||||
annotatedClass.addMethod(getter.tracerName) [
|
||||
returnType = IGeneratorNode.newTypeReference()
|
||||
addParameter('target', t)
|
||||
addParameter('useForDebugging', Boolean.TYPE.newTypeReference())
|
||||
body = '''
|
||||
«EStructuralFeature» feature = target.eClass().getEStructuralFeature("«getter.featureName»");
|
||||
«ILocationData» location = this.location(target, feature, -1);
|
||||
«CompositeGeneratorNode» trace = this.trace(location, useForDebugging);
|
||||
this.append(trace, target.«getter.declaration.simpleName»());
|
||||
return trace;
|
||||
'''
|
||||
]
|
||||
}
|
||||
annotatedClass.addMethod(getter.tracerName) [
|
||||
returnType = IGeneratorNode.newTypeReference
|
||||
|
|
|
@ -38,6 +38,15 @@ public class GeneratorNodeExtensions {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a root trace node for the given location
|
||||
*/
|
||||
public CompositeGeneratorNode trace(final ILocationData data, final boolean useForDebugging) {
|
||||
final TraceNode result = new TraceNode(data);
|
||||
result.setUseForDebugging(useForDebugging);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a trace node for the given location, appended as a child on the given parent
|
||||
*/
|
||||
|
@ -48,6 +57,17 @@ public class GeneratorNodeExtensions {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a trace node for the given location, appended as a child on the given parent
|
||||
*/
|
||||
public CompositeGeneratorNode trace(final CompositeGeneratorNode parent, final ILocationData data, final boolean useForDebugging) {
|
||||
final TraceNode result = new TraceNode(data);
|
||||
result.setUseForDebugging(useForDebugging);
|
||||
List<IGeneratorNode> _children = parent.getChildren();
|
||||
_children.add(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an indentation node, using the default indentation string, appended as a child on the given parent
|
||||
*/
|
||||
|
|
|
@ -348,8 +348,9 @@ public class GeneratorNodeProcessor {
|
|||
boolean __hasContent = this._hasContent(node, ctx);
|
||||
if (__hasContent) {
|
||||
final AbstractTraceRegion beforeRegion = ctx.currentRegion;
|
||||
boolean _isUseForDebugging = node.isUseForDebugging();
|
||||
ILocationData _sourceLocation = node.getSourceLocation();
|
||||
final GeneratorNodeProcessor.CompletableTraceRegion newRegion = new GeneratorNodeProcessor.CompletableTraceRegion(false, _sourceLocation, beforeRegion);
|
||||
final GeneratorNodeProcessor.CompletableTraceRegion newRegion = new GeneratorNodeProcessor.CompletableTraceRegion(_isUseForDebugging, _sourceLocation, beforeRegion);
|
||||
final int offset = ctx.contentLength();
|
||||
final int startLineNumber = ctx.currentLineNumber();
|
||||
try {
|
||||
|
|
|
@ -26,6 +26,8 @@ public class TraceNode extends CompositeGeneratorNode {
|
|||
this.sourceLocation = sourceLocation;
|
||||
}
|
||||
|
||||
private boolean useForDebugging;
|
||||
|
||||
@Pure
|
||||
public ILocationData getSourceLocation() {
|
||||
return this.sourceLocation;
|
||||
|
@ -34,4 +36,13 @@ public class TraceNode extends CompositeGeneratorNode {
|
|||
public void setSourceLocation(final ILocationData sourceLocation) {
|
||||
this.sourceLocation = sourceLocation;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public boolean isUseForDebugging() {
|
||||
return this.useForDebugging;
|
||||
}
|
||||
|
||||
public void setUseForDebugging(final boolean useForDebugging) {
|
||||
this.useForDebugging = useForDebugging;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,5 @@ import org.eclipse.xtext.generator.trace.node.TracedProcessor;
|
|||
@Active(TracedProcessor.class)
|
||||
public @interface Traced {
|
||||
public String tracingSugarFieldName() default "_traceExtensions";
|
||||
public boolean useForDebugging() default false;
|
||||
}
|
||||
|
|
|
@ -111,8 +111,39 @@ public class TracedAccessorsProcessor extends AbstractClassProcessor {
|
|||
it.setBody(_client);
|
||||
};
|
||||
annotatedClass.addMethod(this.tracerName(getter), _function_5);
|
||||
final Procedure1<MutableMethodDeclaration> _function_6 = (MutableMethodDeclaration it) -> {
|
||||
it.setReturnType(context.newTypeReference(IGeneratorNode.class));
|
||||
it.addParameter("target", t);
|
||||
it.addParameter("useForDebugging", context.newTypeReference(Boolean.TYPE));
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
_builder.append(EStructuralFeature.class);
|
||||
_builder.append(" feature = target.eClass().getEStructuralFeature(\"");
|
||||
String _featureName = TracedAccessorsProcessor.this.featureName(getter);
|
||||
_builder.append(_featureName);
|
||||
_builder.append("\");");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append(ILocationData.class);
|
||||
_builder.append(" location = this.location(target, feature, -1);");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append(CompositeGeneratorNode.class);
|
||||
_builder.append(" trace = this.trace(location, useForDebugging);");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append("this.append(trace, target.");
|
||||
String _simpleName = getter.getDeclaration().getSimpleName();
|
||||
_builder.append(_simpleName);
|
||||
_builder.append("());");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append("return trace;");
|
||||
_builder.newLine();
|
||||
}
|
||||
};
|
||||
it.setBody(_client);
|
||||
};
|
||||
annotatedClass.addMethod(this.tracerName(getter), _function_6);
|
||||
}
|
||||
final Procedure1<MutableMethodDeclaration> _function_6 = (MutableMethodDeclaration it) -> {
|
||||
final Procedure1<MutableMethodDeclaration> _function_7 = (MutableMethodDeclaration it) -> {
|
||||
it.setReturnType(context.newTypeReference(IGeneratorNode.class));
|
||||
it.addParameter("target", t);
|
||||
final TypeReference stringProvider = context.newTypeReference(Function.class, rt, context.getString());
|
||||
|
@ -143,7 +174,7 @@ public class TracedAccessorsProcessor extends AbstractClassProcessor {
|
|||
};
|
||||
it.setBody(_client);
|
||||
};
|
||||
annotatedClass.addMethod(this.tracerName(getter), _function_6);
|
||||
annotatedClass.addMethod(this.tracerName(getter), _function_7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
|||
public class TracedProcessor extends AbstractMethodProcessor {
|
||||
@Override
|
||||
public void doTransform(final MutableMethodDeclaration annotatedMethod, @Extension final TransformationContext context) {
|
||||
final boolean useForDebugging = annotatedMethod.findAnnotation(context.findTypeGlobally(Traced.class)).getBooleanValue("useForDebugging");
|
||||
final TypeReference traceSugar = context.newTypeReference(TracingSugar.class);
|
||||
final TypeReference templateClient = context.newTypeReference(StringConcatenationClient.class);
|
||||
final TypeReference nodeType = context.newTypeReference(IGeneratorNode.class);
|
||||
|
@ -95,7 +96,9 @@ public class TracedProcessor extends AbstractMethodProcessor {
|
|||
_builder.append(" _traceNode = this.");
|
||||
String _simpleName_2 = field.getSimpleName();
|
||||
_builder.append(_simpleName_2);
|
||||
_builder.append(".trace(_location);");
|
||||
_builder.append(".trace(_location, ");
|
||||
_builder.append(useForDebugging);
|
||||
_builder.append(");");
|
||||
_builder.newLineIfNotEmpty();
|
||||
_builder.append("this.");
|
||||
String _simpleName_3 = field.getSimpleName();
|
||||
|
|
Loading…
Reference in a new issue