Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Runtime exceptions thrown from the model inferrer
Runtime exceptions thrown from the model inferrer [message #1043994] Thu, 18 April 2013 11:06 Go to next message
Oren Mishali is currently offline Oren Mishali
Messages: 15
Registered: March 2013
Junior Member
Hi all,
I have just installed The 4.2.2 Eclipse-DSL distribution that also containd Xtext. I created an Xtext project, defined the grammar, and implemented a simple Model Inferrer.

Then I started a new Runtime Eclipse, willing to test the new DSL. However, when I wrote down the first keyword in the DSL source code (using auto-completion) I got the following errors:

An internal error occurred during: "Xtext validation".
java.lang.NullPointerException

An internal error occurred during: "XtextReconcilerJob".
java.lang.NullPointerException

The trace tells that an null exception is thrown from the model inferrer, and it seems like it tries to infer a model which doesn't exist yet. Is that the case? should I protect my code from null model values? I don't remember that any of the 7-dsl example languages did that.

Do I miss something very basic?

P.S The Eclipse-DSL distribution contains Xtext 2.3 and not 2.4.

Thanks in advance,
Oren


Re: Runtime exceptions thrown from the model inferrer [message #1044039 is a reply to message #1043994] Thu, 18 April 2013 12:18 Go to previous message
Oren Mishali is currently offline Oren Mishali
Messages: 15
Registered: March 2013
Junior Member
I found out the cause for the problem:

This is a part of my grammar:

Contract:
  'contract' javaClass=JvmTypeReference '{'
     methodContracts += MethodContract*
   '}'
;


Previously (with the error) the model inferrer looked like this:

def dispatch void infer(Contract contract, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {

acceptor.accept(contract.toClass(contract.javaClass.qualifiedName + "Contract"))
   .initializeLater([...])
   ...
}


Now, I was thinking that the infer method is getting executed only for valid models, but is appears that the method is executed even for a model that only contains the 'contract' keyword.

Anyway, the solution was to add the following line before the call to 'accept':

if(contract.javaClass == null) return;


Thanks,
Oren
Previous Topic:ENUM DATA TYPE
Next Topic:Why ScopeProvider is missing when Xbase is used?
Goto Forum:
  


Current Time: Thu Oct 30 16:46:55 GMT 2014

Powered by FUDForum. Page generated in 0.01831 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software