Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xbase, Using XbaseBatchScopeProvider(Understand how to use XBase and Scoping)
Xbase, Using XbaseBatchScopeProvider [message #1731341] Wed, 04 May 2016 12:53 Go to next message
Dhivya Ramanujam is currently offline Dhivya RamanujamFriend
Messages: 4
Registered: May 2016
Junior Member
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 #1731398 is a reply to message #1731341] Wed, 04 May 2016 23:49 Go to previous messageGo to next message
Miguel Jimenez is currently offline Miguel JimenezFriend
Messages: 40
Registered: July 2015
Member
Hi,

I don't understand well. Can you provide an example of what you are trying to achieve? when you say you have a class, is this part of your DSL, your DSL's generated code, Java?

Miguel.
Re: Xbase, Using XbaseBatchScopeProvider [message #1731411 is a reply to message #1731398] Thu, 05 May 2016 04:03 Go to previous messageGo to next message
Dhivya Ramanujam is currently offline Dhivya RamanujamFriend
Messages: 4
Registered: May 2016
Junior Member
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 69 times)
  • Attachment: sample.mydsl
    (Size: 0.19KB, Downloaded 67 times)
Re: Xbase, Using XbaseBatchScopeProvider [message #1731414 is a reply to message #1731411] Thu, 05 May 2016 04:39 Go to previous messageGo to next message
Dhivya Ramanujam is currently offline Dhivya RamanujamFriend
Messages: 4
Registered: May 2016
Junior Member
Also,

I want to generate the following file.
Re: Xbase, Using XbaseBatchScopeProvider [message #1731416 is a reply to message #1731414] Thu, 05 May 2016 04:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Do you Stick to that Syntax?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xbase, Using XbaseBatchScopeProvider [message #1731420 is a reply to message #1731416] Thu, 05 May 2016 05:59 Go to previous messageGo to next message
Dhivya Ramanujam is currently offline Dhivya RamanujamFriend
Messages: 4
Registered: May 2016
Junior Member
I am not sure how to implement this. I can change the syntax if there is a solution.
Re: Xbase, Using XbaseBatchScopeProvider [message #1731433 is a reply to message #1731420] Thu, 05 May 2016 08:24 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Generate Antlr grammar from Xtext
Next Topic:Problem with inferred type and super type declaration
Goto Forum:
  


Current Time: Thu Apr 25 04:13:24 GMT 2024

Powered by FUDForum. Page generated in 0.03543 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top