Search in sources :

Example 16 with IGeneratorNode

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

the class GeneratorNodeExtensions method appendNewLine.

/**
 * Appends a line separator node to the given parent.
 *
 * @return the given parent node
 */
public CompositeGeneratorNode appendNewLine(final CompositeGeneratorNode parent, final String lineSeparator) {
    List<IGeneratorNode> _children = parent.getChildren();
    NewLineNode _newLineNode = new NewLineNode(lineSeparator, false);
    _children.add(_newLineNode);
    return parent;
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) NewLineNode(org.eclipse.xtext.generator.trace.node.NewLineNode)

Example 17 with IGeneratorNode

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

the class GeneratorNodeExtensions method append.

/**
 * Creates a text node containing the toString() representation of the given object and
 * appends it to the given parent node.
 *
 * @return the given parent node
 */
public CompositeGeneratorNode append(final CompositeGeneratorNode parent, final Object object) {
    if ((object instanceof StringConcatenationClient)) {
        this.appendTemplate(parent, ((StringConcatenationClient) object));
    } else {
        if ((object instanceof IGeneratorNode)) {
            List<IGeneratorNode> _children = parent.getChildren();
            _children.add(((IGeneratorNode) object));
        } else {
            if ((object != null)) {
                List<IGeneratorNode> _children_1 = parent.getChildren();
                String _string = object.toString();
                TextNode _textNode = new TextNode(_string);
                _children_1.add(_textNode);
            }
        }
    }
    return parent;
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TextNode(org.eclipse.xtext.generator.trace.node.TextNode)

Example 18 with IGeneratorNode

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

the class TemplateNode method append.

@Override
public void append(final Object object, final String indentation) {
    int _length = indentation.length();
    boolean _greaterThan = (_length > 0);
    if (_greaterThan) {
        final CompositeGeneratorNode before = this.currentParent;
        try {
            IndentNode _indentNode = new IndentNode(indentation, false, true);
            this.currentParent = _indentNode;
            List<IGeneratorNode> _children = before.getChildren();
            _children.add(this.currentParent);
            this.append(object);
        } finally {
            this.currentParent = before;
        }
    } else {
        this.append(object);
    }
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) CompositeGeneratorNode(org.eclipse.xtext.generator.trace.node.CompositeGeneratorNode) IndentNode(org.eclipse.xtext.generator.trace.node.IndentNode)

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