Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] dynamic notion definitions
[Xtext] dynamic notion definitions [message #61155] Mon, 20 July 2009 12:46 Go to next message
Eclipse UserFriend
Originally posted by: alex.gmail.com

Hi everyone,

I have some notions in my model - lets call it 'component'. But the list
of components are defined in runtime only.
So I want at least to be able to populate content assist with that list.
To do that, as far as I understand, I need to implement
MyDslProposalProvider.complete...() methods - I just can't find any
snippet on how to do that.

But basically I would like to do more complicated stuff - which is to
import those notions into the model dynamically. Which means that those
'components' have some properties inside and I want to have those
notions in my model and use them with cross references.

Any ideas?

Best regards,
--A
Re: [Xtext] dynamic notion definitions [message #61204 is a reply to message #61155] Mon, 20 July 2009 13:29 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

if I understood you correctly, you want to make some model elements
available for content assist and cross linking, that are not defined in
your model file or in a referenced model file. These 'components' only
exist in-memory.

I'ld try to implement a scope provider, that makes these elements
available as ScopedElements. ContentAssist and CrossLinking will work
out of the box with them.

As for your first question regarding the implementation of a completeXXX
method: Please have a look at the docs:
http://www.eclipse.org/Xtext/documentation/0_7_0/xtext.html# contentAssist

Hope that helps,
Sebastian

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 20.07.2009 14:46 Uhr, schrieb Alex:
> Hi everyone,
>
> I have some notions in my model - lets call it 'component'. But the list
> of components are defined in runtime only.
> So I want at least to be able to populate content assist with that list.
> To do that, as far as I understand, I need to implement
> MyDslProposalProvider.complete...() methods - I just can't find any
> snippet on how to do that.
>
> But basically I would like to do more complicated stuff - which is to
> import those notions into the model dynamically. Which means that those
> 'components' have some properties inside and I want to have those
> notions in my model and use them with cross references.
>
> Any ideas?
>
> Best regards,
> --A
Re: [Xtext] dynamic notion definitions [message #61327 is a reply to message #61204] Mon, 20 July 2009 14:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex.gmail.com

Sebastian Zarnekow wrote:
> Hi Alex,
>
> if I understood you correctly, you want to make some model elements
> available for content assist and cross linking, that are not defined
> in your model file or in a referenced model file. These 'components'
> only exist in-memory.
>
> I'ld try to implement a scope provider, that makes these elements
> available as ScopedElements. ContentAssist and CrossLinking will work
> out of the box with them.
That's the first stuff I thought about. But then I realised that the
elements I want to reference to are not exist in the model at all and to
use them I should firstly to add (register) them to the model. But I've
no idea if it's possible and easy.
Re: [Xtext] dynamic notion definitions [message #61351 is a reply to message #61204] Mon, 20 July 2009 14:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex.gmail.com

This is a multi-part message in MIME format.
--------------070004010909080906030306
Content-Type: text/plain; charset=windows-1251; format=flowed
Content-Transfer-Encoding: 7bit

Sebastian Zarnekow wrote:
> Hi Alex,
>
> if I understood you correctly, you want to make some model elements
> available for content assist and cross linking, that are not defined
> in your model file or in a referenced model file. These 'components'
> only exist in-memory.
>
> I'ld try to implement a scope provider, that makes these elements
> available as ScopedElements. ContentAssist and CrossLinking will work
> out of the box with them.
>
> As for your first question regarding the implementation of a
> completeXXX method: Please have a look at the docs:
> http://www.eclipse.org/Xtext/documentation/0_7_0/xtext.html# contentAssist
>
> Hope that helps,
> Sebastian
>
and to understand what do I mean think about a simple language using
which you can say "*build *<what> *using* <list_of_components>"
and then on a client side application you types something like "*build
*car *using* component1, component5, component8" but the list of
components with all properties (like price, color etc.) lives on a
server and not hard coded on a client side.

--------------070004010909080906030306
Content-Type: text/html; charset=windows-1251
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=windows-1251"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sebastian Zarnekow wrote:
<blockquote cite="mid:h41rf7$9gu$1@build.eclipse.org" type="cite">Hi
Alex,
<br>
<br>
if I understood you correctly, you want to make some model elements
available for content assist and cross linking, that are not defined in
your model file or in a referenced model file. These 'components' only
exist in-memory.
<br>
<br>
I'ld try to implement a scope provider, that makes these elements
available as ScopedElements. ContentAssist and CrossLinking will work
out of the box with them.
<br>
<br>
As for your first question regarding the implementation of a
completeXXX method: Please have a look at the docs:
<br>
<a class="moz-txt-link-freetext" href=" http://www.eclipse.org/Xtext/documentation/0_7_0/xtext.html# contentAssist"> http://www.eclipse.org/Xtext/documentation/0_7_0/xtext.html# contentAssist</a>
<br>
<br>
Hope that helps,
<br>
Sebastian
<br>
<br>
</blockquote>
and to understand what do I mean think about a simple language using
which you can say
Re: [Xtext] dynamic notion definitions [message #61399 is a reply to message #61327] Mon, 20 July 2009 15:10 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

model elements that are content of a scope are not necessarily contained
in the same resource. But they have to be referable elements, thus you
have to import the epackage in your grammar and declare the cross links
to their type.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 20.07.2009 16:38 Uhr, schrieb Alex:
> Sebastian Zarnekow wrote:
>> Hi Alex,
>>
>> if I understood you correctly, you want to make some model elements
>> available for content assist and cross linking, that are not defined
>> in your model file or in a referenced model file. These 'components'
>> only exist in-memory.
>>
>> I'ld try to implement a scope provider, that makes these elements
>> available as ScopedElements. ContentAssist and CrossLinking will work
>> out of the box with them.
> That's the first stuff I thought about. But then I realised that the
> elements I want to reference to are not exist in the model at all and to
> use them I should firstly to add (register) them to the model. But I've
> no idea if it's possible and easy.
Re: [Xtext] dynamic notion definitions [message #61519 is a reply to message #61399] Mon, 20 July 2009 16:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex.gmail.com

Sebastian Zarnekow wrote:
> Hi Alex,
>
> model elements that are content of a scope are not necessarily
> contained in the same resource. But they have to be referable
> elements, thus you have to import the epackage in your grammar and
> declare the cross links to their type.
>
> Hope that helps,
> Sebastian
That's exactly what I was thinking about. But the only possibility to
achieve that is to generate the file with component definitions in
runtime and than to include it in to the project. But firstly I don't
know how to do that (and any help will be very appreciated) and secondly
I was wondering if there is simpler way to achieve what I'm trying to
achieve.


regards,
--A
Re: [Xtext] dynamic notion definitions [message #61693 is a reply to message #61519] Tue, 21 July 2009 07:08 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

I assume the following scenario, please correct me if I'm wrong:
You'll define a DSL with a concept of components. These components are
not declared by you, but by your clients. Each client may define other
components. You try to find a way to refer to these client specific
components from the DSL. Is this right?

That sounds to me like a very straight forward use case for multiple
languages. You define your DSL as is and another one for the definition
of components. The latter may or may not be a textual DSL, lets assume
it is textual for now.
Usually you would:

1) Start with your component DSL:

grammar org.foo.Components with org.eclipse.xtext.common.Terminals

generate componentsMM "http://org.foo.something/Components"

// rules follow here, at least one of them refers to components
Component:
name=ID // something more;

2) Generate the component DSL.
3) Create your second DSL:
grammar org.foo.DSL with org.eclipse.xtext.common.Terminals

generate dslMM "http://org.foo.something/DSL"
import
" platform:/resource/componentLangProject/src-gen/org/foo/Comp onents.ecore "

// rule go here
Import:
'components' 'from' importURI=STRING;

Something:
referToComponent=[Component] // more to come ...
4) Set the path to the component's genmodel in your MWE file (search
this newsgroup for details)
5) Generate your DSL.

Clients should create their components and refer to them from their DSL
file. The explicit import may be ommitted if you use some convention
over configuration principle.
If you do not want to use a textual notion for the definition of
components, you may create the components EPackage (Metamodel) manually
and refer to it the same way as in step (3). Clients would have to
implement a special interface / extension point / whatever mechanism to
provide their components. However, you'll need to come up with the
appropriate infrastructure for this solution.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 20.07.2009 18:21 Uhr, schrieb Alex:
> Sebastian Zarnekow wrote:
>> Hi Alex,
>>
>> model elements that are content of a scope are not necessarily
>> contained in the same resource. But they have to be referable
>> elements, thus you have to import the epackage in your grammar and
>> declare the cross links to their type.
>>
>> Hope that helps,
>> Sebastian
> That's exactly what I was thinking about. But the only possibility to
> achieve that is to generate the file with component definitions in
> runtime and than to include it in to the project. But firstly I don't
> know how to do that (and any help will be very appreciated) and secondly
> I was wondering if there is simpler way to achieve what I'm trying to
> achieve.
>
>
> regards,
> --A
Previous Topic:Example for linking to imported objects?
Next Topic:OAW to TMF migration: ext allElements migration
Goto Forum:
  


Current Time: Sat Nov 09 00:56:28 GMT 2024

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

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

Back to the top