Home » Modeling » TMF (Xtext) » create object if no ref found
create object if no ref found [message #634090] |
Wed, 20 October 2010 13:42 |
Eclipse User |
|
|
|
Originally posted by: marcel-groups.troos-online.de
Hi,
is there a way to automatically create a new object if no ref could be
found?
Currently this is my .xtext:
Root:
systems+=System+;
System:
'The sys ' SystemTerminal ' consists of:' (subsystems+=SystemPart ',')*
(subsystems+=SystemPart '.');
SystemTerminal returns System:
name=ID;
SystemPart:
type=[System] name=ID;
Id like to use something like:
The sys X consists of: Y part1, Z part2.
The sys Y consists of: Z part3.
The sys OVERALL consists of: X foo.
X,Y,Z and OVERALL should be 'systems', that will be either referenced or
-if no reference was found- created.
I tried something like...
SystemPart:
(type=[System] | type=SystemTerminal) name=ID;
.... but obviously it's not working that way.
Thanks
Best regards
Marcel
|
|
|
Re: create object if no ref found [message #634115 is a reply to message #634090] |
Wed, 20 October 2010 14:32 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Yeah it's possible.
You should do it in the linker, whenerver a broken link
is found (i.e. there is no System for a given name), you could
create a new System. You should add those systems somewhere where it
doesn't get into the way of Xtext.
Maybe as additional eobjects in the Resource.eContents() list or even a
dedicated synthetic resource.
Sven
Am 10/20/10 3:42 PM, schrieb Marcel Sander:
> Hi,
>
> is there a way to automatically create a new object if no ref could be
> found?
>
> Currently this is my .xtext:
>
> Root:
> systems+=System+;
>
> System:
> 'The sys ' SystemTerminal ' consists of:' (subsystems+=SystemPart ',')*
> (subsystems+=SystemPart '.');
>
> SystemTerminal returns System:
> name=ID;
>
> SystemPart:
> type=[System] name=ID;
>
> Id like to use something like:
>
>
> The sys X consists of: Y part1, Z part2.
>
> The sys Y consists of: Z part3.
>
> The sys OVERALL consists of: X foo.
>
>
> X,Y,Z and OVERALL should be 'systems', that will be either referenced or
> -if no reference was found- created.
>
> I tried something like...
>
> SystemPart:
> (type=[System] | type=SystemTerminal) name=ID;
>
>
> ... but obviously it's not working that way.
>
> Thanks
>
> Best regards
>
> Marcel
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
|
|
|
Re: create object if no ref found [message #634182 is a reply to message #634115] |
Wed, 20 October 2010 17:12 |
Eclipse User |
|
|
|
Originally posted by: marcel-groups.troos-online.de
Thanks for your response.
Am I right to hook into
public IScope scope_System(EObject ctx, EReference ref)
?
If yes: How would I create the IScope for the new object?
Marcel
Am 20.10.2010 16:32, schrieb Sven Efftinge:
> Yeah it's possible.
> You should do it in the linker, whenerver a broken link
> is found (i.e. there is no System for a given name), you could
> create a new System. You should add those systems somewhere where it
> doesn't get into the way of Xtext.
>
> Maybe as additional eobjects in the Resource.eContents() list or even a
> dedicated synthetic resource.
>
> Sven
>
> Am 10/20/10 3:42 PM, schrieb Marcel Sander:
>> Hi,
>>
>> is there a way to automatically create a new object if no ref could be
>> found?
>>
>> Currently this is my .xtext:
>>
>> Root:
>> systems+=System+;
>>
>> System:
>> 'The sys ' SystemTerminal ' consists of:' (subsystems+=SystemPart ',')*
>> (subsystems+=SystemPart '.');
>>
>> SystemTerminal returns System:
>> name=ID;
>>
>> SystemPart:
>> type=[System] name=ID;
>>
>> Id like to use something like:
>>
>>
>> The sys X consists of: Y part1, Z part2.
>>
>> The sys Y consists of: Z part3.
>>
>> The sys OVERALL consists of: X foo.
>>
>>
>> X,Y,Z and OVERALL should be 'systems', that will be either referenced or
>> -if no reference was found- created.
>>
>> I tried something like...
>>
>> SystemPart:
>> (type=[System] | type=SystemTerminal) name=ID;
>>
>>
>> ... but obviously it's not working that way.
>>
>> Thanks
>>
>> Best regards
>>
>> Marcel
>
>
|
|
| | |
Re: create object if no ref found [message #650394 is a reply to message #634090] |
Mon, 24 January 2011 17:25 |
Eclipse User |
|
|
|
Originally posted by: Stefan-Isele.gmx.de
Hi Marcel, did you find a solution for this problem ?
I also had some trouble to create/delete/reference objects. It works somehow but its everything else than elegant.
with best regards
Stefan Isele
This is my post from today :
Hello,
I want to calculate derived properties in my model and reference them, without changing the dsl-file.
My dsl contains a dto that is based on a table:
Dto:
'dto' name=ID 'basedOn' basedOn=[sql::Table|QualifiedName]
includeAll?='includeAll'
('properties' '{' properties+=Property* '}')?;
When 'includeAll' is entered, I want to calculate the properties of the Dto using the tables columns.
Other elements that reference a dtos properties should be able to use these calculated properties as well.
Where and how would you do that ?
So far I added an attribute Dto.calculatedProperties using a postprocessor. I put the calculated properties there. This
works more or less, but every now and than I get some race conditions. I know that changing the model should be done in
IUnitOfWork using IXtextDocument but how can I find the IXtextDocument of an EObject ?
Anyway this would only work in the gui. How would it be done in the generator ?
Any help would be appreciated,
Stefan Isele
Marcel Sander schrieb:
> Hi,
>
> is there a way to automatically create a new object if no ref could be
> found?
>
> Currently this is my .xtext:
>
> Root:
> systems+=System+;
>
> System:
> 'The sys ' SystemTerminal ' consists of:' (subsystems+=SystemPart ',')*
> (subsystems+=SystemPart '.');
>
> SystemTerminal returns System:
> name=ID;
>
> SystemPart:
> type=[System] name=ID;
>
> Id like to use something like:
>
>
> The sys X consists of: Y part1, Z part2.
>
> The sys Y consists of: Z part3.
>
> The sys OVERALL consists of: X foo.
>
>
> X,Y,Z and OVERALL should be 'systems', that will be either referenced or
> -if no reference was found- created.
>
> I tried something like...
>
> SystemPart:
> (type=[System] | type=SystemTerminal) name=ID;
>
>
> ... but obviously it's not working that way.
>
> Thanks
>
> Best regards
>
> Marcel
|
|
| | | |
Goto Forum:
Current Time: Thu Apr 25 18:02:03 GMT 2024
Powered by FUDForum. Page generated in 5.04069 seconds
|