Note that there are some explanatory texts on larger screens.

plurals
  1. POException in generated editor: Xtext bug or error in grammar?
    primarykey
    data
    text
    <p>After moving to Xtext 2.4.2 and Eclipse Kepler, a problem appeared in the editor of our DSL. Everything was perfectly working before (Xtext 2.3.x, Juno).</p> <p>Our DSL editor throws a ClassCastException when we edit an initialization list: <code>[1,2,3]</code> <img src="https://i.stack.imgur.com/d8RPV.png" alt="Xtext Error Pop-up"></p> <p><strong>Steps to reproduce:</strong></p> <ol> <li>Create a new "Xtext State-Machine Example" project</li> <li>Edit the grammar with the one below</li> <li>Delete the package org.eclipse.xtext.example.fowlerdsl.generator (it will be regenerated at 4.)</li> <li>Run the org.eclipse.xtext.example.fowlerdsl.GenerateStatemachine.mwe2 workflow</li> <li>Run the eclipse application</li> <li>Create a new file (example.statemachine) in an empty project and copy the folowing content</li> </ol> <p><strong>Grammar:</strong></p> <pre class="lang-xtext prettyprint-override"><code>grammar org.eclipse.xtext.example.fowlerdsl.Statemachine with org.eclipse.xtext.common.Terminals generate statemachine "http://www.eclipse.org/xtext/example/fowlerdsl/Statemachine" Statemachine : {Statemachine} (vars += VarDeclWithOptionalInit)* ; VarDeclWithOptionalInit returns Variable: VarDecl ('=' value=AstExpression)? ; VarDecl returns Variable: 'var' name = ID ; AstExpression: ExpressionList | {AstExpression} INT ; ExpressionList: '[' expressions+=AstExpression (',' expressions+=AstExpression)* ']' ; </code></pre> <p><strong>Content of example.statemachine</strong></p> <pre class="lang-js prettyprint-override"><code>//Adding space between chars inside [] cause Exception var example1 = [1, 2, 3] //Doing the same in [10, 20] or [30, 40] is Ok, but modifying //the top-level list cause the Exception var example2 = [[10, 20], 0, [30, 40], 1, 2] </code></pre> <p>I think the content of the example file is correct. But when I edit lists with new values, or when I add spaces around commas or values, the editor pop-up an error with a ClassCastException from the XtextReconcilierJob.</p> <p>Do you think my grammar has something wrong, or is it a bug from Xtext side ?</p> <p><strong>Additional information</strong></p> <p>I fight against this for some days, and I collected some interesting information:</p> <ul> <li>In the example, editor throws only when editing elements from the top-level list, not from inner ones (see example2 variable)</li> <li>In my tests, sometimes a <code>NullPointerException</code> was throwed earlier in the call stack. <ul> <li>I suspect the method <code>PartialParsingHelper.reparse(IParser parser, IParseResult prev, ReplaceRegion cr)</code> to have a strange behavior</li> <li>This method found the parent of the current modified element in the model, to call eSet() on this with the new value. But in our case, it try to call <code>Statemachine.eSet()</code> instead of <code>Variable.eSet()</code></li> <li>The <code>ClassCastException</code> comes from an equal feature id: <ul> <li><code>StateMachine.vars</code> has a feature id == 0</li> <li><code>Variable.value</code> has a feature id == 0</li> <li>But the 2 features have not the same type</li> </ul></li> <li>If I add some feature BEFORE value in <code>Variable</code>, the Exception thrown (earlier) is a <code>NullPointerException</code>, because <code>Variable.value</code> has a feature id == 2 or 3 when <code>StateMachine</code> has only 2 features (0 and 1)</li> </ul></li> </ul> <p><strong>StackTrace of the error:</strong></p> <pre><code>Thread [Worker-2] (Suspended (exception ClassCastException)) StatemachineImpl.eSet(int, Object) line: 128 StatemachineImpl(BasicEObjectImpl).eSet(EStructuralFeature, Object) line: 1071 PartialParsingHelper.reparse(IParser, IParseResult, ReplaceRegion) line: 161 StatemachineParser(AbstractAntlrParser).doReparse(IParseResult, ReplaceRegion) line: 136 StatemachineParser(AbstractParser).reparse(IParseResult, ReplaceRegion) line: 48 LazyLinkingResource(XtextResource).update(int, int, String) line: 220 XtextDocumentReconcileStrategy.doReconcile(IRegion) line: 125 XtextDocumentReconcileStrategy.reconcile(IRegion) line: 55 XtextReconciler.doRun(XtextResource, IProgressMonitor) line: 329 XtextReconciler.access$3(XtextReconciler, XtextResource, IProgressMonitor) line: 316 XtextReconciler$1.process(XtextResource) line: 273 XtextReconciler$1.process(Object) line: 1 XtextReconciler$1(IUnitOfWork$Void&lt;T&gt;).exec(T) line: 36 XtextDocument$XtextDocumentLocker(AbstractReadWriteAcces&lt;P&gt;).modify(IUnitOfWork&lt;T,P&gt;) line: 81 XtextDocument$XtextDocumentLocker.modify(IUnitOfWork&lt;T,XtextResource&gt;) line: 201 XtextDocument.internalModify(IUnitOfWork&lt;T,XtextResource&gt;) line: 98 XtextReconciler.run(IProgressMonitor) line: 270 Worker.run() line: 53 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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