Xtend2 generation issue [message #669883] |
Wed, 11 May 2011 23:40 |
Edwin Park Messages: 124 Registered: July 2009 |
Senior Member |
|
|
Hi,
I have an Xtend class that is failing to generate into Java code, even though the Xtend class is validating without errors. I have pared down the implementation as much as I could to try to narrow in on the issue. As a result, the resulting minimal example code below may seem nonsensical, but the original purpose of the class is to walk over a UI Screen model and collect any requirements for any of its constituent Widgets.
For the purposes of this example I'm just using simple vanilla Java beans for the model classes:
import java.util.List;
public class Screen {
private List<Widget> widgets;
public List<Widget> getWidgets() {
return widgets;
}
}
import java.util.List;
public class Widget {
private List<Widget> widgets;
public List<Widget> getWidgets() {
return widgets;
}
}
Note that even though Screen and Widget are identical in this minimal example, in reality Widget would be the root of a hierarchy of UI widgets, some of which are containers that may contain other widgets, and Screen is not a widget because a Screen cannot be contained in a widget.
The Xtend file looks like this:
Test.xtend:
import java.util.*
class Test {
requires(Screen s) {
var requires = new LinkedHashSet<String>()
for (child : s.widgets)
requires += child.requires
return requires
}
requires(Widget w) {
var requires = new LinkedHashSet<String>()
for (child : w.widgets)
requires.addAll(child.requires)
return requires
}
}
The Xtend class as shown above fails to compile to Java. However if I comment out one of the for loops within either of the requires() methods, it will compile. I am using the 3.7M6 Xtext 2 beta from: http://blog.efftinge.de/2011/04/eclipse-xtend-beta-available .html
At this point I'm out of my depth as to how to debug the issue further, but hopefully this is enough for someone else to go on!
Thanks,
Edwin
|
|
|
Re: Xtend2 generation issue [message #669932 is a reply to message #669883] |
Thu, 12 May 2011 06:32 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Edwin,
please make sure to use the latest version. It contains a lot of fixes
compared to M6. Please file a ticket if the problem persists.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 12.05.11 01:40, schrieb Edwin Park:
> Hi,
>
> I have an Xtend class that is failing to generate into Java
> code, even though the Xtend class is validating without
> errors. I have pared down the implementation as much as I
> could to try to narrow in on the issue. As a result, the
> resulting minimal example code below may seem nonsensical,
> but the original purpose of the class is to walk over a UI
> Screen model and collect any requirements for any of its
> constituent Widgets.
>
> For the purposes of this example I'm just using simple
> vanilla Java beans for the model classes:
>
>
> import java.util.List;
>
> public class Screen {
>
> private List<Widget> widgets;
>
> public List<Widget> getWidgets() {
> return widgets;
> }
>
> }
>
>
>
> import java.util.List;
>
> public class Widget {
>
> private List<Widget> widgets;
>
> public List<Widget> getWidgets() {
> return widgets;
> }
>
> }
>
>
> Note that even though Screen and Widget are identical in
> this minimal example, in reality Widget would be the root
> of a hierarchy of UI widgets, some of which are containers
> that may contain other widgets, and Screen is not a widget
> because a Screen cannot be contained in a widget.
>
> The Xtend file looks like this:
>
> Test.xtend:
>
> import java.util.*
>
> class Test {
>
> requires(Screen s) {
> var requires = new LinkedHashSet<String>()
>
> for (child : s.widgets)
> requires += child.requires
>
> return requires
> }
>
> requires(Widget w) {
> var requires = new LinkedHashSet<String>()
>
> for (child : w.widgets)
> requires.addAll(child.requires)
>
> return requires
> }
> }
>
>
> The Xtend class as shown above fails to compile to Java.
> However if I comment out one of the for loops within either
> of the requires() methods, it will compile. I am using the
> 3.7M6 Xtext 2 beta from:
> http://blog.efftinge.de/2011/04/eclipse-xtend-beta-available .html
>
> At this point I'm out of my depth as to how to debug the
> issue further, but hopefully this is enough for someone
> else to go on!
>
> Thanks,
> Edwin
>
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04055 seconds