@org.eclipse.xtext.xbase.lib.Extension - java examples

Here are the examples of the java api @org.eclipse.xtext.xbase.lib.Extension taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

137 Examples 7

19 View Complete Implementation : EMFGeneratorFragment2Test.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced EMFGeneratorFragment2Test {

    @Extension
    private final EMFGeneratorFragment2 _eMFGeneratorFragment2 = new EMFGeneratorFragment2();

    @Test
    public void testTrimMultiLineString() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/*foo*/");
        _builder.newLine();
        this.replacedertTrim("foo", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("/* ");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("* foo*/");
        _builder_1.newLine();
        this.replacedertTrim("foo", _builder_1.toString());
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("/* ");
        _builder_2.newLine();
        _builder_2.append(" ");
        _builder_2.append("* ");
        _builder_2.newLine();
        _builder_2.append(" ");
        _builder_2.append("* foo");
        _builder_2.newLine();
        _builder_2.append(" ");
        _builder_2.append("*/");
        _builder_2.newLine();
        this.replacedertTrim("foo", _builder_2.toString());
        StringConcatenation _builder_3 = new StringConcatenation();
        _builder_3.append("multi");
        _builder_3.newLine();
        _builder_3.append("foo");
        StringConcatenation _builder_4 = new StringConcatenation();
        _builder_4.append("/* ");
        _builder_4.newLine();
        _builder_4.append(" ");
        _builder_4.append("* multi");
        _builder_4.newLine();
        _builder_4.append(" ");
        _builder_4.append("* foo");
        _builder_4.newLine();
        _builder_4.append(" ");
        _builder_4.append("* ");
        _builder_4.newLine();
        _builder_4.append(" ");
        _builder_4.append("*/");
        _builder_4.newLine();
        this.replacedertTrim(_builder_3.toString(), _builder_4.toString());
        StringConcatenation _builder_5 = new StringConcatenation();
        _builder_5.append("/* foo */");
        _builder_5.newLine();
        this.replacedertTrim("foo", _builder_5.toString());
        this.replacedertTrim("foo", "foo");
        StringConcatenation _builder_6 = new StringConcatenation();
        _builder_6.append("Copyright (c) 2011, 2019 itemis AG (http://www.itemis.eu) and others.");
        _builder_6.newLine();
        _builder_6.append("All rights reserved. This program and the accompanying materials");
        _builder_6.newLine();
        _builder_6.append("are made available under the terms of the Eclipse Public License v1.0");
        _builder_6.newLine();
        _builder_6.append("which accompanies this distribution, and is available at");
        _builder_6.newLine();
        _builder_6.append("http://www.eclipse.org/legal/epl-v10.html");
        StringConcatenation _builder_7 = new StringConcatenation();
        _builder_7.append("/**");
        _builder_7.newLine();
        _builder_7.append(" ");
        _builder_7.append("* Copyright (c) 2011, 2019 itemis AG (http://www.itemis.eu) and others.");
        _builder_7.newLine();
        _builder_7.append(" ");
        _builder_7.append("* All rights reserved. This program and the accompanying materials");
        _builder_7.newLine();
        _builder_7.append(" ");
        _builder_7.append("* are made available under the terms of the Eclipse Public License v1.0");
        _builder_7.newLine();
        _builder_7.append(" ");
        _builder_7.append("* which accompanies this distribution, and is available at");
        _builder_7.newLine();
        _builder_7.append(" ");
        _builder_7.append("* http://www.eclipse.org/legal/epl-v10.html");
        _builder_7.newLine();
        _builder_7.append(" ");
        _builder_7.append("*/");
        this.replacedertTrim(_builder_6.toString(), _builder_7.toString());
        StringConcatenation _builder_8 = new StringConcatenation();
        _builder_8.append("Copyright (c) 2015, 2019 itemis AG (http://www.itemis.eu) and others.");
        _builder_8.newLine();
        _builder_8.append("All rights reserved. This program and the accompanying materials");
        _builder_8.newLine();
        _builder_8.append("are made available under the terms of the Eclipse Public License v1.0");
        _builder_8.newLine();
        _builder_8.append("which accompanies this distribution, and is available at");
        _builder_8.newLine();
        _builder_8.append("http://www.eclipse.org/legal/epl-v10.html");
        StringConcatenation _builder_9 = new StringConcatenation();
        _builder_9.append("/*******************************************************************************");
        _builder_9.newLine();
        _builder_9.append(" ");
        _builder_9.append("* Copyright (c) 2015, 2019 itemis AG (http://www.itemis.eu) and others.");
        _builder_9.newLine();
        _builder_9.append(" ");
        _builder_9.append("* All rights reserved. This program and the accompanying materials");
        _builder_9.newLine();
        _builder_9.append(" ");
        _builder_9.append("* are made available under the terms of the Eclipse Public License v1.0");
        _builder_9.newLine();
        _builder_9.append(" ");
        _builder_9.append("* which accompanies this distribution, and is available at");
        _builder_9.newLine();
        _builder_9.append(" ");
        _builder_9.append("* http://www.eclipse.org/legal/epl-v10.html");
        _builder_9.newLine();
        _builder_9.append(" ");
        _builder_9.append("*******************************************************************************/");
        this.replacedertTrim(_builder_8.toString(), _builder_9.toString());
    }

    private void replacedertTrim(final String expected, final String original) {
        replacedert.replacedertEquals(expected, this._eMFGeneratorFragment2.trimMultiLineComment(original));
    }
}

19 View Complete Implementation : AbstractFormatter2.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 *  <p>
 *  This is an abstract base clreplaced for language-specific formatters.
 *  </p>
 *
 *  <p>
 *  It is the formatters responsibility to create a list of text replacements, which, when applied to a text doreplacedent,
 *  increase the doreplacedents readability for humans. At the same time the text changes should not have an impact on the
 *  semantic model a parser would create from the doreplacedent.
 *  </p>
 *
 *  <p>
 *  Formatters based on this clreplaced compute text replacements in two logical steps: First, they traverses the semantic
 *  model and collect {@link ITextReplacer text replaces}. Each replacer is responsible for a (small) section of the
 *  doreplacedent. In a second step, the replacers are executed from the beginning to the end of the doreplacedent and create the
 *  actual {@link TextReplacement text replacements}. This decoupling allows it to traverse the semantic model in
 *  arbitrary order and yet compute information that requires sequential processing of the doreplacedent, e.g. indentation.
 *  </p>
 *
 *  <p>
 *  To allow subclreplacedes to implement this mechanism conveniently, there are several helper clreplacedes:
 *  </p>
 *
 *  <ul>
 *  <li>{@link ITextRegionAccess} allows to obtain text regions for elements in the semantic model.</li>
 *  <li>{@link ITextReplacer} creates {@link ITextReplacement replacements} for a specific region in the doreplacedent.</li>
 *  <li>{@link IFormattableDoreplacedent} collects {@link ITextReplacer replacers} and validates if they overlap.</li>
 *  </ul>
 *
 *  <p>
 *  A formatter based on this clreplaced typically uses the {@link ITextRegionAccess} to obtain the {@link IHiddenRegion}
 *  which precedes or trails {@link EObject semantic object}, {@link EStructuralFeature features}, {@link Keyword
 *  keywords}, or {@link RuleCall rule calls}. This {@link IHiddenRegion} represents the whitespace, newlines and
 *  comments between semantic tokens. No matter if there are zero or N hidden tokens between two semantic tokens, there
 *  is always exactly one {@link IHiddenRegion}. In other words, the {@link IHiddenRegion} groups all hidden tokens
 *  between two semantic tokens.
 *  </p>
 *
 *  <p>
 *  For the {@link IHiddenRegion}, the formatter will create a {@link ITextReplacer} and store the replacer in the
 *  {@link IFormattableDoreplacedent}. Typically this is a {@link HiddenRegionReplacer} parameterized with an
 *  {@link IHiddenRegionFormatting}. The {@link HiddenRegionReplacer} will then delegate to a {@link WhitespaceReplacer}
 *  or {@link CommentReplacer}, depending on which kind of tokens are inside the hidden region.
 *  </p>
 *
 *  <p>
 *  To format a doreplacedent with syntax confirming to the parser rule:
 *  </p>
 *
 *  <pre>
 *  Enreplacedy:
 *  	'enreplacedy' name=ValidID '{'
 *  		features+=Feature*
 *  	'}';
 *  </pre>
 *
 *  <p>
 *  the following formatter implementation (Xtend code) can be used:
 *  </p>
 *
 *  <pre>
 * 	def dispatch void format(Enreplacedy enreplacedy, extension IFormattableDoreplacedent doreplacedent) {
 * 		val open = enreplacedy.regionFor.keyword("{")
 * 		val close = enreplacedy.regionFor.keyword("}")
 * 		enreplacedy.regionFor.feature(ABSTRACT_ELEMENT__NAME).surround[oneSpace]
 * 		enreplacedy.superType.surround[oneSpace]
 * 		open.append[newLine]
 * 		interior(open, close)[indent]
 * 		format(enreplacedy.getSuperType(), doreplacedent);
 * 		for (Feature feature : enreplacedy.features) {
 * 			feature.format
 * 			feature.append[setNewLines(1, 1, 2)]
 * 		}
 * 	}
 *  </pre>
 *
 *  <p>
 *  For the full example, see the DomainModel Example. It can be accessed via {@code Eclipse -> File -> New -> Example.}
 *  </p>
 *
 *  <p>
 *  The clreplaced {@code Enreplacedy} is part of the semantic model.
 *  </p>
 *
 *  <p>
 *  The method calls {@code regionFor.feature()} and {@code regionFor.keyword()} are using extension methods: {@link
 *  ITextRegionExtensions#regionFor(EObject)} and {@link
 *  ISemanticRegionFinder#keyword(String)} respectively {@link ISemanticRegionFinder#feature(EStructuralFeature)}. They return an {@link ISemanticRegion}.
 *  </p>
 *
 *  <p>
 *  The methods {@code prepend()}, {@code append()} and {@code surround()} are extension methods from
 *  {@link IFormattableDoreplacedent}. They create and register an {@link HiddenRegionReplacer} for the {@link IHiddenRegion}
 *  before and/or after the provided {@link ISemanticRegion}.
 *  </p>
 *
 *  <p>
 *  Override {@code create*()} methods to customize formatter-local services.
 *  </p>
 *
 *  <p>
 *  This implementation is stateful and cannot be used in parallel.
 *  </p>
 *
 *  @see org.eclipse.xtext.formatting2 The package {@code org.eclipse.xtext.formatting2} for an introduction to the topic
 *  @see IFormatter2 {@code IFormatter2}: the interface to invoke the formatter
 *
 *  @see #format(Object, IFormattableDoreplacedent) The method {@code format(Object, IFormattableDoreplacedent)} should be
 *       overridden to implement a formatter
 *  @see #initialize(FormatterRequest) The method {@code initialize(FormatterRequest)} should be overridden to set values
 *       of member fields
 *  @see #reset() The method {@code reset()} should be overridden to cleanup after execution.
 *
 *  @author Moritz Eysholdt - Initial contribution and API
 *  @since 2.8
 */
public abstract clreplaced AbstractFormatter2 implements IFormatter2 {

    private FormatterRequest request = null;

    /**
     * Offer subclreplacedes access to the methods from {@link ITextRegionAccess} as extension methods.
     */
    @Extension
    protected ITextRegionExtensions textRegionExtensions;

    /**
     * Fall-back for types that are not handled by a subclreplacede's dispatch method.
     */
    protected void _format(Object obj, IFormattableDoreplacedent doreplacedent) {
    }

    /**
     * Fall-back for types that are not handled by a subclreplacede's dispatch method.
     */
    protected void _format(EObject obj, IFormattableDoreplacedent doreplacedent) {
        for (EObject child : obj.eContents()) doreplacedent.format(child);
    }

    /**
     * Fall-back for subclreplacedes that accidently try to dispatch over null values.
     */
    protected void _format(Void obj, IFormattableDoreplacedent doreplacedent) {
    }

    /**
     * For {@link XtextResource resources}, replacedume we want to format the first EObject from the contents list only.
     * Because that's where the parser puts the semantic model.
     */
    protected void _format(XtextResource resource, IFormattableDoreplacedent doreplacedent) {
        List<EObject> contents = resource.getContents();
        if (!contents.isEmpty()) {
            EObject model = contents.get(0);
            doreplacedent.format(model);
        }
    }

    public ITextReplacer createCommentReplacer(IComment comment) {
        EObject grammarElement = comment.getGrammarElement();
        if (grammarElement instanceof AbstractRule) {
            String ruleName = ((AbstractRule) grammarElement).getName();
            if (ruleName.startsWith("ML"))
                return new MultilineCommentReplacer(comment, '*');
            if (ruleName.startsWith("SL")) {
                if (comment.getLineRegions().get(0).getIndentation().getLength() > 0)
                    return new SinglelineDocCommentReplacer(comment, "//");
                else
                    return new SinglelineCodeCommentReplacer(comment, "//");
            }
        }
        String elementName = new GrammarElementreplacedleSwitch().showQualified().showRule().doSwitch(grammarElement);
        throw new IllegalStateException("No " + ITextReplacer.clreplaced.getSimpleName() + " configured for " + elementName);
    }

    public IFormattableDoreplacedent createFormattableRootDoreplacedent() {
        return new RootDoreplacedent(this);
    }

    public IFormattableSubDoreplacedent createFormattableSubDoreplacedent(ITextSegment region, IFormattableDoreplacedent parent) {
        return new SubDoreplacedent(region, parent);
    }

    public IHiddenRegionFormatter createHiddenRegionFormatter(IHiddenRegionFormatting formatting) {
        return new SingleHiddenRegionFormatter(formatting);
    }

    public IHiddenRegionFormatter createHiddenRegionFormatter(IHiddenRegionFormatting f1, IHiddenRegionFormatting f2) {
        return new DoubleHiddenRegionFormatter(f1, f2);
    }

    public IHiddenRegionFormatting createHiddenRegionFormatting() {
        return new HiddenRegionFormatting(this);
    }

    public IMerger<IHiddenRegionFormatting> createHiddenRegionFormattingMerger() {
        return new HiddenRegionFormattingMerger(this);
    }

    public ITextReplacer createHiddenRegionReplacer(IHiddenRegion region, IHiddenRegionFormatting formatting) {
        return new HiddenRegionReplacer(region, formatting);
    }

    public ITextReplacerContext createTextReplacerContext(IFormattableDoreplacedent doreplacedent) {
        return new TextReplacerContext(doreplacedent);
    }

    public IMerger<ITextReplacer> createTextReplacerMerger() {
        return new TextReplacerMerger(this);
    }

    public ITextReplacer createWhitespaceReplacer(ITextSegment hiddens, IHiddenRegionFormatting formatting) {
        return new WhitespaceReplacer(hiddens, formatting);
    }

    @Override
    public final List<ITextReplacement> format(FormatterRequest request) {
        try {
            initialize(request);
            XtextResource xtextResource = request.getTextRegionAccess().getResource();
            IFormattableDoreplacedent doreplacedent = createFormattableRootDoreplacedent();
            try {
                format(xtextResource, doreplacedent);
            } catch (RegionTraceMissingException e) {
                doreplacedent = handleTraceMissing(doreplacedent, e);
            }
            List<ITextReplacement> rendered = doreplacedent.renderToTextReplacements();
            List<ITextReplacement> postprocessed = postProcess(doreplacedent, rendered);
            return postprocessed;
        } finally {
            reset();
        }
    }

    protected IFormattableDoreplacedent handleTraceMissing(IFormattableDoreplacedent problematic, RegionTraceMissingException e) {
        if (request.isEnableDebugTracing()) {
            return problematic;
        }
        request.setEnableDebugTracing(true);
        XtextResource xtextResource = request.getTextRegionAccess().getResource();
        IFormattableDoreplacedent doreplacedent = createFormattableRootDoreplacedent();
        format(xtextResource, doreplacedent);
        return doreplacedent;
    }

    /**
     * Implement this method to create a language-specific formatter.
     *
     * See the JavaDoc of this clreplaced for a more detailed description of what your code should do.
     *
     * @param obj
     *            An XtextResource or an object for from your semantic model.
     * @param doreplacedent
     *            The doreplacedent to collect and execute {@link ITextReplacer}s.
     */
    public abstract void format(Object obj, IFormattableDoreplacedent doreplacedent);

    /**
     * @return a preference value from {@link FormatterRequest#getPreferences()}
     */
    public <T> T getPreference(TypedPreferenceKey<T> key) {
        return request.getPreferences().getPreference(key);
    }

    /**
     * @return the preferences from the {@link FormatterRequest}
     */
    public ITypedPreferenceValues getPreferences() {
        return request.getPreferences();
    }

    /**
     * @return the {@link FormatterRequest} that was preplaceded into {@link IFormatter2#format(FormatterRequest)} when
     *         invoking the formatter.
     */
    public FormatterRequest getRequest() {
        return request;
    }

    public ITextRegionAccess getTextRegionAccess() {
        return request.getTextRegionAccess();
    }

    /**
     * This method is deprecated, use #initialize(FormatterRequest) instead
     */
    @Deprecated
    protected void initalize(FormatterRequest request) {
        initialize(request);
    }

    /**
     * Overwrite this method to initialize member fields before {@link #format(Object, IFormattableDoreplacedent)} is called.
     */
    protected void initialize(FormatterRequest request) {
        this.request = request;
        this.textRegionExtensions = request.getTextRegionAccess().getExtensions();
    }

    protected boolean isInRequestedRange(EObject obj) {
        Collection<ITextRegion> regions = request.getRegions();
        if (regions.isEmpty())
            return true;
        ITextRegionAccess access = request.getTextRegionAccess();
        IEObjectRegion objRegion = access.regionForEObject(obj);
        if (objRegion == null)
            return false;
        IHiddenRegion previousHidden = objRegion.getPreviousHiddenRegion();
        IHiddenRegion nextHidden = objRegion.getNextHiddenRegion();
        int objOffset = previousHidden != null ? previousHidden.getOffset() : 0;
        int objEnd = nextHidden != null ? nextHidden.getEndOffset() : access.regionForRootEObject().getEndOffset();
        for (ITextRegion region : regions) {
            int regionOffset = region.getOffset();
            int regionEnd = regionOffset + region.getLength();
            if (regionOffset <= objEnd && regionEnd >= objOffset)
                return true;
        }
        return false;
    }

    private boolean isInRequestedRange(int offset, int endOffset) {
        Collection<ITextRegion> regions = request.getRegions();
        if (regions.isEmpty())
            return true;
        for (org.eclipse.xtext.util.ITextRegion region : regions) if (region.getOffset() <= offset && region.getOffset() + region.getLength() >= endOffset)
            return true;
        return false;
    }

    protected List<ITextReplacement> postProcess(IFormattableDoreplacedent doreplacedent, List<ITextReplacement> replacements) {
        List<ITextSegment> expected = Lists.newArrayList();
        IHiddenRegion current = getTextRegionAccess().regionForRootEObject().getPreviousHiddenRegion();
        while (current != null) {
            if (current.isUndefined() && isInRequestedRange(current.getOffset(), current.getEndOffset()))
                expected.addAll(current.getMergedSpaces());
            current = current.getNextHiddenRegion();
        }
        if (expected.isEmpty())
            return replacements;
        List<ITextSegment> missing = TextRegions.difference(expected, replacements);
        if (missing.isEmpty())
            return replacements;
        List<ITextReplacement> result = Lists.newArrayList(replacements);
        for (ITextSegment seg : missing) {
            IHiddenRegion h = null;
            if (seg instanceof IHiddenRegion)
                h = (IHiddenRegion) seg;
            if (seg instanceof IHiddenRegionPart)
                h = ((IHiddenRegionPart) seg).getHiddenRegion();
            if (h != null && (h.getNextSemanticRegion() == null || h.getPreviousSemanticRegion() == null))
                result.add(seg.replaceWith(""));
            else
                result.add(seg.replaceWith(" "));
        }
        return result;
    }

    /**
     * Overwrite this method to clean up member fields after {@link #format(Object, IFormattableDoreplacedent)} has been
     * called.
     */
    protected void reset() {
        this.request = null;
        this.textRegionExtensions = null;
    }

    public boolean shouldFormat(Object obj, IFormattableDoreplacedent doreplacedent) {
        if (obj instanceof EObject)
            return isInRequestedRange((EObject) obj);
        return true;
    }
}

19 View Complete Implementation : GeneratorNodeTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sven Efftinge - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced GeneratorNodeTest {

    @Extension
    private GeneratorNodeExtensions exts = new GeneratorNodeExtensions();

    @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.replacedertEquals(_builder.toString(), result.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("CompletableTraceRegion [myOffset=0, myLength=44, useForDebugging=false] replacedociations={");
        _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] replacedociations={");
        _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.replacedertEquals(_builder_1.toString(), result.getTraceRegion().toString());
    }

    @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.replacedertEquals(_builder.toString(), processor.process(node).toString());
    }

    @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.replacedertEquals(this.someCodeGen_noTrace(2).toString(), result.toString());
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("CompletableTraceRegion [myOffset=0, myLength=80, useForDebugging=false] replacedociations={");
        _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] replacedociations={");
        _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] replacedociations={");
        _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] replacedociations={");
        _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] replacedociations={");
        _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.replacedertEquals(_builder.toString(), result.getTraceRegion().toString());
    }

    private StringConcatenationClient someCodeGen(final int n) {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                {
                    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, n, true);
                    for (final Integer i : _doubleDotLessThan) {
                        _builder.append("before ");
                        CompositeGeneratorNode _append = GeneratorNodeTest.this.exts.append(GeneratorNodeTest.this.exts.trace(GeneratorNodeTest.this.loc((10 + (i).intValue()))), "Hello");
                        _builder.append(_append);
                        _builder.append(" after");
                        _builder.newLineIfNotEmpty();
                        _builder.append("  ");
                        StringConcatenationClient _someCodeGen = GeneratorNodeTest.this.someCodeGen((n - 1));
                        _builder.append(_someCodeGen, "  ");
                        _builder.newLineIfNotEmpty();
                    }
                }
            }
        };
        return _client;
    }

    private String someCodeGen_noTrace(final int n) {
        StringConcatenation _builder = new StringConcatenation();
        {
            ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, n, true);
            for (final Integer i : _doubleDotLessThan) {
                _builder.append("before ");
                _builder.append("Hello");
                _builder.append(" after");
                _builder.newLineIfNotEmpty();
                _builder.append("  ");
                String _someCodeGen_noTrace = this.someCodeGen_noTrace((n - 1));
                _builder.append(_someCodeGen_noTrace, "  ");
                _builder.newLineIfNotEmpty();
            }
        }
        return _builder.toString();
    }

    private LocationData loc(final int idx) {
        SourceRelativeURI _sourceRelativeURI = new SourceRelativeURI("foo/mymodel.dsl");
        return new LocationData(idx, (100 - idx), 0, 0, _sourceRelativeURI);
    }

    @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.replacedertEquals(_builder_3.toString(), processor.process(node).toString());
    }

    @Test
    public void testIndentVariants() {
        final CompositeGeneratorNode node = new CompositeGeneratorNode();
        this.doIndent(node, false, false);
        this.doIndent(node, true, false);
        this.doIndent(node, false, true);
        this.doIndent(node, true, true);
        final GeneratorNodeProcessor processor = new GeneratorNodeProcessor();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("// indentImmediately: false, indentEmptyLines: false");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("a");
        _builder.newLine();
        _builder.newLine();
        _builder.append("  ");
        _builder.append("bc");
        _builder.newLine();
        _builder.newLine();
        _builder.append("d");
        _builder.newLine();
        _builder.append("// indentImmediately: true, indentEmptyLines: false");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("a");
        _builder.newLine();
        _builder.newLine();
        _builder.append("  ");
        _builder.append("b  c");
        _builder.newLine();
        _builder.newLine();
        _builder.append("d  ");
        _builder.newLine();
        _builder.append("// indentImmediately: false, indentEmptyLines: true");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("a");
        _builder.newLine();
        _builder.append("  ");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("bc");
        _builder.newLine();
        _builder.append("  ");
        _builder.newLine();
        _builder.append("d");
        _builder.newLine();
        _builder.append("// indentImmediately: true, indentEmptyLines: true");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("a");
        _builder.newLine();
        _builder.append("  ");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("b  c");
        _builder.newLine();
        _builder.append("  ");
        _builder.newLine();
        _builder.append("d  ");
        _builder.newLine();
        this.replacedertEquals(_builder.toString(), processor.process(node).toString());
    }

    private void doIndent(final CompositeGeneratorNode parent, final boolean indentImmediately, final boolean indentEmptyLines) {
        this.exts.append(this.exts.append(parent, "// indentImmediately: "), Boolean.valueOf(indentImmediately));
        this.exts.appendNewLine(this.exts.append(this.exts.append(parent, ", indentEmptyLines: "), Boolean.valueOf(indentEmptyLines)));
        this.exts.append(parent, this.exts.append(this.exts.appendNewLine(this.exts.appendNewLine(this.exts.append(new IndentNode("  ", indentImmediately, indentEmptyLines), "a"))), "b"));
        this.exts.appendNewLine(this.exts.append(parent, this.exts.append(new IndentNode("  ", indentImmediately, indentEmptyLines), "c")));
        this.exts.append(parent, this.exts.appendNewLine(new IndentNode("  ", indentImmediately, indentEmptyLines)));
        this.exts.append(this.exts.append(parent, "d"), this.exts.appendNewLine(new IndentNode("  ", indentImmediately, indentEmptyLines)));
    }

    private void replacedertEquals(final String expected, final String actual) {
        final String expectedM = expected.toString().replaceAll(System.lineSeparator(), "\n");
        final String actualM = actual.toString().replaceAll(System.lineSeparator(), "\n");
        replacedert.replacedertEquals(expectedM, actualM);
    }
}

19 View Complete Implementation : ExtensionMethodsFields.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
@SuppressWarnings("all")
public clreplaced ExtensionMethodsFields {

    @Extension
    private MyListExtensions _myListExtensions = new MyListExtensions();

    public Object n() {
        Object _xblockexpression = null;
        {
            final ArrayList<String> list = new ArrayList<String>();
            this._myListExtensions.aListMethod(list);
            _xblockexpression = this._myListExtensions.anotherListMethod(list);
        }
        return _xblockexpression;
    }

    public Object n(@Extension final MyListExtensions extensions) {
        Object _xblockexpression = null;
        {
            final ArrayList<String> list = new ArrayList<String>();
            extensions.aListMethod(list);
            _xblockexpression = extensions.anotherListMethod(list);
        }
        return _xblockexpression;
    }

    public Object myStringMeth(final List<?> list) {
        return null;
    }

    public Object m() {
        Object _xblockexpression = null;
        {
            final ArrayList<String> list = new ArrayList<String>();
            _xblockexpression = this.myStringMeth(list);
        }
        return _xblockexpression;
    }

    public static void main(final String[] args) {
        String _firstUpper = StringExtensions.toFirstUpper("my string");
        InputOutput.<String>println(_firstUpper);
        final ArrayList<String> list = CollectionLiterals.<String>newArrayList("a", "b", "c");
        list.toString();
    }
}

19 View Complete Implementation : GeneratorNodePerformanceTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Dennis Huebner - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced GeneratorNodePerformanceTest {

    @Extension
    private GeneratorNodeExtensions exts = new GeneratorNodeExtensions();

    private static final int numberOfLines = 40_000;

    @Rule
    public final Timeout timeout = new Timeout(1000, TimeUnit.MILLISECONDS);

    @Test
    public void testBasicCreationAndProcessingPerformance() {
        final LocationData root = this.loc(0);
        CompositeGeneratorNode node = this.exts.appendNewLine(this.exts.append(this.exts.trace(root), "notindented"));
        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, GeneratorNodePerformanceTest.numberOfLines, true);
        for (final Integer i : _doubleDotLessThan) {
            this.exts.appendNewLine(this.exts.append(this.exts.indent(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();
        GeneratorNodeProcessor.Result _process = processor.process(node);
        String _string = null;
        if (_process != null) {
            _string = _process.toString();
        }
        replacedert.replacedertFalse(StringExtensions.isNullOrEmpty(_string));
    }

    private LocationData loc(final int idx) {
        SourceRelativeURI _sourceRelativeURI = new SourceRelativeURI("foo/mymodel.dsl");
        return new LocationData(idx, (100 - idx), 0, 0, _sourceRelativeURI);
    }
}

19 View Complete Implementation : ModelNodeProcessor.java
Copyright Apache License 2.0
Author : JanKoehnlein
@SuppressWarnings("all")
public clreplaced ModelNodeProcessor extends AbstractClreplacedProcessor {

    @Extension
    private TransformationContext context;

    @Override
    public void doTransform(final MutableClreplacedDeclaration annotatedClreplaced, final TransformationContext context) {
        this.context = context;
        final Type modelNodeAnnotationType = this.context.findTypeGlobally(ModelNode.clreplaced);
        final AnnotationReference modelAnnotation = annotatedClreplaced.findAnnotation(modelNodeAnnotationType);
        final ArrayList<String> validPropertyNames = CollectionLiterals.<String>newArrayList();
        final Consumer<String> _function = (String it) -> {
            final MemberDeclaration accessor = this.getPropertyAccessor(annotatedClreplaced, it, true);
            if ((accessor == null)) {
                this.context.addWarning(modelAnnotation, (("Cannot find JavaFX property \'" + it) + "\'"));
            }
            validPropertyNames.add(it);
        };
        ((List<String>) Conversions.doWrapArray(modelAnnotation.getStringArrayValue("value"))).forEach(_function);
        final MutableConstructorDeclaration existingNoArgConstructor = annotatedClreplaced.findDeclaredConstructor();
        if ((existingNoArgConstructor == null)) {
            final Procedure1<MutableConstructorDeclaration> _function_1 = (MutableConstructorDeclaration it) -> {
                it.setDocComment("Automatically generated by @ModelNode. Needed for deserialization.");
            };
            annotatedClreplaced.addConstructor(_function_1);
        }
        final TypeReference modelProviderType = this.context.newTypeReference("de.fxdiagram.core.model.XModelProvider");
        boolean _isreplacedignableFrom = modelProviderType.getType().isreplacedignableFrom(annotatedClreplaced);
        boolean _not = (!_isreplacedignableFrom);
        if (_not) {
            Iterable<? extends TypeReference> _implementedInterfaces = annotatedClreplaced.getImplementedInterfaces();
            Iterable<TypeReference> _plus = Iterables.<TypeReference>concat(_implementedInterfaces, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(modelProviderType)));
            annotatedClreplaced.setImplementedInterfaces(_plus);
        }
        final Procedure1<MutableMethodDeclaration> _function_2 = (MutableMethodDeclaration it) -> {
            it.addParameter("modelElement", this.context.newTypeReference("de.fxdiagram.core.model.ModelElementImpl"));
            Object _value = modelAnnotation.getValue("inherit");
            final boolean isInheritAttribtueSet = (!Objects.equal(_value, Boolean.FALSE));
            final TypeReference superClreplaced = annotatedClreplaced.getExtendedClreplaced();
            boolean _and = false;
            if (!isInheritAttribtueSet) {
                _and = false;
            } else {
                boolean _xifexpression = false;
                if ((superClreplaced != null)) {
                    boolean _xblockexpression = false;
                    {
                        final boolean isSuperImplementsModelProvider = modelProviderType.isreplacedignableFrom(superClreplaced);
                        Type _type = superClreplaced.getType();
                        AnnotationReference _findAnnotation = ((TypeDeclaration) _type).findAnnotation(modelNodeAnnotationType);
                        final boolean isSuperHasModelNodeAnnotation = (_findAnnotation != null);
                        _xblockexpression = (isSuperImplementsModelProvider || isSuperHasModelNodeAnnotation);
                    }
                    _xifexpression = _xblockexpression;
                } else {
                    _xifexpression = false;
                }
                _and = _xifexpression;
            }
            final boolean isInherit = _and;
            StringConcatenationClient _client = new StringConcatenationClient() {

                @Override
                protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                    {
                        if (isInherit) {
                            _builder.append("super.populate(modelElement);");
                        }
                    }
                    _builder.newLineIfNotEmpty();
                    {
                        final Function1<String, MemberDeclaration> _function = (String it_1) -> {
                            return ModelNodeProcessor.this.getPropertyAccessor(annotatedClreplaced, it_1, true);
                        };
                        List<MemberDeclaration> _map = ListExtensions.<String, MemberDeclaration>map(validPropertyNames, _function);
                        for (final MemberDeclaration accessor : _map) {
                            _builder.append("modelElement.addProperty(");
                            String _call = ModelNodeProcessor.this.getCall(accessor);
                            _builder.append(_call);
                            _builder.append(", ");
                            TypeReference _newTypeReference = ModelNodeProcessor.this.context.newTypeReference(ModelNodeProcessor.this.getComponentType(accessor).getType());
                            _builder.append(_newTypeReference);
                            _builder.append(".clreplaced);");
                            _builder.newLineIfNotEmpty();
                        }
                    }
                }
            };
            it.setBody(_client);
        };
        annotatedClreplaced.addMethod("populate", _function_2);
        final Function1<MutableMethodDeclaration, Boolean> _function_3 = (MutableMethodDeclaration it) -> {
            return Boolean.valueOf((Objects.equal(it.getSimpleName(), "postLoad") && IterableExtensions.isEmpty(it.getParameters())));
        };
        boolean _exists = IterableExtensions.exists(annotatedClreplaced.getDeclaredMethods(), _function_3);
        boolean _not_1 = (!_exists);
        if (_not_1) {
            final Procedure1<MutableMethodDeclaration> _function_4 = (MutableMethodDeclaration it) -> {
                StringConcatenationClient _client = new StringConcatenationClient() {

                    @Override
                    protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                    }
                };
                it.setBody(_client);
            };
            annotatedClreplaced.addMethod("postLoad", _function_4);
        }
        final Function1<MutableMethodDeclaration, Boolean> _function_5 = (MutableMethodDeclaration it) -> {
            return Boolean.valueOf((Objects.equal(it.getSimpleName(), "toString") && IterableExtensions.isEmpty(it.getParameters())));
        };
        boolean _exists_1 = IterableExtensions.exists(annotatedClreplaced.getDeclaredMethods(), _function_5);
        boolean _not_2 = (!_exists_1);
        if (_not_2) {
            final Procedure1<MutableMethodDeclaration> _function_6 = (MutableMethodDeclaration it) -> {
                it.setReturnType(this.context.newTypeReference(String.clreplaced));
                StringConcatenationClient _client = new StringConcatenationClient() {

                    @Override
                    protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                        _builder.append("return ");
                        TypeReference _newTypeReference = ModelNodeProcessor.this.context.newTypeReference("de.fxdiagram.core.model.ToString");
                        _builder.append(_newTypeReference);
                        _builder.append(".toString(this);");
                        _builder.newLineIfNotEmpty();
                    }
                };
                it.setBody(_client);
            };
            annotatedClreplaced.addMethod("toString", _function_6);
        }
    }

    protected CharSequence getHierarchy(final ClreplacedDeclaration clazz) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Clreplaced: ");
        String _simpleName = clazz.getSimpleName();
        _builder.append(_simpleName);
        _builder.newLineIfNotEmpty();
        {
            Iterable<? extends MethodDeclaration> _declaredMethods = clazz.getDeclaredMethods();
            for (final MethodDeclaration m : _declaredMethods) {
                _builder.append("\t");
                String _simpleName_1 = m.getSimpleName();
                _builder.append(_simpleName_1, "\t");
                _builder.newLineIfNotEmpty();
            }
        }
        CharSequence _elvis = null;
        TypeReference _extendedClreplaced = clazz.getExtendedClreplaced();
        Type _type = null;
        if (_extendedClreplaced != null) {
            _type = _extendedClreplaced.getType();
        }
        CharSequence _hierarchy = null;
        if (((ClreplacedDeclaration) _type) != null) {
            Type _type_1 = null;
            if (_extendedClreplaced != null) {
                _type_1 = _extendedClreplaced.getType();
            }
            _hierarchy = this.getHierarchy(((ClreplacedDeclaration) _type_1));
        }
        if (_hierarchy != null) {
            _elvis = _hierarchy;
        } else {
            _elvis = "";
        }
        _builder.append(_elvis);
        _builder.newLineIfNotEmpty();
        return _builder;
    }

    protected MemberDeclaration getPropertyAccessor(final ClreplacedDeclaration clazz, final String propertyName, final boolean allowPrivate) {
        FieldDeclaration _elvis = null;
        FieldDeclaration _findDeclaredField = clazz.findDeclaredField(propertyName);
        if (_findDeclaredField != null) {
            _elvis = _findDeclaredField;
        } else {
            FieldDeclaration _findDeclaredField_1 = clazz.findDeclaredField((propertyName + "Property"));
            _elvis = _findDeclaredField_1;
        }
        final FieldDeclaration field = _elvis;
        if (((field != null) && (allowPrivate || (!Objects.equal(field.getVisibility(), Visibility.PRIVATE))))) {
            return field;
        }
        MethodDeclaration _elvis_1 = null;
        MethodDeclaration _elvis_2 = null;
        MethodDeclaration _findDeclaredMethod = clazz.findDeclaredMethod(propertyName);
        if (_findDeclaredMethod != null) {
            _elvis_2 = _findDeclaredMethod;
        } else {
            MethodDeclaration _findDeclaredMethod_1 = clazz.findDeclaredMethod((propertyName + "Property"));
            _elvis_2 = _findDeclaredMethod_1;
        }
        if (_elvis_2 != null) {
            _elvis_1 = _elvis_2;
        } else {
            String _firstUpper = StringExtensions.toFirstUpper(propertyName);
            String _plus = ("get" + _firstUpper);
            MethodDeclaration _findDeclaredMethod_2 = clazz.findDeclaredMethod(_plus);
            _elvis_1 = _findDeclaredMethod_2;
        }
        final MethodDeclaration method = _elvis_1;
        if (((method != null) && (allowPrivate || (!Objects.equal(method.getVisibility(), Visibility.PRIVATE))))) {
            return method;
        }
        TypeReference _extendedClreplaced = clazz.getExtendedClreplaced();
        boolean _tripleNotEquals = (_extendedClreplaced != null);
        if (_tripleNotEquals) {
            Type _type = clazz.getExtendedClreplaced().getType();
            return this.getPropertyAccessor(((ClreplacedDeclaration) _type), propertyName, false);
        }
        return null;
    }

    protected TypeReference getComponentType(final MemberDeclaration member) {
        TypeReference _switchResult = null;
        boolean _matched = false;
        if (member instanceof MethodDeclaration) {
            _matched = true;
            _switchResult = ((MethodDeclaration) member).getReturnType();
        }
        if (!_matched) {
            if (member instanceof FieldDeclaration) {
                _matched = true;
                _switchResult = ((FieldDeclaration) member).getType();
            }
        }
        if (!_matched) {
            _switchResult = this.context.getObject();
        }
        return this.getComponentType(_switchResult);
    }

    protected String getCall(final MemberDeclaration member) {
        String _simpleName = member.getSimpleName();
        String _xifexpression = null;
        if ((member instanceof MethodDeclaration)) {
            _xifexpression = "()";
        } else {
            _xifexpression = "";
        }
        return (_simpleName + _xifexpression);
    }

    protected TypeReference getComponentType(final TypeReference it) {
        boolean _isreplacedignableFrom = this.context.newTypeReference(Property.clreplaced, this.context.newWildcardTypeReference()).isreplacedignableFrom(it);
        if (_isreplacedignableFrom) {
            TypeReference _elvis = null;
            TypeReference _elvis_1 = null;
            TypeReference _elvis_2 = null;
            TypeReference _elvis_3 = null;
            TypeReference _elvis_4 = null;
            TypeReference _elvis_5 = null;
            TypeReference _elvis_6 = null;
            TypeReference _elvis_7 = null;
            TypeReference _elvis_8 = null;
            TypeReference _elvis_9 = null;
            TypeReference _elvis_10 = null;
            TypeReference _elvis_11 = null;
            TypeReference _elvis_12 = null;
            TypeReference _elvis_13 = null;
            TypeReference _isListType = this.isListType(it, Double.clreplaced);
            if (_isListType != null) {
                _elvis_13 = _isListType;
            } else {
                TypeReference _isListType_1 = this.isListType(it, String.clreplaced);
                _elvis_13 = _isListType_1;
            }
            if (_elvis_13 != null) {
                _elvis_12 = _elvis_13;
            } else {
                TypeReference _isListType_2 = this.isListType(it, Integer.clreplaced);
                _elvis_12 = _isListType_2;
            }
            if (_elvis_12 != null) {
                _elvis_11 = _elvis_12;
            } else {
                TypeReference _isListType_3 = this.isListType(it, Boolean.clreplaced);
                _elvis_11 = _isListType_3;
            }
            if (_elvis_11 != null) {
                _elvis_10 = _elvis_11;
            } else {
                TypeReference _isListType_4 = this.isListType(it, Long.clreplaced);
                _elvis_10 = _isListType_4;
            }
            if (_elvis_10 != null) {
                _elvis_9 = _elvis_10;
            } else {
                TypeReference _isListType_5 = this.isListType(it, Float.clreplaced);
                _elvis_9 = _isListType_5;
            }
            if (_elvis_9 != null) {
                _elvis_8 = _elvis_9;
            } else {
                TypeReference _isListType_6 = this.isListType(it, Enum.clreplaced);
                _elvis_8 = _isListType_6;
            }
            if (_elvis_8 != null) {
                _elvis_7 = _elvis_8;
            } else {
                TypeReference _isListType_7 = this.isListType(it, Object.clreplaced);
                _elvis_7 = _isListType_7;
            }
            if (_elvis_7 != null) {
                _elvis_6 = _elvis_7;
            } else {
                TypeReference _isType = this.isType(it, DoubleProperty.clreplaced, Double.clreplaced);
                _elvis_6 = _isType;
            }
            if (_elvis_6 != null) {
                _elvis_5 = _elvis_6;
            } else {
                TypeReference _isType_1 = this.isType(it, StringProperty.clreplaced, String.clreplaced);
                _elvis_5 = _isType_1;
            }
            if (_elvis_5 != null) {
                _elvis_4 = _elvis_5;
            } else {
                TypeReference _isType_2 = this.isType(it, IntegerProperty.clreplaced, Integer.clreplaced);
                _elvis_4 = _isType_2;
            }
            if (_elvis_4 != null) {
                _elvis_3 = _elvis_4;
            } else {
                TypeReference _isType_3 = this.isType(it, BooleanProperty.clreplaced, Boolean.clreplaced);
                _elvis_3 = _isType_3;
            }
            if (_elvis_3 != null) {
                _elvis_2 = _elvis_3;
            } else {
                TypeReference _isType_4 = this.isType(it, LongProperty.clreplaced, Long.clreplaced);
                _elvis_2 = _isType_4;
            }
            if (_elvis_2 != null) {
                _elvis_1 = _elvis_2;
            } else {
                TypeReference _isType_5 = this.isType(it, FloatProperty.clreplaced, Float.clreplaced);
                _elvis_1 = _isType_5;
            }
            if (_elvis_1 != null) {
                _elvis = _elvis_1;
            } else {
                TypeReference _head = IterableExtensions.<TypeReference>head(it.getActualTypeArguments());
                _elvis = _head;
            }
            return _elvis;
        } else {
            return null;
        }
    }

    protected TypeReference isType(final TypeReference typeRef, final Clreplaced<? extends Property<?>> propertyType, final Clreplaced<?> clazz) {
        boolean _isreplacedignableFrom = this.context.newTypeReference(propertyType).isreplacedignableFrom(typeRef);
        if (_isreplacedignableFrom) {
            return this.context.newTypeReference(clazz);
        } else {
            return null;
        }
    }

    protected TypeReference isListType(final TypeReference typeRef, final Clreplaced<?> clazz) {
        final TypeReference componentType = this.context.newTypeReference(clazz);
        boolean _isreplacedignableFrom = this.context.newTypeReference(ListProperty.clreplaced, componentType).isreplacedignableFrom(typeRef);
        if (_isreplacedignableFrom) {
            return componentType;
        } else {
            return null;
        }
    }
}

19 View Complete Implementation : AntlrGrammarComparatorTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Contributes unit tests for {@link AntlrGrammarComparator}.
 *
 * @author Christian Schneider - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced AntlrGrammarComparatorTest {

    @Extension
    private AntlrGrammarComparatorTestHelper _antlrGrammarComparatorTestHelper = new AntlrGrammarComparatorTestHelper();

    /**
     * The pattern of "\"" is not expected to occur in ANTLR grammar,
     *  so I use it for testing the unmatched token check.
     */
    @Test(expected = replacedertionError.clreplaced)
    public void unmatchedTokens01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("\"\\\"\"a");
        _builder.newLine();
        final String testee = _builder.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, testee);
    }

    @Test
    public void stringMatch_00a() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void stringMatch_00b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void stringMatch_01a() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans hugo");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void stringMatch_01b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans hugo");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_01a() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hugo hans");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_01b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hugo hans");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_02a() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans hugo");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_02b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans hugo");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_03a() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_03b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_04() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hu");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans hugo");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void stringMismatch_05() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans hugo");
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans hu");
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void regExMatch01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("RULE_IN_RICH_STRING?");
        _builder.newLine();
        final String expected = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("RULE_IN_RICH_STRING ?");
        _builder_1.newLine();
        final String testee = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void regExMatch02() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("RULE_IN_RICH_STRING*");
        _builder.newLine();
        final String expected = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("RULE_IN_RICH_STRING *");
        _builder_1.newLine();
        final String testee = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void regExMatch03() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("RULE_IN_RICH_STRING+");
        _builder.newLine();
        final String expected = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("RULE_IN_RICH_STRING +");
        _builder_1.newLine();
        final String testee = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void snippetMatch01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("grammar InternalStatemachine;");
        _builder.newLine();
        _builder.append("options {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("superClreplaced=AbstractInternalAntlrParser;");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final String expected = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("grammar InternalStatemachine ;");
        _builder_1.newLine();
        _builder_1.append("options{");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("superClreplaced = AbstractInternalAntlrParser");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append(";");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        final String testee = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void snippetMatch02() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("((\t\'abstract\' ");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("| \t\'annotation\' ");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("| \t\'clreplaced\' ");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("| \t\'(\' ");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("|  RULE_ID | \tRULE_HEX )");
        _builder.newLine();
        final String expected = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("(");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("(\'abstract\' | \'annotation\' | \'clreplaced\' | \'(\' | RULE_ID | RULE_HEX )");
        _builder_1.newLine();
        final String testee = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void matchAllTokens01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("RULE_RICH_TEXT : \'\\\'\\\'\\\'\' RULE_IN_RICH_STRING* (\'\\\'\\\'\\\'\'|(\'\\\'\' \'\\\'\'?)? EOF);");
        _builder.newLine();
        final String testee = _builder.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, testee);
    }

    @Test
    public void matchAllTokens02() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("RULE_RICH_TEXT_START : \'\\\'\\\'\\\'\' RULE_IN_RICH_STRING* (\'\\\'\' \'\\\'\'?)? \'\\u00AB\';");
        _builder.newLine();
        _builder.newLine();
        _builder.append("RULE_RICH_TEXT_END : \'\\u00BB\' RULE_IN_RICH_STRING* (\'\\\'\\\'\\\'\'|(\'\\\'\' \'\\\'\'?)? EOF);");
        _builder.newLine();
        _builder.newLine();
        _builder.append("RULE_RICH_TEXT_INBETWEEN : \'\\u00BB\' RULE_IN_RICH_STRING* (\'\\\'\' \'\\\'\'?)? \'\\u00AB\';");
        _builder.newLine();
        _builder.newLine();
        _builder.append("RULE_COMMENT_RICH_TEXT_INBETWEEN : \'\\u00AB\\u00AB\' ~((\'\\n\'|\'\\r\'))* (\'\\r\'? \'\\n\' RULE_IN_RICH_STRING* (\'\\\'\' \'\\\'\'?)? \'\\u00AB\')?;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("RULE_COMMENT_RICH_TEXT_END : \'\\u00AB\\u00AB\' ~((\'\\n\'|\'\\r\'))* (\'\\r\'? \'\\n\' RULE_IN_RICH_STRING* (\'\\\'\\\'\\\'\'|(\'\\\'\' \'\\\'\'?)? EOF)|EOF);");
        _builder.newLine();
        final String testee = _builder.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, testee);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void mismatchOfParantheses01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans ( ( hugo )");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans ( hugo )");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void mismatchOfParantheses02() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("hans ( hugo ) )");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("hans ( hugo )");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void mismatchOfParantheses03() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("{ \'(\' ( \')\' }");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("{ \'(\' \')\' }");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void mismatchOfParantheses04() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("{ \'(\' \'( \')\' }");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("{ \'(\' \'(\' \')\' }");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void sLCommentIgnoring01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("// rule B");
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("B: \'B\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void sLCommentIgnoring01b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("// rule B");
        _builder_1.newLine();
        _builder_1.append("B: \'B\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void mismatchWithSLComment01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("// rule B");
        _builder_1.newLine();
        _builder_1.append("B: \'C\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compareAndExpectMismatchInLines(testee, expected, 3, 4);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void mismatchWithSLComment01b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("// rule B");
        _builder_1.newLine();
        _builder_1.append("B: \'C\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compareAndExpectMismatchInLines(testee, expected, 4, 4);
    }

    @Test
    public void mLCommentIgnoring01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/*");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("* rule B");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("B: \'B\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void mLCommentIgnoring01b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("/*");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("* rule B");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("*/");
        _builder_1.newLine();
        _builder_1.append("B: \'B\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compare(testee, expected);
    }

    @Test
    public void mismatchWithMLComment01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("/*");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("* rule B");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("*/");
        _builder_1.newLine();
        _builder_1.append("B: \'C\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compareAndExpectMismatchInLines(testee, expected, 3, 6);
    }

    @Test(expected = replacedertionError.clreplaced)
    public void mismatchWithMLComment01b() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("A: \'A\'");
        _builder.newLine();
        _builder.newLine();
        _builder.append("B: \'B\'");
        _builder.newLine();
        final String testee = _builder.toString();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("A: \'A\'");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("/*");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("* rule B");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("*/");
        _builder_1.newLine();
        _builder_1.append("B: \'C\'");
        _builder_1.newLine();
        final String expected = _builder_1.toString();
        this._antlrGrammarComparatorTestHelper.compareAndExpectMismatchInLines(testee, expected, 3, 5);
    }
}

18 View Complete Implementation : FileAwareTestLanguageReferenceUpdater.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced FileAwareTestLanguageReferenceUpdater extends ReferenceUpdater {

    @Inject
    private IQualifiedNameProvider names;

    @Extension
    private FileAwareFactory _fileAwareFactory = FileAwareFactory.eINSTANCE;

    @Override
    public void update(final IReferenceUpdaterContext context) {
        super.update(context);
        EObject _head = IterableExtensions.<EObject>head(context.getResource().getContents());
        final PackageDeclaration pkg = ((PackageDeclaration) _head);
        final QualifiedName pkgName = this.names.getFullyQualifiedName(pkg);
        final Function1<Import, Element> _function = (Import it) -> {
            return it.getElement();
        };
        final Map<Element, Import> actual = IterableExtensions.<Element, Import>toMap(pkg.getImports(), _function);
        final Function1<IUpdatableReference, EObject> _function_1 = (IUpdatableReference it) -> {
            return it.getTargetEObject();
        };
        final Iterable<Element> targets = Iterables.<Element>filter(ListExtensions.<IUpdatableReference, EObject>map(context.getUpdatableReferences(), _function_1), Element.clreplaced);
        final Function1<Element, Boolean> _function_2 = (Element it) -> {
            boolean _startsWith = this.names.getFullyQualifiedName(it).startsWith(pkgName);
            return Boolean.valueOf((!_startsWith));
        };
        final Set<Element> expected = IterableExtensions.<Element>toSet(IterableExtensions.<Element>filter(targets, _function_2));
        final Function1<Element, Boolean> _function_3 = (Element it) -> {
            boolean _containsKey = actual.containsKey(it);
            return Boolean.valueOf((!_containsKey));
        };
        final Set<Element> toAdd = IterableExtensions.<Element>toSet(IterableExtensions.<Element>filter(expected, _function_3));
        final Function2<Element, Import, Boolean> _function_4 = (Element $0, Import $1) -> {
            boolean _contains = expected.contains($0);
            return Boolean.valueOf((!_contains));
        };
        final Map<Element, Import> toDelete = MapExtensions.<Element, Import>filter(actual, _function_4);
        if (((!toAdd.isEmpty()) || (!toDelete.isEmpty()))) {
            final Runnable _function_5 = () -> {
                final Consumer<Import> _function_6 = (Import it) -> {
                    EcoreUtil.remove(it);
                };
                toDelete.values().forEach(_function_6);
                final Consumer<Element> _function_7 = (Element e) -> {
                    EList<Import> _imports = pkg.getImports();
                    Import _createImport = this._fileAwareFactory.createImport();
                    final Procedure1<Import> _function_8 = (Import it) -> {
                        it.setElement(e);
                    };
                    Import _doubleArrow = ObjectExtensions.<Import>operator_doubleArrow(_createImport, _function_8);
                    _imports.add(_doubleArrow);
                };
                toAdd.forEach(_function_7);
            };
            context.modifyModel(_function_5);
        }
    }
}

18 View Complete Implementation : GrammarAccessExtensionsTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced GrammarAccessExtensionsTest {

    @Extension
    private GrammarAccessExtensions _grammarAccessExtensions = new GrammarAccessExtensions();

    @Test
    public void testToJavaIdentifier() {
        replacedert.replacedertEquals("FooBar", this._grammarAccessExtensions.toJavaIdentifier("foo Bar", true));
        replacedert.replacedertEquals("Foo", this._grammarAccessExtensions.toJavaIdentifier("foo;", true));
        replacedert.replacedertEquals("foo", this._grammarAccessExtensions.toJavaIdentifier("foo;", false));
        replacedert.replacedertEquals("Colon", this._grammarAccessExtensions.toJavaIdentifier(":", true));
        replacedert.replacedertEquals("Colon", this._grammarAccessExtensions.toJavaIdentifier(":", false));
        replacedert.replacedertEquals("Semicolon", this._grammarAccessExtensions.toJavaIdentifier(";", false));
        replacedert.replacedertEquals("CommercialAtApostrophe", this._grammarAccessExtensions.toJavaIdentifier("@\'", false));
        replacedert.replacedertEquals("Gr�n", this._grammarAccessExtensions.toJavaIdentifier("Gr�n", true));
        replacedert.replacedertEquals("DollarSign", this._grammarAccessExtensions.toJavaIdentifier("$", true));
        replacedert.replacedertEquals("_", this._grammarAccessExtensions.toJavaIdentifier("_", true));
    }

    /**
     * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=298492
     */
    @Test
    public void testBug() throws Exception {
        replacedert.replacedertEquals("HiragreplacedetterRu", this._grammarAccessExtensions.toJavaIdentifier("\u308b", true));
    }

    @Test
    public void testSmoke() throws Exception {
        for (int i = 0; (i < 4000); i++) {
            {
                final String identifier = this._grammarAccessExtensions.toJavaIdentifier(String.valueOf(((char) i)), false);
                for (int j = 0; (j < identifier.length()); j++) {
                    {
                        final char charAt = identifier.charAt(j);
                        replacedert.replacedertTrue(((identifier + ":") + Character.valueOf(charAt)), this._grammarAccessExtensions.isValidJavaLatinIdentifier(charAt, (j == 0)));
                    }
                }
            }
        }
    }
}

18 View Complete Implementation : ExpressionsInterpreter.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
@SuppressWarnings("all")
public clreplaced ExpressionsInterpreter {

    @Inject
    @Extension
    private ExpressionsTypeProvider _expressionsTypeProvider;

    protected Object _interpret(final Expression e) {
        Object _switchResult = null;
        boolean _matched = false;
        if (!_matched) {
            if (e instanceof IntConstant) {
                _matched = true;
                _switchResult = Integer.valueOf(((IntConstant) e).getValue());
            }
        }
        if (!_matched) {
            if (e instanceof BoolConstant) {
                _matched = true;
                String _value = ((BoolConstant) e).getValue();
                _switchResult = Boolean.valueOf(Boolean.parseBoolean(_value));
            }
        }
        if (!_matched) {
            if (e instanceof StringConstant) {
                _matched = true;
                _switchResult = ((StringConstant) e).getValue();
            }
        }
        if (!_matched) {
            if (e instanceof Not) {
                _matched = true;
                Expression _expression = ((Not) e).getExpression();
                Object _interpret = this.interpret(_expression);
                _switchResult = Boolean.valueOf((!(((Boolean) _interpret)).booleanValue()));
            }
        }
        if (!_matched) {
            if (e instanceof MulOrDiv) {
                _matched = true;
                int _xblockexpression = (int) 0;
                {
                    Expression _left = ((MulOrDiv) e).getLeft();
                    Object _interpret = this.interpret(_left);
                    final Integer left = ((Integer) _interpret);
                    Expression _right = ((MulOrDiv) e).getRight();
                    Object _interpret_1 = this.interpret(_right);
                    final Integer right = ((Integer) _interpret_1);
                    int _xifexpression = (int) 0;
                    String _op = ((MulOrDiv) e).getOp();
                    boolean _equals = Objects.equal(_op, "*");
                    if (_equals) {
                        _xifexpression = ((left).intValue() * (right).intValue());
                    } else {
                        _xifexpression = ((left).intValue() / (right).intValue());
                    }
                    _xblockexpression = _xifexpression;
                }
                _switchResult = Integer.valueOf(_xblockexpression);
            }
        }
        if (!_matched) {
            if (e instanceof Minus) {
                _matched = true;
                Expression _left = ((Minus) e).getLeft();
                Object _interpret = this.interpret(_left);
                Expression _right = ((Minus) e).getRight();
                Object _interpret_1 = this.interpret(_right);
                _switchResult = Integer.valueOf(((((Integer) _interpret)).intValue() - (((Integer) _interpret_1)).intValue()));
            }
        }
        if (!_matched) {
            if (e instanceof Plus) {
                _matched = true;
                Object _xifexpression = null;
                boolean _or = false;
                Expression _left = ((Plus) e).getLeft();
                ExpressionsType _typeFor = this._expressionsTypeProvider.typeFor(_left);
                boolean _isString = this._expressionsTypeProvider.isString(_typeFor);
                if (_isString) {
                    _or = true;
                } else {
                    Expression _right = ((Plus) e).getRight();
                    ExpressionsType _typeFor_1 = this._expressionsTypeProvider.typeFor(_right);
                    boolean _isString_1 = this._expressionsTypeProvider.isString(_typeFor_1);
                    _or = _isString_1;
                }
                if (_or) {
                    Expression _left_1 = ((Plus) e).getLeft();
                    Object _interpret = this.interpret(_left_1);
                    String _string = _interpret.toString();
                    Expression _right_1 = ((Plus) e).getRight();
                    Object _interpret_1 = this.interpret(_right_1);
                    String _string_1 = _interpret_1.toString();
                    _xifexpression = (_string + _string_1);
                } else {
                    Expression _left_2 = ((Plus) e).getLeft();
                    Object _interpret_2 = this.interpret(_left_2);
                    Expression _right_2 = ((Plus) e).getRight();
                    Object _interpret_3 = this.interpret(_right_2);
                    _xifexpression = Integer.valueOf(((((Integer) _interpret_2)).intValue() + (((Integer) _interpret_3)).intValue()));
                }
                _switchResult = ((Comparable<?>) _xifexpression);
            }
        }
        if (!_matched) {
            if (e instanceof Equality) {
                _matched = true;
                boolean _xifexpression = false;
                String _op = ((Equality) e).getOp();
                boolean _equals = Objects.equal(_op, "==");
                if (_equals) {
                    Expression _left = ((Equality) e).getLeft();
                    Object _interpret = this.interpret(_left);
                    Expression _right = ((Equality) e).getRight();
                    Object _interpret_1 = this.interpret(_right);
                    _xifexpression = Objects.equal(_interpret, _interpret_1);
                } else {
                    Expression _left_1 = ((Equality) e).getLeft();
                    Object _interpret_2 = this.interpret(_left_1);
                    Expression _right_1 = ((Equality) e).getRight();
                    Object _interpret_3 = this.interpret(_right_1);
                    _xifexpression = (!Objects.equal(_interpret_2, _interpret_3));
                }
                _switchResult = Boolean.valueOf(_xifexpression);
            }
        }
        if (!_matched) {
            if (e instanceof And) {
                _matched = true;
                boolean _and = false;
                Expression _left = ((And) e).getLeft();
                Object _interpret = this.interpret(_left);
                if (!(((Boolean) _interpret)).booleanValue()) {
                    _and = false;
                } else {
                    Expression _right = ((And) e).getRight();
                    Object _interpret_1 = this.interpret(_right);
                    _and = (((Boolean) _interpret_1)).booleanValue();
                }
                _switchResult = Boolean.valueOf(_and);
            }
        }
        if (!_matched) {
            if (e instanceof Or) {
                _matched = true;
                boolean _or = false;
                Expression _left = ((Or) e).getLeft();
                Object _interpret = this.interpret(_left);
                if ((((Boolean) _interpret)).booleanValue()) {
                    _or = true;
                } else {
                    Expression _right = ((Or) e).getRight();
                    Object _interpret_1 = this.interpret(_right);
                    _or = (((Boolean) _interpret_1)).booleanValue();
                }
                _switchResult = Boolean.valueOf(_or);
            }
        }
        if (!_matched) {
            if (e instanceof Comparison) {
                _matched = true;
                boolean _xifexpression = false;
                Expression _left = ((Comparison) e).getLeft();
                ExpressionsType _typeFor = this._expressionsTypeProvider.typeFor(_left);
                boolean _isString = this._expressionsTypeProvider.isString(_typeFor);
                if (_isString) {
                    boolean _xblockexpression = false;
                    {
                        Expression _left_1 = ((Comparison) e).getLeft();
                        Object _interpret = this.interpret(_left_1);
                        final String left = ((String) _interpret);
                        Expression _right = ((Comparison) e).getRight();
                        Object _interpret_1 = this.interpret(_right);
                        final String right = ((String) _interpret_1);
                        boolean _switchResult_1 = false;
                        String _op = ((Comparison) e).getOp();
                        boolean _matched_1 = false;
                        if (!_matched_1) {
                            if (Objects.equal(_op, "<")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) < 0);
                            }
                        }
                        if (!_matched_1) {
                            if (Objects.equal(_op, ">")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) > 0);
                            }
                        }
                        if (!_matched_1) {
                            if (Objects.equal(_op, ">=")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) >= 0);
                            }
                        }
                        if (!_matched_1) {
                            if (Objects.equal(_op, "<=")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) <= 0);
                            }
                        }
                        if (!_matched_1) {
                            _switchResult_1 = false;
                        }
                        _xblockexpression = _switchResult_1;
                    }
                    _xifexpression = _xblockexpression;
                } else {
                    boolean _xblockexpression_1 = false;
                    {
                        Expression _left_1 = ((Comparison) e).getLeft();
                        Object _interpret = this.interpret(_left_1);
                        final Integer left = ((Integer) _interpret);
                        Expression _right = ((Comparison) e).getRight();
                        Object _interpret_1 = this.interpret(_right);
                        final Integer right = ((Integer) _interpret_1);
                        boolean _switchResult_1 = false;
                        String _op = ((Comparison) e).getOp();
                        boolean _matched_1 = false;
                        if (!_matched_1) {
                            if (Objects.equal(_op, "<")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) < 0);
                            }
                        }
                        if (!_matched_1) {
                            if (Objects.equal(_op, ">")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) > 0);
                            }
                        }
                        if (!_matched_1) {
                            if (Objects.equal(_op, ">=")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) >= 0);
                            }
                        }
                        if (!_matched_1) {
                            if (Objects.equal(_op, "<=")) {
                                _matched_1 = true;
                                _switchResult_1 = (left.compareTo(right) <= 0);
                            }
                        }
                        if (!_matched_1) {
                            _switchResult_1 = false;
                        }
                        _xblockexpression_1 = _switchResult_1;
                    }
                    _xifexpression = _xblockexpression_1;
                }
                _switchResult = Boolean.valueOf(_xifexpression);
            }
        }
        if (!_matched) {
            if (e instanceof VariableRef) {
                _matched = true;
                Variable _variable = ((VariableRef) e).getVariable();
                _switchResult = this.interpret(_variable);
            }
        }
        return _switchResult;
    }

    protected Object _interpret(final Variable v) {
        Expression _expression = v.getExpression();
        return this.interpret(_expression);
    }

    public Object interpret(final AbstractElement e) {
        if (e instanceof Expression) {
            return _interpret((Expression) e);
        } else if (e instanceof Variable) {
            return _interpret((Variable) e);
        } else {
            throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(e).toString());
        }
    }
}

18 View Complete Implementation : UriExtensionsTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
@RunWith(XtextRunner.clreplaced)
@InjectWith(TestLanguageIdeInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced UriExtensionsTest {

    @Inject
    @Extension
    private UriExtensions _uriExtensions;

    @Test
    public void test_toUri01() {
        replacedert.replacedertEquals(URI.createURI("file://path/to/resource"), this._uriExtensions.toUri("file://path/to/resource"));
    }

    @Test
    public void test_toUri_02() {
        replacedert.replacedertEquals(URI.createURI("file:///path/to/resource"), this._uriExtensions.toUri("file:///path/to/resource"));
    }

    @Test
    public void test_toUri03() {
        replacedert.replacedertEquals(URI.createURI("file://path%20with%20whitespaces/to/resource"), this._uriExtensions.toUri("file://path%20with%20whitespaces/to/resource"));
    }

    @Test
    public void test_toUri_04() {
        replacedert.replacedertEquals(URI.createURI("file:///path%20with%20whitespaces/to/resource"), this._uriExtensions.toUri("file:///path%20with%20whitespaces/to/resource"));
    }

    @Test
    public void test_toUri_05() {
        replacedert.replacedertEquals(URI.createURI("file:///dir/\u0424\u0443%20\u0411\u0430\u0440"), this._uriExtensions.toUri("file:///dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
    }

    @Test
    public void test_toUri_06() {
        replacedert.replacedertEquals(URI.createURI("file://dir/\u0424\u0443%20\u0411\u0430\u0440"), this._uriExtensions.toUri("file://dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
    }

    @Test
    public void test_toUri_07() {
        replacedert.replacedertEquals(URI.createURI("something:/path/to/resource"), this._uriExtensions.toUri("something:/path/to/resource"));
    }

    @Test
    public void test_toUri_08() {
        replacedert.replacedertEquals(URI.createURI("something://path/to/resource"), this._uriExtensions.toUri("something://path/to/resource"));
    }

    @Test
    public void test_toUri_09() {
        replacedert.replacedertEquals(URI.createURI("something:/dir/\u0424\u0443%20\u0411\u0430\u0440"), this._uriExtensions.toUri("something:/dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
    }

    @Test
    public void test_toUri_10() {
        replacedert.replacedertEquals(URI.createURI("something://dir/\u0424\u0443%20\u0411\u0430\u0440"), this._uriExtensions.toUri("something://dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
    }

    @Test
    public void test_toUri_11() {
        replacedert.replacedertEquals(URI.createURI("something:/path%20with%20whitespaces/to/resource"), this._uriExtensions.toUri("something:/path%20with%20whitespaces/to/resource"));
    }

    @Test
    public void test_toUri_12() {
        replacedert.replacedertEquals(URI.createURI("something://path%20with%20whitespaces/to/resource"), this._uriExtensions.toUri("something://path%20with%20whitespaces/to/resource"));
    }

    @Test
    public void test_toUri_13() {
        replacedert.replacedertEquals(URI.createURI("file:///c:/Users/dietrich/git/MyDSL_Imports/mydsl/workspace/src/something.mydsl"), this._uriExtensions.toUri("file:///c%3A/Users/dietrich/git/MyDSL_Imports/mydsl/workspace/src/something.mydsl"));
    }

    @Test
    public void test_toUri_14() {
        replacedert.replacedertEquals(URI.createURI("file:///c:/Users/dietrich/\u0424\u0443%20\u0411\u0430\u0440.mydsl"), this._uriExtensions.toUri("file:///c%3A/Users/dietrich/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80.mydsl"));
    }

    @Test
    public void test_toUriString_01() {
        replacedert.replacedertEquals("file:///path/to/resource", this._uriExtensions.toUriString(java.net.URI.create("file:///path/to/resource")));
    }

    @Test
    public void test_toUriString_02() {
        replacedert.replacedertEquals("file://path/to/resource", this._uriExtensions.toUriString(java.net.URI.create("file://path/to/resource")));
    }

    @Test
    public void test_toUriString_03() {
        replacedert.replacedertEquals("file:///dir/\u0424\u0443%20\u0411\u0430\u0440", this._uriExtensions.toUriString(java.net.URI.create("file:/dir/\u0424\u0443%20\u0411\u0430\u0440")));
    }

    @Test
    public void test_toUriString_04() {
        replacedert.replacedertEquals("file://dir/\u0424\u0443%20\u0411\u0430\u0440", this._uriExtensions.toUriString(java.net.URI.create("file://dir/\u0424\u0443%20\u0411\u0430\u0440")));
    }

    @Test
    public void test_toUriString_05() {
        replacedert.replacedertEquals("file://path/to/resource/", this._uriExtensions.toUriString(java.net.URI.create("file://path/to/resource/")));
    }

    @Test
    public void test_toUriString_06() {
        replacedert.replacedertEquals("file:///path/to/resource/", this._uriExtensions.toUriString(java.net.URI.create("file:/path/to/resource/")));
    }

    @Test
    public void test_toUriString_07() {
        replacedert.replacedertEquals("file:///path/to/resource/", this._uriExtensions.toUriString(java.net.URI.create("file:///path/to/resource/")));
    }

    @Test
    public void test_symmetric_01() {
        replacedert.replacedertEquals(URI.createURI("file:///path/to/resource"), this._uriExtensions.toUri(this._uriExtensions.toUriString(java.net.URI.create("file:///path/to/resource"))));
    }

    @Test
    public void test_symmetric_02() {
        replacedert.replacedertEquals(URI.createURI("file://path/to/resource"), this._uriExtensions.toUri(this._uriExtensions.toUriString(java.net.URI.create("file://path/to/resource"))));
    }

    @Test
    public void test_symmetric_03() {
        replacedert.replacedertEquals(URI.createURI("something:/path/to/resource"), this._uriExtensions.toUri(this._uriExtensions.toUriString(java.net.URI.create("something:/path/to/resource"))));
    }

    @Test
    public void test_symmetric_04() {
        replacedert.replacedertEquals(URI.createURI("something://path/to/resource"), this._uriExtensions.toUri(this._uriExtensions.toUriString(java.net.URI.create("something://path/to/resource"))));
    }

    @Test
    public void testConversion() {
        replacedert.replacedertEquals("file:///dir/name.ext", this._uriExtensions.toUriString(this._uriExtensions.toUri("file:///dir/name.ext")));
    }

    @Test
    public void testFileUriConversion() {
        try {
            final String expected = Paths.get(new File(".").getCanonicalPath()).resolve("dir").resolve("name.ext").toUri().toString();
            replacedert.replacedertEquals(expected, this._uriExtensions.toUriString(URI.createFileURI(new File("dir/name.ext").getAbsolutePath())));
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testFilesWithSpaces() {
        final URI x = this._uriExtensions.toUri("file:///dir/Foo%20Bar.testlang");
        final String y = this._uriExtensions.toUriString(x);
        replacedert.replacedertEquals("file:///dir/Foo%20Bar.testlang", y);
    }

    @Test
    public void testFilesWithCyrillicSymbols() {
        replacedert.replacedertEquals("file:///dir/\u0424\u0443%20\u0411\u0430\u0440.testlang", this._uriExtensions.toUriString(this._uriExtensions.toUri("file:///dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80.testlang")));
    }

    @Test
    public void testFolderIsPrefix() {
        File directory = new File("./test-data2/test-project");
        directory.mkdirs();
        replacedert.replacedertTrue(directory.exists());
        replacedert.replacedertTrue(directory.isDirectory());
        String _absolutePath = directory.getAbsolutePath();
        String _plus = (_absolutePath + "/");
        URI uri = this._uriExtensions.toUri(this._uriExtensions.toUriString(URI.createFileURI(_plus)));
        replacedert.replacedertTrue(uri.isPrefix());
    }

    @Test
    public void testFolderIsPrefixWithWhitespace() {
        File directory = this.createTempDir("some name with whitespaces").toFile();
        replacedert.replacedertTrue(directory.exists());
        replacedert.replacedertTrue(directory.isDirectory());
        replacedert.replacedertTrue(CharMatcher.whitespace().matchesAnyOf(directory.getName()));
        String _absolutePath = directory.getAbsolutePath();
        String _plus = (_absolutePath + "/");
        URI uri = this._uriExtensions.toUri(this._uriExtensions.toUriString(URI.createFileURI(_plus)));
        replacedert.replacedertTrue(uri.isPrefix());
    }

    @Test
    public void test_withEmptyAuthority() {
        final URI uriWithoutAuthority = URI.createURI("file:/path/to/resource/");
        replacedert.replacedertNull(uriWithoutAuthority.authority());
        final URI uriWithEmptyAuthority = this._uriExtensions.withEmptyAuthority(uriWithoutAuthority);
        replacedert.replacedertNotSame(uriWithoutAuthority, uriWithEmptyAuthority);
        replacedert.replacedertEquals("Returned URI is expected to have an empty instead of null authority", "", uriWithEmptyAuthority.authority());
        final URI uriWithAuthority = URI.createURI("https://xtext.org/path/to/resource/");
        replacedert.replacedertNotNull(uriWithAuthority.authority());
        replacedert.replacedertEquals("xtext.org", uriWithAuthority.authority());
        replacedert.replacedertSame(uriWithAuthority, this._uriExtensions.withEmptyAuthority(uriWithAuthority));
    }

    private Path createTempDir(final String prefix) {
        try {
            return Files.createTempDirectory(this.getTempDirPath(), prefix);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    private Path getTempDirPath() {
        return Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
    }
}

18 View Complete Implementation : PrepareRenameTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced PrepareRenameTest extends AbstractTestLangLanguageServerTest {

    @Inject
    @Extension
    private UriExtensions _uriExtensions;

    @Test
    public void testRenameFqn_missing_file_null() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("missing.");
            _builder.append(this.fileExtension);
            final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
            this.initializeWithPrepareSupport();
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 5);
            final RenameParams params = new RenameParams(_textDoreplacedentIdentifier, _position, "Does not matter");
            replacedert.replacedertNull(this.languageServer.rename(params).get());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_missing_file_null() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("missing.");
            _builder.append(this.fileExtension);
            final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
            this.initializeWithPrepareSupport();
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 5);
            final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
            replacedert.replacedertNull(this.languageServer.prepareRename(params).get());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_missing_file_exception() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("missing.");
        _builder.append(this.fileExtension);
        final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
        this.initialize();
        TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
        Position _position = new Position(2, 5);
        final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
        try {
            replacedert.replacedertNull(this.languageServer.prepareRename(params).get());
            replacedert.fail("Expected an error.");
        } catch (final Throwable _t) {
            if (_t instanceof Exception) {
                final Exception e = (Exception) _t;
                Throwable _rootCause = Throwables.getRootCause(e);
                replacedert.replacedertTrue((_rootCause instanceof FileNotFoundException));
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    }

    @Test
    public void testRenameFqn_invalid_error() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo.bar {");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("type A {");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("foo.bar.MyType bar");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("}");
        _builder.newLine();
        _builder.append("  ");
        _builder.append("type MyType { }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final String uri = this.writeFile("my-type-invalid.testlang", _builder);
        this.initialize();
        TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
        Position _position = new Position(2, 5);
        final RenameParams params = new RenameParams(_textDoreplacedentIdentifier, _position, "Does not matter");
        try {
            final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("Expected an expcetion when trying to rename doreplacedent but got a valid workspace edit instead: ");
            _builder_1.append(workspaceEdit);
            replacedert.fail(_builder_1.toString());
        } catch (final Throwable _t) {
            if (_t instanceof Exception) {
                final Exception e = (Exception) _t;
                final Throwable rootCause = Throwables.getRootCause(e);
                replacedert.replacedertTrue((rootCause instanceof ResponseErrorException));
                final ResponseError error = ((ResponseErrorException) rootCause).getResponseError();
                replacedert.replacedertTrue(error.getData().toString().contains("No element found at position"));
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    }

    @Test
    public void testRenameFqn_invalid_null() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String uri = this.writeFile("my-type-invalid.testlang", _builder);
            this.initializeWithPrepareSupport();
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 5);
            final RenameParams params = new RenameParams(_textDoreplacedentIdentifier, _position, "Does not matter");
            replacedert.replacedertNull(this.languageServer.rename(params).get());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testRenameFqn_before_ok() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String uri = this.writeFile("my-type-valid.testlang", _builder);
            this.initializeWithPrepareSupport();
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 13);
            final RenameParams params = new RenameParams(_textDoreplacedentIdentifier, _position, "YourType");
            final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("changes :");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("my-type-valid.testlang : foo.bar.YourType [[2, 4] .. [2, 18]]");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("YourType [[4, 7] .. [4, 13]]");
            _builder_1.newLine();
            _builder_1.append("doreplacedentChanges : ");
            _builder_1.newLine();
            this.replacedertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_before_nok() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String model = _builder.toString();
            this.initializeWithPrepareSupport();
            final String uri = this.writeFile("my-type-valid.testlang", model);
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 11);
            final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
            replacedert.replacedertNull(this.languageServer.prepareRename(params).get());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_start_ok() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String model = _builder.toString();
            this.initializeWithPrepareSupport();
            final String uri = this.writeFile("my-type-valid.testlang", model);
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 12);
            final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
            final Range range = this.languageServer.prepareRename(params).get().getLeft();
            this.replacedertEquals("MyType", new Doreplacedent(Integer.valueOf(0), model).getSubstring(range));
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_in_ok() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String model = _builder.toString();
            this.initializeWithPrepareSupport();
            final String uri = this.writeFile("my-type-valid.testlang", model);
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 14);
            final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
            final Range range = this.languageServer.prepareRename(params).get().getLeft();
            this.replacedertEquals("MyType", new Doreplacedent(Integer.valueOf(0), model).getSubstring(range));
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_end_ok() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String model = _builder.toString();
            this.initializeWithPrepareSupport();
            final String uri = this.writeFile("my-type-valid.testlang", model);
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 18);
            final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
            final Range range = this.languageServer.prepareRename(params).get().getLeft();
            this.replacedertEquals("MyType", new Doreplacedent(Integer.valueOf(0), model).getSubstring(range));
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testPrepareRenameFqn_end_null() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("package foo.bar {");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type A {");
            _builder.newLine();
            _builder.append("    ");
            _builder.append("foo.bar.MyType bar");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("}");
            _builder.newLine();
            _builder.append("  ");
            _builder.append("type MyType { }");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            final String model = _builder.toString();
            this.initialize();
            final String uri = this.writeFile("my-type-valid.testlang", model);
            TextDoreplacedentIdentifier _textDoreplacedentIdentifier = new TextDoreplacedentIdentifier(uri);
            Position _position = new Position(2, 18);
            final TextDoreplacedentPositionParams params = new TextDoreplacedentPositionParams(_textDoreplacedentIdentifier, _position);
            replacedert.replacedertNull(this.languageServer.prepareRename(params).get());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    private InitializeResult initializeWithPrepareSupport() {
        final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
            ClientCapabilities _clientCapabilities = new ClientCapabilities();
            final Procedure1<ClientCapabilities> _function_1 = (ClientCapabilities it_1) -> {
                TextDoreplacedentClientCapabilities _textDoreplacedentClientCapabilities = new TextDoreplacedentClientCapabilities();
                final Procedure1<TextDoreplacedentClientCapabilities> _function_2 = (TextDoreplacedentClientCapabilities it_2) -> {
                    RenameCapabilities _renameCapabilities = new RenameCapabilities();
                    final Procedure1<RenameCapabilities> _function_3 = (RenameCapabilities it_3) -> {
                        it_3.setPrepareSupport(Boolean.valueOf(true));
                    };
                    RenameCapabilities _doubleArrow = ObjectExtensions.<RenameCapabilities>operator_doubleArrow(_renameCapabilities, _function_3);
                    it_2.setRename(_doubleArrow);
                };
                TextDoreplacedentClientCapabilities _doubleArrow = ObjectExtensions.<TextDoreplacedentClientCapabilities>operator_doubleArrow(_textDoreplacedentClientCapabilities, _function_2);
                it_1.setTextDoreplacedent(_doubleArrow);
            };
            ClientCapabilities _doubleArrow = ObjectExtensions.<ClientCapabilities>operator_doubleArrow(_clientCapabilities, _function_1);
            it.setCapabilities(_doubleArrow);
        };
        return this.initialize(_function);
    }
}

18 View Complete Implementation : ExpressionsValidator.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
/**
 * Custom validation rules.
 *
 * see http://www.eclipse.org/Xtext/doreplacedentation.html#validation
 */
@SuppressWarnings("all")
public clreplaced ExpressionsValidator extends AbstractExpressionsValidator {

    public final static String FORWARD_REFERENCE = "org.example.expressions.ForwardReference";

    public final static String WRONG_TYPE = "org.example.expressions.WrongType";

    @Inject
    @Extension
    private ExpressionsTypeProvider _expressionsTypeProvider;

    @Check
    public void checkForwardReference(final VariableRef varRef) {
        final Variable variable = varRef.getVariable();
        boolean _and = false;
        boolean _notEquals = (!Objects.equal(variable, null));
        if (!_notEquals) {
            _and = false;
        } else {
            List<Variable> _variablesDefinedBefore = ExpressionsModelUtil.variablesDefinedBefore(varRef);
            boolean _contains = _variablesDefinedBefore.contains(variable);
            boolean _not = (!_contains);
            _and = _not;
        }
        if (_and) {
            String _name = variable.getName();
            String _plus = ("variable forward reference not allowed: \'" + _name);
            String _plus_1 = (_plus + "\'");
            EReference _variableRef_Variable = ExpressionsPackage.eINSTANCE.getVariableRef_Variable();
            String _name_1 = variable.getName();
            this.error(_plus_1, _variableRef_Variable, ExpressionsValidator.FORWARD_REFERENCE, _name_1);
        }
    }

    @Check
    public void checkType(final Not not) {
        Expression _expression = not.getExpression();
        this.checkExpectedBoolean(_expression, ExpressionsPackage.Literals.NOT__EXPRESSION);
    }

    @Check
    public void checkType(final MulOrDiv mulOrDiv) {
        Expression _left = mulOrDiv.getLeft();
        this.checkExpectedInt(_left, ExpressionsPackage.Literals.MUL_OR_DIV__LEFT);
        Expression _right = mulOrDiv.getRight();
        this.checkExpectedInt(_right, ExpressionsPackage.Literals.MUL_OR_DIV__RIGHT);
    }

    @Check
    public void checkType(final Minus minus) {
        Expression _left = minus.getLeft();
        this.checkExpectedInt(_left, ExpressionsPackage.Literals.MINUS__LEFT);
        Expression _right = minus.getRight();
        this.checkExpectedInt(_right, ExpressionsPackage.Literals.MINUS__RIGHT);
    }

    @Check
    public void checkType(final And and) {
        Expression _left = and.getLeft();
        this.checkExpectedBoolean(_left, ExpressionsPackage.Literals.AND__LEFT);
        Expression _right = and.getRight();
        this.checkExpectedBoolean(_right, ExpressionsPackage.Literals.AND__RIGHT);
    }

    @Check
    public void checkType(final Or or) {
        Expression _left = or.getLeft();
        this.checkExpectedBoolean(_left, ExpressionsPackage.Literals.OR__LEFT);
        Expression _right = or.getRight();
        this.checkExpectedBoolean(_right, ExpressionsPackage.Literals.OR__RIGHT);
    }

    @Check
    public void checkType(final Equality equality) {
        Expression _left = equality.getLeft();
        final ExpressionsType leftType = this.getTypeAndCheckNotNull(_left, ExpressionsPackage.Literals.EQUALITY__LEFT);
        Expression _right = equality.getRight();
        final ExpressionsType rightType = this.getTypeAndCheckNotNull(_right, ExpressionsPackage.Literals.EQUALITY__RIGHT);
        this.checkExpectedSame(leftType, rightType);
    }

    @Check
    public void checkType(final Comparison comparison) {
        Expression _left = comparison.getLeft();
        final ExpressionsType leftType = this.getTypeAndCheckNotNull(_left, ExpressionsPackage.Literals.COMPARISON__LEFT);
        Expression _right = comparison.getRight();
        final ExpressionsType rightType = this.getTypeAndCheckNotNull(_right, ExpressionsPackage.Literals.COMPARISON__RIGHT);
        this.checkExpectedSame(leftType, rightType);
        this.checkNotBoolean(leftType, ExpressionsPackage.Literals.COMPARISON__LEFT);
        this.checkNotBoolean(rightType, ExpressionsPackage.Literals.COMPARISON__RIGHT);
    }

    @Check
    public void checkType(final Plus plus) {
        Expression _left = plus.getLeft();
        final ExpressionsType leftType = this.getTypeAndCheckNotNull(_left, ExpressionsPackage.Literals.PLUS__LEFT);
        Expression _right = plus.getRight();
        final ExpressionsType rightType = this.getTypeAndCheckNotNull(_right, ExpressionsPackage.Literals.PLUS__RIGHT);
        boolean _or = false;
        boolean _or_1 = false;
        boolean _equals = Objects.equal(leftType, ExpressionsTypeProvider.intType);
        if (_equals) {
            _or_1 = true;
        } else {
            boolean _equals_1 = Objects.equal(rightType, ExpressionsTypeProvider.intType);
            _or_1 = _equals_1;
        }
        if (_or_1) {
            _or = true;
        } else {
            boolean _and = false;
            boolean _notEquals = (!Objects.equal(leftType, ExpressionsTypeProvider.stringType));
            if (!_notEquals) {
                _and = false;
            } else {
                boolean _notEquals_1 = (!Objects.equal(rightType, ExpressionsTypeProvider.stringType));
                _and = _notEquals_1;
            }
            _or = _and;
        }
        if (_or) {
            this.checkNotBoolean(leftType, ExpressionsPackage.Literals.PLUS__LEFT);
            this.checkNotBoolean(rightType, ExpressionsPackage.Literals.PLUS__RIGHT);
        }
    }

    private void checkExpectedSame(final ExpressionsType left, final ExpressionsType right) {
        boolean _and = false;
        boolean _and_1 = false;
        boolean _notEquals = (!Objects.equal(right, null));
        if (!_notEquals) {
            _and_1 = false;
        } else {
            boolean _notEquals_1 = (!Objects.equal(left, null));
            _and_1 = _notEquals_1;
        }
        if (!_and_1) {
            _and = false;
        } else {
            boolean _notEquals_2 = (!Objects.equal(right, left));
            _and = _notEquals_2;
        }
        if (_and) {
            EAttribute _eIDAttribute = ExpressionsPackage.Literals.EQUALITY.getEIDAttribute();
            this.error(((("expected the same type, but was " + left) + ", ") + right), _eIDAttribute, ExpressionsValidator.WRONG_TYPE);
        }
    }

    private void checkNotBoolean(final ExpressionsType type, final EReference reference) {
        boolean _equals = Objects.equal(type, ExpressionsTypeProvider.boolType);
        if (_equals) {
            this.error("cannot be boolean", reference, ExpressionsValidator.WRONG_TYPE);
        }
    }

    private void checkExpectedBoolean(final Expression exp, final EReference reference) {
        this.checkExpectedType(exp, ExpressionsTypeProvider.boolType, reference);
    }

    private void checkExpectedInt(final Expression exp, final EReference reference) {
        this.checkExpectedType(exp, ExpressionsTypeProvider.intType, reference);
    }

    private void checkExpectedType(final Expression exp, final ExpressionsType expectedType, final EReference reference) {
        final ExpressionsType actualType = this.getTypeAndCheckNotNull(exp, reference);
        boolean _notEquals = (!Objects.equal(actualType, expectedType));
        if (_notEquals) {
            this.error(((("expected " + expectedType) + " type, but was ") + actualType), reference, ExpressionsValidator.WRONG_TYPE);
        }
    }

    private ExpressionsType getTypeAndCheckNotNull(final Expression exp, final EReference reference) {
        ExpressionsType _typeFor = null;
        if (exp != null) {
            _typeFor = this._expressionsTypeProvider.typeFor(exp);
        }
        ExpressionsType type = _typeFor;
        boolean _equals = Objects.equal(type, null);
        if (_equals) {
            this.error("null type", reference, ExpressionsValidator.WRONG_TYPE);
        }
        return type;
    }
}

18 View Complete Implementation : EntitiesJvmModelInferrer.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
/**
 * <p>Infers a JVM model from the source model.</p>
 *
 * <p>The JVM model should contain all elements that would appear in the Java code
 * which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
 */
@SuppressWarnings("all")
public clreplaced EnreplacediesJvmModelInferrer extends AbstractModelInferrer {

    @Inject
    @Extension
    private JvmTypesBuilder _jvmTypesBuilder;

    /**
     * The dispatch method {@code infer} is called for each instance of the
     * given element's type that is contained in a resource.
     *
     * @param element
     *            the model to create one or more
     *            {@link org.eclipse.xtext.common.types.JvmDeclaredType declared
     *            types} from.
     * @param acceptor
     *            each created
     *            {@link org.eclipse.xtext.common.types.JvmDeclaredType type}
     *            without a container should be preplaceded to the acceptor in order
     *            get attached to the current resource. The acceptor's
     *            {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType)
     *            accept(..)} method takes the constructed empty type for the
     *            pre-indexing phase. This one is further initialized in the
     *            indexing phase using the closure you preplaced to the returned
     *            {@link org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor.IPostIndexingInitializing#initializeLater(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)
     *            initializeLater(..)}.
     * @param isPreIndexingPhase
     *            whether the method is called in a pre-indexing phase, i.e.
     *            when the global index is not yet fully updated. You must not
     *            rely on linking using the index if isPreIndexingPhase is
     *            <code>true</code>.
     */
    protected void _infer(final Enreplacedy enreplacedy, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
        String _name = enreplacedy.getName();
        String _plus = ("enreplacedies." + _name);
        JvmGenericType _clreplaced = this._jvmTypesBuilder.toClreplaced(enreplacedy, _plus);
        final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() {

            @Override
            public void apply(final JvmGenericType it) {
                String _doreplacedentation = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.getDoreplacedentation(enreplacedy);
                EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.setDoreplacedentation(it, _doreplacedentation);
                JvmParameterizedTypeReference _superType = enreplacedy.getSuperType();
                boolean _notEquals = (!Objects.equal(_superType, null));
                if (_notEquals) {
                    EList<JvmTypeReference> _superTypes = it.getSuperTypes();
                    JvmParameterizedTypeReference _superType_1 = enreplacedy.getSuperType();
                    JvmTypeReference _cloneWithProxies = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.cloneWithProxies(_superType_1);
                    EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _cloneWithProxies);
                }
                EList<Attribute> _attributes = enreplacedy.getAttributes();
                final Procedure1<Attribute> _function = new Procedure1<Attribute>() {

                    @Override
                    public void apply(final Attribute a) {
                        JvmTypeReference _elvis = null;
                        JvmTypeReference _type = a.getType();
                        if (_type != null) {
                            _elvis = _type;
                        } else {
                            XExpression _initexpression = a.getInitexpression();
                            JvmTypeReference _inferredType = null;
                            if (_initexpression != null) {
                                _inferredType = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.inferredType(_initexpression);
                            }
                            _elvis = _inferredType;
                        }
                        final JvmTypeReference type = _elvis;
                        EList<JvmMember> _members = it.getMembers();
                        String _name = a.getName();
                        final Procedure1<JvmField> _function = new Procedure1<JvmField>() {

                            @Override
                            public void apply(final JvmField it) {
                                String _doreplacedentation = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.getDoreplacedentation(a);
                                EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.setDoreplacedentation(it, _doreplacedentation);
                                XExpression _initexpression = a.getInitexpression();
                                boolean _notEquals = (!Objects.equal(_initexpression, null));
                                if (_notEquals) {
                                    XExpression _initexpression_1 = a.getInitexpression();
                                    EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.setInitializer(it, _initexpression_1);
                                }
                            }
                        };
                        JvmField _field = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.toField(a, _name, type, _function);
                        EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmField>operator_add(_members, _field);
                        EList<JvmMember> _members_1 = it.getMembers();
                        String _name_1 = a.getName();
                        JvmOperation _getter = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.toGetter(a, _name_1, type);
                        EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _getter);
                        EList<JvmMember> _members_2 = it.getMembers();
                        String _name_2 = a.getName();
                        JvmOperation _setter = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.toSetter(a, _name_2, type);
                        EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _setter);
                    }
                };
                IterableExtensions.<Attribute>forEach(_attributes, _function);
                EList<Operation> _operations = enreplacedy.getOperations();
                final Procedure1<Operation> _function_1 = new Procedure1<Operation>() {

                    @Override
                    public void apply(final Operation op) {
                        EList<JvmMember> _members = it.getMembers();
                        String _name = op.getName();
                        JvmTypeReference _elvis = null;
                        JvmTypeReference _type = op.getType();
                        if (_type != null) {
                            _elvis = _type;
                        } else {
                            JvmTypeReference _inferredType = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.inferredType();
                            _elvis = _inferredType;
                        }
                        final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() {

                            @Override
                            public void apply(final JvmOperation it) {
                                String _doreplacedentation = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.getDoreplacedentation(op);
                                EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.setDoreplacedentation(it, _doreplacedentation);
                                EList<JvmFormalParameter> _params = op.getParams();
                                for (final JvmFormalParameter p : _params) {
                                    EList<JvmFormalParameter> _parameters = it.getParameters();
                                    String _name = p.getName();
                                    JvmTypeReference _parameterType = p.getParameterType();
                                    JvmFormalParameter _parameter = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.toParameter(p, _name, _parameterType);
                                    EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
                                }
                                XExpression _body = op.getBody();
                                EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _body);
                            }
                        };
                        JvmOperation _method = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.toMethod(op, _name, _elvis, _function);
                        EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
                    }
                };
                IterableExtensions.<Operation>forEach(_operations, _function_1);
                EList<JvmMember> _members = it.getMembers();
                JvmTypeReference _typeRef = EnreplacediesJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.clreplaced);
                final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() {

                    @Override
                    public void apply(final JvmOperation it) {
                        final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {

                            @Override
                            public void apply(final ITreeAppendable it) {
                                StringConcatenation _builder = new StringConcatenation();
                                _builder.append("return");
                                _builder.newLine();
                                _builder.append("\"enreplacedy ");
                                String _name = enreplacedy.getName();
                                _builder.append(_name, "");
                                _builder.append(" {\\n\" +");
                                _builder.newLineIfNotEmpty();
                                {
                                    EList<Attribute> _attributes = enreplacedy.getAttributes();
                                    for (final Attribute a : _attributes) {
                                        _builder.append("\t");
                                        _builder.append("\"\\t");
                                        String _name_1 = a.getName();
                                        _builder.append(_name_1, "\t");
                                        _builder.append(" = \" + ");
                                        String _name_2 = a.getName();
                                        _builder.append(_name_2, "\t");
                                        _builder.append(".toString() + \"\\n\" +");
                                        _builder.newLineIfNotEmpty();
                                    }
                                }
                                _builder.append("\"}\";");
                                it.append(_builder);
                            }
                        };
                        EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.setBody(it, _function);
                    }
                };
                JvmOperation _method = EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.toMethod(enreplacedy, "toString", _typeRef, _function_2);
                EnreplacediesJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
            }
        };
        acceptor.<JvmGenericType>accept(_clreplaced, _function);
    }

    public void infer(final EObject enreplacedy, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
        if (enreplacedy instanceof Enreplacedy) {
            _infer((Enreplacedy) enreplacedy, acceptor, isPreIndexingPhase);
            return;
        } else if (enreplacedy != null) {
            _infer(enreplacedy, acceptor, isPreIndexingPhase);
            return;
        } else {
            throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(enreplacedy, acceptor, isPreIndexingPhase).toString());
        }
    }
}

18 View Complete Implementation : TestLanguageRenameService.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced TestLanguageRenameService extends RenameService2 {

    @Inject
    @Extension
    private EObjectAtOffsetHelper _eObjectAtOffsetHelper;

    @Override
    protected EObject getElementWithIdentifierAt(final XtextResource xtextResource, final int offset) {
        if ((offset >= 0)) {
            IParseResult _parseResult = null;
            if (xtextResource != null) {
                _parseResult = xtextResource.getParseResult();
            }
            ICompositeNode _rootNode = null;
            if (_parseResult != null) {
                _rootNode = _parseResult.getRootNode();
            }
            final ICompositeNode rootNode = _rootNode;
            if ((rootNode != null)) {
                final ILeafNode leaf = NodeModelUtils.findLeafNodeAtOffset(rootNode, offset);
                if (((leaf != null) && this.isIdentifier(leaf))) {
                    final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(xtextResource, offset);
                    if ((element != null)) {
                        final IQualifiedNameProvider nameProvider = xtextResource.getResourceServiceProvider().<IQualifiedNameProvider>get(IQualifiedNameProvider.clreplaced);
                        final QualifiedName fqn = nameProvider.getFullyQualifiedName(element);
                        if ((fqn != null)) {
                            final String leafText = NodeModelUtils.getTokenText(leaf);
                            if ((((fqn.getSegmentCount() == 1) && Objects.equal(fqn.toString(), leafText)) || Objects.equal(fqn.getLastSegment(), leafText))) {
                                return element;
                            }
                        }
                    }
                }
            }
        }
        return null;
    }
}

18 View Complete Implementation : DomainModelUtil.java
Copyright Apache License 2.0
Author : JanKoehnlein
@SuppressWarnings("all")
public clreplaced DomainModelUtil {

    @Inject
    @Extension
    private IJvmModelreplacedociations _iJvmModelreplacedociations;

    @Inject
    private CommonTypeComputationServices services;

    public Enreplacedy getReferencedEnreplacedy(final JvmTypeReference it) {
        Object _xblockexpression = null;
        {
            JvmTypeReference _componentType = null;
            if (it != null) {
                _componentType = this.getComponentType(it);
            }
            JvmType _type = null;
            if (_componentType != null) {
                _type = _componentType.getType();
            }
            EObject _primarySourceElement = null;
            if (_type != null) {
                _primarySourceElement = this._iJvmModelreplacedociations.getPrimarySourceElement(_type);
            }
            final EObject sourceType = _primarySourceElement;
            Object _xifexpression = null;
            if ((sourceType instanceof Enreplacedy)) {
                return ((Enreplacedy) sourceType);
            } else {
                _xifexpression = null;
            }
            _xblockexpression = _xifexpression;
        }
        return ((Enreplacedy) _xblockexpression);
    }

    public JvmTypeReference getComponentType(final JvmTypeReference it) {
        final LightweightTypeReference type = new StandardTypeReferenceOwner(this.services, it).toLightweightTypeReference(it);
        LightweightTypeReference _xifexpression = null;
        boolean _isArray = type.isArray();
        if (_isArray) {
            _xifexpression = type.getComponentType();
        } else {
            LightweightTypeReference _xifexpression_1 = null;
            if ((type.isSubtypeOf(Iterable.clreplaced) && (!type.getTypeArguments().isEmpty()))) {
                _xifexpression_1 = IterableExtensions.<LightweightTypeReference>head(type.getTypeArguments()).getInvariantBoundSubsreplacedute();
            } else {
                _xifexpression_1 = type;
            }
            _xifexpression = _xifexpression_1;
        }
        final LightweightTypeReference componentType = _xifexpression;
        return componentType.toJavaCompliantTypeReference();
    }
}

18 View Complete Implementation : AbstractXtextDiagramConfig.java
Copyright Apache License 2.0
Author : JanKoehnlein
@SuppressWarnings("all")
public abstract clreplaced AbstractXtextDiagramConfig extends AbstractEclipseDiagramConfig {

    @Inject(optional = true)
    @Extension
    private IStorage2UriMapper _iStorage2UriMapper;

    @Override
    public void initialize(final XDomainObjectOwner shape) {
        ReadOnlyObjectProperty<DomainObjectDescriptor> _domainObjectDescriptorProperty = shape.domainObjectDescriptorProperty();
        if (_domainObjectDescriptorProperty != null) {
            InitializingListener<DomainObjectDescriptor> _initializingListener = new InitializingListener<DomainObjectDescriptor>();
            final Procedure1<InitializingListener<DomainObjectDescriptor>> _function = (InitializingListener<DomainObjectDescriptor> it) -> {
                final Procedure1<Object> _function_1 = (Object it_1) -> {
                    if ((it_1 instanceof AbstractXtextDescriptor<?>)) {
                        ((AbstractXtextDescriptor<?>) it_1).injectMembers(shape);
                    }
                };
                it.setSet(_function_1);
            };
            InitializingListener<DomainObjectDescriptor> _doubleArrow = ObjectExtensions.<InitializingListener<DomainObjectDescriptor>>operator_doubleArrow(_initializingListener, _function);
            CoreExtensions.<DomainObjectDescriptor>addInitializingListener(_domainObjectDescriptorProperty, _doubleArrow);
        }
        super.initialize(shape);
    }

    @Override
    protected IMappedElementDescriptorProvider createDomainObjectProvider() {
        return new XtextDomainObjectProvider();
    }

    public String getFilePath(final EObject element) {
        IStorage _first = IterableExtensions.<Pair<IStorage, IProject>>head(this._iStorage2UriMapper.getStorages(element.eResource().getURI())).getFirst();
        String _string = ((IFile) _first).getFullPath().removeFileExtension().toString();
        return (_string + ".fxd");
    }
}

18 View Complete Implementation : SmallJavaAccessibility.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
@SuppressWarnings("all")
public clreplaced SmallJavaAccessibility {

    @Inject
    @Extension
    private SmallJavaTypeConformance _smallJavaTypeConformance;

    public boolean isAccessibleFrom(final SJMember member, final EObject context) {
        boolean _xblockexpression = false;
        {
            final SJClreplaced contextClreplaced = SmallJavaModelUtil.containingClreplaced(context);
            final SJClreplaced memberClreplaced = SmallJavaModelUtil.containingClreplaced(member);
            boolean _switchResult = false;
            boolean _matched = false;
            if (!_matched) {
                boolean _equals = Objects.equal(contextClreplaced, memberClreplaced);
                if (_equals) {
                    _matched = true;
                    _switchResult = true;
                }
            }
            if (!_matched) {
                boolean _isSubclreplacedOf = this._smallJavaTypeConformance.isSubclreplacedOf(contextClreplaced, memberClreplaced);
                if (_isSubclreplacedOf) {
                    _matched = true;
                    SJAccessLevel _access = member.getAccess();
                    _switchResult = (!Objects.equal(_access, SJAccessLevel.PRIVATE));
                }
            }
            if (!_matched) {
                SJAccessLevel _access_1 = member.getAccess();
                _switchResult = Objects.equal(_access_1, SJAccessLevel.PUBLIC);
            }
            _xblockexpression = _switchResult;
        }
        return _xblockexpression;
    }
}

18 View Complete Implementation : CommentFormatterTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(FormatterTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced CommentFormatterTest {

    @Inject
    @Extension
    private GenericFormatterTester _genericFormatterTester;

    @Test
    public void SL_inline() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist  //x");
            _builder.newLine();
            _builder.append("a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist //x");
            _builder_1.newLine();
            _builder_1.append("a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void SL_multiline() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist  ");
            _builder.newLine();
            _builder.newLine();
            _builder.append("//x");
            _builder.newLine();
            _builder.newLine();
            _builder.newLine();
            _builder.append("a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist //x");
            _builder_1.newLine();
            _builder_1.append("a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void MLSL_inline() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist  /*x*/  a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist /*x*/ a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void MLSL_paragraph() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist");
            _builder.newLine();
            _builder.newLine();
            _builder.newLine();
            _builder.append("/*x*/");
            _builder.newLine();
            _builder.newLine();
            _builder.newLine();
            _builder.append("a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist /*x*/");
            _builder_1.newLine();
            _builder_1.append("a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void MLML_inline() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist  /*");
            _builder.newLine();
            _builder.append("x");
            _builder.newLine();
            _builder.append("*/  a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist");
            _builder_1.newLine();
            _builder_1.append("/*");
            _builder_1.newLine();
            _builder_1.append(" ");
            _builder_1.append("* x");
            _builder_1.newLine();
            _builder_1.append(" ");
            _builder_1.append("*/");
            _builder_1.newLine();
            _builder_1.append("a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void MLML_paragraph() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist");
            _builder.newLine();
            _builder.newLine();
            _builder.newLine();
            _builder.append("/*");
            _builder.newLine();
            _builder.append("x");
            _builder.newLine();
            _builder.append("*/");
            _builder.newLine();
            _builder.newLine();
            _builder.newLine();
            _builder.append("a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("/*");
            _builder_1.newLine();
            _builder_1.append(" ");
            _builder_1.append("* x");
            _builder_1.newLine();
            _builder_1.append(" ");
            _builder_1.append("*/");
            _builder_1.newLine();
            _builder_1.append("a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }
}

18 View Complete Implementation : SmallJavaProposalProvider.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
/**
 * see http://www.eclipse.org/Xtext/doreplacedentation/latest/xtext.html#contentreplacedist on how to customize content replacedistant
 */
@SuppressWarnings("all")
public clreplaced SmallJavaProposalProvider extends AbstractSmallJavaProposalProvider {

    @Inject
    @Extension
    private SmallJavaAccessibility _smallJavaAccessibility;

    @Override
    public void completeSJSelectionExpression_Member(final EObject model, final replacedignment replacedignment, final ContentreplacedistContext context, final ICompletionProposalAcceptor acceptor) {
        AbstractElement _terminal = replacedignment.getTerminal();
        final Predicate<IEObjectDescription> _function = new Predicate<IEObjectDescription>() {

            @Override
            public boolean apply(final IEObjectDescription description) {
                EObject _eObjectOrProxy = description.getEObjectOrProxy();
                return SmallJavaProposalProvider.this._smallJavaAccessibility.isAccessibleFrom(((SJMember) _eObjectOrProxy), model);
            }
        };
        this.lookupCrossReference(((CrossReference) _terminal), context, acceptor, _function);
    }

    @Override
    public StyledString getStyledDisplayString(final EObject element, final String qualifiedNamereplacedtring, final String shortName) {
        StyledString _xifexpression = null;
        if ((element instanceof SJMember)) {
            String _memberreplacedtringWithType = SmallJavaModelUtil.memberreplacedtringWithType(((SJMember) element));
            StyledString _styledString = new StyledString(_memberreplacedtringWithType);
            SJClreplaced _containingClreplaced = SmallJavaModelUtil.containingClreplaced(element);
            String _name = _containingClreplaced.getName();
            String _plus = (" - " + _name);
            StyledString _styledString_1 = new StyledString(_plus, StyledString.QUALIFIER_STYLER);
            _xifexpression = _styledString.append(_styledString_1);
        } else {
            _xifexpression = super.getStyledDisplayString(element, qualifiedNamereplacedtring, shortName);
        }
        return _xifexpression;
    }
}

18 View Complete Implementation : FormattingConflictTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(FormatterTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced FormattingConflictTest {

    @Inject
    @Extension
    private GenericFormatterTester _genericFormatterTester;

    @Test
    public void enableDebugTracingTrue() {
        final Wrapper<Throwable> wrapper = new Wrapper<Throwable>();
        final Wrapper<Integer> execution = new Wrapper<Integer>(Integer.valueOf(0));
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    Integer _get = execution.get();
                    int _plus = ((_get).intValue() + 1);
                    execution.set(Integer.valueOf(_plus));
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.setSpace(" ");
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                        it_1.setSpace("\t");
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function_1);
                }
            };
            it.setFormatter(_function_1);
            FormatterRequest _request = it.getRequest();
            _request.setEnableDebugTracing(true);
            FormatterRequest _request_1 = it.getRequest();
            final IAcceptor<Exception> _function_2 = (Exception e) -> {
                wrapper.set(e);
            };
            _request_1.setExceptionHandler(_function_2);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
        Throwable _get = wrapper.get();
        final ConflictingRegionsException exception = ((ConflictingRegionsException) _get);
        replacedert.replacedertEquals(1, (execution.get()).intValue());
        replacedert.replacedertEquals(2, exception.getTraces().size());
    }

    @Test
    public void enableDebugTracingFalse() {
        final Wrapper<Throwable> wrapper = new Wrapper<Throwable>();
        final Wrapper<Integer> execution = new Wrapper<Integer>(Integer.valueOf(0));
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    Integer _get = execution.get();
                    int _plus = ((_get).intValue() + 1);
                    execution.set(Integer.valueOf(_plus));
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.setSpace(" ");
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                        it_1.setSpace("\t");
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function_1);
                }
            };
            it.setFormatter(_function_1);
            FormatterRequest _request = it.getRequest();
            _request.setEnableDebugTracing(false);
            FormatterRequest _request_1 = it.getRequest();
            final IAcceptor<Exception> _function_2 = (Exception e) -> {
                wrapper.set(e);
            };
            _request_1.setExceptionHandler(_function_2);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
        Throwable _get = wrapper.get();
        final ConflictingRegionsException exception = ((ConflictingRegionsException) _get);
        replacedert.replacedertEquals(2, (execution.get()).intValue());
        replacedert.replacedertEquals(2, exception.getTraces().size());
    }
}

18 View Complete Implementation : TestLanguageFormatter.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Christian Dietrich - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced TestLanguageFormatter extends AbstractFormatter2 {

    @Inject
    @Extension
    private TestLanguageGrammarAccess _testLanguageGrammarAccess;

    protected void _format(final Model model, @Extension final IFormattableDoreplacedent doreplacedent) {
        EList<AbstractElement> _elements = model.getElements();
        for (final AbstractElement type : _elements) {
            doreplacedent.<AbstractElement>format(type);
        }
    }

    protected void _format(final TypeDeclaration type, @Extension final IFormattableDoreplacedent doreplacedent) {
        final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
            it.newLine();
        };
        doreplacedent.append(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), _function);
        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
            it.newLine();
        };
        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
            it.newLine();
        };
        doreplacedent.append(doreplacedent.prepend(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_1), _function_2);
        final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
            it.indent();
        };
        doreplacedent.<ISemanticRegion, ISemanticRegion>interior(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_3);
        Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.clreplaced);
        for (final Property property : _filter) {
            doreplacedent.<Property>format(property);
        }
    }

    protected void _format(final Property property, @Extension final IFormattableDoreplacedent doreplacedent) {
        final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
            it.newLine();
        };
        doreplacedent.<Property>append(property, _function);
    }

    public void format(final Object property, final IFormattableDoreplacedent doreplacedent) {
        if (property instanceof XtextResource) {
            _format((XtextResource) property, doreplacedent);
            return;
        } else if (property instanceof Property) {
            _format((Property) property, doreplacedent);
            return;
        } else if (property instanceof TypeDeclaration) {
            _format((TypeDeclaration) property, doreplacedent);
            return;
        } else if (property instanceof Model) {
            _format((Model) property, doreplacedent);
            return;
        } else if (property instanceof EObject) {
            _format((EObject) property, doreplacedent);
            return;
        } else if (property == null) {
            _format((Void) null, doreplacedent);
            return;
        } else if (property != null) {
            _format(property, doreplacedent);
            return;
        } else {
            throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(property, doreplacedent).toString());
        }
    }
}

18 View Complete Implementation : ExpressionsJvmModelInferrer.java
Copyright Eclipse Public License 1.0
Author : LorenzoBettini
/**
 * <p>Infers a JVM model from the source model.</p>
 *
 * <p>The JVM model should contain all elements that would appear in the Java code
 * which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
 */
@SuppressWarnings("all")
public clreplaced ExpressionsJvmModelInferrer extends AbstractModelInferrer {

    /**
     * convenience API to build and initialize JVM types and their members.
     */
    @Inject
    @Extension
    private JvmTypesBuilder _jvmTypesBuilder;

    /**
     * The dispatch method {@code infer} is called for each instance of the
     * given element's type that is contained in a resource.
     *
     * @param element
     *            the model to create one or more
     *            {@link org.eclipse.xtext.common.types.JvmDeclaredType declared
     *            types} from.
     * @param acceptor
     *            each created
     *            {@link org.eclipse.xtext.common.types.JvmDeclaredType type}
     *            without a container should be preplaceded to the acceptor in order
     *            get attached to the current resource. The acceptor's
     *            {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType)
     *            accept(..)} method takes the constructed empty type for the
     *            pre-indexing phase. This one is further initialized in the
     *            indexing phase using the closure you preplaced to the returned
     *            {@link org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor.IPostIndexingInitializing#initializeLater(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)
     *            initializeLater(..)}.
     * @param isPreIndexingPhase
     *            whether the method is called in a pre-indexing phase, i.e.
     *            when the global index is not yet fully updated. You must not
     *            rely on linking using the index if isPreIndexingPhase is
     *            <code>true</code>.
     */
    protected void _infer(final ExpressionsModel model, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
        Resource _eResource = model.eResource();
        URI _uRI = _eResource.getURI();
        URI _trimFileExtension = _uRI.trimFileExtension();
        final String clreplacedName = _trimFileExtension.lastSegment();
        JvmGenericType _clreplaced = this._jvmTypesBuilder.toClreplaced(model, clreplacedName);
        final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() {

            @Override
            public void apply(final JvmGenericType it) {
                EList<JvmMember> _members = it.getMembers();
                JvmTypeReference _typeRef = ExpressionsJvmModelInferrer.this._typeReferenceBuilder.typeRef(Void.TYPE);
                final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() {

                    @Override
                    public void apply(final JvmOperation it) {
                        EList<JvmFormalParameter> _parameters = it.getParameters();
                        JvmTypeReference _typeRef = ExpressionsJvmModelInferrer.this._typeReferenceBuilder.typeRef(String.clreplaced);
                        JvmTypeReference _addArrayTypeDimension = ExpressionsJvmModelInferrer.this._jvmTypesBuilder.addArrayTypeDimension(_typeRef);
                        JvmFormalParameter _parameter = ExpressionsJvmModelInferrer.this._jvmTypesBuilder.toParameter(model, "args", _addArrayTypeDimension);
                        ExpressionsJvmModelInferrer.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
                        it.setStatic(true);
                        ExpressionsJvmModelInferrer.this._jvmTypesBuilder.setBody(it, model);
                    }
                };
                JvmOperation _method = ExpressionsJvmModelInferrer.this._jvmTypesBuilder.toMethod(model, "main", _typeRef, _function);
                ExpressionsJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
            }
        };
        acceptor.<JvmGenericType>accept(_clreplaced, _function);
    }

    public void infer(final EObject model, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
        if (model instanceof ExpressionsModel) {
            _infer((ExpressionsModel) model, acceptor, isPreIndexingPhase);
            return;
        } else if (model != null) {
            _infer(model, acceptor, isPreIndexingPhase);
            return;
        } else {
            throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(model, acceptor, isPreIndexingPhase).toString());
        }
    }
}

18 View Complete Implementation : SerializationAfterModelChangeTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Stefan Oehme - Initial contribution and API
 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424027
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(HiddenTokenSequencerTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced SerializationAfterModelChangeTest {

    @Inject
    @Extension
    private ParseHelper<Model> _parseHelper;

    @Inject
    @Extension
    private ISerializer _iSerializer;

    @Test
    public void smokeTest() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//before existing element");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo /* within existing element */ \"Bar\" /* after existing element*/");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//unrelated comment");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//before deleted element");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Baz \"Fizzle\" /* after deleted element */");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//between deleted elements");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//another deleted element");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Blurb /* a comment within a deleted element */ \"Bla\"");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//before inserted element");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            Enreplacedy _createEnreplacedy = HiddentokensequencertestFactory.eINSTANCE.createEnreplacedy();
            final Procedure1<Enreplacedy> _function = (Enreplacedy it) -> {
                it.setName("AAA");
                it.setDescription("BBB");
            };
            final Enreplacedy event = ObjectExtensions.<Enreplacedy>operator_doubleArrow(_createEnreplacedy, _function);
            model.getDomainModel().getEnreplacedies().remove(1);
            model.getDomainModel().getEnreplacedies().remove(1);
            model.getDomainModel().getEnreplacedies().add(event);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//before existing element");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo /* within existing element */ \"Bar\" /* after existing element*/");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//unrelated comment");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//between deleted elements");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//before inserted element");
            _builder_1.newLine();
            _builder_1.append("AAA \"BBB\" end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    /**
     * TODO does not work yet, because HiddenTokenSequencer
     * always searches in one direction,
     * but the order of the elements has changed here.
     */
    @Test
    @Ignore
    public void testMoveElement() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//comment between elements");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Baz \"Fizzle\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            final Enreplacedy head = IterableExtensions.<Enreplacedy>head(model.getDomainModel().getEnreplacedies());
            model.getDomainModel().getEnreplacedies().move(1, head);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Baz \"Fizzle\"");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//comment between elements");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"");
            _builder_1.newLine();
            _builder_1.append("end");
            _builder_1.newLine();
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testWhiteSpaceOnly() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            Enreplacedy _createEnreplacedy = HiddentokensequencertestFactory.eINSTANCE.createEnreplacedy();
            final Procedure1<Enreplacedy> _function = (Enreplacedy it) -> {
                it.setName("Baz");
                it.setDescription("Fizzle");
            };
            final Enreplacedy event = ObjectExtensions.<Enreplacedy>operator_doubleArrow(_createEnreplacedy, _function);
            model.getDomainModel().getEnreplacedies().add(event);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"");
            _builder_1.newLine();
            _builder_1.append("Baz \"Fizzle\" end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testCommentBeforeInsertedElement() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//comment before inserted element");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            Enreplacedy _createEnreplacedy = HiddentokensequencertestFactory.eINSTANCE.createEnreplacedy();
            final Procedure1<Enreplacedy> _function = (Enreplacedy it) -> {
                it.setName("Baz");
                it.setDescription("Fizzle");
            };
            final Enreplacedy event = ObjectExtensions.<Enreplacedy>operator_doubleArrow(_createEnreplacedy, _function);
            model.getDomainModel().getEnreplacedies().add(event);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//comment before inserted element");
            _builder_1.newLine();
            _builder_1.append("Baz \"Fizzle\" end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testAddElementAfterInlineComment() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"\t//inline comment before inserted element");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            Enreplacedy _createEnreplacedy = HiddentokensequencertestFactory.eINSTANCE.createEnreplacedy();
            final Procedure1<Enreplacedy> _function = (Enreplacedy it) -> {
                it.setName("Baz");
                it.setDescription("Fizzle");
            };
            final Enreplacedy event = ObjectExtensions.<Enreplacedy>operator_doubleArrow(_createEnreplacedy, _function);
            model.getDomainModel().getEnreplacedies().add(event);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"\t//inline comment before inserted element");
            _builder_1.newLine();
            _builder_1.append("Baz \"Fizzle\" end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testCommentOnRemovedElement() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\" //inline comment before deleted element");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//comment on deleted element");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("/**");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* another comment on the deleted element");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Baz \"Fizzle\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            model.getDomainModel().getEnreplacedies().remove(1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\" //inline comment before deleted element");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testUnrelatedCommentBeforeRemovedElement() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//unrelated comment before deleted element");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Baz \"Fizzle\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            model.getDomainModel().getEnreplacedies().remove(1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//unrelated comment before deleted element");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testRemoveElementAfterInlineComment() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\" //inline comment before deleted element");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Baz \"Fizzle\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            model.getDomainModel().getEnreplacedies().remove(1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\" //inline comment before deleted element");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testRemoveElementWithInlineComment() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Baz \"Fizzle\" //inline comment after deleted element");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            model.getDomainModel().getEnreplacedies().remove(1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testRemoveElementInSameLine() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\" /* the foo */ Baz \"Fizzle\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            model.getDomainModel().getEnreplacedies().remove(1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\" /* the foo */");
            _builder_1.newLine();
            _builder_1.append("end");
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testAddElementBeforeCommentedElement() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("//the comment");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("Foo \"Bar\"");
            _builder.newLine();
            _builder.append("end");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            Enreplacedy _createEnreplacedy = HiddentokensequencertestFactory.eINSTANCE.createEnreplacedy();
            final Procedure1<Enreplacedy> _function = (Enreplacedy it) -> {
                it.setName("Baz");
                it.setDescription("Fizzle");
            };
            final Enreplacedy event = ObjectExtensions.<Enreplacedy>operator_doubleArrow(_createEnreplacedy, _function);
            model.getDomainModel().getEnreplacedies().add(0, event);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("enreplacedies Baz \"Fizzle\"");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("//the comment");
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("Foo \"Bar\"");
            _builder_1.newLine();
            _builder_1.append("end");
            _builder_1.newLine();
            this.replacedertSerializesTo(model, _builder_1);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    private void replacedertSerializesTo(final Model model, final CharSequence expectation) {
        replacedert.replacedertEquals(expectation.toString(), this._iSerializer.serialize(model));
    }
}

17 View Complete Implementation : RegionAccessCommentsTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
@InjectWith(RegionAccessTestLanguageInjectorProvider.clreplaced)
@RunWith(XtextRunner.clreplaced)
@SuppressWarnings("all")
public clreplaced RegionAccessCommentsTest {

    @Inject
    @Extension
    private RegionAccessTestHelper _regionAccessTestHelper;

    @Test
    public void testDeleteFirstRegion1() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/*h*/");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/*8*/");
        _builder.newLine();
        _builder.append("8 //8");
        _builder.newLine();
        _builder.append("/*a*/");
        _builder.newLine();
        _builder.append("a");
        _builder.newLine();
        final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
        final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
            final ISemanticRegion foo = access.regionForRootEObject().getAllRegionsFor().keyword("8");
            it.remove(foo);
        };
        ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append(" ");
        _builder_1.append("0    1 H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("13   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("B ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("13  1    S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("E ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("14  0   H");
        _builder_1.newLine();
        _builder_1.append("------------ diff 1 ------------");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("0    H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*8*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("13   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("13  1 S \"8\"        Root:\'8\'");
        _builder_1.newLine();
        _builder_1.append("14    H \" \"        Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"//8\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("11   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
    }

    @Test
    public void testDeleteFirstRegion2() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/*h*/");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/*81*/");
        _builder.newLine();
        _builder.append("/*82*/");
        _builder.newLine();
        _builder.append("8 //8");
        _builder.newLine();
        _builder.append("/*a*/");
        _builder.newLine();
        _builder.append("a");
        _builder.newLine();
        final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
        final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
            final ISemanticRegion foo = access.regionForRootEObject().getAllRegionsFor().keyword("8");
            it.remove(foo);
        };
        ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append(" ");
        _builder_1.append("0    1 H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("13   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("B ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("13  1    S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("E ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("14  0   H");
        _builder_1.newLine();
        _builder_1.append("------------ diff 1 ------------");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("0    H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*81*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*82*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("21   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("21  1 S \"8\"        Root:\'8\'");
        _builder_1.newLine();
        _builder_1.append("22    H \" \"        Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"//8\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("11   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
    }

    @Test
    public void testDeleteFirstRegion3() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/*h*/");
        _builder.newLine();
        _builder.append("/*81*/");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/*82*/");
        _builder.newLine();
        _builder.append("8 //8");
        _builder.newLine();
        _builder.append("/*a*/");
        _builder.newLine();
        _builder.append("a");
        _builder.newLine();
        final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
        final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
            final ISemanticRegion foo = access.regionForRootEObject().getAllRegionsFor().keyword("8");
            it.remove(foo);
        };
        ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append(" ");
        _builder_1.append("0    1 H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*81*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("20   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("B ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("20  1    S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("E ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("21  0   H");
        _builder_1.newLine();
        _builder_1.append("------------ diff 1 ------------");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("0    H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*81*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*82*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("21   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("21  1 S \"8\"        Root:\'8\'");
        _builder_1.newLine();
        _builder_1.append("22    H \" \"        Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"//8\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("11   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
    }

    @Test
    public void testDeleteFirstRegion4() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/*h*/");
        _builder.newLine();
        _builder.append("/*81*/");
        _builder.newLine();
        _builder.append("/*82*/");
        _builder.newLine();
        _builder.newLine();
        _builder.append("8 //8");
        _builder.newLine();
        _builder.append("/*a*/");
        _builder.newLine();
        _builder.append("a");
        _builder.newLine();
        final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
        final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
            final ISemanticRegion foo = access.regionForRootEObject().getAllRegionsFor().keyword("8");
            it.remove(foo);
        };
        ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append(" ");
        _builder_1.append("0    1 H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*81*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*82*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("27   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("B ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("27  1    S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("E ValueList\'[a]\' Root");
        _builder_1.newLine();
        _builder_1.append("28  0   H");
        _builder_1.newLine();
        _builder_1.append("------------ diff 1 ------------");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("0    H \"/*h*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*81*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*82*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:CONTAINER");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("21   \"\\n\\n\"     Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("21  1 S \"8\"        Root:\'8\'");
        _builder_1.newLine();
        _builder_1.append("22    H \" \"        Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"//8\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("11   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
    }

    @Test
    public void testDeleteMiddleRegion() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("8");
        _builder.newLine();
        _builder.append("a /*a*/ //a");
        _builder.newLine();
        _builder.append("/*b1*/");
        _builder.newLine();
        _builder.append("/*b2*/");
        _builder.newLine();
        _builder.append("b");
        _builder.newLine();
        final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
        final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
            final ISemanticRegion foo = IterableExtensions.<ISemanticRegion>head(access.regionForRootEObject().getAllRegionsFor().features(RegionaccesstestlanguagePackage.Literals.VALUE_LIST__NAME));
            it.remove(foo);
        };
        ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append(" ");
        _builder_1.append("0  0   H");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("B ValueList\'[a, b]\' Root");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("0  1    S \"8\"        Root:\'8\'");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("1    1  H \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("         ");
        _builder_1.append("\"/*b1*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("         ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("         ");
        _builder_1.append("\"/*b2*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("15    \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("16  1    S \"b\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("E ValueList\'[a, b]\' Root");
        _builder_1.newLine();
        _builder_1.append("17  0   H");
        _builder_1.newLine();
        _builder_1.append("------------ diff 1 ------------");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("1  1 H \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("2  1 S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("3    H \" \"        Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\" \"        Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"//a\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*b1*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*b2*/\"   Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("25   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
    }

    @Test
    public void testMove() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("8//8");
        _builder.newLine();
        _builder.append("/*a*/");
        _builder.newLine();
        _builder.append("a//a");
        _builder.newLine();
        _builder.append("/*b*/");
        _builder.newLine();
        _builder.append("b//b");
        _builder.newLine();
        _builder.append("/*c*/");
        _builder.newLine();
        _builder.append("c");
        _builder.newLine();
        final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
        final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
            final List<ISemanticRegion> regions = access.regionForRootEObject().getAllRegionsFor().features(RegionaccesstestlanguagePackage.Literals.VALUE_LIST__NAME);
            final ISemanticRegion a = regions.get(0);
            final ISemanticRegion b = regions.get(1);
            it.move(b.getNextHiddenRegion(), a.getPreviousHiddenRegion(), a.getNextHiddenRegion());
        };
        ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append(" ");
        _builder_1.append("0  0   H");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("B ValueList\'[a, b, c]\' Root");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("0  1    S \"8\"        Root:\'8\'");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("1    1  H \"//8\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("         ");
        _builder_1.append("\"/*b*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("10    \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("11  1    S \"b\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("12    2  H \"//b\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("         ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("10    \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("22  1 2  S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("23    2  H \"//a\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("         ");
        _builder_1.append("\"/*c*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("10    \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("33  1    S \"c\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("E ValueList\'[a, b, c]\' Root");
        _builder_1.newLine();
        _builder_1.append("34  0   H");
        _builder_1.newLine();
        _builder_1.append("------------ diff 1 ------------");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("1    H \"//8\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*a*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("10   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("11  1 S \"a\"        ValueList:name+=ID");
        _builder_1.newLine();
        _builder_1.append("12    H \"//a\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*b*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("10   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        _builder_1.append("------------ diff 2 ------------");
        _builder_1.newLine();
        _builder_1.append("23    H \"//b\\n\"    Comment:TerminalRule\'SL_COMMENT\' replacedociation:PREVIOUS");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("\"/*c*/\"    Comment:TerminalRule\'ML_COMMENT\' replacedociation:NEXT");
        _builder_1.newLine();
        _builder_1.append("   ");
        _builder_1.append("10   \"\\n\"       Whitespace:TerminalRule\'WS\'");
        _builder_1.newLine();
        this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
    }
}

17 View Complete Implementation : TracingSugarTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sven Efftinge - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(LazyLinkingTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced TracingSugarTest {

    @TracedAccessors(LazyLinkingFactory.clreplaced)
    public static clreplaced MyExtensions extends TracingSugar {

        /**
         * manual implementation for unsupported multi cross reference
         */
        public IGeneratorNode _type(final Property it, final Function1<? super Type, ? extends String> provider) {
            final ILocationData location = this.location(it, it.eClreplaced().getEStructuralFeature("type"), 0);
            final CompositeGeneratorNode result = this.trace(location);
            this.append(result, provider.apply(IterableExtensions.<Type>head(it.getType())));
            return result;
        }

        public IGeneratorNode _name(final Property target) {
            EStructuralFeature feature = target.eClreplaced().getEStructuralFeature("name");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, target.getName());
            return trace;
        }

        public IGeneratorNode _name(final Property target, final boolean useForDebugging) {
            EStructuralFeature feature = target.eClreplaced().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.eClreplaced().getEStructuralFeature("name");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, stringProvider.apply(target.getName()));
            return trace;
        }

        public IGeneratorNode _extends(final Type target, final Function<Type, String> stringProvider) {
            EStructuralFeature feature = target.eClreplaced().getEStructuralFeature("extends");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, stringProvider.apply(target.getExtends()));
            return trace;
        }

        public IGeneratorNode _name(final Type target) {
            EStructuralFeature feature = target.eClreplaced().getEStructuralFeature("name");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, target.getName());
            return trace;
        }

        public IGeneratorNode _name(final Type target, final boolean useForDebugging) {
            EStructuralFeature feature = target.eClreplaced().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.eClreplaced().getEStructuralFeature("name");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, stringProvider.apply(target.getName()));
            return trace;
        }

        public IGeneratorNode _parentId(final Type target, final Function<Property, String> stringProvider) {
            EStructuralFeature feature = target.eClreplaced().getEStructuralFeature("parentId");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, stringProvider.apply(target.getParentId()));
            return trace;
        }

        public IGeneratorNode _name(final UnresolvedProxyProperty target) {
            EStructuralFeature feature = target.eClreplaced().getEStructuralFeature("name");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, target.getName());
            return trace;
        }

        public IGeneratorNode _name(final UnresolvedProxyProperty target, final boolean useForDebugging) {
            EStructuralFeature feature = target.eClreplaced().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.eClreplaced().getEStructuralFeature("name");
            ILocationData location = this.location(target, feature, -1);
            CompositeGeneratorNode trace = this.trace(location);
            this.append(trace, stringProvider.apply(target.getName()));
            return trace;
        }
    }

    @Inject
    @Extension
    private TracingSugarTest.MyExtensions _myExtensions;

    @Inject
    private ParseHelper<Model> parseHelper;

    @Test
    public void testCodeGeneration() {
        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 __generateType = TracingSugarTest.this._generateType(t);
                            _builder.append(__generateType);
                            _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 _generateType = this.generateType(t);
                    _builder_1.append(_generateType);
                    _builder_1.newLineIfNotEmpty();
                }
            }
            replacedert.replacedertEquals(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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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("}");
            replacedert.replacedertEquals(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();
                }
            }
            replacedert.replacedertEquals(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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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("}");
            replacedert.replacedertEquals(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();
                }
            }
            replacedert.replacedertEquals(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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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] replacedociations={");
            _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("}");
            replacedert.replacedertEquals(LineDelimiters.toUnix(_builder_2.toString()), trace.toString());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Traced
    public IGeneratorNode _generateType(final Type it) {
        ILocationData _location = this._myExtensions.location(it);
        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, 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("Clreplaced ");
        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 generateTypeWithDebugging(final Type it) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Clreplaced ");
        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 ");
        String _name = it.getName();
        _builder.append(_name);
        _builder.append(" : ");
        String _name_1 = IterableExtensions.<Type>head(it.getType()).getName();
        _builder.append(_name_1);
        _builder.newLineIfNotEmpty();
        return _builder;
    }

    public StringConcatenationClient __generateType(final Type it) {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("Clreplaced ");
                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 __generateTypeWithDebugging(final Type it) {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("Clreplaced ");
                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("Clreplaced ");
                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
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("Property ");
                IGeneratorNode __name = TracingSugarTest.this._myExtensions._name(it);
                _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;
    }

    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;
    }
}

17 View Complete Implementation : AbstractFragmentsTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
@SuppressWarnings("all")
public abstract clreplaced AbstractFragmentsTest extends AbstractXtextTests {

    @Inject
    @Extension
    private ParseHelper<ParserRuleFragments> parseHelper;

    @Inject
    @Extension
    private ValidationTestHelper validationTestHelper;

    @Inject
    @Extension
    private InvariantChecker invariantChecker;

    @Override
    protected void setInjector(final Injector injector) {
        super.setInjector(injector);
        this.injectMembers(this);
    }

    @Test
    public void testSimpleModel() {
        final ParserRuleFragments fragments = this.parseAndValidate("#1 myName");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
    }

    @Test
    public void testReference() {
        final ParserRuleFragments fragments = this.parseAndValidate("#2 myName -> myName");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        replacedert.replacedertEquals(fragments.getElement(), fragments.getRef());
    }

    @Test
    public void testReference_02() {
        final ParserRuleFragments fragments = this.parseAndValidate("#1 myName : myName");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        replacedert.replacedertEquals(fragments.getElement(), fragments.getElement().getRef());
    }

    @Test
    public void testReferenceInFragment() {
        final ParserRuleFragments fragments = this.parseAndValidate("#1 myName - myName");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        replacedert.replacedertEquals(fragments.getElement(), fragments.getElement().getRef());
    }

    @Test
    public void testReferenceBeforeFragment() {
        final ParserRuleFragments fragments = this.parseAndValidate("#3 myName <- myName");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        replacedert.replacedertEquals(fragments.getElement(), fragments.getElement().getRef());
    }

    @Test
    public void testAction() {
        final ParserRuleFragments fragments = this.parseAndValidate("#4 prev current");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("current", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        replacedert.replacedertEquals("prev", ((PRFNamedWithAction) _element).getPrev().getName());
    }

    @Test
    public void testActionAndReference() {
        final ParserRuleFragments fragments = this.parseAndValidate("#4 prev current prev current");
        replacedert.replacedertNotNull(fragments);
        final PRFNamed element = fragments.getElement();
        replacedert.replacedertEquals("current", element.getName());
        final PRFNamed prev = ((PRFNamedWithAction) element).getPrev();
        replacedert.replacedertEquals("prev", prev.getName());
        replacedert.replacedertEquals(prev, element.getRef());
        replacedert.replacedertEquals(element, ((PRFNamedWithAction) element).getRef2());
    }

    @Test
    @Ignore("Actions are currently not supported in fragments")
    public void testActionInFragment_01() {
        final ParserRuleFragments fragments = this.parseAndValidate("#5 prev current");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("current", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        replacedert.replacedertEquals("prev", ((PRFNamedWithAction) _element).getPrev().getName());
    }

    @Test
    @Ignore("Actions are currently not supported in fragments")
    public void testActionInFragment_02() {
        final ParserRuleFragments fragments = this.parseAndValidate("#6 prev current");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("current", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        replacedert.replacedertEquals("prev", ((PRFNamedWithAction) _element).getPrev().getName());
    }

    @Test
    @Ignore("Actions are currently not supported in fragments")
    public void testActionInFragmentAndReference_01() {
        final ParserRuleFragments fragments = this.parseAndValidate("#5 prev current current - prev");
        replacedert.replacedertNotNull(fragments);
        final PRFNamed element = fragments.getElement();
        replacedert.replacedertEquals("current", element.getName());
        final PRFNamed prev = ((PRFNamedWithAction) element).getPrev();
        replacedert.replacedertEquals("prev", prev.getName());
        replacedert.replacedertEquals(prev, element.getRef());
        replacedert.replacedertEquals(element, ((PRFNamedWithAction) element).getRef2());
    }

    @Test
    @Ignore("Actions are currently not supported in fragments")
    public void testActionInFragmentAndReference_02() {
        final ParserRuleFragments fragments = this.parseAndValidate("#6 prev current current - prev");
        replacedert.replacedertNotNull(fragments);
        final PRFNamed element = fragments.getElement();
        replacedert.replacedertEquals("current", element.getName());
        final PRFNamed prev = ((PRFNamedWithAction) element).getPrev();
        replacedert.replacedertEquals("prev", prev.getName());
        replacedert.replacedertEquals(prev, element.getRef());
        replacedert.replacedertEquals(element, ((PRFNamedWithAction) element).getRef2());
    }

    @Test
    @Ignore("Actions are currently not supported in fragments")
    public void testActionInFragmentAndReferenceLoop() {
        final ParserRuleFragments fragments = this.parseAndValidate("#7 root -> a a -> b b -> c c - root");
        replacedert.replacedertNotNull(fragments);
        PRFNamed element = fragments.getElement();
        while ((element instanceof PRFNamedWithAction)) {
            {
                replacedert.replacedertEquals(element, ((PRFNamedWithAction) element).getRef2());
                element = ((PRFNamedWithAction) element).getPrev();
            }
        }
        replacedert.replacedertEquals(element, element.getRef());
    }

    @Test
    public void testDatatypeRule_01() {
        final ParserRuleFragments fragments = this.parseAndValidate("#8 a - a");
        replacedert.replacedertNotNull(fragments);
        PRFNamed element = fragments.getElement();
        replacedert.replacedertEquals(element, element.getRef());
    }

    @Test
    public void testDatatypeRule_02() {
        final ParserRuleFragments fragments = this.parseAndValidate("#8 a.b.c.d");
        replacedert.replacedertNotNull(fragments);
        PRFNamed element = fragments.getElement();
        replacedert.replacedertEquals("a.b.c.d", element.getName());
    }

    @Test
    public void testDatatypeRule_03() {
        final ParserRuleFragments fragments = this.parseAndValidate("#8 a.b.c.d - a.b.c.d");
        replacedert.replacedertNotNull(fragments);
        PRFNamed element = fragments.getElement();
        replacedert.replacedertEquals(element, element.getRef());
    }

    @Test
    public void testFragmentWithPredicate() {
        final ParserRuleFragments fragments = this.parseAndValidate("#9 myName - myName");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        replacedert.replacedertEquals(fragments.getElement(), fragments.getElement().getRef());
    }

    @Test
    public void testFragmentRecursive_01() {
        final ParserRuleFragments fragments = this.parseAndValidate("#10 myName myPrev");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        final PRFNamed prev = ((PRFNamedWithAction) _element).getPrev();
        replacedert.replacedertEquals("myPrev", prev.getName());
        final ICompositeNode node = NodeModelUtils.findActualNodeFor(prev);
        replacedert.replacedertEquals(" myPrev", node.getText());
        final EObject lookup = NodeModelUtils.findActualSemanticObjectFor(node);
        replacedert.replacedertSame(prev, lookup);
    }

    @Test
    public void testFragmentRecursive_02() {
        final ParserRuleFragments fragments = this.parseAndValidate("#10 myName ((myPrev))");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        final PRFNamed prev = ((PRFNamedWithAction) _element).getPrev();
        replacedert.replacedertEquals("myPrev", prev.getName());
        final ICompositeNode node = NodeModelUtils.findActualNodeFor(prev);
        replacedert.replacedertEquals(" ((myPrev))", node.getText());
        final EObject lookup = NodeModelUtils.findActualSemanticObjectFor(node);
        replacedert.replacedertSame(prev, lookup);
    }

    @Test
    public void testFragmentRecursive_03() {
        final ParserRuleFragments fragments = this.parseAndValidate("#11 myName myPrev");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        final PRFNamed prev = ((PRFNamedWithAction) _element).getPrev();
        replacedert.replacedertEquals("myPrev", prev.getName());
        final ICompositeNode node = NodeModelUtils.findActualNodeFor(prev);
        replacedert.replacedertEquals(" myPrev", node.getText());
        final EObject lookup = NodeModelUtils.findActualSemanticObjectFor(node);
        replacedert.replacedertSame(prev, lookup);
    }

    @Test
    public void testFragmentRecursive_04() {
        final ParserRuleFragments fragments = this.parseAndValidate("#11 myName ((myPrev))");
        replacedert.replacedertNotNull(fragments);
        replacedert.replacedertEquals("myName", fragments.getElement().getName());
        PRFNamed _element = fragments.getElement();
        final PRFNamed prev = ((PRFNamedWithAction) _element).getPrev();
        replacedert.replacedertEquals("myPrev", prev.getName());
        final ICompositeNode node = NodeModelUtils.findActualNodeFor(prev);
        replacedert.replacedertEquals("myPrev", node.getText());
        final EObject lookup = NodeModelUtils.findActualSemanticObjectFor(node);
        replacedert.replacedertSame(prev, lookup);
    }

    protected ParserRuleFragments parseAndValidate(final CharSequence s) {
        try {
            final ParserRuleFragments result = this.parseHelper.parse(s);
            this.validationTestHelper.replacedertNoIssues(result);
            Resource _eResource = result.eResource();
            final XtextResource resource = ((XtextResource) _eResource);
            final ICompositeNode node = resource.getParseResult().getRootNode();
            this.invariantChecker.checkInvariant(node);
            return result;
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }
}

17 View Complete Implementation : FormattableDocumentTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(FormatterTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced FormattableDoreplacedentTest {

    @Inject
    @Extension
    private GenericFormatterTester _genericFormatterTester;

    @Inject
    @Extension
    private FormatterTestLanguageGrammarAccess _formatterTestLanguageGrammarAccess;

    @Test
    public void simple() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist  a");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist a");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void autowrap() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist  aaa  bbb  ccc  ddd  eee  fff");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_2 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Consumer<ISemanticRegion> _function = (ISemanticRegion it_1) -> {
                        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_2) -> {
                            it_2.autowrap();
                            it_2.oneSpace();
                        };
                        doreplacedent.prepend(it_1, _function_1);
                    };
                    regions.regionFor(model).ruleCallsTo(FormattableDoreplacedentTest.this._formatterTestLanguageGrammarAccess.getIDRule()).forEach(_function);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist aaa");
            _builder_1.newLine();
            _builder_1.append("bbb ccc");
            _builder_1.newLine();
            _builder_1.append("ddd eee fff");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void autowrapNotInPreviousLineBetweenFormattedRegions() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(5));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist kw1");
            _builder.newLine();
            _builder.append("kw2 kw3 kw4  kw5");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kwlist"), _function);
                    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw4"), _function_1);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist kw1");
            _builder_1.newLine();
            _builder_1.append("kw2 kw3 kw4 kw5");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void autowrapNotInPreviousLineInFormattedRegion() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist kw1 kw2 kw3 kw4  kw5");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kwlist"), _function);
                    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                        it_1.newLine();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw1"), _function_1);
                    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw4"), _function_2);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist kw1");
            _builder_1.newLine();
            _builder_1.append("kw2 kw3 kw4 kw5");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void autoWrapWithSpan() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist  kw1  kw2  kw3  kw4");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap(6);
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kwlist"), _function);
                    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw1"), _function_1);
                    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw2"), _function_2);
                    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        it_1.oneSpace();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw3"), _function_3);
                    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        it_1.newLine();
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kw4"), _function_4);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist");
            _builder_1.newLine();
            _builder_1.append("kw1 kw2");
            _builder_1.newLine();
            _builder_1.append("kw3 kw4");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void autoWrapRewrite() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist  kw1  kw2");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        final IAutowrapFormatter _function_1 = (ITextSegment region, IHiddenRegionFormatting wrapped, IFormattableDoreplacedent doc) -> {
                            final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_2) -> {
                                it_2.setSpace("!");
                            };
                            doc.append(regions.regionFor(model).keyword("kw1"), _function_2);
                        };
                        it_1.setOnAutowrap(_function_1);
                        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_2) -> {
                            it_2.setSpace("@");
                            it_2.lowPriority();
                        };
                        doreplacedent.append(regions.regionFor(model).keyword("kw1"), _function_2);
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kwlist"), _function);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist");
            _builder_1.newLine();
            _builder_1.append("kw1!kw2");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void autoWrapInsert() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist  kw1  kw2");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.autowrap();
                        final IAutowrapFormatter _function_1 = (ITextSegment region, IHiddenRegionFormatting wrapped, IFormattableDoreplacedent doc) -> {
                            final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_2) -> {
                                it_2.setSpace("!");
                            };
                            doc.append(regions.regionFor(model).keyword("kw1"), _function_2);
                        };
                        it_1.setOnAutowrap(_function_1);
                        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_2) -> {
                            String _property = System.getProperty("line.separator");
                            String _plus = ("@" + _property);
                            it_2.setSpace(_plus);
                        };
                        doreplacedent.append(regions.regionFor(model).keyword("kw2"), _function_2);
                    };
                    doreplacedent.append(regions.regionFor(model).keyword("kwlist"), _function);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist");
            _builder_1.newLine();
            _builder_1.append("kw1!kw2@");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void conditionalFormatting1() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(10));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist  kw1  kw2");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final ISubFormatter _function = (IFormattableSubDoreplacedent doc) -> {
                        @Extension
                        final IFormattableSubDoreplacedent fits = doc.requireFitsInLine();
                        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                            it_1.oneSpace();
                        };
                        fits.append(regions.regionFor(model).keyword("kwlist"), _function_1);
                        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
                            it_1.oneSpace();
                        };
                        fits.append(regions.regionFor(model).keyword("kw1"), _function_2);
                    };
                    final ISubFormatter _function_1 = (IFormattableSubDoreplacedent doc) -> {
                        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
                            it_1.newLine();
                        };
                        doc.append(regions.regionFor(model).keyword("kwlist"), _function_2);
                        final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it_1) -> {
                            it_1.newLine();
                        };
                        doc.append(regions.regionFor(model).keyword("kw1"), _function_3);
                    };
                    doreplacedent.formatConditionally(model, _function, _function_1);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist");
            _builder_1.newLine();
            _builder_1.append("kw1");
            _builder_1.newLine();
            _builder_1.append("kw2");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void conditionalFormatting2() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            final Procedure1<MapBasedPreferenceValues> _function_1 = (MapBasedPreferenceValues it_1) -> {
                it_1.<Integer>put(FormatterPreferenceKeys.maxLineWidth, Integer.valueOf(30));
            };
            it.preferences(_function_1);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kwlist  kw1  kw2");
            _builder.newLine();
            it.setToBeFormatted(_builder);
            final GenericFormatter<KWList> _function_2 = new GenericFormatter<KWList>() {

                @Override
                protected void format(final KWList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final ISubFormatter _function = (IFormattableSubDoreplacedent doc) -> {
                        @Extension
                        final IFormattableSubDoreplacedent fits = doc.requireFitsInLine();
                        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
                            it_1.oneSpace();
                        };
                        fits.append(regions.regionFor(model).keyword("kwlist"), _function_1);
                        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
                            it_1.oneSpace();
                        };
                        fits.append(regions.regionFor(model).keyword("kw1"), _function_2);
                    };
                    final ISubFormatter _function_1 = (IFormattableSubDoreplacedent doc) -> {
                        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it_1) -> {
                            it_1.newLine();
                        };
                        doc.append(regions.regionFor(model).keyword("kwlist"), _function_2);
                        final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it_1) -> {
                            it_1.newLine();
                        };
                        doc.append(regions.regionFor(model).keyword("kw1"), _function_3);
                    };
                    doreplacedent.formatConditionally(model, _function, _function_1);
                }
            };
            it.setFormatter(_function_2);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("kwlist kw1 kw2");
            _builder_1.newLine();
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void aroundDoreplacedent() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            Collection<ITextRegion> _regions = it.getRequest().getRegions();
            TextRegion _textRegion = new TextRegion(0, 6);
            _regions.add(_textRegion);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist");
            it.setToBeFormatted(_builder);
            final GenericFormatter<IDList> _function_1 = new GenericFormatter<IDList>() {

                @Override
                protected void format(final IDList model, @Extension final ITextRegionExtensions regions, @Extension final IFormattableDoreplacedent doreplacedent) {
                    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it_1) -> {
                        it_1.setSpace("!");
                    };
                    doreplacedent.surround(regions.regionFor(model).keyword("idlist"), _function);
                }
            };
            it.setFormatter(_function_1);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("!idlist!");
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test
    public void shouldFormat() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            Collection<ITextRegion> _regions = it.getRequest().getRegions();
            TextRegion _textRegion = new TextRegion(0, 6);
            _regions.add(_textRegion);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist");
            it.setToBeFormatted(_builder);
            it.setFormatter(new GenericFormatter() {

                @Override
                protected void format(final EObject model, final ITextRegionExtensions regionAccess, final IFormattableDoreplacedent doreplacedent) {
                    throw new IllegalStateException("this method should never be called");
                }

                @Override
                public boolean shouldFormat(final Object obj, final IFormattableDoreplacedent doreplacedent) {
                    return false;
                }
            });
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist");
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }

    @Test(expected = IllegalStateException.clreplaced)
    public void shouldFormat_02() {
        final Procedure1<GenericFormatterTestRequest> _function = (GenericFormatterTestRequest it) -> {
            Collection<ITextRegion> _regions = it.getRequest().getRegions();
            TextRegion _textRegion = new TextRegion(0, 6);
            _regions.add(_textRegion);
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("idlist");
            it.setToBeFormatted(_builder);
            it.setFormatter(new GenericFormatter() {

                @Override
                protected void format(final EObject model, final ITextRegionExtensions regionAccess, final IFormattableDoreplacedent doreplacedent) {
                    throw new IllegalStateException("this method should never be called");
                }

                @Override
                public boolean shouldFormat(final Object obj, final IFormattableDoreplacedent doreplacedent) {
                    return true;
                }
            });
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("idlist");
            it.setExpectation(_builder_1);
        };
        this._genericFormatterTester.replacedertFormatted(_function);
    }
}

17 View Complete Implementation : NodeModelTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(IndentationAwareTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced NodeModelTest {

    public static void replacedertEquals(final Object expected, final Object actual) {
        replacedert.replacedertEquals(expected.toString().replaceAll("\r\n", "\n"), actual.toString().replaceAll("\r\n", "\n"));
    }

    @Inject
    private ParseHelper<Tree> parseHelper;

    @Inject
    @Extension
    private InvariantChecker invariantChecker;

    @Test
    public void testEmptyTree() {
        final ICompositeNode tree = this.getRootNode("");
        NodeModelTest.replacedertEquals("", this.asText(tree));
    }

    @Test
    public void testSingleRootNode() {
        final ICompositeNode tree = this.getRootNode("root");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("[ID:root]");
        _builder.newLine();
        NodeModelTest.replacedertEquals(_builder.toString().trim(), this.asText(tree));
    }

    @Test
    public void testTwoRootNodes() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("first");
        _builder.newLine();
        _builder.append("second");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:first][-WS:");
        _builder_1.newLine();
        _builder_1.append("][ID:second][-WS:");
        _builder_1.newLine();
        _builder_1.append("]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testParentChild() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("parent");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("child");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:parent][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t][INDENT:][ID:child][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testParentChildWithEof() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("parent");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("child");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder.toString().trim());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:parent][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t][INDENT:][ID:child][DEDENT:]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testParentChildren() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("parent");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("child");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("child");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:parent][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t][INDENT:][ID:child][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t][ID:child][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testTree_01() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("a");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("b");
        _builder.newLine();
        _builder.append("\t ");
        _builder.append("c");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("d");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:a][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t][INDENT:][ID:b][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t ][INDENT:][ID:c][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:][-WS:\\t][ID:d][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testWeirdTree() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("root");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("s4");
        _builder.newLine();
        _builder.append("        ");
        _builder.append("s8");
        _builder.newLine();
        _builder.append("      ");
        _builder.append("s6");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:root][-WS:");
        _builder_1.newLine();
        _builder_1.append("    ");
        _builder_1.append("][INDENT:][ID:s4][-WS:");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("][INDENT:][ID:s8][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:][-WS:      ][INDENT:][ID:s6][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:][DEDENT:]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testWeirdTreeEof() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("root");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("s4");
        _builder.newLine();
        _builder.append("        ");
        _builder.append("s8");
        _builder.newLine();
        _builder.append("      ");
        _builder.append("s6");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder.toString().trim());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:root][-WS:");
        _builder_1.newLine();
        _builder_1.append("    ");
        _builder_1.append("][INDENT:][ID:s4][-WS:");
        _builder_1.newLine();
        _builder_1.append("        ");
        _builder_1.append("][INDENT:][ID:s8][-WS:");
        _builder_1.newLine();
        _builder_1.append("][DEDENT:][-WS:      ][INDENT:][ID:s6][DEDENT:][DEDENT:]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_1() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("first");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("second");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[ID:first][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t");
        _builder_1.newLine();
        _builder_1.append("][ID:second][-WS:");
        _builder_1.newLine();
        _builder_1.append("]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_2() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("\"first\"");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\"second\"");
        _builder.newLine();
        final ICompositeNode tree = this.getRootNode(_builder);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("[STRING:\"first\"][-WS:");
        _builder_1.newLine();
        _builder_1.append("\\t");
        _builder_1.newLine();
        _builder_1.append("][STRING:\"second\"][-WS:");
        _builder_1.newLine();
        _builder_1.append("]");
        _builder_1.newLine();
        NodeModelTest.replacedertEquals(_builder_1.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_3() {
        final ICompositeNode tree = this.getRootNode("first\n\t");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("[ID:first][-WS:");
        _builder.newLine();
        _builder.append("\\t]");
        _builder.newLine();
        NodeModelTest.replacedertEquals(_builder.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_4() {
        final ICompositeNode tree = this.getRootNode("first\n\t\tabc\n\t");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("[ID:first][-WS:");
        _builder.newLine();
        _builder.append("\\t\\t][INDENT:][ID:abc][-WS:");
        _builder.newLine();
        _builder.append("][DEDENT:][-WS:\\t]");
        _builder.newLine();
        NodeModelTest.replacedertEquals(_builder.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_5() {
        final ICompositeNode tree = this.getRootNode("first\n\t\tabc\n\n");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("[ID:first][-WS:");
        _builder.newLine();
        _builder.append("\\t\\t][INDENT:][ID:abc][-WS:");
        _builder.newLine();
        _builder.append("][DEDENT:][-WS:");
        _builder.newLine();
        _builder.append("]");
        _builder.newLine();
        NodeModelTest.replacedertEquals(_builder.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_6() {
        final ICompositeNode tree = this.getRootNode("first\n\t\tabc\n\t\n");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("[ID:first][-WS:");
        _builder.newLine();
        _builder.append("\\t\\t][INDENT:][ID:abc][-WS:");
        _builder.newLine();
        _builder.append("][DEDENT:][-WS:\\t");
        _builder.newLine();
        _builder.append("]");
        _builder.newLine();
        NodeModelTest.replacedertEquals(_builder.toString().trim(), this.asText(tree));
    }

    @Test
    public void testIgnoreEmptyLines_7() {
        final ICompositeNode tree = this.getRootNode("a\n\tb\n\t ");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("[ID:a][-WS:");
        _builder.newLine();
        _builder.append("\\t][INDENT:][ID:b][-WS:");
        _builder.newLine();
        _builder.append("\\t ][DEDENT:]");
        _builder.newLine();
        NodeModelTest.replacedertEquals(_builder.toString().trim(), this.asText(tree));
    }

    private ICompositeNode getRootNode(final CharSequence seq) {
        try {
            final Tree model = this.parseHelper.parse(seq.toString().replaceAll("\r\n", "\n"));
            final ICompositeNode result = NodeModelUtils.getNode(model).getRootNode();
            this.invariantChecker.checkInvariant(result);
            return result;
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    private String asText(final INode node) {
        final Function1<ILeafNode, Boolean> _function = (ILeafNode it) -> {
            EObject _grammarElement = it.getGrammarElement();
            return Boolean.valueOf((!(_grammarElement instanceof Action)));
        };
        final Function1<ILeafNode, CharSequence> _function_1 = (ILeafNode it) -> {
            String _xifexpression = null;
            boolean _isHidden = it.isHidden();
            if (_isHidden) {
                _xifexpression = "-";
            } else {
                _xifexpression = "";
            }
            String _kenType = this.tokenType(it.getGrammarElement());
            String _plus = (_xifexpression + _kenType);
            String _plus_1 = (_plus + ":");
            String _replace = it.getText().replace("\t", "\\t");
            return (_plus_1 + _replace);
        };
        return IterableExtensions.<ILeafNode>join(IterableExtensions.<ILeafNode>filter(node.getLeafNodes(), _function), "[", "][", "]", _function_1);
    }

    private String tokenType(final EObject obj) {
        String _switchResult = null;
        boolean _matched = false;
        if (obj instanceof RuleCall) {
            _matched = true;
            _switchResult = ((RuleCall) obj).getRule().getName();
        }
        if (!_matched) {
            if (obj instanceof Keyword) {
                _matched = true;
                _switchResult = ((Keyword) obj).getValue();
            }
        }
        if (!_matched) {
            if (obj instanceof AbstractRule) {
                _matched = true;
                _switchResult = ((AbstractRule) obj).getName();
            }
        }
        return _switchResult;
    }
}

17 View Complete Implementation : SerializerPerformanceTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Stefan Oehme - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(HiddenTokenSequencerTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced SerializerPerformanceTest {

    @Inject
    @Extension
    private ParseHelper<Model> _parseHelper;

    @Inject
    @Extension
    private ISerializer _iSerializer;

    @Rule
    public final Timeout timeout = new Timeout(5000, TimeUnit.MILLISECONDS);

    private static final int numberOfElements = 1000;

    private static final int editEvery = 100;

    private Model model;

    @Before
    public void setup() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("enreplacedies");
            _builder.newLine();
            {
                ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, SerializerPerformanceTest.numberOfElements, true);
                for (final Integer i : _doubleDotLessThan) {
                    _builder.append("\t");
                    _builder.append("//comment before element");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("Foo /* comment between elements*/ \"Bar\" //comment after element ");
                    _builder.newLine();
                }
            }
            _builder.append("end");
            _builder.newLine();
            this.model = this._parseHelper.parse(_builder);
            final EList<Enreplacedy> enreplacedies = this.model.getDomainModel().getEnreplacedies();
            final Function1<Integer, Boolean> _function = (Integer it) -> {
                return Boolean.valueOf((((it).intValue() % SerializerPerformanceTest.editEvery) == 0));
            };
            final Function1<Integer, Enreplacedy> _function_1 = (Integer it) -> {
                return enreplacedies.get((it).intValue());
            };
            final Iterable<Enreplacedy> removeUs = IterableExtensions.<Integer, Enreplacedy>map(IterableExtensions.<Integer>filter(new ExclusiveRange(0, SerializerPerformanceTest.numberOfElements, true), _function), _function_1);
            CollectionExtensions.<Enreplacedy>removeAll(enreplacedies, removeUs);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void test() {
        this._iSerializer.serialize(this.model);
    }
}

17 View Complete Implementation : SerializerValidationDiagnosticsTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(SequencerTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced SerializerValidationDiagnosticsTest {

    @Inject
    @Extension
    private ParseHelper<Model> _parseHelper;

    @Inject
    @Extension
    private ISerializer _iSerializer;

    @Test
    public void testSingleValueMandatoryGenerated() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("#1 foo bar");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            SimpleGroup _x1 = model.getX1();
            _x1.setVal1(null);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("A value for feature \'val1\' is missing but required.");
            _builder_1.newLine();
            _builder_1.append("Semantic Object: Model.x1->SimpleGroup");
            _builder_1.newLine();
            _builder_1.append("URI: __synthetic0.sequencertestlanguage");
            _builder_1.newLine();
            this.replacedertSerializationError(model, _builder_1.toString());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testSingleValueMandatoryBacktracking() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("#3 foo kw1 kw2 bar kw3");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            SimpleMultiplicities _x3 = model.getX3();
            _x3.setVal1(null);
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("Could not serialize SimpleMultiplicities:");
            _builder_1.newLine();
            _builder_1.append("SimpleMultiplicities.val1 is required to have a value, but it does not.");
            _builder_1.newLine();
            _builder_1.append("Semantic Object: Model.x3->SimpleMultiplicities");
            _builder_1.newLine();
            _builder_1.append("URI: __synthetic0.sequencertestlanguage");
            _builder_1.newLine();
            _builder_1.append("Context: SimpleMultiplicities returns SimpleMultiplicities");
            _builder_1.newLine();
            this.replacedertSerializationError(model, _builder_1.toString());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testMultiValueUpperBoundBacktracking() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("#17 foo");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            EObject _x11 = model.getX11();
            final MultiKeywordsOrID mt = ((MultiKeywordsOrID) _x11);
            EList<String> _val = mt.getVal();
            _val.add("bar");
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("Could not serialize MultiKeywordsOrID:");
            _builder_1.newLine();
            _builder_1.append("MultiKeywordsOrID.val violates the upper bound: It holds 2 values, but only 1 are allowed.");
            _builder_1.newLine();
            _builder_1.append("Semantic Object: Model.x11->MultiKeywordsOrID");
            _builder_1.newLine();
            _builder_1.append("URI: __synthetic0.sequencertestlanguage");
            _builder_1.newLine();
            _builder_1.append("Context: MultiKeywordsOrID returns MultiKeywordsOrID");
            _builder_1.newLine();
            this.replacedertSerializationError(model, _builder_1.toString());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testMultiValueLowerBoundBacktracking() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("#17 foo");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            EObject _x11 = model.getX11();
            final MultiKeywordsOrID mt = ((MultiKeywordsOrID) _x11);
            mt.getVal().clear();
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("Could not serialize MultiKeywordsOrID:");
            _builder_1.newLine();
            _builder_1.append("MultiKeywordsOrID.val violates the lower bound: It holds 0 values, but at least 1 are required.");
            _builder_1.newLine();
            _builder_1.append("Semantic Object: Model.x11->MultiKeywordsOrID");
            _builder_1.newLine();
            _builder_1.append("URI: __synthetic0.sequencertestlanguage");
            _builder_1.newLine();
            _builder_1.append("Context: MultiKeywordsOrID returns MultiKeywordsOrID");
            _builder_1.newLine();
            this.replacedertSerializationError(model, _builder_1.toString());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testBacktracking() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("#8 foo bar");
            _builder.newLine();
            final Model model = this._parseHelper.parse(_builder);
            AltList1 _x8 = model.getX8();
            _x8.setVal3("baz");
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("Could not serialize AltList1 via backtracking.");
            _builder_1.newLine();
            _builder_1.append("Constraint: AltList1_AltList1 returns AltList1: ((val1=ID val2=ID) | (val1=ID val3=ID) | (val1=ID val4=ID?));");
            _builder_1.newLine();
            _builder_1.append("Values: val1(1), val2(1), val3(1)");
            _builder_1.newLine();
            _builder_1.append("Semantic Object: Model.x8->AltList1");
            _builder_1.newLine();
            _builder_1.append("URI: __synthetic0.sequencertestlanguage");
            _builder_1.newLine();
            _builder_1.append("Context: AltList1 returns AltList1");
            _builder_1.newLine();
            this.replacedertSerializationError(model, _builder_1.toString());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    private void replacedertSerializationError(final EObject obj, final String expected) {
        try {
            this._iSerializer.serialize(obj);
            replacedert.fail("Serialization should not succeed.");
        } catch (final Throwable _t) {
            if (_t instanceof Throwable) {
                final Throwable t = (Throwable) _t;
                final String expectedM = expected.toString().trim().replaceAll(System.lineSeparator(), "\n");
                final String messageM = t.getMessage().replaceAll(System.lineSeparator(), "\n");
                replacedert.replacedertEquals(expectedM, messageM);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    }
}

17 View Complete Implementation : IndentationAwarePartialParsingErrorTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
@RunWith(XtextRunner.clreplaced)
@InjectWith(IndentationAwareTestLanguageInjectorProvider.clreplaced)
@SuppressWarnings("all")
public clreplaced IndentationAwarePartialParsingErrorTest {

    @Inject
    @Extension
    private ParseHelper<Tree> parseHelper;

    @Test
    public void testResourceUpdate() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("a");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("b // single tab");
            _builder.newLine();
            _builder.append("         ");
            _builder.append("// 8 spaces eq 1 tab");
            _builder.newLine();
            _builder.append("d");
            _builder.newLine();
            final String model = _builder.toString();
            final Tree tree = this.parseHelper.parse(model);
            Resource _eResource = tree.eResource();
            final XtextResource resource = ((XtextResource) _eResource);
            final int idx = model.indexOf(" // 8");
            resource.update(idx, 0, "c");
            EObject _head = IterableExtensions.<EObject>head(resource.getContents());
            final Tree reparsed = ((Tree) _head);
            replacedert.replacedertNotSame(tree, reparsed);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @Test
    public void testResourceUpdate_02() {
        try {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("a");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("x");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("b // two tabs");
            _builder.newLine();
            _builder.append("\t         ");
            _builder.append("// tab and 8 spaces (eq 2 tabs)");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("y");
            _builder.newLine();
            final String model = _builder.toString();
            final Tree tree = this.parseHelper.parse(model);
            Resource _eResource = tree.eResource();
            final XtextResource resource = ((XtextResource) _eResource);
            final int idx = model.indexOf(" // tab");
            resource.update(idx, 0, "c");
            EObject _head = IterableExtensions.<EObject>head(resource.getContents());
            final Tree reparsed = ((Tree) _head);
            replacedert.replacedertNotSame(tree, reparsed);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }
}

17 View Complete Implementation : ContentAssistGrammarNaming.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced ContentreplacedistGrammarNaming extends GrammarNaming {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Override
    protected String getParserPackage(final Grammar it) {
        StringConcatenation _builder = new StringConcatenation();
        String _genericIdeBasePackage = this._xtextGeneratorNaming.getGenericIdeBasePackage(it);
        _builder.append(_genericIdeBasePackage);
        _builder.append(".contentreplacedist.antlr");
        return _builder.toString();
    }

    @Override
    public TypeReference getLexerSuperClreplaced(final Grammar it) {
        return new TypeReference("org.eclipse.xtext.ide.editor.contentreplacedist.antlr.internal.Lexer");
    }

    @Override
    public TypeReference getInternalParserSuperClreplaced(final Grammar it) {
        return new TypeReference("org.eclipse.xtext.ide.editor.contentreplacedist.antlr.internal.AbstractInternalContentreplacedistParser");
    }

    @Override
    public TypeReference getParserSuperClreplaced(final Grammar it, final boolean partialParsing) {
        TypeReference _xifexpression = null;
        if (partialParsing) {
            _xifexpression = new TypeReference("org.eclipse.xtext.ide.editor.contentreplacedist.antlr.AbstractPartialContentreplacedistParser");
        } else {
            _xifexpression = new TypeReference("org.eclipse.xtext.ide.editor.contentreplacedist.antlr.AbstractContentreplacedistParser");
        }
        return _xifexpression;
    }
}

17 View Complete Implementation : ResourceFactoryFragment2.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Contributes the registration <code>org.eclipse.emf.ecore.extension_parser</code>
 * to the Eclipse (UI) plugin's plugin.xml. See
 * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=264578">
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=264578</a> for details.
 *
 * @author Christian Schneider - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced ResourceFactoryFragment2 extends AbstractXtextGeneratorFragment {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Override
    public void generate() {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append(IResourceFactory.clreplaced);
                _builder.append(" resourceFactory = injector.getInstance(");
                _builder.append(IResourceFactory.clreplaced);
                _builder.append(".clreplaced);");
                _builder.newLineIfNotEmpty();
                _builder.append(IResourceServiceProvider.clreplaced);
                _builder.append(" serviceProvider = injector.getInstance(");
                _builder.append(IResourceServiceProvider.clreplaced);
                _builder.append(".clreplaced);");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                {
                    List<String> _fileExtensions = ResourceFactoryFragment2.this.getLanguage().getFileExtensions();
                    for (final String fileExtension : _fileExtensions) {
                        _builder.append(Resource.clreplaced);
                        _builder.append(".Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(\"");
                        _builder.append(fileExtension);
                        _builder.append("\", resourceFactory);");
                        _builder.newLineIfNotEmpty();
                        _builder.append(IResourceServiceProvider.clreplaced);
                        _builder.append(".Registry.INSTANCE.getExtensionToFactoryMap().put(\"");
                        _builder.append(fileExtension);
                        _builder.append("\", serviceProvider);");
                        _builder.newLineIfNotEmpty();
                    }
                }
            }
        };
        this.getLanguage().getRuntimeGenSetup().getRegistrations().add(_client);
        IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
        PluginXmlAccess _pluginXml = null;
        if (_eclipsePlugin != null) {
            _pluginXml = _eclipsePlugin.getPluginXml();
        }
        boolean _tripleNotEquals = (_pluginXml != null);
        if (_tripleNotEquals) {
            List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("<!-- adding resource factories -->");
            _builder.newLine();
            {
                List<String> _fileExtensions = this.getLanguage().getFileExtensions();
                for (final String fileExtension : _fileExtensions) {
                    _builder.append("<extension");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("point=\"org.eclipse.emf.ecore.extension_parser\">");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("<parser");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("clreplaced=\"");
                    TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
                    _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
                    _builder.append(":org.eclipse.xtext.resource.IResourceFactory\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("type=\"");
                    _builder.append(fileExtension, "\t\t");
                    _builder.append("\">");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("</parser>");
                    _builder.newLine();
                    _builder.append("</extension>");
                    _builder.newLine();
                    _builder.append("<extension point=\"org.eclipse.xtext.extension_resourceServiceProvider\">");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("<resourceServiceProvider");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("clreplaced=\"");
                    TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
                    _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
                    _builder.append(":org.eclipse.xtext.ui.resource.IResourceUIServiceProvider\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("uriExtension=\"");
                    _builder.append(fileExtension, "\t\t");
                    _builder.append("\">");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("</resourceServiceProvider>");
                    _builder.newLine();
                    _builder.append("</extension>");
                    _builder.newLine();
                }
            }
            _entries.add(_builder.toString());
        }
    }
}

17 View Complete Implementation : CompareFragment2.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Contributes the registration of compare infrastructure.
 *
 * @author Christian Schneider - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced CompareFragment2 extends AbstractXtextGeneratorFragment {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Override
    public void generate() {
        IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
        ManifestAccess _manifest = null;
        if (_eclipsePlugin != null) {
            _manifest = _eclipsePlugin.getManifest();
        }
        boolean _tripleNotEquals = (_manifest != null);
        if (_tripleNotEquals) {
            Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
            Iterables.<String>addAll(_requiredBundles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.compare", "org.eclipse.xtext.ui")));
        }
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("binder.bind(");
                _builder.append(String.clreplaced);
                _builder.append(".clreplaced).annotatedWith(");
                _builder.append(Names.clreplaced);
                _builder.append(".named(");
                TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.UIBindings");
                _builder.append(_typeReference);
                _builder.append(".COMPARE_VIEWER_replacedLE)).toInstance(\"");
                String _simpleName = GrammarUtil.getSimpleName(CompareFragment2.this.getGrammar());
                _builder.append(_simpleName);
                _builder.append(" Compare\");");
            }
        };
        final StringConcatenationClient statement = _client;
        GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
        TypeReference _typeReference = new TypeReference("org.eclipse.compare.IViewerCreator");
        TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.ui.compare.DefaultViewerCreator");
        _bindingFactory.addTypeToType(_typeReference, _typeReference_1).addConfiguredBinding("CompareViewerreplacedle", statement).contributeTo(this.getLanguage().getEclipsePluginGenModule());
        IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
        PluginXmlAccess _pluginXml = null;
        if (_eclipsePlugin_1 != null) {
            _pluginXml = _eclipsePlugin_1.getPluginXml();
        }
        boolean _tripleNotEquals_1 = (_pluginXml != null);
        if (_tripleNotEquals_1) {
            List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("<extension point=\"org.eclipse.compare.contentViewers\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<viewer id=\"");
            String _name = this.getGrammar().getName();
            _builder.append(_name, "\t");
            _builder.append(".compare.contentViewers\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.compare.InjectableViewerCreator\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("extensions=\"");
            String _join = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
            _builder.append(_join, "\t\t");
            _builder.append("\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</viewer>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<contentTypeBinding");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("contentTypeId=\"");
            String _name_1 = this.getGrammar().getName();
            _builder.append(_name_1, "\t\t");
            _builder.append(".contenttype\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("contentViewerId=\"");
            String _name_2 = this.getGrammar().getName();
            _builder.append(_name_2, "\t\t");
            _builder.append(".compare.contentViewers\" />");
            _builder.newLineIfNotEmpty();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension point=\"org.eclipse.compare.contentMergeViewers\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<viewer id=\"");
            String _name_3 = this.getGrammar().getName();
            _builder.append(_name_3, "\t");
            _builder.append(".compare.contentMergeViewers\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.compare.InjectableViewerCreator\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("extensions=\"");
            String _join_1 = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
            _builder.append(_join_1, "\t\t");
            _builder.append("\" label=\"");
            String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName, "\t\t");
            _builder.append(" Compare\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</viewer>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<contentTypeBinding");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("contentTypeId=\"");
            String _name_4 = this.getGrammar().getName();
            _builder.append(_name_4, "\t\t");
            _builder.append(".contenttype\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("contentMergeViewerId=\"");
            String _name_5 = this.getGrammar().getName();
            _builder.append(_name_5, "\t\t");
            _builder.append(".compare.contentMergeViewers\" />");
            _builder.newLineIfNotEmpty();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension point=\"org.eclipse.ui.editors.doreplacedentProviders\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<provider id=\"");
            String _name_6 = this.getGrammar().getName();
            _builder.append(_name_6, "\t");
            _builder.append(".editors.doreplacedentProviders\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory_2 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory_2, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.editor.model.XtextDoreplacedentProvider\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("extensions=\"");
            String _join_2 = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
            _builder.append(_join_2, "\t\t");
            _builder.append("\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</provider>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension point=\"org.eclipse.team.core.fileTypes\">");
            _builder.newLine();
            {
                List<String> _fileExtensions = this.getLanguage().getFileExtensions();
                for (final String modelFileExtension : _fileExtensions) {
                    _builder.append("\t");
                    _builder.append("<fileTypes");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("extension=\"");
                    _builder.append(modelFileExtension, "\t\t");
                    _builder.append("\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("type=\"text\">");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("</fileTypes>");
                    _builder.newLine();
                }
            }
            _builder.append("</extension>");
            _builder.newLine();
            _entries.add(_builder.toString());
        }
    }
}

17 View Complete Implementation : AntlrGrammarGenerator.java
Copyright Eclipse Public License 1.0
Author : eclipse
@Singleton
@SuppressWarnings("all")
public clreplaced AntlrGrammarGenerator extends AbstractAntlrGrammarWithActionsGenerator {

    @Inject
    @Extension
    private GrammarNaming naming;

    @Override
    protected GrammarNaming getGrammarNaming() {
        return this.naming;
    }

    @Override
    protected String compileParserImports(final Grammar it, final AntlrOptions options) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.newLine();
        _builder.append("import org.eclipse.xtext.*;");
        _builder.newLine();
        _builder.append("import org.eclipse.xtext.parser.*;");
        _builder.newLine();
        _builder.append("import org.eclipse.xtext.parser.impl.*;");
        _builder.newLine();
        _builder.append("import org.eclipse.emf.ecore.util.EcoreUtil;");
        _builder.newLine();
        _builder.append("import org.eclipse.emf.ecore.EObject;");
        _builder.newLine();
        {
            boolean _isEmpty = GrammarUtil.allEnumRules(it).isEmpty();
            boolean _not = (!_isEmpty);
            if (_not) {
                _builder.append("import org.eclipse.emf.common.util.Enumerator;");
                _builder.newLine();
            }
        }
        _builder.append("import ");
        String _name = this.getGrammarNaming().getInternalParserSuperClreplaced(it).getName();
        _builder.append(_name);
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        _builder.append("import org.eclipse.xtext.parser.antlr.XtextTokenStream;");
        _builder.newLine();
        _builder.append("import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens;");
        _builder.newLine();
        {
            if (((!IterableExtensions.isEmpty(Iterables.<UnorderedGroup>filter((Iterables.<EObject>concat(ListExtensions.<ParserRule, List<EObject>>map(GrammarUtil.allParserRules(it), ((Function1<ParserRule, List<EObject>>) (ParserRule it_1) -> {
                return EcoreUtil2.eAllContentsAsList(it_1);
            })))), UnorderedGroup.clreplaced))) && options.isBacktrack())) {
                _builder.append("import org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper.UnorderedGroupState;");
                _builder.newLine();
            }
        }
        _builder.append("import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken;");
        _builder.newLine();
        _builder.append("import ");
        String _name_1 = this._grammarAccessExtensions.getGrammarAccess(it).getName();
        _builder.append(_name_1);
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        _builder.newLine();
        return _builder.toString();
    }

    @Override
    protected String compileParserMembers(final Grammar it, final AntlrOptions options) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.newLine();
        _builder.append("@");
        {
            boolean _isCombinedGrammar = this.isCombinedGrammar();
            if (_isCombinedGrammar) {
                _builder.append("parser::");
            }
        }
        _builder.append("members {");
        _builder.newLineIfNotEmpty();
        _builder.newLine();
        {
            boolean _isBacktrack = options.isBacktrack();
            if (_isBacktrack) {
                _builder.append("/*");
                _builder.newLine();
                _builder.append("  ");
                _builder.append("This grammar contains a lot of empty actions to work around a bug in ANTLR.");
                _builder.newLine();
                _builder.append("  ");
                _builder.append("Otherwise the ANTLR tool will create synpreds that cannot be compiled in some rare cases.");
                _builder.newLine();
                _builder.append("*/");
                _builder.newLine();
                _builder.newLine();
            }
        }
        _builder.append(" \t");
        _builder.append("private ");
        String _simpleName = this._grammarAccessExtensions.getGrammarAccess(it).getSimpleName();
        _builder.append(_simpleName, " \t");
        _builder.append(" grammarAccess;");
        _builder.newLineIfNotEmpty();
        _builder.newLine();
        _builder.append("    ");
        _builder.append("public ");
        String _simpleName_1 = this.naming.getInternalParserClreplaced(it).getSimpleName();
        _builder.append(_simpleName_1, "    ");
        _builder.append("(TokenStream input, ");
        String _simpleName_2 = this._grammarAccessExtensions.getGrammarAccess(it).getSimpleName();
        _builder.append(_simpleName_2, "    ");
        _builder.append(" grammarAccess) {");
        _builder.newLineIfNotEmpty();
        _builder.append("        ");
        _builder.append("this(input);");
        _builder.newLine();
        _builder.append("        ");
        _builder.append("this.grammarAccess = grammarAccess;");
        _builder.newLine();
        _builder.append("        ");
        _builder.append("registerRules(grammarAccess.getGrammar());");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("    ");
        _builder.append("@Override");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("protected String getFirstRuleName() {");
        _builder.newLine();
        _builder.append("    \t");
        _builder.append("return \"");
        String _name = AntlrGrammarGenUtil.<ParserRule>getOriginalElement(IterableExtensions.<ParserRule>head(GrammarUtil.allParserRules(it))).getName();
        _builder.append(_name, "    \t");
        _builder.append("\";");
        _builder.newLineIfNotEmpty();
        _builder.append("   \t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("   \t");
        _builder.append("@Override");
        _builder.newLine();
        _builder.append("   \t");
        _builder.append("protected ");
        String _simpleName_3 = this._grammarAccessExtensions.getGrammarAccess(it).getSimpleName();
        _builder.append(_simpleName_3, "   \t");
        _builder.append(" getGrammarAccess() {");
        _builder.newLineIfNotEmpty();
        _builder.append("   \t\t");
        _builder.append("return grammarAccess;");
        _builder.newLine();
        _builder.append("   \t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        return _builder.toString();
    }

    @Override
    protected String compileRuleCatch(final Grammar it, final AntlrOptions options) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.newLine();
        _builder.append("@rulecatch {");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("catch (RecognitionException re) {");
        _builder.newLine();
        _builder.append("        ");
        _builder.append("recover(input,re);");
        _builder.newLine();
        _builder.append("        ");
        _builder.append("appendSkippedTokens();");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        return _builder.toString();
    }

    @Override
    protected boolean shouldBeSkipped(final TerminalRule it, final Grammar grammar) {
        return false;
    }

    @Override
    protected CharSequence _compileRule(final ParserRule it, final Grammar grammar, final AntlrOptions options) {
        StringConcatenation _builder = new StringConcatenation();
        {
            boolean _isValidEntryRule = AntlrGrammarGenUtil.isValidEntryRule(it);
            if (_isValidEntryRule) {
                String _compileEntryRule = this.compileEntryRule(it, grammar, options);
                _builder.append(_compileEntryRule);
                _builder.newLineIfNotEmpty();
            }
        }
        _builder.newLine();
        String _compileEBNF = this.compileEBNF(it, options);
        _builder.append(_compileEBNF);
        _builder.newLineIfNotEmpty();
        return _builder;
    }

    protected String compileEntryRule(final ParserRule it, final Grammar grammar, final AntlrOptions options) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("// Entry rule ");
        String _entryRuleName = this._grammarAccessExtensions.entryRuleName(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(it));
        _builder.append(_entryRuleName);
        _builder.newLineIfNotEmpty();
        String _entryRuleName_1 = this._grammarAccessExtensions.entryRuleName(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(it));
        _builder.append(_entryRuleName_1);
        _builder.append(" returns ");
        String _compileEntryReturns = this.compileEntryReturns(it, options);
        _builder.append(_compileEntryReturns);
        CharSequence _compileEntryInit = this.compileEntryInit(it, options);
        _builder.append(_compileEntryInit);
        _builder.append(":");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("{ ");
        CharSequence _newCompositeNode = this.newCompositeNode(it);
        _builder.append(_newCompositeNode, "\t");
        _builder.append(" }");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("iv_");
        String _ruleName = this._grammarAccessExtensions.ruleName(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(it));
        _builder.append(_ruleName, "\t");
        _builder.append("=");
        String _ruleName_1 = this._grammarAccessExtensions.ruleName(it);
        _builder.append(_ruleName_1, "\t");
        String _defaultArgumentList = AntlrGrammarGenUtil.getDefaultArgumentList(it);
        _builder.append(_defaultArgumentList, "\t");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("{ $current=$iv_");
        String _ruleName_2 = this._grammarAccessExtensions.ruleName(it);
        _builder.append(_ruleName_2, "\t");
        _builder.append(".current");
        {
            boolean _isDatatypeRule = GrammarUtil.isDatatypeRule(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(it));
            if (_isDatatypeRule) {
                _builder.append(".getText()");
            }
        }
        _builder.append("; }");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("EOF;");
        _builder.newLine();
        CharSequence _compileEntryFinally = this.compileEntryFinally(it, options);
        _builder.append(_compileEntryFinally);
        _builder.newLineIfNotEmpty();
        return _builder.toString();
    }

    protected String compileEntryReturns(final ParserRule it, final AntlrOptions options) {
        boolean _isDatatypeRule = GrammarUtil.isDatatypeRule(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(it));
        if (_isDatatypeRule) {
            return "[String current=null]";
        } else {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("[");
            String _currentType = this.getCurrentType();
            _builder.append(_currentType);
            _builder.append(" current=null]");
            return _builder.toString();
        }
    }

    @Override
    protected String compileInit(final AbstractRule it, final AntlrOptions options) {
        StringConcatenation _builder = new StringConcatenation();
        {
            if ((it instanceof ParserRule)) {
                boolean _isPreplacedCurrentIntoFragment = this.isPreplacedCurrentIntoFragment();
                boolean _not = (!_isPreplacedCurrentIntoFragment);
                String _parameterList = AntlrGrammarGenUtil.getParameterList(((ParserRule) it), Boolean.valueOf(_not), this.getCurrentType());
                _builder.append(_parameterList);
            }
        }
        _builder.append(" returns ");
        CharSequence _compileReturns = this.compileReturns(it, options);
        _builder.append(_compileReturns);
        _builder.newLineIfNotEmpty();
        _builder.append("@init {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("enterRule();");
        _builder.newLine();
        _builder.append("\t");
        CharSequence _compileInitHiddenTokens = this.compileInitHiddenTokens(it, options);
        _builder.append(_compileInitHiddenTokens, "\t");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        CharSequence _compileInitUnorderedGroups = this.compileInitUnorderedGroups(it, options);
        _builder.append(_compileInitUnorderedGroups, "\t");
        _builder.newLineIfNotEmpty();
        _builder.append("}");
        _builder.newLine();
        _builder.append("@after {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("leaveRule();");
        _builder.newLine();
        _builder.append("}");
        return _builder.toString();
    }

    protected CharSequence compileReturns(final AbstractRule it, final AntlrOptions options) {
        CharSequence _switchResult = null;
        boolean _matched = false;
        if (it instanceof EnumRule) {
            _matched = true;
            _switchResult = "[Enumerator current=null]";
        }
        if (!_matched) {
            if (it instanceof ParserRule) {
                boolean _isDatatypeRule = GrammarUtil.isDatatypeRule(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(((ParserRule) it)));
                if (_isDatatypeRule) {
                    _matched = true;
                    _switchResult = "[AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()]";
                }
            }
        }
        if (!_matched) {
            if (it instanceof ParserRule) {
                boolean _isEObjectFragmentRule = GrammarUtil.isEObjectFragmentRule(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(((ParserRule) it)));
                if (_isEObjectFragmentRule) {
                    _matched = true;
                    StringConcatenation _builder = new StringConcatenation();
                    _builder.append("[");
                    String _currentType = this.getCurrentType();
                    _builder.append(_currentType);
                    _builder.append(" current=in_current]");
                    _switchResult = _builder;
                }
            }
        }
        if (!_matched) {
            if (it instanceof ParserRule) {
                _matched = true;
                StringConcatenation _builder = new StringConcatenation();
                _builder.append("[");
                String _currentType = this.getCurrentType();
                _builder.append(_currentType);
                _builder.append(" current=null]");
                _switchResult = _builder;
            }
        }
        if (!_matched) {
            throw new IllegalStateException(("Unexpected rule: " + it));
        }
        return _switchResult;
    }

    @Override
    protected String _dataTypeEbnf2(final Keyword it, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("kw=");
            String __dataTypeEbnf2 = super._dataTypeEbnf2(it, supportActions);
            _builder.append(__dataTypeEbnf2);
            _builder.newLineIfNotEmpty();
            _builder.append("{");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("$current.merge(kw);");
            _builder.newLine();
            _builder.append("\t");
            CharSequence _newLeafNode = this.newLeafNode(it, "kw");
            _builder.append(_newLeafNode, "\t");
            _builder.newLineIfNotEmpty();
            _builder.append("}");
            _builder.newLine();
            _xifexpression = _builder.toString();
        } else {
            _xifexpression = super._dataTypeEbnf2(it, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected String _dataTypeEbnf2(final RuleCall it, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            String _switchResult = null;
            AbstractRule _rule = it.getRule();
            boolean _matched = false;
            if (_rule instanceof EnumRule) {
                boolean _isreplacedigned = GrammarUtil.isreplacedigned(it);
                if (_isreplacedigned) {
                    _matched = true;
                }
            }
            if (!_matched) {
                if (_rule instanceof ParserRule) {
                    boolean _isreplacedigned = GrammarUtil.isreplacedigned(it);
                    if (_isreplacedigned) {
                        _matched = true;
                    }
                }
            }
            if (_matched) {
                _switchResult = super._dataTypeEbnf2(it, supportActions);
            }
            if (!_matched) {
                if (_rule instanceof EnumRule) {
                    _matched = true;
                }
                if (!_matched) {
                    if (_rule instanceof ParserRule) {
                        _matched = true;
                    }
                }
                if (_matched) {
                    StringConcatenation _builder = new StringConcatenation();
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    CharSequence _newCompositeNode = this.newCompositeNode(it);
                    _builder.append(_newCompositeNode, "\t");
                    _builder.newLineIfNotEmpty();
                    _builder.append("}");
                    _builder.newLine();
                    String _localVar = this._grammarAccessExtensions.localVar(it);
                    _builder.append(_localVar);
                    _builder.append("=");
                    String __dataTypeEbnf2 = super._dataTypeEbnf2(it, supportActions);
                    _builder.append(__dataTypeEbnf2);
                    String _argumentList = AntlrGrammarGenUtil.getArgumentList(it, this.isPreplacedCurrentIntoFragment(), (!supportActions));
                    _builder.append(_argumentList);
                    _builder.newLineIfNotEmpty();
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("$current.merge(");
                    String _localVar_1 = this._grammarAccessExtensions.localVar(it);
                    _builder.append(_localVar_1, "\t");
                    _builder.append(");");
                    _builder.newLineIfNotEmpty();
                    _builder.append("}");
                    _builder.newLine();
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("afterParserOrEnumRuleCall();");
                    _builder.newLine();
                    _builder.append("}");
                    _builder.newLine();
                    _switchResult = _builder.toString();
                }
            }
            if (!_matched) {
                if (_rule instanceof TerminalRule) {
                    _matched = true;
                    StringConcatenation _builder_1 = new StringConcatenation();
                    String _localVar_2 = this._grammarAccessExtensions.localVar(it);
                    _builder_1.append(_localVar_2);
                    _builder_1.append("=");
                    String __dataTypeEbnf2_1 = super._dataTypeEbnf2(it, supportActions);
                    _builder_1.append(__dataTypeEbnf2_1);
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    _builder_1.append("$current.merge(");
                    String _localVar_3 = this._grammarAccessExtensions.localVar(it);
                    _builder_1.append(_localVar_3, "\t");
                    _builder_1.append(");");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it));
                    _builder_1.append(_newLeafNode, "\t");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _switchResult = _builder_1.toString();
                }
            }
            if (!_matched) {
                _switchResult = super._dataTypeEbnf2(it, supportActions);
            }
            _xifexpression = _switchResult;
        } else {
            _xifexpression = super._dataTypeEbnf2(it, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected String _ebnf2(final Action it, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            StringConcatenation _builder = new StringConcatenation();
            {
                boolean _isBacktrack = options.isBacktrack();
                if (_isBacktrack) {
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("/* */");
                    _builder.newLine();
                    _builder.append("}");
                    _builder.newLine();
                }
            }
            _builder.append("{");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("$current = forceCreateModelElement");
            {
                String _feature = it.getFeature();
                boolean _tripleNotEquals = (_feature != null);
                if (_tripleNotEquals) {
                    _builder.append("And");
                    String _firstUpper = StringExtensions.toFirstUpper(this._grammarAccessExtensions.setOrAdd(it));
                    _builder.append(_firstUpper, "\t");
                }
            }
            _builder.append("(");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("grammarAccess.");
            String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<Action>getOriginalElement(it));
            _builder.append(_grammarElementAccess, "\t\t");
            _builder.append(",");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("$current);");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            _xifexpression = _builder.toString();
        } else {
            _xifexpression = super._ebnf2(it, options, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected String _ebnf2(final Keyword it, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if ((!supportActions)) {
            _xifexpression = super._ebnf2(it, options, supportActions);
        } else {
            String _xifexpression_1 = null;
            boolean _isreplacedigned = GrammarUtil.isreplacedigned(it);
            if (_isreplacedigned) {
                StringConcatenation _builder = new StringConcatenation();
                String __ebnf2 = super._ebnf2(it, options, supportActions);
                _builder.append(__ebnf2);
                _builder.newLineIfNotEmpty();
                _builder.append("{");
                _builder.newLine();
                _builder.append("\t");
                CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(GrammarUtil.containingreplacedignment(it), it));
                _builder.append(_newLeafNode, "\t");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
                _xifexpression_1 = _builder.toString();
            } else {
                StringConcatenation _builder_1 = new StringConcatenation();
                String _localVar = this._grammarAccessExtensions.localVar(it);
                _builder_1.append(_localVar);
                _builder_1.append("=");
                String __ebnf2_1 = super._ebnf2(it, options, supportActions);
                _builder_1.append(__ebnf2_1);
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("{");
                _builder_1.newLine();
                _builder_1.append("\t");
                CharSequence _newLeafNode_1 = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it));
                _builder_1.append(_newLeafNode_1, "\t");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("}");
                _builder_1.newLine();
                _xifexpression_1 = _builder_1.toString();
            }
            _xifexpression = _xifexpression_1;
        }
        return _xifexpression;
    }

    @Override
    protected String _ebnf2(final EnumLiteralDeclaration it, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if ((!supportActions)) {
            _xifexpression = super._ebnf2(it, options, supportActions);
        } else {
            StringConcatenation _builder = new StringConcatenation();
            String _localVar = this._grammarAccessExtensions.localVar(it);
            _builder.append(_localVar);
            _builder.append("=");
            String __ebnf2 = super._ebnf2(it, options, supportActions);
            _builder.append(__ebnf2);
            _builder.newLineIfNotEmpty();
            _builder.append("{");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("$current = grammarAccess.");
            String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<EnumLiteralDeclaration>getOriginalElement(it));
            _builder.append(_grammarElementAccess, "\t");
            _builder.append(".getEnumLiteral().getInstance();");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it));
            _builder.append(_newLeafNode, "\t");
            _builder.newLineIfNotEmpty();
            _builder.append("}");
            _builder.newLine();
            _xifexpression = _builder.toString();
        }
        return _xifexpression;
    }

    @Override
    protected String _ebnf2(final RuleCall it, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if ((!supportActions)) {
            _xifexpression = super._ebnf2(it, options, supportActions);
        } else {
            String _switchResult = null;
            AbstractRule _rule = it.getRule();
            final AbstractRule rule = _rule;
            boolean _matched = false;
            if (rule instanceof EnumRule) {
                boolean _isreplacedigned = GrammarUtil.isreplacedigned(it);
                if (_isreplacedigned) {
                    _matched = true;
                }
            }
            if (!_matched) {
                if (rule instanceof ParserRule) {
                    boolean _isreplacedigned = GrammarUtil.isreplacedigned(it);
                    if (_isreplacedigned) {
                        _matched = true;
                    }
                }
            }
            if (_matched) {
                _switchResult = super._ebnf2(it, options, supportActions);
            }
            if (!_matched) {
                if (rule instanceof EnumRule) {
                    _matched = true;
                }
                if (!_matched) {
                    if (rule instanceof ParserRule) {
                        boolean _isDatatypeRule = GrammarUtil.isDatatypeRule(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(((ParserRule) rule)));
                        if (_isDatatypeRule) {
                            _matched = true;
                        }
                    }
                }
                if (_matched) {
                    StringConcatenation _builder = new StringConcatenation();
                    {
                        boolean _isBacktrack = options.isBacktrack();
                        if (_isBacktrack) {
                            _builder.append("{");
                            _builder.newLine();
                            _builder.append("\t");
                            _builder.append("/* */");
                            _builder.newLine();
                            _builder.append("}");
                            _builder.newLine();
                        }
                    }
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    CharSequence _newCompositeNode = this.newCompositeNode(it);
                    _builder.append(_newCompositeNode, "\t");
                    _builder.newLineIfNotEmpty();
                    _builder.append("}");
                    _builder.newLine();
                    String __ebnf2 = super._ebnf2(it, options, supportActions);
                    _builder.append(__ebnf2);
                    _builder.newLineIfNotEmpty();
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("afterParserOrEnumRuleCall();");
                    _builder.newLine();
                    _builder.append("}");
                    _builder.newLine();
                    _switchResult = _builder.toString();
                }
            }
            if (!_matched) {
                if (rule instanceof ParserRule) {
                    _matched = true;
                    StringConcatenation _builder_1 = new StringConcatenation();
                    {
                        boolean _isBacktrack_1 = options.isBacktrack();
                        if (_isBacktrack_1) {
                            _builder_1.append("{");
                            _builder_1.newLine();
                            _builder_1.append("\t");
                            _builder_1.append("/* */");
                            _builder_1.newLine();
                            _builder_1.append("}");
                            _builder_1.newLine();
                        }
                    }
                    _builder_1.append("{");
                    _builder_1.newLine();
                    {
                        boolean _isEObjectFragmentRuleCall = GrammarUtil.isEObjectFragmentRuleCall(it);
                        if (_isEObjectFragmentRuleCall) {
                            _builder_1.append("\t");
                            _builder_1.append("if ($current==null) {");
                            _builder_1.newLine();
                            _builder_1.append("\t");
                            _builder_1.append("\t");
                            _builder_1.append("$current = ");
                            CharSequence _createModelElement = this.createModelElement(it);
                            _builder_1.append(_createModelElement, "\t\t");
                            _builder_1.append(";");
                            _builder_1.newLineIfNotEmpty();
                            _builder_1.append("\t");
                            _builder_1.append("}");
                            _builder_1.newLine();
                        }
                    }
                    _builder_1.append("\t");
                    CharSequence _newCompositeNode_1 = this.newCompositeNode(it);
                    _builder_1.append(_newCompositeNode_1, "\t");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    String _localVar = this._grammarAccessExtensions.localVar(it);
                    _builder_1.append(_localVar);
                    _builder_1.append("=");
                    String __ebnf2_1 = super._ebnf2(it, options, supportActions);
                    _builder_1.append(__ebnf2_1);
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    _builder_1.append("$current = $");
                    String _localVar_1 = this._grammarAccessExtensions.localVar(it);
                    _builder_1.append(_localVar_1, "\t");
                    _builder_1.append(".current;");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("\t");
                    _builder_1.append("afterParserOrEnumRuleCall();");
                    _builder_1.newLine();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _switchResult = _builder_1.toString();
                }
            }
            if (!_matched) {
                if (rule instanceof TerminalRule) {
                    _matched = true;
                    StringConcatenation _builder_1 = new StringConcatenation();
                    String _localVar = this._grammarAccessExtensions.localVar(it);
                    _builder_1.append(_localVar);
                    _builder_1.append("=");
                    String __ebnf2_1 = super._ebnf2(it, options, supportActions);
                    _builder_1.append(__ebnf2_1);
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it));
                    _builder_1.append(_newLeafNode, "\t");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _switchResult = _builder_1.toString();
                }
            }
            if (!_matched) {
                _switchResult = super._ebnf2(it, options, supportActions);
            }
            _xifexpression = _switchResult;
        }
        return _xifexpression;
    }

    @Override
    protected String crossrefEbnf(final AbstractRule it, final RuleCall call, final CrossReference ref, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            String _switchResult = null;
            boolean _matched = false;
            if (it instanceof EnumRule) {
                _matched = true;
            }
            if (!_matched) {
                if (it instanceof ParserRule) {
                    _matched = true;
                }
            }
            if (_matched) {
                StringConcatenation _builder = new StringConcatenation();
                _builder.append("{");
                _builder.newLine();
                _builder.append("\t");
                CharSequence _newCompositeNode = this.newCompositeNode(ref);
                _builder.append(_newCompositeNode, "\t");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
                String _ruleName = this._grammarAccessExtensions.ruleName(it);
                _builder.append(_ruleName);
                String _argumentList = AntlrGrammarGenUtil.getArgumentList(call, this.isPreplacedCurrentIntoFragment(), (!supportActions));
                _builder.append(_argumentList);
                _builder.newLineIfNotEmpty();
                _builder.append("{");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("afterParserOrEnumRuleCall();");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
                _switchResult = _builder.toString();
            }
            if (!_matched) {
                if (it instanceof TerminalRule) {
                    _matched = true;
                    StringConcatenation _builder_1 = new StringConcatenation();
                    String _localVar = this._grammarAccessExtensions.localVar(GrammarUtil.containingreplacedignment(ref));
                    _builder_1.append(_localVar);
                    _builder_1.append("=");
                    String _ruleName_1 = this._grammarAccessExtensions.ruleName(it);
                    _builder_1.append(_ruleName_1);
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    CharSequence _newLeafNode = this.newLeafNode(ref, this._grammarAccessExtensions.localVar(GrammarUtil.containingreplacedignment(ref)));
                    _builder_1.append(_newLeafNode, "\t");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _switchResult = _builder_1.toString();
                }
            }
            if (!_matched) {
                throw new IllegalStateException(("crossrefEbnf is not supported for " + it));
            }
            _xifexpression = _switchResult;
        } else {
            _xifexpression = super.crossrefEbnf(it, call, ref, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected String _replacedignmentEbnf(final CrossReference it, final replacedignment replacedignment, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            StringConcatenation _builder = new StringConcatenation();
            {
                boolean _isBacktrack = options.isBacktrack();
                if (_isBacktrack) {
                    _builder.append("{");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("/* */");
                    _builder.newLine();
                    _builder.append("}");
                    _builder.newLine();
                }
            }
            _builder.append("{");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("if ($current==null) {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("$current = ");
            CharSequence _createModelElement = this.createModelElement(replacedignment);
            _builder.append(_createModelElement, "\t\t");
            _builder.append(";");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
            String __replacedignmentEbnf = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
            _builder.append(__replacedignmentEbnf);
            _xifexpression = _builder.toString();
        } else {
            _xifexpression = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected String _replacedignmentEbnf(final AbstractElement it, final replacedignment replacedignment, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            StringConcatenation _builder = new StringConcatenation();
            String _localVar = this._grammarAccessExtensions.localVar(replacedignment, it);
            _builder.append(_localVar);
            _builder.append("=");
            String __replacedignmentEbnf = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
            _builder.append(__replacedignmentEbnf);
            _builder.newLineIfNotEmpty();
            _builder.append("{");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("if ($current==null) {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("$current = ");
            CharSequence _createModelElement = this.createModelElement(replacedignment);
            _builder.append(_createModelElement, "\t\t");
            _builder.append(";");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("\t");
            String _setOrAdd = this._grammarAccessExtensions.setOrAdd(replacedignment);
            _builder.append(_setOrAdd, "\t");
            _builder.append("WithLastConsumed($current, \"");
            String _feature = replacedignment.getFeature();
            _builder.append(_feature, "\t");
            _builder.append("\", ");
            {
                boolean _isBooleanreplacedignment = GrammarUtil.isBooleanreplacedignment(replacedignment);
                if (_isBooleanreplacedignment) {
                    _builder.append("true");
                } else {
                    String _localVar_1 = this._grammarAccessExtensions.localVar(replacedignment, it);
                    _builder.append(_localVar_1, "\t");
                }
            }
            _builder.append(", ");
            CharSequence _stringLiteral = this._grammarAccessExtensions.toStringLiteral(replacedignment.getTerminal());
            _builder.append(_stringLiteral, "\t");
            _builder.append(");");
            _builder.newLineIfNotEmpty();
            _builder.append("}");
            _builder.newLine();
            _xifexpression = _builder.toString();
        } else {
            _xifexpression = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected String _replacedignmentEbnf(final RuleCall it, final replacedignment replacedignment, final AntlrOptions options, final boolean supportActions) {
        String _xifexpression = null;
        if (supportActions) {
            String _switchResult = null;
            AbstractRule _rule = it.getRule();
            boolean _matched = false;
            if (_rule instanceof EnumRule) {
                _matched = true;
            }
            if (!_matched) {
                if (_rule instanceof ParserRule) {
                    _matched = true;
                }
            }
            if (_matched) {
                StringConcatenation _builder = new StringConcatenation();
                _builder.append("{");
                _builder.newLine();
                _builder.append("\t");
                CharSequence _newCompositeNode = this.newCompositeNode(it);
                _builder.append(_newCompositeNode, "\t");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
                String _localVar = this._grammarAccessExtensions.localVar(replacedignment, it);
                _builder.append(_localVar);
                _builder.append("=");
                String __replacedignmentEbnf = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
                _builder.append(__replacedignmentEbnf);
                _builder.newLineIfNotEmpty();
                _builder.append("{");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("if ($current==null) {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("$current = ");
                CharSequence _createModelElementForParent = this.createModelElementForParent(replacedignment);
                _builder.append(_createModelElementForParent, "\t\t");
                _builder.append(";");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                String _setOrAdd = this._grammarAccessExtensions.setOrAdd(replacedignment);
                _builder.append(_setOrAdd, "\t");
                _builder.append("(");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("$current,");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("\"");
                String _feature = replacedignment.getFeature();
                _builder.append(_feature, "\t\t");
                _builder.append("\",");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                {
                    boolean _isBooleanreplacedignment = GrammarUtil.isBooleanreplacedignment(replacedignment);
                    if (_isBooleanreplacedignment) {
                        _builder.append("true");
                    } else {
                        String _localVar_1 = this._grammarAccessExtensions.localVar(replacedignment, it);
                        _builder.append(_localVar_1, "\t\t");
                    }
                }
                _builder.append(",");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                CharSequence _stringLiteral = this._grammarAccessExtensions.toStringLiteral(it);
                _builder.append(_stringLiteral, "\t\t");
                _builder.append(");");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("afterParserOrEnumRuleCall();");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
                _switchResult = _builder.toString();
            }
            if (!_matched) {
                if (_rule instanceof TerminalRule) {
                    _matched = true;
                    StringConcatenation _builder_1 = new StringConcatenation();
                    String _localVar_2 = this._grammarAccessExtensions.localVar(replacedignment, it);
                    _builder_1.append(_localVar_2);
                    _builder_1.append("=");
                    String __replacedignmentEbnf_1 = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
                    _builder_1.append(__replacedignmentEbnf_1);
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(replacedignment, it));
                    _builder_1.append(_newLeafNode, "\t");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _builder_1.append("{");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    _builder_1.append("if ($current==null) {");
                    _builder_1.newLine();
                    _builder_1.append("\t\t");
                    _builder_1.append("$current = ");
                    CharSequence _createModelElement = this.createModelElement(replacedignment);
                    _builder_1.append(_createModelElement, "\t\t");
                    _builder_1.append(";");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("\t");
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _builder_1.append("\t");
                    String _setOrAdd_1 = this._grammarAccessExtensions.setOrAdd(replacedignment);
                    _builder_1.append(_setOrAdd_1, "\t");
                    _builder_1.append("WithLastConsumed(");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("\t\t");
                    _builder_1.append("$current,");
                    _builder_1.newLine();
                    _builder_1.append("\t\t");
                    _builder_1.append("\"");
                    String _feature_1 = replacedignment.getFeature();
                    _builder_1.append(_feature_1, "\t\t");
                    _builder_1.append("\",");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("\t\t");
                    {
                        boolean _isBooleanreplacedignment_1 = GrammarUtil.isBooleanreplacedignment(replacedignment);
                        if (_isBooleanreplacedignment_1) {
                            _builder_1.append("true");
                        } else {
                            String _localVar_3 = this._grammarAccessExtensions.localVar(replacedignment, it);
                            _builder_1.append(_localVar_3, "\t\t");
                        }
                    }
                    _builder_1.append(",");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("\t\t");
                    CharSequence _stringLiteral_1 = this._grammarAccessExtensions.toStringLiteral(it);
                    _builder_1.append(_stringLiteral_1, "\t\t");
                    _builder_1.append(");");
                    _builder_1.newLineIfNotEmpty();
                    _builder_1.append("}");
                    _builder_1.newLine();
                    _switchResult = _builder_1.toString();
                }
            }
            if (!_matched) {
                throw new IllegalStateException(("replacedignmentEbnf is not supported for " + it));
            }
            _xifexpression = _switchResult;
        } else {
            _xifexpression = super._replacedignmentEbnf(it, replacedignment, options, supportActions);
        }
        return _xifexpression;
    }

    @Override
    protected boolean isPreplacedCurrentIntoFragment() {
        return true;
    }

    protected CharSequence createModelElement(final EObject grammarElement) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("createModelElement(grammarAccess.");
        String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(GrammarUtil.containingParserRule(grammarElement)));
        _builder.append(_grammarElementAccess);
        _builder.append(")");
        return _builder;
    }

    protected CharSequence createModelElementForParent(final EObject grammarElement) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("createModelElementForParent(grammarAccess.");
        String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<ParserRule>getOriginalElement(GrammarUtil.containingParserRule(grammarElement)));
        _builder.append(_grammarElementAccess);
        _builder.append(")");
        return _builder;
    }

    protected CharSequence newCompositeNode(final EObject it) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("newCompositeNode(grammarAccess.");
        String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<EObject>getOriginalElement(it));
        _builder.append(_grammarElementAccess);
        _builder.append(");");
        return _builder;
    }

    protected CharSequence newLeafNode(final EObject it, final String token) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("newLeafNode(");
        _builder.append(token);
        _builder.append(", grammarAccess.");
        String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<EObject>getOriginalElement(it));
        _builder.append(_grammarElementAccess);
        _builder.append(");");
        return _builder;
    }

    @Override
    protected CharSequence compileRule(final Object it, final Grammar grammar, final AntlrOptions options) {
        if (it instanceof EnumRule) {
            return _compileRule((EnumRule) it, grammar, options);
        } else if (it instanceof ParserRule) {
            return _compileRule((ParserRule) it, grammar, options);
        } else if (it instanceof TerminalRule) {
            return _compileRule((TerminalRule) it, grammar, options);
        } else if (it instanceof String) {
            return _compileRule((String) it, grammar, options);
        } else {
            throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, grammar, options).toString());
        }
    }
}

17 View Complete Implementation : TemplateFileWizardFragment.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Add a new file wizard with an (optional) template selection page.
 *
 * Example usage:
 * <pre>
 * component = XtextGenerator {
 *     language = StandardLanguage {
 *         fileWizard = {
 *             generate = true
 *         }
 *     }
 * }
 * </pre>
 *
 * @author Arne Deutsch - Initial contribution and API
 * @since 2.14
 */
@Beta
@SuppressWarnings("all")
public clreplaced TemplateFileWizardFragment extends AbstractXtextGeneratorFragment {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Inject
    private FileAccessFactory fileAccessFactory;

    @Accessors
    private boolean generate = false;

    @Accessors
    private boolean generateToolbarButton = false;

    @Override
    public void generate() {
        if ((!this.generate)) {
            return;
        }
        IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
        ManifestAccess _manifest = null;
        if (_eclipsePlugin != null) {
            _manifest = _eclipsePlugin.getManifest();
        }
        boolean _tripleNotEquals = (_manifest != null);
        if (_tripleNotEquals) {
            Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
            Iterables.<String>addAll(_requiredBundles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.core.runtime", "org.eclipse.core.resources", "org.eclipse.ui", "org.eclipse.ui.ide", "org.eclipse.ui.forms")));
            Set<String> _exportedPackages = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
            String _eclipsePluginBasePackage = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
            String _plus = (_eclipsePluginBasePackage + ".wizard");
            Iterables.<String>addAll(_exportedPackages, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_plus)));
        }
        IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
        PluginXmlAccess _pluginXml = null;
        if (_eclipsePlugin_1 != null) {
            _pluginXml = _eclipsePlugin_1.getPluginXml();
        }
        boolean _tripleNotEquals_1 = (_pluginXml != null);
        if (_tripleNotEquals_1) {
            List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.ui.newWizards\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<category id=\"");
            String _eclipsePluginBasePackage_1 = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
            _builder.append(_eclipsePluginBasePackage_1, "\t");
            _builder.append(".category\" name=\"");
            String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName, "\t");
            _builder.append("\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</category>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<wizard");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("category=\"");
            String _eclipsePluginBasePackage_2 = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
            _builder.append(_eclipsePluginBasePackage_2, "\t\t");
            _builder.append(".category\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.wizard.template.TemplateNewFileWizard\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("id=\"");
            String _fileWizardClreplacedName = this.getFileWizardClreplacedName();
            _builder.append(_fileWizardClreplacedName, "\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("name=\"");
            String _simpleName_1 = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName_1, "\t\t");
            _builder.append(" File\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("icon=\"icons/new_");
            String _simpleName_2 = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName_2, "\t\t");
            _builder.append("_file.png\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</wizard>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.xtext.ui.fileTemplate\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<fileTemplateProvider");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
            _builder.append(":");
            String _fileTemplateProviderClreplacedName = this.getFileTemplateProviderClreplacedName();
            _builder.append(_fileTemplateProviderClreplacedName, "\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("grammarName=\"");
            String _languageId = GrammarUtil.getLanguageId(this.getGrammar());
            _builder.append(_languageId, "\t\t");
            _builder.append("\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</fileTemplateProvider>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.ui.perspectiveExtensions\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<perspectiveExtension targetID=\"org.eclipse.ui.resourcePerspective\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<newWizardShortcut id=\"");
            String _fileWizardClreplacedName_1 = this.getFileWizardClreplacedName();
            _builder.append(_fileWizardClreplacedName_1, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</perspectiveExtension>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<perspectiveExtension targetID=\"org.eclipse.jdt.ui.JavaPerspective\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<newWizardShortcut id=\"");
            String _fileWizardClreplacedName_2 = this.getFileWizardClreplacedName();
            _builder.append(_fileWizardClreplacedName_2, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</perspectiveExtension>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _entries.add(_builder.toString());
            if (this.generateToolbarButton) {
                List<CharSequence> _entries_1 = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
                StringConcatenation _builder_1 = new StringConcatenation();
                _builder_1.append("<extension");
                _builder_1.newLine();
                _builder_1.append("\t");
                _builder_1.append("point=\"org.eclipse.ui.menus\">");
                _builder_1.newLine();
                _builder_1.append("\t");
                _builder_1.append("<menuContribution");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("allPopups=\"false\"");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("locationURI=\"toolbar:org.eclipse.ui.main.toolbar\">");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("<toolbar");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("id=\"");
                String _eclipsePluginBasePackage_3 = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
                _builder_1.append(_eclipsePluginBasePackage_3, "\t\t\t");
                _builder_1.append(".toolbar\">");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("\t\t\t");
                _builder_1.append("<!--");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("For some reason the tooltip is not shown when hovering over the toolbar button");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("See also https://www.eclipse.org/forums/index.php/t/1079111/");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("-->");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("<command");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("commandId=\"org.eclipse.ui.newWizard\"");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("tooltip=\"Create a new ");
                String _simpleName_3 = GrammarUtil.getSimpleName(this.getGrammar());
                _builder_1.append(_simpleName_3, "\t\t\t\t");
                _builder_1.append(" file\">");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("<parameter");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t\t");
                _builder_1.append("name=\"newWizardId\"");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t\t");
                _builder_1.append("value=\"");
                String _fileWizardClreplacedName_3 = this.getFileWizardClreplacedName();
                _builder_1.append(_fileWizardClreplacedName_3, "\t\t\t\t\t");
                _builder_1.append("\">");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("</parameter>");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("</command>");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("</toolbar>");
                _builder_1.newLine();
                _builder_1.append("\t");
                _builder_1.append("</menuContribution>");
                _builder_1.newLine();
                _builder_1.append("</extension>");
                _builder_1.newLine();
                _entries_1.add(_builder_1.toString());
            }
        }
        this.generateProjectTemplateProvider();
        this.generateDefaultIcons();
    }

    public void generateProjectTemplateProvider() {
        final TypeReference initialContentsClreplaced = TypeReference.typeRef(this.getFileTemplateProviderClreplacedName());
        final String quotes = "\'\'\'";
        final String openVar = "�";
        final String closeVar = "�";
        final XtendFileAccess file = this.fileAccessFactory.createXtendFile(initialContentsClreplaced);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("import org.eclipse.xtext.ui.wizard.template.FileTemplate");
                _builder.newLine();
                _builder.append("import org.eclipse.xtext.ui.wizard.template.IFileGenerator");
                _builder.newLine();
                _builder.append("import org.eclipse.xtext.ui.wizard.template.IFileTemplateProvider");
                _builder.newLine();
                _builder.newLine();
                _builder.append("/**");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Create a list with all file templates to be shown in the template new file wizard.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* ");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Each template is able to generate one or more files.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("clreplaced ");
                String _simpleName = initialContentsClreplaced.getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" implements IFileTemplateProvider {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("override getFileTemplates() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("#[new HelloWorldFile]");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
                _builder.newLine();
                _builder.append("@FileTemplate(label=\"Hello World\", icon=\"file_template.png\", description=\"Create a hello world for ");
                String _simpleName_1 = GrammarUtil.getSimpleName(TemplateFileWizardFragment.this.getGrammar());
                _builder.append(_simpleName_1);
                _builder.append(".\")");
                _builder.newLineIfNotEmpty();
                _builder.append("final clreplaced HelloWorldFile {");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("val helloName = combo(\"Hello Name:\", #[\"Xtext\", \"World\", \"Foo\", \"Bar\"], \"The name to say \'Hello\' to\")");
                _builder.newLine();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("override generateFiles(IFileGenerator generator) {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("generator.generate(");
                _builder.append(quotes, "\t\t");
                _builder.append(openVar, "\t\t");
                _builder.append("folder");
                _builder.append(closeVar, "\t\t");
                _builder.append("/");
                _builder.append(openVar, "\t\t");
                _builder.append("name");
                _builder.append(closeVar, "\t\t");
                _builder.append(".");
                String _get = TemplateFileWizardFragment.this.getLanguage().getFileExtensions().get(0);
                _builder.append(_get, "\t\t");
                _builder.append(quotes, "\t\t");
                _builder.append(", ");
                _builder.append(quotes, "\t\t");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t\t");
                _builder.append("/*");
                _builder.newLine();
                _builder.append("\t\t\t ");
                _builder.append("* This is an example model");
                _builder.newLine();
                _builder.append("\t\t\t ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("\t\t\t");
                _builder.append("Hello ");
                _builder.append(openVar, "\t\t\t");
                _builder.append("helloName");
                _builder.append(closeVar, "\t\t\t");
                _builder.append("!");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append(quotes, "\t\t");
                _builder.append(")");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        file.setContent(_client);
        file.writeTo(this.getProjectConfig().getEclipsePlugin().getSrc());
    }

    public void generateDefaultIcons() {
        final BinaryFileAccess projectTemplate = this.fileAccessFactory.createBinaryFile("file_template.png");
        boolean _existIn = projectTemplate.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
        boolean _not = (!_existIn);
        if (_not) {
            projectTemplate.setContent(this.readBinaryFileFromPackage("file_template.png"));
            projectTemplate.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
        }
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus = ("new_" + _simpleName);
        String _plus_1 = (_plus + "_file.png");
        final BinaryFileAccess newProject = this.fileAccessFactory.createBinaryFile(_plus_1);
        boolean _existIn_1 = newProject.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
        boolean _not_1 = (!_existIn_1);
        if (_not_1) {
            newProject.setContent(this.readBinaryFileFromPackage("new_xfile.png"));
            newProject.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
        }
    }

    private byte[] readBinaryFileFromPackage(final String fileName) {
        try {
            final InputStream stream = TemplateFileWizardFragment.clreplaced.getResourcereplacedtream(fileName);
            try {
                return ByteStreams.toByteArray(stream);
            } finally {
                stream.close();
            }
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    protected String getFileTemplateProviderClreplacedName() {
        String _fileWizardPackage = this.getFileWizardPackage();
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus = (_fileWizardPackage + _simpleName);
        return (_plus + "FileTemplateProvider");
    }

    protected String getFileWizardClreplacedName() {
        String _fileWizardPackage = this.getFileWizardPackage();
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus = (_fileWizardPackage + _simpleName);
        return (_plus + "NewFileWizard");
    }

    protected String getFileWizardPackage() {
        String _eclipsePluginBasePackage = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
        return (_eclipsePluginBasePackage + ".wizard.");
    }

    /**
     * Generate the wizard. Set to 'false' by default. Change to 'true' to generate the wizard.
     */
    public boolean setGenerate(final boolean value) {
        return this.generate = value;
    }

    /**
     * Generate a new file wizard toolbar button. Set to 'false' by default. Change to 'true' to add the new file wizard button to the toolbar.
     *
     * @since 2.20
     */
    public boolean setGenerateToolbarButton(final boolean value) {
        return this.generateToolbarButton = value;
    }

    @Pure
    public boolean isGenerate() {
        return this.generate;
    }

    @Pure
    public boolean isGenerateToolbarButton() {
        return this.generateToolbarButton;
    }
}

17 View Complete Implementation : QuickOutlineFragment2.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Contributes the 'Quick Outline' entry to the language editor's context menu.
 *
 * @author Christian Schneider - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced QuickOutlineFragment2 extends AbstractXtextGeneratorFragment {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Override
    public void generate() {
        ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
        boolean _tripleNotEquals = (_manifest != null);
        if (_tripleNotEquals) {
            Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
            _requiredBundles.add("org.eclipse.xtext.ui");
        }
        PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
        boolean _tripleNotEquals_1 = (_pluginXml != null);
        if (_tripleNotEquals_1) {
            List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("<!-- Quick Outline -->");
            _builder.newLine();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.ui.handlers\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<handler ");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("commandId=\"org.eclipse.xtext.ui.editor.outline.QuickOutline\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<activeWhen>");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("<reference");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("definitionId=\"");
            String _name = this.getGrammar().getName();
            _builder.append(_name, "\t\t\t\t");
            _builder.append(".Editor.opened\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t\t");
            _builder.append("</reference>");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("</activeWhen>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</handler>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.ui.commands\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<command");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("description=\"Open the quick outline.\"");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("id=\"org.eclipse.xtext.ui.editor.outline.QuickOutline\"");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("name=\"Quick Outline\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</command>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension point=\"org.eclipse.ui.menus\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<menuContribution");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("locationURI=\"popup:#TextEditorContext?after=group.open\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<command commandId=\"org.eclipse.xtext.ui.editor.outline.QuickOutline\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("style=\"push\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("tooltip=\"Open Quick Outline\">");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("<visibleWhen checkEnabled=\"false\">");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("<reference definitionId=\"");
            String _name_1 = this.getGrammar().getName();
            _builder.append(_name_1, "\t\t\t\t");
            _builder.append(".Editor.opened\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t\t");
            _builder.append("</visibleWhen>");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("</command>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</menuContribution>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _entries.add(_builder.toString());
        }
    }
}

17 View Complete Implementation : TemplateProjectWizardFragment.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Add a new project wizard with a template selection page.
 *
 * Example usage:
 * <pre>
 * component = XtextGenerator {
 *     language = StandardLanguage {
 *         projectWizard = {
 *             generate = true
 *         }
 *     }
 * }
 * </pre>
 *
 * @author Arne Deutsch - Initial contribution and API
 * @since 2.14
 */
@Beta
@SuppressWarnings("all")
public clreplaced TemplateProjectWizardFragment extends AbstractXtextGeneratorFragment {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Inject
    private FileAccessFactory fileAccessFactory;

    @Accessors
    private boolean generate = false;

    @Accessors
    private boolean generateToolbarButton = false;

    @Accessors
    private boolean pluginProject = true;

    @Override
    public void generate() {
        if ((!this.generate)) {
            return;
        }
        IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
        ManifestAccess _manifest = null;
        if (_eclipsePlugin != null) {
            _manifest = _eclipsePlugin.getManifest();
        }
        boolean _tripleNotEquals = (_manifest != null);
        if (_tripleNotEquals) {
            Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
            Iterables.<String>addAll(_requiredBundles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.core.runtime", "org.eclipse.core.resources", "org.eclipse.ui", "org.eclipse.ui.ide", "org.eclipse.ui.forms", "org.eclipse.xtend.lib")));
            if (this.pluginProject) {
                Set<String> _requiredBundles_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
                Iterables.<String>addAll(_requiredBundles_1, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.jdt.core", "org.eclipse.pde.core")));
            }
            Set<String> _exportedPackages = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
            String _eclipsePluginBasePackage = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
            String _plus = (_eclipsePluginBasePackage + ".wizard");
            Iterables.<String>addAll(_exportedPackages, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_plus)));
        }
        GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
        TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.wizard.IProjectCreator");
        TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.ui.wizard.template.DefaultTemplateProjectCreator");
        _bindingFactory.addTypeToType(_typeReference, _typeReference_1).contributeTo(this.getLanguage().getEclipsePluginGenModule());
        IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
        PluginXmlAccess _pluginXml = null;
        if (_eclipsePlugin_1 != null) {
            _pluginXml = _eclipsePlugin_1.getPluginXml();
        }
        boolean _tripleNotEquals_1 = (_pluginXml != null);
        if (_tripleNotEquals_1) {
            List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.ui.newWizards\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<category id=\"");
            String _eclipsePluginBasePackage_1 = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
            _builder.append(_eclipsePluginBasePackage_1, "\t");
            _builder.append(".category\" name=\"");
            String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName, "\t");
            _builder.append("\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</category>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<wizard");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("category=\"");
            String _eclipsePluginBasePackage_2 = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
            _builder.append(_eclipsePluginBasePackage_2, "\t\t");
            _builder.append(".category\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.wizard.template.TemplateNewProjectWizard\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("id=\"");
            String _projectWizardClreplacedName = this.getProjectWizardClreplacedName();
            _builder.append(_projectWizardClreplacedName, "\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("name=\"");
            String _simpleName_1 = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName_1, "\t\t");
            _builder.append(" Project\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("icon=\"icons/new_");
            String _simpleName_2 = GrammarUtil.getSimpleName(this.getGrammar());
            _builder.append(_simpleName_2, "\t\t");
            _builder.append("_proj.gif\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("project=\"true\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</wizard>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.xtext.ui.projectTemplate\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<projectTemplateProvider");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
            _builder.append(":");
            String _projectTemplateProviderClreplacedName = this.getProjectTemplateProviderClreplacedName();
            _builder.append(_projectTemplateProviderClreplacedName, "\t\t");
            _builder.append("\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("grammarName=\"");
            String _languageId = GrammarUtil.getLanguageId(this.getGrammar());
            _builder.append(_languageId, "\t\t");
            _builder.append("\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</projectTemplateProvider>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("point=\"org.eclipse.ui.perspectiveExtensions\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<perspectiveExtension targetID=\"org.eclipse.ui.resourcePerspective\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<newWizardShortcut id=\"");
            String _projectWizardClreplacedName_1 = this.getProjectWizardClreplacedName();
            _builder.append(_projectWizardClreplacedName_1, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</perspectiveExtension>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<perspectiveExtension targetID=\"org.eclipse.jdt.ui.JavaPerspective\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<newWizardShortcut id=\"");
            String _projectWizardClreplacedName_2 = this.getProjectWizardClreplacedName();
            _builder.append(_projectWizardClreplacedName_2, "\t\t");
            _builder.append("\"/>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</perspectiveExtension>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _entries.add(_builder.toString());
            if (this.generateToolbarButton) {
                List<CharSequence> _entries_1 = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
                StringConcatenation _builder_1 = new StringConcatenation();
                _builder_1.append("<extension");
                _builder_1.newLine();
                _builder_1.append("\t");
                _builder_1.append("point=\"org.eclipse.ui.menus\">");
                _builder_1.newLine();
                _builder_1.append("\t");
                _builder_1.append("<menuContribution");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("allPopups=\"false\"");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("locationURI=\"toolbar:org.eclipse.ui.main.toolbar\">");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("<toolbar");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("id=\"");
                String _eclipsePluginBasePackage_3 = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
                _builder_1.append(_eclipsePluginBasePackage_3, "\t\t\t");
                _builder_1.append(".toolbar\">");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("\t\t\t");
                _builder_1.append("<!--");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("For some reason the tooltip is not shown when hovering over the toolbar button");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("See also https://www.eclipse.org/forums/index.php/t/1079111/");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("-->");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("<command");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("commandId=\"org.eclipse.ui.newWizard\"");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("tooltip=\"Create a new ");
                String _simpleName_3 = GrammarUtil.getSimpleName(this.getGrammar());
                _builder_1.append(_simpleName_3, "\t\t\t\t");
                _builder_1.append(" project\">");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("<parameter");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t\t");
                _builder_1.append("name=\"newWizardId\"");
                _builder_1.newLine();
                _builder_1.append("\t\t\t\t\t");
                _builder_1.append("value=\"");
                String _projectWizardClreplacedName_3 = this.getProjectWizardClreplacedName();
                _builder_1.append(_projectWizardClreplacedName_3, "\t\t\t\t\t");
                _builder_1.append("\">");
                _builder_1.newLineIfNotEmpty();
                _builder_1.append("\t\t\t\t");
                _builder_1.append("</parameter>");
                _builder_1.newLine();
                _builder_1.append("\t\t\t");
                _builder_1.append("</command>");
                _builder_1.newLine();
                _builder_1.append("\t\t");
                _builder_1.append("</toolbar>");
                _builder_1.newLine();
                _builder_1.append("\t");
                _builder_1.append("</menuContribution>");
                _builder_1.newLine();
                _builder_1.append("</extension>");
                _builder_1.newLine();
                _entries_1.add(_builder_1.toString());
            }
        }
        this.generateProjectTemplateProvider();
        this.generateDefaultIcons();
    }

    public void generateProjectTemplateProvider() {
        final TypeReference initialContentsClreplaced = TypeReference.typeRef(this.getProjectTemplateProviderClreplacedName());
        final String quotes = "\'\'\'";
        final String openVar = "�";
        final String closeVar = "�";
        final XtendFileAccess file = this.fileAccessFactory.createXtendFile(initialContentsClreplaced);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("import org.eclipse.core.runtime.Status");
                _builder.newLine();
                {
                    if (TemplateProjectWizardFragment.this.pluginProject) {
                        _builder.append("import org.eclipse.jdt.core.JavaCore");
                        _builder.newLine();
                    }
                }
                _builder.append("import org.eclipse.xtext.ui.XtextProjectHelper");
                _builder.newLine();
                {
                    if (TemplateProjectWizardFragment.this.pluginProject) {
                        _builder.append("import org.eclipse.xtext.ui.util.PluginProjectFactory");
                        _builder.newLine();
                    } else {
                        _builder.append("import org.eclipse.xtext.ui.util.ProjectFactory");
                        _builder.newLine();
                    }
                }
                _builder.append("import org.eclipse.xtext.ui.wizard.template.IProjectGenerator");
                _builder.newLine();
                _builder.append("import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider");
                _builder.newLine();
                _builder.append("import org.eclipse.xtext.ui.wizard.template.ProjectTemplate");
                _builder.newLine();
                _builder.newLine();
                _builder.append("import static org.eclipse.core.runtime.IStatus.*");
                _builder.newLine();
                _builder.newLine();
                _builder.append("/**");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Create a list with all project templates to be shown in the template new project wizard.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* ");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Each template is able to generate one or more projects. Each project can be configured such that any number of files are included.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("clreplaced ");
                String _simpleName = initialContentsClreplaced.getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" implements IProjectTemplateProvider {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("override getProjectTemplates() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("#[new HelloWorldProject]");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
                _builder.newLine();
                _builder.append("@ProjectTemplate(label=\"Hello World\", icon=\"project_template.png\", description=\"<p><b>Hello World</b></p>");
                _builder.newLine();
                _builder.append("<p>This is a parameterized hello world for ");
                String _simpleName_1 = GrammarUtil.getSimpleName(TemplateProjectWizardFragment.this.getGrammar());
                _builder.append(_simpleName_1);
                _builder.append(". You can set a parameter to modify the content in the generated file");
                _builder.newLineIfNotEmpty();
                _builder.append("and a parameter to set the package the file is created in.</p>\")");
                _builder.newLine();
                _builder.append("final clreplaced HelloWorldProject {");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("val advanced = check(\"Advanced:\", false)");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("val advancedGroup = group(\"Properties\")");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("val name = combo(\"Name:\", #[\"Xtext\", \"World\", \"Foo\", \"Bar\"], \"The name to say \'Hello\' to\", advancedGroup)");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("val path = text(\"Package:\", \"mydsl\", \"The package path to place the files in\", advancedGroup)");
                _builder.newLine();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("override protected updateVariables() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("name.enabled = advanced.value");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("path.enabled = advanced.value");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("if (!advanced.value) {");
                _builder.newLine();
                _builder.append("\t\t\t");
                _builder.append("name.value = \"Xtext\"");
                _builder.newLine();
                _builder.append("\t\t\t");
                _builder.append("path.value = \"");
                String _get = TemplateProjectWizardFragment.this.getLanguage().getFileExtensions().get(0);
                _builder.append(_get, "\t\t\t");
                _builder.append("\"");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("override protected validate() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("if (path.value.matches(\'[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*\'))");
                _builder.newLine();
                _builder.append("\t\t\t");
                _builder.append("null");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("else");
                _builder.newLine();
                _builder.append("\t\t\t");
                _builder.append("new Status(ERROR, \"Wizard\", \"\'\" + path + \"\' is not a valid package name\")");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.newLine();
                {
                    if (TemplateProjectWizardFragment.this.pluginProject) {
                        _builder.append("\t");
                        _builder.append("override generateProjects(IProjectGenerator generator) {");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t");
                        _builder.append("generator.generate(new PluginProjectFactory => [");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("projectName = projectInfo.projectName");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("location = projectInfo.locationPath");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("projectNatures += #[JavaCore.NATURE_ID, \"org.eclipse.pde.PluginNature\", XtextProjectHelper.NATURE_ID]");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("builderIds += #[JavaCore.BUILDER_ID, XtextProjectHelper.BUILDER_ID]");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("folders += \"src\"");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("addFile(");
                        _builder.append(quotes, "\t\t\t");
                        _builder.append("src/");
                        _builder.append(openVar, "\t\t\t");
                        _builder.append("path");
                        _builder.append(closeVar, "\t\t\t");
                        _builder.append("/Model.");
                        String _get_1 = TemplateProjectWizardFragment.this.getLanguage().getFileExtensions().get(0);
                        _builder.append(_get_1, "\t\t\t");
                        _builder.append(quotes, "\t\t\t");
                        _builder.append(", ");
                        _builder.append(quotes, "\t\t\t");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t\t\t");
                        _builder.append("/*");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t\t ");
                        _builder.append("* This is an example model");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t\t ");
                        _builder.append("*/");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t\t");
                        _builder.append("Hello ");
                        _builder.append(openVar, "\t\t\t\t");
                        _builder.append("name");
                        _builder.append(closeVar, "\t\t\t\t");
                        _builder.append("!");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append(quotes, "\t\t\t");
                        _builder.append(")");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t");
                        _builder.append("])");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("}");
                        _builder.newLine();
                    } else {
                        _builder.append("\t");
                        _builder.append("override generateProjects(IProjectGenerator generator) {");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t");
                        _builder.append("generator.generate(new ProjectFactory => [");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("projectName = projectInfo.projectName");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("location = projectInfo.locationPath");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("projectNatures += XtextProjectHelper.NATURE_ID");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("builderIds += XtextProjectHelper.BUILDER_ID");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append("addFile(");
                        _builder.append(quotes, "\t\t\t");
                        _builder.append("src/");
                        _builder.append(openVar, "\t\t\t");
                        _builder.append("path");
                        _builder.append(closeVar, "\t\t\t");
                        _builder.append("/Model.");
                        String _get_2 = TemplateProjectWizardFragment.this.getLanguage().getFileExtensions().get(0);
                        _builder.append(_get_2, "\t\t\t");
                        _builder.append(quotes, "\t\t\t");
                        _builder.append(", ");
                        _builder.append(quotes, "\t\t\t");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t\t\t");
                        _builder.append("/*");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t\t ");
                        _builder.append("* This is an example model");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t\t ");
                        _builder.append("*/");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("\t\t\t");
                        _builder.append("Hello ");
                        _builder.append(openVar, "\t\t\t\t");
                        _builder.append("name");
                        _builder.append(closeVar, "\t\t\t\t");
                        _builder.append("!");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t\t");
                        _builder.append(quotes, "\t\t\t");
                        _builder.append(")");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t");
                        _builder.append("])");
                        _builder.newLine();
                        _builder.append("\t");
                        _builder.append("}");
                        _builder.newLine();
                    }
                }
                _builder.append("}");
                _builder.newLine();
            }
        };
        file.setContent(_client);
        file.writeTo(this.getProjectConfig().getEclipsePlugin().getSrc());
    }

    public void generateDefaultIcons() {
        final BinaryFileAccess projectTemplate = this.fileAccessFactory.createBinaryFile("project_template.png");
        boolean _existIn = projectTemplate.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
        boolean _not = (!_existIn);
        if (_not) {
            projectTemplate.setContent(this.readBinaryFileFromPackage("project_template.png"));
            projectTemplate.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
        }
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus = ("new_" + _simpleName);
        String _plus_1 = (_plus + "_proj.gif");
        final BinaryFileAccess newProject = this.fileAccessFactory.createBinaryFile(_plus_1);
        boolean _existIn_1 = newProject.existIn(this.getProjectConfig().getEclipsePlugin().getIcons());
        boolean _not_1 = (!_existIn_1);
        if (_not_1) {
            newProject.setContent(this.readBinaryFileFromPackage("new_xproj.gif"));
            newProject.writeTo(this.getProjectConfig().getEclipsePlugin().getIcons());
        }
    }

    private byte[] readBinaryFileFromPackage(final String fileName) {
        try {
            final InputStream stream = TemplateProjectWizardFragment.clreplaced.getResourcereplacedtream(fileName);
            try {
                return ByteStreams.toByteArray(stream);
            } finally {
                stream.close();
            }
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    protected String getProjectTemplateProviderClreplacedName() {
        String _projectWizardPackage = this.getProjectWizardPackage();
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus = (_projectWizardPackage + _simpleName);
        return (_plus + "ProjectTemplateProvider");
    }

    protected String getProjectWizardClreplacedName() {
        String _projectWizardPackage = this.getProjectWizardPackage();
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus = (_projectWizardPackage + _simpleName);
        return (_plus + "NewProjectWizard");
    }

    protected String getProjectWizardPackage() {
        String _eclipsePluginBasePackage = this._xtextGeneratorNaming.getEclipsePluginBasePackage(this.getGrammar());
        return (_eclipsePluginBasePackage + ".wizard.");
    }

    /**
     * Generate the wizard. Set to 'false' by default. Change to 'true' to generate the wizard.
     */
    public boolean setGenerate(final boolean value) {
        return this.generate = value;
    }

    /**
     * Generate a new project wizard toolbar button. Set to 'false' by default. Change to 'true' to add the new project wizard button to the toolbar.
     *
     * @since 2.20
     */
    public boolean setGenerateToolbarButton(final boolean value) {
        return this.generateToolbarButton = value;
    }

    /**
     * Generate the projects as eclipse plugins. Affects only the example content of the templates. Can be changed
     * manually afterwards.
     */
    public boolean setPluginProject(final boolean value) {
        return this.pluginProject = value;
    }

    @Pure
    public boolean isGenerate() {
        return this.generate;
    }

    @Pure
    public boolean isGenerateToolbarButton() {
        return this.generateToolbarButton;
    }

    @Pure
    public boolean isPluginProject() {
        return this.pluginProject;
    }
}

17 View Complete Implementation : QuickfixProviderFragment2.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Contributes the Quickfix provider stub, either in Xtend or Java language.
 *
 * @author Christian Schneider - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced QuickfixProviderFragment2 extends AbstractInheritingFragment {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    @Inject
    @Extension
    private ValidatorNaming _validatorNaming;

    @Inject
    private FileAccessFactory fileAccessFactory;

    protected TypeReference getQuickfixProviderClreplaced(final Grammar g) {
        String _eclipsePluginBasePackage = this._xtextGeneratorNaming.getEclipsePluginBasePackage(g);
        String _plus = (_eclipsePluginBasePackage + ".quickfix.");
        String _simpleName = GrammarUtil.getSimpleName(g);
        String _plus_1 = (_plus + _simpleName);
        String _plus_2 = (_plus_1 + "QuickfixProvider");
        return new TypeReference(_plus_2);
    }

    protected TypeReference getQuickfixProviderSuperClreplaced(final Grammar g) {
        TypeReference _xblockexpression = null;
        {
            final Grammar superGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g);
            TypeReference _xifexpression = null;
            if ((this.isInheritImplementation() && (superGrammar != null))) {
                _xifexpression = this.getQuickfixProviderClreplaced(superGrammar);
            } else {
                _xifexpression = this.getDefaultQuickfixProviderSuperClreplaced();
            }
            _xblockexpression = _xifexpression;
        }
        return _xblockexpression;
    }

    /**
     * Extra getter facilitates customization by overriding.
     */
    protected TypeReference getDefaultQuickfixProviderSuperClreplaced() {
        return new TypeReference("org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider");
    }

    @Override
    public void generate() {
        GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
        TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider");
        _bindingFactory.addTypeToType(_typeReference, this.getQuickfixProviderClreplaced(this.getGrammar())).contributeTo(this.getLanguage().getEclipsePluginGenModule());
        boolean _isGenerateStub = this.isGenerateStub();
        if (_isGenerateStub) {
            IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
            IXtextGeneratorFileSystemAccess _src = null;
            if (_eclipsePlugin != null) {
                _src = _eclipsePlugin.getSrc();
            }
            boolean _tripleNotEquals = (_src != null);
            if (_tripleNotEquals) {
                boolean _isGenerateXtendStub = this.isGenerateXtendStub();
                if (_isGenerateXtendStub) {
                    this.generateXtendQuickfixProvider();
                } else {
                    this.generateJavaQuickfixProvider();
                }
            }
            ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
            boolean _tripleNotEquals_1 = (_manifest != null);
            if (_tripleNotEquals_1) {
                Set<String> _exportedPackages = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
                String _packageName = this.getQuickfixProviderClreplaced(this.getGrammar()).getPackageName();
                _exportedPackages.add(_packageName);
            }
            PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
            boolean _tripleNotEquals_2 = (_pluginXml != null);
            if (_tripleNotEquals_2) {
                this.addRegistrationToPluginXml();
            }
        } else {
            IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
            IXtextGeneratorFileSystemAccess _srcGen = null;
            if (_eclipsePlugin_1 != null) {
                _srcGen = _eclipsePlugin_1.getSrcGen();
            }
            boolean _tripleNotEquals_3 = (_srcGen != null);
            if (_tripleNotEquals_3) {
                this.generateGenQuickfixProvider();
            }
            ManifestAccess _manifest_1 = this.getProjectConfig().getEclipsePlugin().getManifest();
            boolean _tripleNotEquals_4 = (_manifest_1 != null);
            if (_tripleNotEquals_4) {
                Set<String> _exportedPackages_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
                String _packageName_1 = this.getQuickfixProviderClreplaced(this.getGrammar()).getPackageName();
                _exportedPackages_1.add(_packageName_1);
            }
        }
    }

    public void generateGenQuickfixProvider() {
        final TypeReference genClreplaced = this.getQuickfixProviderClreplaced(this.getGrammar());
        final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(genClreplaced);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("public clreplaced ");
                String _simpleName = genClreplaced.getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _quickfixProviderSuperClreplaced = QuickfixProviderFragment2.this.getQuickfixProviderSuperClreplaced(QuickfixProviderFragment2.this.getGrammar());
                _builder.append(_quickfixProviderSuperClreplaced);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
            }
        };
        file.setContent(_client);
        file.writeTo(this.getProjectConfig().getEclipsePlugin().getSrcGen());
    }

    protected void generateXtendQuickfixProvider() {
        TypeReference _quickfixProviderClreplaced = this.getQuickfixProviderClreplaced(this.getGrammar());
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("/**");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Custom quickfixes.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* See https://www.eclipse.org/Xtext/doreplacedentation/310_eclipse_support.html#quick-fixes");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("clreplaced ");
                String _simpleName = QuickfixProviderFragment2.this.getQuickfixProviderClreplaced(QuickfixProviderFragment2.this.getGrammar()).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _quickfixProviderSuperClreplaced = QuickfixProviderFragment2.this.getQuickfixProviderSuperClreplaced(QuickfixProviderFragment2.this.getGrammar());
                _builder.append(_quickfixProviderSuperClreplaced);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                _builder.append("//\t@Fix(");
                String _simpleName_1 = QuickfixProviderFragment2.this._validatorNaming.getValidatorClreplaced(QuickfixProviderFragment2.this.getGrammar()).getSimpleName();
                _builder.append(_simpleName_1);
                _builder.append(".INVALID_NAME)");
                _builder.newLineIfNotEmpty();
                _builder.append("//\tdef capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {");
                _builder.newLine();
                _builder.append("//\t\tacceptor.accept(issue, \'Capitalize name\', \'Capitalize the name.\', \'upcase.png\') [");
                _builder.newLine();
                _builder.append("//\t\t\tcontext |");
                _builder.newLine();
                _builder.append("//\t\t\tval xtextDoreplacedent = context.xtextDoreplacedent");
                _builder.newLine();
                _builder.append("//\t\t\tval firstLetter = xtextDoreplacedent.get(issue.offset, 1)");
                _builder.newLine();
                _builder.append("//\t\t\txtextDoreplacedent.replace(issue.offset, 1, firstLetter.toUpperCase)");
                _builder.newLine();
                _builder.append("//\t\t]");
                _builder.newLine();
                _builder.append("//\t}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        this.fileAccessFactory.createXtendFile(_quickfixProviderClreplaced, _client).writeTo(this.getProjectConfig().getEclipsePlugin().getSrc());
    }

    protected void generateJavaQuickfixProvider() {
        TypeReference _quickfixProviderClreplaced = this.getQuickfixProviderClreplaced(this.getGrammar());
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("/**");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Custom quickfixes.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* See https://www.eclipse.org/Xtext/doreplacedentation/310_eclipse_support.html#quick-fixes");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("public clreplaced ");
                String _simpleName = QuickfixProviderFragment2.this.getQuickfixProviderClreplaced(QuickfixProviderFragment2.this.getGrammar()).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _quickfixProviderSuperClreplaced = QuickfixProviderFragment2.this.getQuickfixProviderSuperClreplaced(QuickfixProviderFragment2.this.getGrammar());
                _builder.append(_quickfixProviderSuperClreplaced);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                _builder.append("//\t@Fix(");
                String _simpleName_1 = QuickfixProviderFragment2.this._validatorNaming.getValidatorClreplaced(QuickfixProviderFragment2.this.getGrammar()).getSimpleName();
                _builder.append(_simpleName_1);
                _builder.append(".INVALID_NAME)");
                _builder.newLineIfNotEmpty();
                _builder.append("//\tpublic void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {");
                _builder.newLine();
                _builder.append("//\t\tacceptor.accept(issue, \"Capitalize name\", \"Capitalize the name.\", \"upcase.png\", new IModification() {");
                _builder.newLine();
                _builder.append("//\t\t\tpublic void apply(IModificationContext context) throws BadLocationException {");
                _builder.newLine();
                _builder.append("//\t\t\t\tIXtextDoreplacedent xtextDoreplacedent = context.getXtextDoreplacedent();");
                _builder.newLine();
                _builder.append("//\t\t\t\tString firstLetter = xtextDoreplacedent.get(issue.getOffset(), 1);");
                _builder.newLine();
                _builder.append("//\t\t\t\txtextDoreplacedent.replace(issue.getOffset(), 1, firstLetter.toUpperCase());");
                _builder.newLine();
                _builder.append("//\t\t\t}");
                _builder.newLine();
                _builder.append("//\t\t});");
                _builder.newLine();
                _builder.append("//\t}");
                _builder.newLine();
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        this.fileAccessFactory.createJavaFile(_quickfixProviderClreplaced, _client).writeTo(this.getProjectConfig().getEclipsePlugin().getSrc());
    }

    protected boolean addRegistrationToPluginXml() {
        boolean _xblockexpression = false;
        {
            String _name = this.getProjectConfig().getEclipsePlugin().getName();
            String _plus = (_name + ".");
            String _lowerCase = GrammarUtil.getSimpleName(this.getGrammar()).toLowerCase();
            final String markerTypePrefix = (_plus + _lowerCase);
            final TypeReference executableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
            List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("<!-- quickfix marker resolution generator for ");
            String _name_1 = this.getGrammar().getName();
            _builder.append(_name_1);
            _builder.append(" -->");
            _builder.newLineIfNotEmpty();
            _builder.append("<extension");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("point=\"org.eclipse.ui.ide.markerResolution\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<markerResolutionGenerator");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            _builder.append(executableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("markerType=\"");
            _builder.append(markerTypePrefix, "\t\t");
            _builder.append(".check.fast\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<attribute");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("name=\"FIXABLE_KEY\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("value=\"true\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("</attribute>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</markerResolutionGenerator>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<markerResolutionGenerator");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            _builder.append(executableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("markerType=\"");
            _builder.append(markerTypePrefix, "\t\t");
            _builder.append(".check.normal\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<attribute");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("name=\"FIXABLE_KEY\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("value=\"true\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("</attribute>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</markerResolutionGenerator>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<markerResolutionGenerator");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("clreplaced=\"");
            _builder.append(executableExtensionFactory, "\t\t");
            _builder.append(":org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator\"");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("markerType=\"");
            _builder.append(markerTypePrefix, "\t\t");
            _builder.append(".check.expensive\">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("<attribute");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("name=\"FIXABLE_KEY\"");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("value=\"true\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("</attribute>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("</markerResolutionGenerator>");
            _builder.newLine();
            _builder.append("</extension>");
            _builder.newLine();
            _xblockexpression = _entries.add(_builder.toString());
        }
        return _xblockexpression;
    }
}

17 View Complete Implementation : XtypeGeneratorFragment2.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced XtypeGeneratorFragment2 extends AbstractXtextGeneratorFragment {

    @Inject
    @Extension
    private XbaseUsageDetector _xbaseUsageDetector;

    @Override
    public void generate() {
        if ((this._xbaseUsageDetector.inheritsXtype(this.getLanguage().getGrammar()) && (this.getProjectConfig().getEclipsePlugin().getManifest() != null))) {
            Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
            _requiredBundles.add("org.eclipse.xtext.xbase.ui");
        }
    }
}

17 View Complete Implementation : XsemanticsTypeSystemGen.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced XsemanticsTypeSystemGen extends XsemanticsRuntimeSystem {

    public final static String XEXPRESSIONTYPE = "org.eclipse.xsemantics.dsl.typing.XExpressionType";

    public final static String XVARIABLEDECLARATIONTYPE = "org.eclipse.xsemantics.dsl.typing.XVariableDeclarationType";

    public final static String EXPRESSIONINCONCLUSIONTYPE = "org.eclipse.xsemantics.dsl.typing.ExpressionInConclusionType";

    public final static String RULEPARAMETERTYPE = "org.eclipse.xsemantics.dsl.typing.RuleParameterType";

    public final static String INPUTPARAMETERTYPE = "org.eclipse.xsemantics.dsl.typing.InputParameterType";

    public final static String OUTPUTPARAMETERTYPE = "org.eclipse.xsemantics.dsl.typing.OutputParameterType";

    public final static String JVMFORMALPARAMETERTYPE = "org.eclipse.xsemantics.dsl.typing.JvmFormalParameterType";

    public final static String AUXILIARYDESCRIPTIONTYPE = "org.eclipse.xsemantics.dsl.typing.AuxiliaryDescriptionType";

    @Inject
    @Extension
    private TypeReferences typeReferences;

    @Inject
    private IBatchTypeResolver typeResolver;

    private PolymorphicDispatcher<Result<JvmTypeReference>> typeDispatcher;

    public XsemanticsTypeSystemGen() {
        init();
    }

    public void init() {
        typeDispatcher = buildPolymorphicDispatcher1("typeImpl", 3, "|-", ":");
    }

    public TypeReferences getTypeReferences() {
        return this.typeReferences;
    }

    public void setTypeReferences(final TypeReferences typeReferences) {
        this.typeReferences = typeReferences;
    }

    public IBatchTypeResolver getTypeResolver() {
        return this.typeResolver;
    }

    public void setTypeResolver(final IBatchTypeResolver typeResolver) {
        this.typeResolver = typeResolver;
    }

    public Result<JvmTypeReference> type(final EObject exp) {
        return type(new RuleEnvironment(), null, exp);
    }

    public Result<JvmTypeReference> type(final RuleEnvironment _environment_, final EObject exp) {
        return type(_environment_, null, exp);
    }

    public Result<JvmTypeReference> type(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EObject exp) {
        try {
            return typeInternal(_environment_, _trace_, exp);
        } catch (Exception _e_type) {
            return resultForFailure(_e_type);
        }
    }

    protected Result<JvmTypeReference> typeInternal(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EObject exp) {
        try {
            checkParamsNotNull(exp);
            return typeDispatcher.invoke(_environment_, _trace_, exp);
        } catch (Exception _e_type) {
            sneakyThrowRuleFailedException(_e_type);
            return null;
        }
    }

    protected void typeThrowException(final String _error, final String _issue, final Exception _ex, final EObject exp, final ErrorInformation[] _errorInformations) throws RuleFailedException {
        throwRuleFailedException(_error, _issue, _ex, _errorInformations);
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final XExpression e) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleXExpressionType(G, _subtrace_, e);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("XExpressionType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleXExpressionType) {
            typeThrowException(ruleName("XExpressionType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "JvmTypeReference", XEXPRESSIONTYPE, e_applyRuleXExpressionType, e, new ErrorInformation[] { new ErrorInformation(e) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleXExpressionType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final XExpression e) throws RuleFailedException {
        return new Result<JvmTypeReference>(_applyRuleXExpressionType_1(G, e));
    }

    private JvmTypeReference _applyRuleXExpressionType_1(final RuleEnvironment G, final XExpression e) throws RuleFailedException {
        IResolvedTypes _resolveTypes = this.typeResolver.resolveTypes(e);
        LightweightTypeReference _actualType = _resolveTypes.getActualType(e);
        JvmTypeReference _typeReference = null;
        if (_actualType != null) {
            _typeReference = _actualType.toTypeReference();
        }
        return _typeReference;
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final XVariableDeclaration e) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleXVariableDeclarationType(G, _subtrace_, e);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("XVariableDeclarationType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleXVariableDeclarationType) {
            typeThrowException(ruleName("XVariableDeclarationType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "JvmTypeReference", XVARIABLEDECLARATIONTYPE, e_applyRuleXVariableDeclarationType, e, new ErrorInformation[] { new ErrorInformation(e) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleXVariableDeclarationType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final XVariableDeclaration e) throws RuleFailedException {
        return new Result<JvmTypeReference>(_applyRuleXVariableDeclarationType_1(G, e));
    }

    private JvmTypeReference _applyRuleXVariableDeclarationType_1(final RuleEnvironment G, final XVariableDeclaration e) throws RuleFailedException {
        JvmTypeReference _type = e.getType();
        return _type;
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ExpressionInConclusion e) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleExpressionInConclusionType(G, _subtrace_, e);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("ExpressionInConclusionType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleExpressionInConclusionType) {
            typeThrowException(ruleName("ExpressionInConclusionType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "JvmTypeReference", EXPRESSIONINCONCLUSIONTYPE, e_applyRuleExpressionInConclusionType, e, new ErrorInformation[] { new ErrorInformation(e) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleExpressionInConclusionType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ExpressionInConclusion e) throws RuleFailedException {
        // output parameter
        JvmTypeReference type = null;
        /* G |- e.expression : type */
        XExpression _expression = e.getExpression();
        Result<JvmTypeReference> result = typeInternal(G, _trace_, _expression);
        checkreplacedignableTo(result.getFirst(), JvmTypeReference.clreplaced);
        type = (JvmTypeReference) result.getFirst();
        return new Result<JvmTypeReference>(type);
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final RuleParameter p) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleRuleParameterType(G, _subtrace_, p);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("RuleParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleRuleParameterType) {
            typeThrowException(ruleName("RuleParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + "JvmTypeReference", RULEPARAMETERTYPE, e_applyRuleRuleParameterType, p, new ErrorInformation[] { new ErrorInformation(p) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleRuleParameterType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final RuleParameter p) throws RuleFailedException {
        return new Result<JvmTypeReference>(_applyRuleRuleParameterType_1(G, p));
    }

    private JvmTypeReference _applyRuleRuleParameterType_1(final RuleEnvironment G, final RuleParameter p) throws RuleFailedException {
        JvmFormalParameter _parameter = p.getParameter();
        JvmTypeReference _parameterType = _parameter.getParameterType();
        return _parameterType;
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final InputParameter p) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleInputParameterType(G, _subtrace_, p);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("InputParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleInputParameterType) {
            typeThrowException(ruleName("InputParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + "JvmTypeReference", INPUTPARAMETERTYPE, e_applyRuleInputParameterType, p, new ErrorInformation[] { new ErrorInformation(p) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleInputParameterType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final InputParameter p) throws RuleFailedException {
        return new Result<JvmTypeReference>(_applyRuleInputParameterType_1(G, p));
    }

    private JvmTypeReference _applyRuleInputParameterType_1(final RuleEnvironment G, final InputParameter p) throws RuleFailedException {
        JvmFormalParameter _parameter = p.getParameter();
        JvmTypeReference _parameterType = _parameter.getParameterType();
        return _parameterType;
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final OutputParameter p) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleOutputParameterType(G, _subtrace_, p);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("OutputParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleOutputParameterType) {
            typeThrowException(ruleName("OutputParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + "JvmTypeReference", OUTPUTPARAMETERTYPE, e_applyRuleOutputParameterType, p, new ErrorInformation[] { new ErrorInformation(p) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleOutputParameterType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final OutputParameter p) throws RuleFailedException {
        return new Result<JvmTypeReference>(_applyRuleOutputParameterType_1(G, p));
    }

    private JvmTypeReference _applyRuleOutputParameterType_1(final RuleEnvironment G, final OutputParameter p) throws RuleFailedException {
        JvmTypeReference _jvmTypeReference = p.getJvmTypeReference();
        return _jvmTypeReference;
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final JvmFormalParameter p) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleJvmFormalParameterType(G, _subtrace_, p);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("JvmFormalParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleJvmFormalParameterType) {
            typeThrowException(ruleName("JvmFormalParameterType") + stringRepForEnv(G) + " |- " + stringRep(p) + " : " + "JvmTypeReference", JVMFORMALPARAMETERTYPE, e_applyRuleJvmFormalParameterType, p, new ErrorInformation[] { new ErrorInformation(p) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleJvmFormalParameterType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final JvmFormalParameter p) throws RuleFailedException {
        return new Result<JvmTypeReference>(_applyRuleJvmFormalParameterType_1(G, p));
    }

    private JvmTypeReference _applyRuleJvmFormalParameterType_1(final RuleEnvironment G, final JvmFormalParameter p) throws RuleFailedException {
        JvmTypeReference _parameterType = p.getParameterType();
        return _parameterType;
    }

    protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final AuxiliaryDescription aux) throws RuleFailedException {
        try {
            final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
            final Result<JvmTypeReference> _result_ = applyRuleAuxiliaryDescriptionType(G, _subtrace_, aux);
            addToTrace(_trace_, new Provider<Object>() {

                public Object get() {
                    return ruleName("AuxiliaryDescriptionType") + stringRepForEnv(G) + " |- " + stringRep(aux) + " : " + stringRep(_result_.getFirst());
                }
            });
            addreplacedubtrace(_trace_, _subtrace_);
            return _result_;
        } catch (Exception e_applyRuleAuxiliaryDescriptionType) {
            typeThrowException(ruleName("AuxiliaryDescriptionType") + stringRepForEnv(G) + " |- " + stringRep(aux) + " : " + "JvmTypeReference", AUXILIARYDESCRIPTIONTYPE, e_applyRuleAuxiliaryDescriptionType, aux, new ErrorInformation[] { new ErrorInformation(aux) });
            return null;
        }
    }

    protected Result<JvmTypeReference> applyRuleAuxiliaryDescriptionType(final RuleEnvironment G, final RuleApplicationTrace _trace_, final AuxiliaryDescription aux) throws RuleFailedException {
        // output parameter
        JvmTypeReference type = null;
        /* { aux.type != null type = aux.type } or type = getTypeForName(Boolean, aux) */
        try {
            JvmTypeReference _type = aux.getType();
            boolean _notEquals = (!Objects.equal(_type, null));
            /* aux.type != null */
            if (!_notEquals) {
                sneakyThrowRuleFailedException("aux.type != null");
            }
            JvmTypeReference _type_1 = aux.getType();
            type = _type_1;
        } catch (Exception e) {
            JvmTypeReference _typeForName = this.typeReferences.getTypeForName(Boolean.clreplaced, aux);
            type = _typeForName;
        }
        return new Result<JvmTypeReference>(type);
    }
}

17 View Complete Implementation : Layouter.java
Copyright Apache License 2.0
Author : JanKoehnlein
@SuppressWarnings("all")
public clreplaced Layouter {

    @Extension
    private KLayoutDataFactory _kLayoutDataFactory = KLayoutDataFactory.eINSTANCE;

    @Extension
    private KGraphFactory _kGraphFactory = KGraphFactory.eINSTANCE;

    private Map<LayoutType, AbstractLayoutProvider> layoutProviders = CollectionLiterals.<LayoutType, AbstractLayoutProvider>newHashMap();

    public Layouter() {
        LayoutParameters _layoutParameters = new LayoutParameters();
        this.getLayoutProvider(_layoutParameters);
    }

    public LazyCommand createLayoutCommand(final LayoutParameters parameters, final XDiagram diagram, final Duration duration) {
        return this.createLayoutCommand(parameters, diagram, duration, null);
    }

    public LazyCommand createLayoutCommand(final XDiagram diagram, final Duration duration) {
        return this.createLayoutCommand(diagram.getLayoutParameters(), diagram, duration, null);
    }

    public LazyCommand createLayoutCommand(final LayoutParameters parameters, final XDiagram diagram, final Duration duration, final XShape fixed) {
        final LazyCommand _function = new LazyCommand() {

            @Override
            protected AnimationCommand createDelegate() {
                final HashMap<Object, KGraphElement> cache = Layouter.this.calculateLayout(parameters, diagram);
                return Layouter.this.composeCommand(cache, duration, fixed, diagram);
            }
        };
        return _function;
    }

    public void layout(final LayoutParameters parameters, final XDiagram diagram, final XShape fixed) {
        final HashMap<Object, KGraphElement> cache = this.calculateLayout(parameters, diagram);
        this.applyLayout(cache, fixed, diagram);
    }

    protected HashMap<Object, KGraphElement> calculateLayout(final LayoutParameters parameters, final XDiagram diagram) {
        LayoutParameters _elvis = null;
        if (parameters != null) {
            _elvis = parameters;
        } else {
            LayoutParameters _layoutParameters = new LayoutParameters();
            _elvis = _layoutParameters;
        }
        final LayoutParameters theParameters = _elvis;
        final AbstractLayoutProvider provider = this.getLayoutProvider(theParameters);
        final HashMap<Object, KGraphElement> cache = CollectionLiterals.<Object, KGraphElement>newHashMap();
        diagram.layout();
        final KNode kRoot = this.toKRootNode(diagram, theParameters, cache);
        BasicProgressMonitor _basicProgressMonitor = new BasicProgressMonitor();
        provider.doLayout(kRoot, _basicProgressMonitor);
        return cache;
    }

    protected AbstractLayoutProvider getLayoutProvider(final LayoutParameters parameters) {
        AbstractLayoutProvider layoutProvider = this.layoutProviders.get(parameters.getType());
        boolean _equals = Objects.equal(layoutProvider, null);
        if (_equals) {
            GraphvizLayoutProvider _graphvizLayoutProvider = new GraphvizLayoutProvider();
            final Procedure1<GraphvizLayoutProvider> _function = (GraphvizLayoutProvider it) -> {
                it.initialize(parameters.getType().toString());
            };
            GraphvizLayoutProvider _doubleArrow = ObjectExtensions.<GraphvizLayoutProvider>operator_doubleArrow(_graphvizLayoutProvider, _function);
            layoutProvider = _doubleArrow;
            this.layoutProviders.put(parameters.getType(), layoutProvider);
        }
        return layoutProvider;
    }

    protected void applyLayout(final Map<Object, KGraphElement> map, final XShape fixed, final XDiagram diagram) {
        final Point2D delta = this.getDelta(map, fixed, diagram);
        Set<Map.Entry<Object, KGraphElement>> _entrySet = map.entrySet();
        for (final Map.Entry<Object, KGraphElement> entry : _entrySet) {
            {
                final Object xElement = entry.getKey();
                final KGraphElement kElement = entry.getValue();
                boolean _matched = false;
                if (xElement instanceof XNode) {
                    _matched = true;
                    ((XNode) xElement).setManuallyPlaced(false);
                    final KShapeLayout shapeLayout = IterableExtensions.<KShapeLayout>head(Iterables.<KShapeLayout>filter(kElement.getData(), KShapeLayout.clreplaced));
                    Point2D _xifexpression = null;
                    boolean _isTopLevel = this.isTopLevel(kElement);
                    if (_isTopLevel) {
                        _xifexpression = delta;
                    } else {
                        Point2D _xblockexpression = null;
                        {
                            EObject _eContainer = kElement.eContainer();
                            final KInsets insets = ((KNode) _eContainer).<KShapeLayout>getData(KShapeLayout.clreplaced).getInsets();
                            float _left = 0f;
                            if (insets != null) {
                                _left = insets.getLeft();
                            }
                            float _minus = (-_left);
                            float _top = 0f;
                            if (insets != null) {
                                _top = insets.getTop();
                            }
                            float _minus_1 = (-_top);
                            _xblockexpression = new Point2D(_minus, _minus_1);
                        }
                        _xifexpression = _xblockexpression;
                    }
                    final Point2D correction = _xifexpression;
                    float _xpos = shapeLayout.getXpos();
                    float _ypos = shapeLayout.getYpos();
                    Point2D _point2D = new Point2D(_xpos, _ypos);
                    final Point2D newPosition = Point2DExtensions.operator_minus(_point2D, correction);
                    final Point2D snappedPosition = diagram.getSnappedPosition(newPosition, ((XShape) xElement));
                    ((XNode) xElement).setLayoutX(snappedPosition.getX());
                    ((XNode) xElement).setLayoutY(snappedPosition.getY());
                }
                if (!_matched) {
                    if (xElement instanceof XConnection) {
                        _matched = true;
                        final Consumer<XConnectionLabel> _function = (XConnectionLabel it) -> {
                            it.place(true);
                        };
                        ((XConnection) xElement).getLabels().forEach(_function);
                        final KEdgeLayout edgeLayout = IterableExtensions.<KEdgeLayout>head(Iterables.<KEdgeLayout>filter(kElement.getData(), KEdgeLayout.clreplaced));
                        final Function1<KVector, Point2D> _function_1 = (KVector it) -> {
                            return new Point2D(it.x, it.y);
                        };
                        final List<Point2D> layoutPoints = ListExtensions.<KVector, Point2D>map(edgeLayout.createVectorChain(), _function_1);
                        XConnection.Kind _switchResult_1 = null;
                        XConnection.Kind _connectionKind = diagram.getLayoutParameters().getConnectionKind();
                        if (_connectionKind != null) {
                            switch(_connectionKind) {
                                case CUBIC_CURVE:
                                case QUAD_CURVE:
                                    XConnection.Kind _switchResult_2 = null;
                                    EdgeRouting _property = edgeLayout.<EdgeRouting>getProperty(LayoutOptions.EDGE_ROUTING);
                                    if (_property != null) {
                                        switch(_property) {
                                            case SPLINES:
                                                XConnection.Kind _xifexpression = null;
                                                int _size = layoutPoints.size();
                                                int _minus = (_size - 1);
                                                int _modulo = (_minus % 3);
                                                boolean _equals = (_modulo == 0);
                                                if (_equals) {
                                                    _xifexpression = XConnection.Kind.CUBIC_CURVE;
                                                } else {
                                                    XConnection.Kind _xifexpression_1 = null;
                                                    int _size_1 = layoutPoints.size();
                                                    int _minus_1 = (_size_1 - 1);
                                                    int _modulo_1 = (_minus_1 % 2);
                                                    boolean _equals_1 = (_modulo_1 == 0);
                                                    if (_equals_1) {
                                                        _xifexpression_1 = XConnection.Kind.QUAD_CURVE;
                                                    } else {
                                                        _xifexpression_1 = XConnection.Kind.POLYLINE;
                                                    }
                                                    _xifexpression = _xifexpression_1;
                                                }
                                                _switchResult_2 = _xifexpression;
                                                break;
                                            default:
                                                _switchResult_2 = XConnection.Kind.POLYLINE;
                                                break;
                                        }
                                    } else {
                                        _switchResult_2 = XConnection.Kind.POLYLINE;
                                    }
                                    _switchResult_1 = _switchResult_2;
                                    break;
                                default:
                                    _switchResult_1 = diagram.getLayoutParameters().getConnectionKind();
                                    break;
                            }
                        } else {
                            _switchResult_1 = diagram.getLayoutParameters().getConnectionKind();
                        }
                        final XConnection.Kind newKind = _switchResult_1;
                        boolean _equals_2 = Objects.equal(newKind, XConnection.Kind.POLYLINE);
                        if (_equals_2) {
                            this.removeDuplicates(layoutPoints);
                        }
                        ((XConnection) xElement).setKind(newKind);
                        int _size_2 = ((XConnection) xElement).getControlPoints().size();
                        int _size_3 = layoutPoints.size();
                        boolean _lessThan = (_size_2 < _size_3);
                        if (_lessThan) {
                            ((XConnection) xElement).getConnectionRouter().growToSize(layoutPoints.size());
                        } else {
                            ((XConnection) xElement).getConnectionRouter().shrinkToSize(layoutPoints.size());
                        }
                        ConnectionRouter _connectionRouter = ((XConnection) xElement).getConnectionRouter();
                        _connectionRouter.setSplineShapeKeeperEnabled(false);
                        final KNode kSource = ((KEdge) kElement).getSource();
                        Point2D _xifexpression_2 = null;
                        boolean _isTopLevel = this.isTopLevel(kSource);
                        if (_isTopLevel) {
                            _xifexpression_2 = delta;
                        } else {
                            Point2D _xblockexpression = null;
                            {
                                EObject _eContainer = kSource.eContainer();
                                final KInsets insets = ((KNode) _eContainer).<KShapeLayout>getData(KShapeLayout.clreplaced).getInsets();
                                double _x = delta.getX();
                                float _left = 0f;
                                if (insets != null) {
                                    _left = insets.getLeft();
                                }
                                double _minus_2 = (_x - _left);
                                double _y = delta.getY();
                                float _top = 0f;
                                if (insets != null) {
                                    _top = insets.getTop();
                                }
                                double _minus_3 = (_y - _top);
                                _xblockexpression = new Point2D(_minus_2, _minus_3);
                            }
                            _xifexpression_2 = _xblockexpression;
                        }
                        final Point2D correction = _xifexpression_2;
                        final Function1<Point2D, Point2D> _function_2 = (Point2D it) -> {
                            return Point2DExtensions.operator_minus(it, correction);
                        };
                        final List<Point2D> xLayoutPoints = ListExtensions.<Point2D, Point2D>map(IterableExtensions.<Point2D>toList(this.layoutPointsInRoot(layoutPoints, kSource)), _function_2);
                        int _size_4 = layoutPoints.size();
                        int _minus_2 = (_size_4 - 1);
                        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(1, _minus_2, true);
                        for (final Integer i : _doubleDotLessThan) {
                            {
                                final XControlPoint controlPoint = ((XConnection) xElement).getControlPoints().get((i).intValue());
                                final Point2D snappedPosition = diagram.getSnappedPosition(xLayoutPoints.get((i).intValue()), controlPoint);
                                controlPoint.setLayoutX(snappedPosition.getX());
                                controlPoint.setLayoutY(snappedPosition.getY());
                                controlPoint.setManuallyPlaced(false);
                            }
                        }
                    }
                }
            }
        }
    }

    protected void removeDuplicates(final List<Point2D> layoutPoints) {
        for (int i = (layoutPoints.size() - 2); (i > 0); i--) {
            boolean _areOnSameLine = Point2DExtensions.areOnSameLine(layoutPoints.get((i - 1)), layoutPoints.get(i), layoutPoints.get((i + 1)));
            if (_areOnSameLine) {
                layoutPoints.remove(i);
            }
        }
    }

    protected ParallelAnimationCommand composeCommand(final Map<Object, KGraphElement> map, final Duration duration, final XShape fixed, final XDiagram diagram) {
        final ParallelAnimationCommand composite = new ParallelAnimationCommand();
        final Point2D delta = this.getDelta(map, fixed, diagram);
        Set<Map.Entry<Object, KGraphElement>> _entrySet = map.entrySet();
        for (final Map.Entry<Object, KGraphElement> entry : _entrySet) {
            {
                final Object xElement = entry.getKey();
                final KGraphElement kElement = entry.getValue();
                boolean _matched = false;
                if (xElement instanceof XNode) {
                    _matched = true;
                    ((XNode) xElement).setManuallyPlaced(false);
                    final KShapeLayout shapeLayout = IterableExtensions.<KShapeLayout>head(Iterables.<KShapeLayout>filter(kElement.getData(), KShapeLayout.clreplaced));
                    Point2D _xifexpression = null;
                    boolean _isTopLevel = this.isTopLevel(kElement);
                    if (_isTopLevel) {
                        _xifexpression = delta;
                    } else {
                        Point2D _xblockexpression = null;
                        {
                            EObject _eContainer = kElement.eContainer();
                            final KInsets insets = ((KNode) _eContainer).<KShapeLayout>getData(KShapeLayout.clreplaced).getInsets();
                            float _left = 0f;
                            if (insets != null) {
                                _left = insets.getLeft();
                            }
                            float _minus = (-_left);
                            float _top = 0f;
                            if (insets != null) {
                                _top = insets.getTop();
                            }
                            float _minus_1 = (-_top);
                            _xblockexpression = new Point2D(_minus, _minus_1);
                        }
                        _xifexpression = _xblockexpression;
                    }
                    final Point2D correction = _xifexpression;
                    float _xpos = shapeLayout.getXpos();
                    float _ypos = shapeLayout.getYpos();
                    Point2D _point2D = new Point2D(_xpos, _ypos);
                    final Point2D newPosition = Point2DExtensions.operator_minus(_point2D, correction);
                    final Point2D snappedPosition = diagram.getSnappedPosition(newPosition, ((XShape) xElement));
                    double _x = snappedPosition.getX();
                    double _y = snappedPosition.getY();
                    MoveCommand _moveCommand = new MoveCommand(((XShape) xElement), _x, _y, true);
                    final Procedure1<MoveCommand> _function = (MoveCommand it) -> {
                        it.setExecuteDuration(duration);
                    };
                    MoveCommand _doubleArrow = ObjectExtensions.<MoveCommand>operator_doubleArrow(_moveCommand, _function);
                    composite.operator_add(_doubleArrow);
                }
                if (!_matched) {
                    if (xElement instanceof XConnection) {
                        _matched = true;
                        final Consumer<XConnectionLabel> _function = (XConnectionLabel it) -> {
                            it.place(true);
                        };
                        ((XConnection) xElement).getLabels().forEach(_function);
                        final KEdgeLayout edgeLayout = IterableExtensions.<KEdgeLayout>head(Iterables.<KEdgeLayout>filter(kElement.getData(), KEdgeLayout.clreplaced));
                        final Function1<KVector, Point2D> _function_1 = (KVector it) -> {
                            return new Point2D(it.x, it.y);
                        };
                        final List<Point2D> layoutPoints = ListExtensions.<KVector, Point2D>map(edgeLayout.createVectorChain(), _function_1);
                        XConnection.Kind _switchResult_1 = null;
                        XConnection.Kind _connectionKind = diagram.getLayoutParameters().getConnectionKind();
                        if (_connectionKind != null) {
                            switch(_connectionKind) {
                                case CUBIC_CURVE:
                                case QUAD_CURVE:
                                    XConnection.Kind _switchResult_2 = null;
                                    EdgeRouting _property = edgeLayout.<EdgeRouting>getProperty(LayoutOptions.EDGE_ROUTING);
                                    if (_property != null) {
                                        switch(_property) {
                                            case SPLINES:
                                                XConnection.Kind _xifexpression = null;
                                                int _size = layoutPoints.size();
                                                int _minus = (_size - 1);
                                                int _modulo = (_minus % 3);
                                                boolean _equals = (_modulo == 0);
                                                if (_equals) {
                                                    _xifexpression = XConnection.Kind.CUBIC_CURVE;
                                                } else {
                                                    XConnection.Kind _xifexpression_1 = null;
                                                    int _size_1 = layoutPoints.size();
                                                    int _minus_1 = (_size_1 - 1);
                                                    int _modulo_1 = (_minus_1 % 2);
                                                    boolean _equals_1 = (_modulo_1 == 0);
                                                    if (_equals_1) {
                                                        _xifexpression_1 = XConnection.Kind.QUAD_CURVE;
                                                    } else {
                                                        _xifexpression_1 = XConnection.Kind.POLYLINE;
                                                    }
                                                    _xifexpression = _xifexpression_1;
                                                }
                                                _switchResult_2 = _xifexpression;
                                                break;
                                            default:
                                                _switchResult_2 = XConnection.Kind.POLYLINE;
                                                break;
                                        }
                                    } else {
                                        _switchResult_2 = XConnection.Kind.POLYLINE;
                                    }
                                    _switchResult_1 = _switchResult_2;
                                    break;
                                default:
                                    _switchResult_1 = diagram.getLayoutParameters().getConnectionKind();
                                    break;
                            }
                        } else {
                            _switchResult_1 = diagram.getLayoutParameters().getConnectionKind();
                        }
                        final XConnection.Kind newKind = _switchResult_1;
                        boolean _equals_2 = Objects.equal(newKind, XConnection.Kind.POLYLINE);
                        if (_equals_2) {
                            this.removeDuplicates(layoutPoints);
                        }
                        ConnectionRouter _connectionRouter = ((XConnection) xElement).getConnectionRouter();
                        _connectionRouter.setSplineShapeKeeperEnabled(false);
                        final KNode kSource = ((KEdge) kElement).getSource();
                        Point2D _xifexpression_2 = null;
                        boolean _isTopLevel = this.isTopLevel(kSource);
                        if (_isTopLevel) {
                            _xifexpression_2 = delta;
                        } else {
                            Point2D _xblockexpression = null;
                            {
                                EObject _eContainer = kSource.eContainer();
                                final KInsets insets = ((KNode) _eContainer).<KShapeLayout>getData(KShapeLayout.clreplaced).getInsets();
                                double _x = delta.getX();
                                float _left = 0f;
                                if (insets != null) {
                                    _left = insets.getLeft();
                                }
                                double _minus_2 = (_x - _left);
                                double _y = delta.getY();
                                float _top = 0f;
                                if (insets != null) {
                                    _top = insets.getTop();
                                }
                                double _minus_3 = (_y - _top);
                                _xblockexpression = new Point2D(_minus_2, _minus_3);
                            }
                            _xifexpression_2 = _xblockexpression;
                        }
                        final Point2D correction = _xifexpression_2;
                        final Function1<Point2D, Point2D> _function_2 = (Point2D it) -> {
                            Point2D _minus_2 = Point2DExtensions.operator_minus(it, correction);
                            return diagram.getSnappedPosition(_minus_2);
                        };
                        final Function1<Point2D, XControlPoint> _function_3 = (Point2D p) -> {
                            XControlPoint _xControlPoint = new XControlPoint();
                            final Procedure1<XControlPoint> _function_4 = (XControlPoint it) -> {
                                it.setManuallyPlaced(false);
                                it.setLayoutX(p.getX());
                                it.setLayoutY(p.getY());
                            };
                            return ObjectExtensions.<XControlPoint>operator_doubleArrow(_xControlPoint, _function_4);
                        };
                        final List<XControlPoint> xLayoutPoints = ListExtensions.<Point2D, XControlPoint>map(ListExtensions.<Point2D, Point2D>map(IterableExtensions.<Point2D>toList(this.layoutPointsInRoot(layoutPoints, kSource)), _function_2), _function_3);
                        XControlPoint _head = IterableExtensions.<XControlPoint>head(xLayoutPoints);
                        if (_head != null) {
                            _head.setType(XControlPoint.Type.ANCHOR);
                        }
                        XControlPoint _last = IterableExtensions.<XControlPoint>last(xLayoutPoints);
                        if (_last != null) {
                            _last.setType(XControlPoint.Type.ANCHOR);
                        }
                        ConnectionRelayoutCommand _connectionRelayoutCommand = new ConnectionRelayoutCommand(((XConnection) xElement), newKind, xLayoutPoints);
                        final Procedure1<ConnectionRelayoutCommand> _function_4 = (ConnectionRelayoutCommand it) -> {
                            it.setExecuteDuration(duration);
                        };
                        ConnectionRelayoutCommand _doubleArrow = ObjectExtensions.<ConnectionRelayoutCommand>operator_doubleArrow(_connectionRelayoutCommand, _function_4);
                        composite.operator_add(_doubleArrow);
                    }
                }
            }
        }
        return composite;
    }

    protected boolean isTopLevel(final KGraphElement kElement) {
        boolean _switchResult = false;
        boolean _matched = false;
        if (kElement instanceof KNode) {
            _matched = true;
            EObject _eContainer = null;
            if (((KNode) kElement) != null) {
                _eContainer = ((KNode) kElement).eContainer();
            }
            EObject _eContainer_1 = null;
            if (_eContainer != null) {
                _eContainer_1 = _eContainer.eContainer();
            }
            _switchResult = Objects.equal(_eContainer_1, null);
        }
        if (!_matched) {
            if (kElement instanceof KEdge) {
                _matched = true;
                _switchResult = this.isTopLevel(((KEdge) kElement).getSource());
            }
        }
        if (!_matched) {
            _switchResult = false;
        }
        return _switchResult;
    }

    protected Iterable<Point2D> layoutPointsInRoot(final Iterable<Point2D> layoutPoints, final KNode refKNode) {
        Iterable<Point2D> _xblockexpression = null;
        {
            final EObject parentKNode = refKNode.eContainer();
            Iterable<Point2D> _xifexpression = null;
            if ((parentKNode instanceof KNode)) {
                Iterable<Point2D> _xblockexpression_1 = null;
                {
                    final KShapeLayout pos = IterableExtensions.<KShapeLayout>head(Iterables.<KShapeLayout>filter(((KNode) parentKNode).getData(), KShapeLayout.clreplaced));
                    final Function1<Point2D, Point2D> _function = (Point2D it) -> {
                        float _xpos = pos.getXpos();
                        double _x = it.getX();
                        double _plus = (_xpos + _x);
                        float _ypos = pos.getYpos();
                        double _y = it.getY();
                        double _plus_1 = (_ypos + _y);
                        return new Point2D(_plus, _plus_1);
                    };
                    _xblockexpression_1 = this.layoutPointsInRoot(IterableExtensions.<Point2D, Point2D>map(layoutPoints, _function), ((KNode) parentKNode));
                }
                _xifexpression = _xblockexpression_1;
            } else {
                _xifexpression = layoutPoints;
            }
            _xblockexpression = _xifexpression;
        }
        return _xblockexpression;
    }

    protected Point2D getDelta(final Map<Object, KGraphElement> map, final XShape xFixed, final XDiagram diagram) {
        boolean _equals = Objects.equal(xFixed, null);
        if (_equals) {
            final Function1<KNode, BoundingBox> _function = (KNode it) -> {
                BoundingBox _xblockexpression = null;
                {
                    final KShapeLayout layout = IterableExtensions.<KShapeLayout>head(Iterables.<KShapeLayout>filter(it.getData(), KShapeLayout.clreplaced));
                    float _xpos = layout.getXpos();
                    float _ypos = layout.getYpos();
                    float _width = layout.getWidth();
                    float _height = layout.getHeight();
                    _xblockexpression = new BoundingBox(_xpos, _ypos, _width, _height);
                }
                return _xblockexpression;
            };
            final Function2<BoundingBox, BoundingBox, BoundingBox> _function_1 = (BoundingBox $0, BoundingBox $1) -> {
                return BoundsExtensions.operator_plus($0, $1);
            };
            BoundingBox _reduce = IterableExtensions.<BoundingBox>reduce(IterableExtensions.<KNode, BoundingBox>map(Iterables.<KNode>filter(map.values(), KNode.clreplaced), _function), _function_1);
            Point2D _center = null;
            if (_reduce != null) {
                _center = BoundsExtensions.center(_reduce);
            }
            final Point2D newCenter = _center;
            boolean _notEquals = (!Objects.equal(newCenter, null));
            if (_notEquals) {
                final Scene scene = diagram.getScene();
                boolean _equals_1 = Objects.equal(scene, null);
                if (_equals_1) {
                    return newCenter;
                } else {
                    double _width = scene.getWidth();
                    double _multiply = (0.5 * _width);
                    double _height = scene.getHeight();
                    double _multiply_1 = (0.5 * _height);
                    final Point2D currentCenter = diagram.sceneToLocal(_multiply, _multiply_1);
                    return Point2DExtensions.operator_minus(newCenter, currentCenter);
                }
            }
        }
        final KGraphElement kFixed = map.get(xFixed);
        boolean _matched = false;
        if (kFixed instanceof KNode) {
            _matched = true;
            final KShapeLayout shapeLayout = IterableExtensions.<KShapeLayout>head(Iterables.<KShapeLayout>filter(((KNode) kFixed).getData(), KShapeLayout.clreplaced));
            float _xpos = shapeLayout.getXpos();
            double _minX = xFixed.getLayoutBounds().getMinX();
            double _minus = (_xpos - _minX);
            double _layoutX = xFixed.getLayoutX();
            double _minus_1 = (_minus - _layoutX);
            float _ypos = shapeLayout.getYpos();
            double _minY = xFixed.getLayoutBounds().getMinY();
            double _minus_2 = (_ypos - _minY);
            double _layoutY = xFixed.getLayoutY();
            double _minus_3 = (_minus_2 - _layoutY);
            return new Point2D(_minus_1, _minus_3);
        }
        if (!_matched) {
            if (kFixed instanceof KEdge) {
                _matched = true;
                final KEdgeLayout edgeLayout = IterableExtensions.<KEdgeLayout>head(Iterables.<KEdgeLayout>filter(((KEdge) kFixed).getData(), KEdgeLayout.clreplaced));
                final Function1<KVector, BoundingBox> _function_2 = (KVector it) -> {
                    return new BoundingBox(it.x, it.y, 0, 0);
                };
                final Function2<BoundingBox, BoundingBox, BoundingBox> _function_3 = (BoundingBox $0, BoundingBox $1) -> {
                    return BoundsExtensions.operator_plus($0, $1);
                };
                BoundingBox _reduce_1 = IterableExtensions.<BoundingBox>reduce(ListExtensions.<KVector, BoundingBox>map(edgeLayout.createVectorChain(), _function_2), _function_3);
                Point2D _center_1 = null;
                if (_reduce_1 != null) {
                    _center_1 = BoundsExtensions.center(_reduce_1);
                }
                final Point2D edgeCenter = _center_1;
                boolean _notEquals_1 = (!Objects.equal(edgeCenter, null));
                if (_notEquals_1) {
                    return edgeCenter;
                }
            }
        }
        return new Point2D(0, 0);
    }

    protected KNode toKRootNode(final XDiagram it, final LayoutParameters parameters, final Map<Object, KGraphElement> cache) {
        KNode _xblockexpression = null;
        {
            final KNode kRoot = this._kGraphFactory.createKNode();
            final KShapeLayout shapeLayout = this._kLayoutDataFactory.createKShapeLayout();
            shapeLayout.setInsets(this._kLayoutDataFactory.createKInsets());
            shapeLayout.<Boolean>setProperty(LayoutOptions.LAYOUT_HIERARCHY, Boolean.valueOf(true));
            EdgeRouting _switchResult = null;
            XConnection.Kind _connectionKind = parameters.getConnectionKind();
            if (_connectionKind != null) {
                switch(_connectionKind) {
                    case CUBIC_CURVE:
                    case QUAD_CURVE:
                        _switchResult = EdgeRouting.SPLINES;
                        break;
                    case RECTILINEAR:
                        _switchResult = EdgeRouting.ORTHOGONAL;
                        break;
                    default:
                        _switchResult = EdgeRouting.POLYLINE;
                        break;
                }
            } else {
                _switchResult = EdgeRouting.POLYLINE;
            }
            final EdgeRouting edgeRouting = _switchResult;
            shapeLayout.<EdgeRouting>setProperty(LayoutOptions.EDGE_ROUTING, edgeRouting);
            EList<KGraphData> _data = kRoot.getData();
            _data.add(shapeLayout);
            cache.put(it, kRoot);
            final Consumer<XNode> _function = (XNode it_1) -> {
                EList<KNode> _children = kRoot.getChildren();
                KNode _kNode = this.toKNode(it_1, parameters, cache);
                _children.add(_kNode);
            };
            it.getNodes().forEach(_function);
            double spacing = Math.max(Math.max(60.0, this.transformConnections(it.getConnections(), parameters, cache)), this.transformNestedConnections(it.getNodes(), parameters, cache));
            shapeLayout.<Float>setProperty(LayoutOptions.SPACING, Float.valueOf(((float) spacing)));
            _xblockexpression = kRoot;
        }
        return _xblockexpression;
    }

    protected double transformConnections(final Iterable<XConnection> connections, final LayoutParameters parameters, final Map<Object, KGraphElement> cache) {
        double _xblockexpression = (double) 0;
        {
            double spacing = 0.0;
            for (final XConnection it : connections) {
                {
                    this.toKEdge(it, parameters, cache);
                    double minLength = 0.0;
                    ObservableList<XConnectionLabel> _labels = it.getLabels();
                    for (final XConnectionLabel label : _labels) {
                        double _minLength = minLength;
                        double _width = label.getBoundsInLocal().getWidth();
                        minLength = (_minLength + _width);
                    }
                    ArrowHead _sourceArrowHead = it.getSourceArrowHead();
                    boolean _notEquals = (!Objects.equal(_sourceArrowHead, null));
                    if (_notEquals) {
                        double _minLength_1 = minLength;
                        double _width_1 = it.getSourceArrowHead().getWidth();
                        minLength = (_minLength_1 + _width_1);
                    }
                    ArrowHead _targetArrowHead = it.getTargetArrowHead();
                    boolean _notEquals_1 = (!Objects.equal(_targetArrowHead, null));
                    if (_notEquals_1) {
                        double _minLength_2 = minLength;
                        double _width_2 = it.getTargetArrowHead().getWidth();
                        minLength = (_minLength_2 + _width_2);
                    }
                    spacing = Math.max(spacing, minLength);
                }
            }
            _xblockexpression = spacing;
        }
        return _xblockexpression;
    }

    protected double transformNestedConnections(final Iterable<XNode> nodes, final LayoutParameters parameters, final Map<Object, KGraphElement> cache) {
        final Function1<XDiagramContainer, Boolean> _function = (XDiagramContainer it) -> {
            return Boolean.valueOf(it.isInnerDiagramActive());
        };
        final Function1<XDiagramContainer, Double> _function_1 = (XDiagramContainer it) -> {
            return Double.valueOf(Math.max(this.transformConnections(it.getInnerDiagram().getConnections(), parameters, cache), this.transformNestedConnections(it.getInnerDiagram().getNodes(), parameters, cache)));
        };
        final Function2<Double, Double, Double> _function_2 = (Double $0, Double $1) -> {
            return Double.valueOf(Math.max(($0).doubleValue(), ($1).doubleValue()));
        };
        return (double) IterableExtensions.<Double, Double>fold(IterableExtensions.<XDiagramContainer, Double>map(IterableExtensions.<XDiagramContainer>filter(Iterables.<XDiagramContainer>filter(nodes, XDiagramContainer.clreplaced), _function), _function_1), Double.valueOf(0.0), _function_2);
    }

    protected KNode toKNode(final XNode xNode, final LayoutParameters parameters, final Map<Object, KGraphElement> cache) {
        KNode _xblockexpression = null;
        {
            final KNode kNode = this._kGraphFactory.createKNode();
            final KShapeLayout shapeLayout = this._kLayoutDataFactory.createKShapeLayout();
            final Dimension2D autoLayoutDimension = xNode.getAutoLayoutDimension();
            double _width = autoLayoutDimension.getWidth();
            double _height = autoLayoutDimension.getHeight();
            shapeLayout.setSize(((float) _width), ((float) _height));
            EList<KGraphData> _data = kNode.getData();
            _data.add(shapeLayout);
            cache.put(xNode, kNode);
            if ((xNode instanceof XDiagramContainer)) {
                boolean _isInnerDiagramActive = ((XDiagramContainer) xNode).isInnerDiagramActive();
                if (_isInnerDiagramActive) {
                    KInsets _createKInsets = this._kLayoutDataFactory.createKInsets();
                    final Procedure1<KInsets> _function = (KInsets it) -> {
                        Insets _insets = ((XDiagramContainer) xNode).getInsets();
                        double _left = 0.0;
                        if (_insets != null) {
                            _left = _insets.getLeft();
                        }
                        it.setLeft(((float) _left));
                        it.setRight(0);
                        Insets _insets_1 = ((XDiagramContainer) xNode).getInsets();
                        double _top = 0.0;
                        if (_insets_1 != null) {
                            _top = _insets_1.getTop();
                        }
                        it.setTop(((float) _top));
                        it.setBottom(0);
                    };
                    KInsets _doubleArrow = ObjectExtensions.<KInsets>operator_doubleArrow(_createKInsets, _function);
                    shapeLayout.setInsets(_doubleArrow);
                    final Consumer<XNode> _function_1 = (XNode it) -> {
                        EList<KNode> _children = kNode.getChildren();
                        KNode _kNode = this.toKNode(it, parameters, cache);
                        _children.add(_kNode);
                    };
                    ((XDiagramContainer) xNode).getInnerDiagram().getNodes().forEach(_function_1);
                }
            }
            _xblockexpression = kNode;
        }
        return _xblockexpression;
    }

    protected KEdge toKEdge(final XConnection it, final LayoutParameters parameters, final Map<Object, KGraphElement> cache) {
        KEdge _xblockexpression = null;
        {
            final KGraphElement kSource = cache.get(it.getSource());
            final KGraphElement kTarget = cache.get(it.getTarget());
            KEdge _xifexpression = null;
            if (((kSource instanceof KNode) && (kTarget instanceof KNode))) {
                KEdge _xblockexpression_1 = null;
                {
                    final KEdge kEdge = this._kGraphFactory.createKEdge();
                    EList<KEdge> _outgoingEdges = ((KNode) kSource).getOutgoingEdges();
                    _outgoingEdges.add(kEdge);
                    EList<KEdge> _incomingEdges = ((KNode) kTarget).getIncomingEdges();
                    _incomingEdges.add(kEdge);
                    final KEdgeLayout edgeLayout = this._kLayoutDataFactory.createKEdgeLayout();
                    edgeLayout.setSourcePoint(this._kLayoutDataFactory.createKPoint());
                    edgeLayout.setTargetPoint(this._kLayoutDataFactory.createKPoint());
                    EList<KGraphData> _data = kEdge.getData();
                    _data.add(edgeLayout);
                    cache.put(it, kEdge);
                    _xblockexpression_1 = kEdge;
                }
                _xifexpression = _xblockexpression_1;
            } else {
                _xifexpression = null;
            }
            _xblockexpression = _xifexpression;
        }
        return _xblockexpression;
    }

    protected KLabel toKLabel(final XConnectionLabel it, final LayoutParameters parameters, final Map<Object, KGraphElement> cache) {
        KLabel _xblockexpression = null;
        {
            final KLabel kLabel = this._kGraphFactory.createKLabel();
            String _elvis = null;
            Text _text = null;
            if (it != null) {
                _text = it.getText();
            }
            String _text_1 = null;
            if (_text != null) {
                _text_1 = _text.getText();
            }
            if (_text_1 != null) {
                _elvis = _text_1;
            } else {
                _elvis = "";
            }
            kLabel.setText(_elvis);
            final KShapeLayout shapeLayout = this._kLayoutDataFactory.createKShapeLayout();
            double _width = it.getLayoutBounds().getWidth();
            double _height = it.getLayoutBounds().getHeight();
            shapeLayout.setSize(((float) _width), ((float) _height));
            shapeLayout.<Integer>setProperty(LayoutOptions.FONT_SIZE, Integer.valueOf(12));
            shapeLayout.<EdgeLabelPlacement>setProperty(LayoutOptions.EDGE_LABEL_PLACEMENT, EdgeLabelPlacement.CENTER);
            EList<KGraphData> _data = kLabel.getData();
            _data.add(shapeLayout);
            cache.put(it, kLabel);
            _xblockexpression = kLabel;
        }
        return _xblockexpression;
    }
}

17 View Complete Implementation : ValidatorNaming.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Separates the composition of the generated validator clreplacedes' names from
 *  the template of those clreplacedes (which may be specialized by clients),
 *  since the name is used in the template of the generated quickfix provider clreplacedes, too.
 *
 * @author Christian Schneider - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced ValidatorNaming {

    @Inject
    @Extension
    private XtextGeneratorNaming _xtextGeneratorNaming;

    public TypeReference getValidatorClreplaced(final Grammar grammar) {
        String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(grammar);
        String _plus = (_runtimeBasePackage + ".validation.");
        String _simpleName = GrammarUtil.getSimpleName(grammar);
        String _plus_1 = (_plus + _simpleName);
        String _plus_2 = (_plus_1 + "Validator");
        return new TypeReference(_plus_2);
    }

    protected TypeReference getAbstractValidatorClreplaced(final Grammar grammar) {
        String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(grammar);
        String _plus = (_runtimeBasePackage + ".validation.Abstract");
        String _simpleName = GrammarUtil.getSimpleName(grammar);
        String _plus_1 = (_plus + _simpleName);
        String _plus_2 = (_plus_1 + "Validator");
        return new TypeReference(_plus_2);
    }
}

17 View Complete Implementation : DocumentExtensions.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author kosyakov - Initial contribution and API
 * @since 2.11
 */
@Singleton
@SuppressWarnings("all")
public clreplaced DoreplacedentExtensions {

    @Inject
    @Extension
    private UriExtensions _uriExtensions;

    @Inject
    private ILocationInFileProvider locationInFileProvider;

    public Position newPosition(final Resource resource, final int offset) {
        if ((resource instanceof XtextResource)) {
            final ICompositeNode rootNode = ((XtextResource) resource).getParseResult().getRootNode();
            final LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(rootNode, offset);
            int _line = lineAndColumn.getLine();
            int _minus = (_line - 1);
            int _column = lineAndColumn.getColumn();
            int _minus_1 = (_column - 1);
            return new Position(_minus, _minus_1);
        }
        return null;
    }

    public Range newRange(final Resource resource, final int startOffset, final int endOffset) {
        final Position startPosition = this.newPosition(resource, startOffset);
        if ((startPosition == null)) {
            return null;
        }
        final Position endPosition = this.newPosition(resource, endOffset);
        if ((endPosition == null)) {
            return null;
        }
        return new Range(startPosition, endPosition);
    }

    public Range newRange(final Resource resource, final ITextRegion region) {
        if ((region == null)) {
            return null;
        }
        int _offset = region.getOffset();
        int _offset_1 = region.getOffset();
        int _length = region.getLength();
        int _plus = (_offset_1 + _length);
        return this.newRange(resource, _offset, _plus);
    }

    public Location newLocation(final Resource resource, final ITextRegion textRegion) {
        final Range range = this.newRange(resource, textRegion);
        if ((range == null)) {
            return null;
        }
        final String uri = this._uriExtensions.toUriString(resource.getURI());
        return new Location(uri, range);
    }

    public Location newLocation(final EObject object) {
        final Resource resource = object.eResource();
        final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(object);
        return this.newLocation(resource, textRegion);
    }

    /**
     * Returns with the {@link Location location} that represents the {@link ILocationInFileProvider#getFullTextRegion full text region}
     * of the argument.
     *
     * @since 2.16
     */
    public Location newFullLocation(final EObject object) {
        final Resource resource = object.eResource();
        final ITextRegion textRegion = this.locationInFileProvider.getFullTextRegion(object);
        return this.newLocation(resource, textRegion);
    }

    public Location newLocation(final EObject owner, final EStructuralFeature feature, final int indexInList) {
        final Resource resource = owner.eResource();
        final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(owner, feature, indexInList);
        return this.newLocation(resource, textRegion);
    }
}

17 View Complete Implementation : ChangeConverter2.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author koehnlein - Initial contribution and API
 * @since 2.18
 */
@SuppressWarnings("all")
public clreplaced ChangeConverter2 implements IAcceptor<IEmfResourceChange> {

    public static clreplaced Factory {

        @Inject
        protected IResourceServiceProvider.Registry registry;

        @Inject
        protected UriExtensions uriExtensions;

        /**
         * @since 2.18
         */
        public ChangeConverter2 create(final WorkspaceEdit edit, final ILanguageServerAccess access) {
            return new ChangeConverter2(this.registry, edit, access, this.uriExtensions);
        }
    }

    private final IResourceServiceProvider.Registry registry;

    @Extension
    private final UriExtensions uriExtensions;

    private final WorkspaceEdit edit;

    private final ILanguageServerAccess access;

    private final boolean useDoreplacedentChanges;

    protected ChangeConverter2(final IResourceServiceProvider.Registry registry, final WorkspaceEdit edit, final ILanguageServerAccess access, final UriExtensions uriExtensions) {
        this.registry = registry;
        this.uriExtensions = uriExtensions;
        this.edit = edit;
        this.access = access;
        InitializeParams _initializeParams = null;
        if (access != null) {
            _initializeParams = access.getInitializeParams();
        }
        ClientCapabilities _capabilities = null;
        if (_initializeParams != null) {
            _capabilities = _initializeParams.getCapabilities();
        }
        WorkspaceClientCapabilities _workspace = null;
        if (_capabilities != null) {
            _workspace = _capabilities.getWorkspace();
        }
        WorkspaceEditCapabilities _workspaceEdit = null;
        if (_workspace != null) {
            _workspaceEdit = _workspace.getWorkspaceEdit();
        }
        Boolean _doreplacedentChanges = null;
        if (_workspaceEdit != null) {
            _doreplacedentChanges = _workspaceEdit.getDoreplacedentChanges();
        }
        boolean _tripleEquals = (_doreplacedentChanges == Boolean.TRUE);
        this.useDoreplacedentChanges = _tripleEquals;
        if (this.useDoreplacedentChanges) {
            this.edit.setDoreplacedentChanges(CollectionLiterals.<Either<TextDoreplacedentEdit, ResourceOperation>>newArrayList());
        } else {
            this.edit.setChanges(CollectionLiterals.<String, List<TextEdit>>newLinkedHashMap());
        }
    }

    @Override
    public void accept(final IEmfResourceChange change) {
        this.handleReplacements(change);
    }

    protected void _handleReplacements(final IEmfResourceChange change) {
        try {
            final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            final String uri = this.uriExtensions.toUriString(change.getResource().getURI());
            change.getResource().save(outputStream, null);
            byte[] _byteArray = outputStream.toByteArray();
            String _charset = this.getCharset(change.getResource());
            final String newContent = new String(_byteArray, _charset);
            final Function<ILanguageServerAccess.Context, Object> _function = (ILanguageServerAccess.Context context) -> {
                Object _xblockexpression = null;
                {
                    final Doreplacedent doreplacedent = context.getDoreplacedent();
                    Position _position = doreplacedent.getPosition(0);
                    Position _position_1 = doreplacedent.getPosition(doreplacedent.getContents().length());
                    final Range range = new Range(_position, _position_1);
                    final TextEdit textEdit = new TextEdit(range, newContent);
                    _xblockexpression = this.addTextEdit(uri, doreplacedent, textEdit);
                }
                return _xblockexpression;
            };
            this.access.<Object>doRead(uri, _function).get();
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    protected String getCharset(final Resource resource) {
        String _xblockexpression = null;
        {
            final IEncodingProvider xtextEncodingProvider = this.registry.getResourceServiceProvider(resource.getURI()).<IEncodingProvider>get(IEncodingProvider.clreplaced);
            String _xifexpression = null;
            if ((xtextEncodingProvider != null)) {
                return xtextEncodingProvider.getEncoding(resource.getURI());
            } else {
                String _xifexpression_1 = null;
                if ((resource instanceof XMLResource)) {
                    _xifexpression_1 = ((XMLResource) resource).getEncoding();
                } else {
                    _xifexpression_1 = Charset.defaultCharset().toString();
                }
                _xifexpression = _xifexpression_1;
            }
            _xblockexpression = _xifexpression;
        }
        return _xblockexpression;
    }

    protected void _handleReplacements(final ITextDoreplacedentChange change) {
        try {
            int _size = change.getReplacements().size();
            boolean _greaterThan = (_size > 0);
            if (_greaterThan) {
                final String uri = this.uriExtensions.toUriString(change.getNewURI());
                final Function<ILanguageServerAccess.Context, Object> _function = (ILanguageServerAccess.Context context) -> {
                    Object _xblockexpression = null;
                    {
                        final Doreplacedent doreplacedent = context.getDoreplacedent();
                        final Function1<ITextReplacement, TextEdit> _function_1 = (ITextReplacement replacement) -> {
                            TextEdit _xblockexpression_1 = null;
                            {
                                final Position start = doreplacedent.getPosition(replacement.getOffset());
                                int _offset = replacement.getOffset();
                                int _length = replacement.getLength();
                                int _plus = (_offset + _length);
                                final Position end = doreplacedent.getPosition(_plus);
                                final Range range = new Range(start, end);
                                String _replacementText = replacement.getReplacementText();
                                _xblockexpression_1 = new TextEdit(range, _replacementText);
                            }
                            return _xblockexpression_1;
                        };
                        final List<TextEdit> textEdits = ListExtensions.<ITextReplacement, TextEdit>map(change.getReplacements(), _function_1);
                        _xblockexpression = this.addTextEdit(uri, doreplacedent, ((TextEdit[]) Conversions.unwrapArray(textEdits, TextEdit.clreplaced)));
                    }
                    return _xblockexpression;
                };
                this.access.<Object>doRead(uri, _function).get();
            }
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    protected Object addTextEdit(final String theUri, final Doreplacedent doreplacedent, final TextEdit... textEdits) {
        Object _xifexpression = null;
        if (this.useDoreplacedentChanges) {
            List<Either<TextDoreplacedentEdit, ResourceOperation>> _doreplacedentChanges = this.edit.getDoreplacedentChanges();
            TextDoreplacedentEdit _textDoreplacedentEdit = new TextDoreplacedentEdit();
            final Procedure1<TextDoreplacedentEdit> _function = (TextDoreplacedentEdit it) -> {
                VersionedTextDoreplacedentIdentifier _versionedTextDoreplacedentIdentifier = new VersionedTextDoreplacedentIdentifier();
                final Procedure1<VersionedTextDoreplacedentIdentifier> _function_1 = (VersionedTextDoreplacedentIdentifier it_1) -> {
                    it_1.setUri(theUri);
                    it_1.setVersion(doreplacedent.getVersion());
                };
                VersionedTextDoreplacedentIdentifier _doubleArrow = ObjectExtensions.<VersionedTextDoreplacedentIdentifier>operator_doubleArrow(_versionedTextDoreplacedentIdentifier, _function_1);
                it.setTextDoreplacedent(_doubleArrow);
                it.setEdits(((List<TextEdit>) Conversions.doWrapArray(textEdits)));
            };
            TextDoreplacedentEdit _doubleArrow = ObjectExtensions.<TextDoreplacedentEdit>operator_doubleArrow(_textDoreplacedentEdit, _function);
            Either<TextDoreplacedentEdit, ResourceOperation> _forLeft = Either.<TextDoreplacedentEdit, ResourceOperation>forLeft(_doubleArrow);
            _xifexpression = Boolean.valueOf(_doreplacedentChanges.add(_forLeft));
        } else {
            _xifexpression = this.edit.getChanges().put(theUri, ((List<TextEdit>) Conversions.doWrapArray(textEdits)));
        }
        return _xifexpression;
    }

    protected void handleReplacements(final IEmfResourceChange change) {
        if (change instanceof ITextDoreplacedentChange) {
            _handleReplacements((ITextDoreplacedentChange) change);
            return;
        } else if (change != null) {
            _handleReplacements(change);
            return;
        } else {
            throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(change).toString());
        }
    }
}

17 View Complete Implementation : SemanticHighlightingTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced SemanticHighlightingTest extends AbstractTestLangLanguageServerTest {

    @Inject
    @Extension
    private UriExtensions _uriExtensions;

    private List<List<String>> scopes;

    @Before
    public void before() {
        final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
            ClientCapabilities _clientCapabilities = new ClientCapabilities();
            final Procedure1<ClientCapabilities> _function_1 = (ClientCapabilities it_1) -> {
                TextDoreplacedentClientCapabilities _textDoreplacedentClientCapabilities = new TextDoreplacedentClientCapabilities();
                final Procedure1<TextDoreplacedentClientCapabilities> _function_2 = (TextDoreplacedentClientCapabilities it_2) -> {
                    SemanticHighlightingCapabilities _semanticHighlightingCapabilities = new SemanticHighlightingCapabilities();
                    final Procedure1<SemanticHighlightingCapabilities> _function_3 = (SemanticHighlightingCapabilities it_3) -> {
                        it_3.setSemanticHighlighting(Boolean.valueOf(true));
                    };
                    SemanticHighlightingCapabilities _doubleArrow = ObjectExtensions.<SemanticHighlightingCapabilities>operator_doubleArrow(_semanticHighlightingCapabilities, _function_3);
                    it_2.setSemanticHighlightingCapabilities(_doubleArrow);
                };
                TextDoreplacedentClientCapabilities _doubleArrow = ObjectExtensions.<TextDoreplacedentClientCapabilities>operator_doubleArrow(_textDoreplacedentClientCapabilities, _function_2);
                it_1.setTextDoreplacedent(_doubleArrow);
            };
            ClientCapabilities _doubleArrow = ObjectExtensions.<ClientCapabilities>operator_doubleArrow(_clientCapabilities, _function_1);
            it.setCapabilities(_doubleArrow);
        };
        this.scopes = this.initialize(_function).getCapabilities().getSemanticHighlighting().getScopes();
    }

    @Test
    public void testDidOpen() {
        Path _path = this.root.toPath();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("MyModel.");
        _builder.append(this.fileExtension);
        final File file = _path.resolve(_builder.toString()).toFile();
        final String uri = this._uriExtensions.toUriString(file.toURI());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A {");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("int a");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("op foo() {}");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("op foo(a: A): string {}");
        _builder_1.newLine();
        _builder_1.append("}");
        this.open(uri, _builder_1.toString());
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("0 : [5:1:[typeDeclaration]]");
        _builder_2.newLine();
        _builder_2.append("1 : [2:3:[primitiveType], 6:1:[identifier]]");
        _builder_2.newLine();
        _builder_2.append("2 : [5:3:[identifier]]");
        _builder_2.newLine();
        _builder_2.append("3 : [5:3:[identifier], 9:1:[parameterName], 12:1:[type], 16:6:[primitiveType]]");
        _builder_2.newLine();
        _builder_2.append("4 : []");
        this.replacedertInfos(uri, _builder_2.toString());
    }

    @Test
    public void testDidOpen_multiLine() {
        Path _path = this.root.toPath();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("MyModel.");
        _builder.append(this.fileExtension);
        final File file = _path.resolve(_builder.toString()).toFile();
        final String uri = this._uriExtensions.toUriString(file.toURI());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A {");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("op foo() { ");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.newLine();
        _builder_1.append("    ");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("}");
        this.open(uri, _builder_1.toString());
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("0 : [5:1:[typeDeclaration]]");
        _builder_2.newLine();
        _builder_2.append("1 : [5:3:[identifier], 12:1:[opBody]]");
        _builder_2.newLine();
        _builder_2.append("2 : [0:2:[opBody]]");
        _builder_2.newLine();
        _builder_2.append("3 : [0:4:[opBody]]");
        _builder_2.newLine();
        _builder_2.append("4 : [0:2:[opBody]]");
        _builder_2.newLine();
        _builder_2.append("5 : []");
        this.replacedertInfos(uri, _builder_2.toString());
    }

    @Test
    public void testChange() {
        Path _path = this.root.toPath();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("MyModel.");
        _builder.append(this.fileExtension);
        final File file = _path.resolve(_builder.toString()).toFile();
        final String fileUri = this._uriExtensions.toUriString(file.toURI());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type A {");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("int a");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("op foo() {}");
        _builder_1.newLine();
        _builder_1.append("  ");
        _builder_1.append("op foo(a: A): string {}");
        _builder_1.newLine();
        _builder_1.append("}");
        this.open(fileUri, _builder_1.toString());
        this.notifications.clear();
        DidChangeTextDoreplacedentParams _didChangeTextDoreplacedentParams = new DidChangeTextDoreplacedentParams();
        final Procedure1<DidChangeTextDoreplacedentParams> _function = (DidChangeTextDoreplacedentParams it) -> {
            VersionedTextDoreplacedentIdentifier _versionedTextDoreplacedentIdentifier = new VersionedTextDoreplacedentIdentifier();
            final Procedure1<VersionedTextDoreplacedentIdentifier> _function_1 = (VersionedTextDoreplacedentIdentifier it_1) -> {
                it_1.setUri(fileUri);
                it_1.setVersion(Integer.valueOf(2));
            };
            VersionedTextDoreplacedentIdentifier _doubleArrow = ObjectExtensions.<VersionedTextDoreplacedentIdentifier>operator_doubleArrow(_versionedTextDoreplacedentIdentifier, _function_1);
            it.setTextDoreplacedent(_doubleArrow);
            TextDoreplacedentContentChangeEvent _textDoreplacedentContentChangeEvent = new TextDoreplacedentContentChangeEvent();
            final Procedure1<TextDoreplacedentContentChangeEvent> _function_2 = (TextDoreplacedentContentChangeEvent it_1) -> {
                StringConcatenation _builder_2 = new StringConcatenation();
                _builder_2.append("type A {");
                _builder_2.newLine();
                _builder_2.append("  ");
                _builder_2.append("int a");
                _builder_2.newLine();
                _builder_2.append("  ");
                _builder_2.append("op foo(a: A): string {}");
                _builder_2.newLine();
                _builder_2.append("}");
                it_1.setText(_builder_2.toString());
                Position _position = new Position(0, 0);
                Position _position_1 = new Position(4, 1);
                Range _range = new Range(_position, _position_1);
                it_1.setRange(_range);
            };
            TextDoreplacedentContentChangeEvent _doubleArrow_1 = ObjectExtensions.<TextDoreplacedentContentChangeEvent>operator_doubleArrow(_textDoreplacedentContentChangeEvent, _function_2);
            it.setContentChanges(Collections.<TextDoreplacedentContentChangeEvent>unmodifiableList(CollectionLiterals.<TextDoreplacedentContentChangeEvent>newArrayList(_doubleArrow_1)));
        };
        DidChangeTextDoreplacedentParams _doubleArrow = ObjectExtensions.<DidChangeTextDoreplacedentParams>operator_doubleArrow(_didChangeTextDoreplacedentParams, _function);
        this.languageServer.didChange(_doubleArrow);
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("0 : [5:1:[typeDeclaration]]");
        _builder_2.newLine();
        _builder_2.append("1 : [2:3:[primitiveType], 6:1:[identifier]]");
        _builder_2.newLine();
        _builder_2.append("2 : [5:3:[identifier], 9:1:[parameterName], 12:1:[type], 16:6:[primitiveType]]");
        _builder_2.newLine();
        _builder_2.append("3 : []");
        this.replacedertInfos(fileUri, _builder_2.toString());
        this.notifications.clear();
        DidChangeTextDoreplacedentParams _didChangeTextDoreplacedentParams_1 = new DidChangeTextDoreplacedentParams();
        final Procedure1<DidChangeTextDoreplacedentParams> _function_1 = (DidChangeTextDoreplacedentParams it) -> {
            VersionedTextDoreplacedentIdentifier _versionedTextDoreplacedentIdentifier = new VersionedTextDoreplacedentIdentifier();
            final Procedure1<VersionedTextDoreplacedentIdentifier> _function_2 = (VersionedTextDoreplacedentIdentifier it_1) -> {
                it_1.setUri(fileUri);
                it_1.setVersion(Integer.valueOf(3));
            };
            VersionedTextDoreplacedentIdentifier _doubleArrow_1 = ObjectExtensions.<VersionedTextDoreplacedentIdentifier>operator_doubleArrow(_versionedTextDoreplacedentIdentifier, _function_2);
            it.setTextDoreplacedent(_doubleArrow_1);
            TextDoreplacedentContentChangeEvent _textDoreplacedentContentChangeEvent = new TextDoreplacedentContentChangeEvent();
            final Procedure1<TextDoreplacedentContentChangeEvent> _function_3 = (TextDoreplacedentContentChangeEvent it_1) -> {
                StringConcatenation _builder_3 = new StringConcatenation();
                _builder_3.append("type A {");
                _builder_3.newLine();
                _builder_3.append("  ");
                _builder_3.append("int a");
                _builder_3.newLine();
                _builder_3.append("}");
                it_1.setText(_builder_3.toString());
                Position _position = new Position(0, 0);
                Position _position_1 = new Position(3, 1);
                Range _range = new Range(_position, _position_1);
                it_1.setRange(_range);
            };
            TextDoreplacedentContentChangeEvent _doubleArrow_2 = ObjectExtensions.<TextDoreplacedentContentChangeEvent>operator_doubleArrow(_textDoreplacedentContentChangeEvent, _function_3);
            it.setContentChanges(Collections.<TextDoreplacedentContentChangeEvent>unmodifiableList(CollectionLiterals.<TextDoreplacedentContentChangeEvent>newArrayList(_doubleArrow_2)));
        };
        DidChangeTextDoreplacedentParams _doubleArrow_1 = ObjectExtensions.<DidChangeTextDoreplacedentParams>operator_doubleArrow(_didChangeTextDoreplacedentParams_1, _function_1);
        this.languageServer.didChange(_doubleArrow_1);
        StringConcatenation _builder_3 = new StringConcatenation();
        _builder_3.append("0 : [5:1:[typeDeclaration]]");
        _builder_3.newLine();
        _builder_3.append("1 : [2:3:[primitiveType], 6:1:[identifier]]");
        _builder_3.newLine();
        _builder_3.append("2 : []");
        this.replacedertInfos(fileUri, _builder_3.toString());
        this.notifications.clear();
        DidChangeTextDoreplacedentParams _didChangeTextDoreplacedentParams_2 = new DidChangeTextDoreplacedentParams();
        final Procedure1<DidChangeTextDoreplacedentParams> _function_2 = (DidChangeTextDoreplacedentParams it) -> {
            VersionedTextDoreplacedentIdentifier _versionedTextDoreplacedentIdentifier = new VersionedTextDoreplacedentIdentifier();
            final Procedure1<VersionedTextDoreplacedentIdentifier> _function_3 = (VersionedTextDoreplacedentIdentifier it_1) -> {
                it_1.setUri(fileUri);
                it_1.setVersion(Integer.valueOf(3));
            };
            VersionedTextDoreplacedentIdentifier _doubleArrow_2 = ObjectExtensions.<VersionedTextDoreplacedentIdentifier>operator_doubleArrow(_versionedTextDoreplacedentIdentifier, _function_3);
            it.setTextDoreplacedent(_doubleArrow_2);
            TextDoreplacedentContentChangeEvent _textDoreplacedentContentChangeEvent = new TextDoreplacedentContentChangeEvent();
            final Procedure1<TextDoreplacedentContentChangeEvent> _function_4 = (TextDoreplacedentContentChangeEvent it_1) -> {
                StringConcatenation _builder_4 = new StringConcatenation();
                _builder_4.append("type A {");
                _builder_4.newLine();
                _builder_4.append("  ");
                _builder_4.append("int a");
                _builder_4.newLine();
                _builder_4.append("  ");
                _builder_4.append("op foo() {}");
                _builder_4.newLine();
                _builder_4.append("  ");
                _builder_4.append("op foo(a: A): string {}");
                _builder_4.newLine();
                _builder_4.append("}");
                it_1.setText(_builder_4.toString());
                Position _position = new Position(0, 0);
                Position _position_1 = new Position(2, 1);
                Range _range = new Range(_position, _position_1);
                it_1.setRange(_range);
            };
            TextDoreplacedentContentChangeEvent _doubleArrow_3 = ObjectExtensions.<TextDoreplacedentContentChangeEvent>operator_doubleArrow(_textDoreplacedentContentChangeEvent, _function_4);
            it.setContentChanges(Collections.<TextDoreplacedentContentChangeEvent>unmodifiableList(CollectionLiterals.<TextDoreplacedentContentChangeEvent>newArrayList(_doubleArrow_3)));
        };
        DidChangeTextDoreplacedentParams _doubleArrow_2 = ObjectExtensions.<DidChangeTextDoreplacedentParams>operator_doubleArrow(_didChangeTextDoreplacedentParams_2, _function_2);
        this.languageServer.didChange(_doubleArrow_2);
        StringConcatenation _builder_4 = new StringConcatenation();
        _builder_4.append("0 : [5:1:[typeDeclaration]]");
        _builder_4.newLine();
        _builder_4.append("1 : [2:3:[primitiveType], 6:1:[identifier]]");
        _builder_4.newLine();
        _builder_4.append("2 : [5:3:[identifier]]");
        _builder_4.newLine();
        _builder_4.append("3 : [5:3:[identifier], 9:1:[parameterName], 12:1:[type], 16:6:[primitiveType]]");
        _builder_4.newLine();
        _builder_4.append("4 : []");
        this.replacedertInfos(fileUri, _builder_4.toString());
    }

    protected void replacedertInfos(final String uri, final String expected) {
        final Map<VersionedTextDoreplacedentIdentifier, List<SemanticHighlightingInformation>> params = this.getSemanticHighlightingParams();
        replacedert.replacedertEquals(1, params.size());
        final Function1<Map.Entry<VersionedTextDoreplacedentIdentifier, List<SemanticHighlightingInformation>>, Boolean> _function = (Map.Entry<VersionedTextDoreplacedentIdentifier, List<SemanticHighlightingInformation>> it) -> {
            String _uri = it.getKey().getUri();
            return Boolean.valueOf(Objects.equal(_uri, uri));
        };
        final Map.Entry<VersionedTextDoreplacedentIdentifier, List<SemanticHighlightingInformation>> entry = IterableExtensions.<Map.Entry<VersionedTextDoreplacedentIdentifier, List<SemanticHighlightingInformation>>>findFirst(params.entrySet(), _function);
        replacedert.replacedertNotNull(entry);
        final Comparator<SemanticHighlightingInformation> _function_1 = (SemanticHighlightingInformation left, SemanticHighlightingInformation right) -> {
            int _line = left.getLine();
            int _line_1 = right.getLine();
            return (_line - _line_1);
        };
        final Function1<SemanticHighlightingInformation, Pair<SemanticHighlightingInformation, List<List<String>>>> _function_2 = (SemanticHighlightingInformation it) -> {
            return Pair.<SemanticHighlightingInformation, List<List<String>>>of(it, this.scopes);
        };
        final Function1<Pair<SemanticHighlightingInformation, List<List<String>>>, String> _function_3 = (Pair<SemanticHighlightingInformation, List<List<String>>> it) -> {
            return this.toExpectation(it);
        };
        final String actual = IterableExtensions.join(ListExtensions.<Pair<SemanticHighlightingInformation, List<List<String>>>, String>map(ListExtensions.<SemanticHighlightingInformation, Pair<SemanticHighlightingInformation, List<List<String>>>>map(IterableExtensions.<SemanticHighlightingInformation>sortWith(entry.getValue(), _function_1), _function_2), _function_3), "\n");
        this.replacedertEquals(expected, actual);
    }
}

17 View Complete Implementation : WorkspaceManagerTest.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Sven Efftinge - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced WorkspaceManagerTest {

    @Test
    public void testDoRead() {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type Test {");
        _builder.newLine();
        _builder.append("    ");
        _builder.append("string foo");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final URI path = this.operator_mappedTo("MyType1.testlang", _builder);
        this.workspaceManger.doBuild(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(path)), CollectionLiterals.<URI>emptyList(), null);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type Test {");
        _builder_1.newLine();
        _builder_1.append("    ");
        _builder_1.append("Test foo");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        final String inMemContents = _builder_1.toString();
        this.workspaceManger.didOpen(path, Integer.valueOf(1), inMemContents).build(null);
        final Function2<Doreplacedent, XtextResource, String> _function = (Doreplacedent $0, XtextResource $1) -> {
            return $0.getContents();
        };
        replacedert.replacedertEquals(inMemContents, this.workspaceManger.<String>doRead(path, _function));
    }

    @Inject
    protected WorkspaceManager workspaceManger;

    @Inject
    @Extension
    protected UriExtensions uriExtensions;

    @Before
    public void setup() {
        try {
            ServerModule _serverModule = new ServerModule();
            final Injector injector = Guice.createInjector(_serverModule);
            injector.injectMembers(this);
            File _file = new File("./test-data/test-project");
            this.root = _file;
            boolean _mkdirs = this.root.mkdirs();
            boolean _not = (!_mkdirs);
            if (_not) {
                Files.cleanFolder(this.root, null, true, false);
            }
            this.root.deleteOnExit();
            final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> {
                this.diagnostics.put($0, IterableExtensions.<Issue>toList($1));
            };
            this.workspaceManger.initialize(this.uriExtensions.withEmptyAuthority(URI.createFileURI(this.root.getAbsolutePath())), _function, null);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    @After
    public void cleanup() {
        try {
            boolean _exists = this.root.exists();
            if (_exists) {
                Files.cleanFolder(this.root, null, true, true);
            }
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }

    protected Map<URI, List<Issue>> diagnostics = CollectionLiterals.<URI, List<Issue>>newHashMap();

    protected File root;

    public URI operator_mappedTo(final String path, final CharSequence contents) {
        try {
            final File file = new File(this.root, path);
            file.getParentFile().mkdirs();
            file.createNewFile();
            FileWriter _fileWriter = new FileWriter(file);
            final Procedure1<FileWriter> _function = (FileWriter it) -> {
                try {
                    it.write(contents.toString());
                    it.close();
                } catch (Throwable _e) {
                    throw Exceptions.sneakyThrow(_e);
                }
            };
            ObjectExtensions.<FileWriter>operator_doubleArrow(_fileWriter, _function);
            return URI.createFileURI(file.getAbsolutePath());
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    }
}

17 View Complete Implementation : TestLanguageIdeContentProposalProvider.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * @author Christian Dietrich - Initial contribution and API
 */
@SuppressWarnings("all")
public clreplaced TestLanguageIdeContentProposalProvider extends IdeContentProposalProvider {

    @Inject
    @Extension
    private TestLanguageGrammarAccess _testLanguageGrammarAccess;

    @Override
    protected void _createProposals(final RuleCall ruleCall, final ContentreplacedistContext context, final IIdeContentProposalAcceptor acceptor) {
        AbstractRule _rule = ruleCall.getRule();
        ParserRule _typeDeclarationRule = this._testLanguageGrammarAccess.getTypeDeclarationRule();
        boolean _equals = Objects.equal(_rule, _typeDeclarationRule);
        if (_equals) {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("type ${1|A,B,C|} {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("}");
            acceptor.accept(this.getProposalCreator().createSnippet(_builder.toString(), "Sample Snippet", context), 0);
        }
        super._createProposals(ruleCall, context, acceptor);
    }
}

17 View Complete Implementation : ImportURIScopingFragment2.java
Copyright Eclipse Public License 1.0
Author : eclipse
@SuppressWarnings("all")
public clreplaced ImportURIScopingFragment2 extends ImportNamespacesScopingFragment2 {

    @Inject
    @Extension
    private XbaseUsageDetector _xbaseUsageDetector;

    @Override
    public TypeReference getDelegateScopeProvider() {
        TypeReference _xifexpression = null;
        boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(this.getLanguage().getGrammar());
        if (_inheritsXbase) {
            _xifexpression = TypeReference.typeRef("org.eclipse.xtext.xbase.scoping.XImportSectionNamespaceScopeProvider");
        } else {
            _xifexpression = TypeReference.typeRef(SimpleLocalScopeProvider.clreplaced);
        }
        return _xifexpression;
    }

    @Override
    protected TypeReference getGlobalScopeProvider() {
        return TypeReference.typeRef(ImportUriGlobalScopeProvider.clreplaced);
    }
}