java.lang.ClassCastException: org.eclipse.xtext.impl.KeywordImpl cannot be cast to org.eclipse.xtext.RuleCall

StackOverflow https://stackoverflow.com/questions/21167121

  •  28-09-2022
  •  | 
  •  

Question

After upgrading Xtext in my Eclipse from 2.3.1 to 2.4.3, I see these errors in the log:

org.eclipse.xtext.parser.ParseException: java.lang.ClassCastException: org.eclipse.xtext.impl.KeywordImpl cannot be cast to org.eclipse.xtext.RuleCall
                at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:105)
                at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.parse(AbstractAntlrParser.java:84)
                at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:62)
                at org.eclipse.xtext.parser.AbstractParser.parse(AbstractParser.java:32)
                at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:162)
                at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:81)
                at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
                at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.loadResource(XtextDocumentProvider.java:227)

What's causing this? How do I get rid of them?

Was it helpful?

Solution

According to this Eclipse Forum post, when a grammar A extends B (B is often Xbase or Xcore), then changes in B mean that A has to be regenerated.

In my case, I upgraded to a new version of Xbase. Hence the need to run the MWE workflow again to update the sources.

Kudos to Brian S for finding the blog post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top