Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to configure Xtext mwe.Reader to fill the root element in a slot
    text
    copied!<p><em>I am using Xtext 2.0 with MWE 1 and XPand, but I guess the Problem for MWE 2 and XTend is exactly the same.</em></p> <p>My Xtext grammer looks like this (excerpt):</p> <pre><code>grammer org.test.Test with org.eclipse.xtext.common.Terminals generate test "http://www.test.org/test/Test Model : "COMMON STUFF" "{" (formatterDefs+=FormatterDef)* "}" ... FormatterDef : "Formatter" name=ID ":" formatter=STRING; </code></pre> <p>When I use this mwe definiton (excerpt):</p> <pre><code>&lt;component class="org.eclipse.xtext.mwe.Reader" path="${project.src.directory}/xtext/model/" &gt; &lt;register class="org.test.TestStandaloneSetup"/&gt; &lt;load slot='formatterDefs' type='FormatterDef'/&gt; &lt;/component&gt; &lt;component class="org.eclipse.xpand2.Generator"&gt; &lt;metaModel class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/&gt; &lt;expand value="templates::Formatter::formatterTxt FOREACH formatterDefs"/&gt; &lt;/component&gt; </code></pre> <p>So the slot <code>formatterDefs</code> is filled with all <code>FormaterDef</code>, and then this is used for the template, and every think works fine.</p> <p><strong>But I have some templates that requires the model root element, named <code>Model</code> in the grammar. So I tryed to use</strong></p> <pre><code>&lt;load slot='formatterDefs' type='FormatterDef'/&gt; </code></pre> <p>and </p> <pre><code>&lt;expand value="templates::Main::main FOREACH model"/&gt; </code></pre> <p>instead.</p> <p>But then I get this warning:</p> <blockquote> <p><strong>org.eclipse.xtext.mwe.SlotEntry - Could not find any exported element of type 'Model' -> Slot 'model' is empty.</strong></p> </blockquote> <p>And the slot contains an empty list.</p> <p>So my Question is: <strong>what do I need to do, to get the root <code>Model</code> into my templates?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload