Xbase, Using XbaseBatchScopeProvider [message #1731341] |
Wed, 04 May 2016 08:53  |
Eclipse User |
|
|
|
Hi,
I am relatively new to Xbase:
This is my query:
I have my xtext grammar:
with
source = XAdditiveExpression '=' destination=XMemberFeatureCall
I have a class, Person1, with firstname and lastname as fields
Another class Person2, with fullname
I want my language to help me access, firstname and lastname of the Person class.Similarly access fullname of Person2 class.
I am using Additive Expression, say i want to concatente firstname and lastname of Person1 class.
|
|
|
|
Re: Xbase, Using XbaseBatchScopeProvider [message #1731411 is a reply to message #1731398] |
Thu, 05 May 2016 00:03   |
Eclipse User |
|
|
|
Hi Miguel,
I have a Java Class,
It is not a generated code, it is an existing POJO class.
Ex:
Class Person {
String firstName;
String LastName;
//getters
//setters
}
Class PersonVO{
String FullName;
// getters
//setters
}
WhatI want to do with my grammar is that, I want to concatenate firstName and lastName from Person Object to the FullName variable in PersonVO Object
That is I want to get attributes from Person and map it to Setter attributes in PersonVO obj.
DSL:
In my grammar, I want to make use of Xbase.( I have attached Domain.xtext)
My grammar is as follows:
..
'{'
(propertyMapping+=PropertyMapping)*
'}';
PropertyMapping:
source=XMemberFeatureCall MapsToToken destination=XMemberFeatureCall ('using' using=JvmTypeReference)? ';';
MapsToToken:
'=>';
.
What I am expecting is that, When I create a Domain Model, In propertyMapping I want the Source part to give me the getters (Person Obj) and the destination to give me Setters(PersonVO).
Attachment: Domain.xtext
(Size: 0.60KB, Downloaded 96 times)
Attachment: sample.mydsl
(Size: 0.19KB, Downloaded 87 times)
|
|
|
|
|
|
Re: Xbase, Using XbaseBatchScopeProvider [message #1731433 is a reply to message #1731420] |
Thu, 05 May 2016 04:24  |
Eclipse User |
|
|
|
Well you have basically 4 Parts
1 the Target Type
2 a Member of the Target Type
(Can be handled with a JvmTypeReference and a reference to a jvm member- the Second one scoped with the members of the First one by a customization of the scoping)
3 a Source type
4 a Expressionismus that accesses members of the Source Type and has the Type of 2 as a result
So what about Inferring for 4 a Method with the Body set to the expression and returntype the Type of 2
Putting 3 as Method Parameter with name it
EG
from Person firstname.concat(Lastname) set PersonVo.fullname
|
|
|
Powered by
FUDForum. Page generated in 0.04918 seconds