|
Re: XbaseCompiler creating new objects for this access [message #1032663 is a reply to message #1032659] |
Wed, 03 April 2013 09:13 |
|
Hi
I'm the author of that blog post, and I haven't checked whether that
still works with Xtext 2.4.
However, that was an experiment to understand the XbaseCompiler, but, if
you use the JvmModelInferrer, I think you should rely on that instead of
writing your own generator... or are you using the XbaseCompiler in the
inferrer itself?
On 04/03/2013 11:06 AM, Dustin Steiner wrote:
> In our Xtext-based project (Master thesis MDD research stuff ;), we
> reuse XBlockExpression from Xbase in order to have some kind of methods
> for our DSL.
> In the generator we want to use the XBaseCompiler in order to get
> working Java code (found this code via http://www.rcp-vision.com/?p=1640):
>
> val result = new FakeTreeAppendable(manager);
> if (expression != null) {
> xbaseCompiler.toJavaStatement(expression, result, false);
> }
>
> Unfortunately when running this code, the XBaseCompiler creates new
> variables for the this reference. Here's an example:
> Our DSL looks like that:
> entity Todo {
> title: String {
> get; set;
> }
> def test():void {
> val a = this.title;
> }
> }
>
> And we manually create the following Java file:
> public class Todo {
> protected String mTitle;
> public String getTitle() {
> return mTitle;
> }
> public void setTitle(String value) {
> mTitle = value;
> }
>
> public void test() {
> Todo _Todo = Todo;
> final String a = _Todo.getTitle();
> }
> }
>
> Here you see the problem. Instead of accessing this.getTitle(), it tries
> to create this new Todo _Todo variable (which doesn't even use the
> new-keyword).
> In the background we also use the JVMInferrer to get autocompletion for
> the editors and to be able to have the JVMTypes available in the
> XExpressions of course.
>
> Is this a known problem or will I have to recreate the whole project
> again and check, if this is the result of some unknown combination of
> Xtext features?
> Would be great if you could help us out! :)
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
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.03877 seconds