|
Re: [Xbase 2.6] Generating from XAnnotation leads to NullPointerException [message #1386110 is a reply to message #1386067] |
Fri, 13 June 2014 12:41 |
|
On 13/06/2014 12:22, Boris Brodski wrote:
> Hello,
>
> converting my Xbase DSL to Xtext 2.6 I stuck with the following problem:
>
> In my grammar:
>
>
> grammar my.myDsl with
> org.eclipse.xtext.xbase.annotations.XbaseWithAnnotations
> ..
> MyRule:
> ...
> (customAnnotations += XAnnotation)*
> ...
> ;
>
>
> In Inferrer:
>
>
> ...
> members += methodDefinition.toMethod(...) [
> myRule.customAnnotations.translateAnnotationsTo(it)
> ...
> ]
>
>
> In DSL
>
>
> @Override
>
>
> works, but
>
>
> @SuppressWarnings("all")
>
>
> throws NullPointerException in
>
> public class LiteralsCompiler extends TypeConvertingCompiler {
> protected void toJavaExpression(XStringLiteral literal,
> ITreeAppendable appendable, boolean useUnicodeEscapes) {
> LightweightTypeReference type = getLightweightType(literal);
>
> // type is NULL
> // literal is XStringLiteralImpl (value: all)
>
> Should I invoke type resolution somehow?
Hi
I experienced NPE exceptions after switching to Xbase 2.6.0 for string
literals... do you have a custom type computer for custom XExpressions?
In my case the problem was due to the way I was invoking computeTypes.
As for annotations, I translate them like this
annotations.filterNull.filter[annotationType !=
null].translateAnnotationsTo(target)
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03105 seconds