Runtime exceptions thrown from the model inferrer [message #1043994] |
Thu, 18 April 2013 07:06  |
Eclipse User |
|
|
|
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 08:18  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.25680 seconds