Search in sources :

Example 6 with IGeneratorNode

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

the class TracingSugarTest method testCodeGenerationWithDebug_02.

@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]");
        _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);
    }
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) EList(org.eclipse.emf.common.util.EList) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) AbstractTraceRegion(org.eclipse.xtext.generator.trace.AbstractTraceRegion) InMemoryFileSystemAccess(org.eclipse.xtext.generator.InMemoryFileSystemAccess) ITraceRegionProvider(org.eclipse.xtext.generator.trace.ITraceRegionProvider) Test(org.junit.Test)

Example 7 with IGeneratorNode

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

the class TracingSugarTest method __generateTypeWithDebugging.

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;
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) EList(org.eclipse.emf.common.util.EList) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property)

Example 8 with IGeneratorNode

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

the class TracingSugarTest method __generatePropertyWithDebugging.

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;
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 9 with IGeneratorNode

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

the class TracingSugarTest method __generateType.

public StringConcatenationClient __generateType(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;
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) EList(org.eclipse.emf.common.util.EList) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property)

Example 10 with IGeneratorNode

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

the class TracingSugarTest method __generateTypeWithDebugging02.

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;
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) EList(org.eclipse.emf.common.util.EList) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property)

Aggregations

IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)18 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)9 EList (org.eclipse.emf.common.util.EList)6 Type (org.eclipse.xtext.linking.lazy.lazyLinking.Type)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 InMemoryFileSystemAccess (org.eclipse.xtext.generator.InMemoryFileSystemAccess)3 AbstractTraceRegion (org.eclipse.xtext.generator.trace.AbstractTraceRegion)3 ITraceRegionProvider (org.eclipse.xtext.generator.trace.ITraceRegionProvider)3 NewLineNode (org.eclipse.xtext.generator.trace.node.NewLineNode)3 Model (org.eclipse.xtext.linking.lazy.lazyLinking.Model)3 Property (org.eclipse.xtext.linking.lazy.lazyLinking.Property)3 UnresolvedProxyProperty (org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty)3 Test (org.junit.Test)3 IndentNode (org.eclipse.xtext.generator.trace.node.IndentNode)2 TraceNode (org.eclipse.xtext.generator.trace.node.TraceNode)2 CompositeGeneratorNode (org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode)1 TemplateNode (org.eclipse.xtext.generator.trace.node.TemplateNode)1 TextNode (org.eclipse.xtext.generator.trace.node.TextNode)1