Home » Modeling » TMF (Xtext) » xText - how to define an include statement
xText - how to define an include statement [message #14610] |
Sat, 24 May 2008 08:56  |
Eclipse User |
|
|
|
Originally posted by: kheinz57.gmx.de
Is it possible define an include(or import) statement in my own DSL
which the generated editor is aware of?
example:
Taking the statemachine example
( http://effi-blog.blogspot.com/2006/04/textual-dsl-framework- xtext.html
) this shows my intention:
file1.mydsl:
================
state externalState{....}
================
file2.mydsl:
================
include "file1.mydsl"
state A {
myTransition -> externalState
}
================
externalState is not defined in the second file. But the checker and the
editor should still be aware of it.
Possible?
|
|
| |
Re: xText - how to define an include statement [message #19784 is a reply to message #14639] |
Fri, 08 August 2008 07:40   |
Eclipse User |
|
|
|
I tried this solution and it works fine
however, in my language, I'd like not to specify the complete resource
URI, for instance, if no path is specified then the current directory (I
mean the same directory of the file being edited) should be used... is
it possible to do this somehow?
Moreover, I noticed that while the completion for symbols (i.e., ID)
defined in another file works perfectly, jumping to the definition of
that symbol with F3 (or Ctrl+click) does not work...
Sven Efftinge wrote:
> Hi Heinz,
>
> it is possible using the URI token:
>
> Statemachine :
> (includes+=Include)*
> (states+=State)*;
>
> Include :
> 'include' resource=URI;
>
> State :
> .....
>
> The referenced files need to be an EMF resource URI (e.g. using the
> 'platform:/resource/projectname/...' protocol)
>
> references models can be obtained using the generated extension
> 'allElements()'. There is also an extension called 'resource(Include)'
> which can be used to get the referenced elements only.
>
> hope that helps,
> Sven
>
> Heinz Häberle schrieb:
>> Is it possible define an include(or import) statement in my own DSL
>> which the generated editor is aware of?
>>
>>
>> example:
>> Taking the statemachine example
>> ( http://effi-blog.blogspot.com/2006/04/textual-dsl-framework- xtext.html
>> ) this shows my intention:
>>
>> file1.mydsl:
>> ================
>> state externalState{....}
>> ================
>>
>> file2.mydsl:
>> ================
>> include "file1.mydsl"
>> state A {
>> myTransition -> externalState
>> }
>> ================
>>
>> externalState is not defined in the second file. But the checker and
>> the editor should still be aware of it.
>>
>> Possible?
>>
>>
>>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
|
|
|
[Xtext] how to define an include statement [message #19816 is a reply to message #14639] |
Fri, 08 August 2008 08:12   |
Eclipse User |
|
|
|
I tried this solution and it works fine
however, in my language, I'd like not to specify the complete resource
URI, for instance, if no path is specified then the current directory (I
mean the same directory of the file being edited) should be used... is
it possible to do this somehow?
Moreover, I noticed that while the completion for symbols (i.e., ID)
defined in another file works perfectly, jumping to the definition of
that symbol with F3 (or Ctrl+click) does not work...
Sven Efftinge wrote:
> Hi Heinz,
>
> it is possible using the URI token:
>
> Statemachine :
> (includes+=Include)*
> (states+=State)*;
>
> Include :
> 'include' resource=URI;
>
> State :
> .....
>
> The referenced files need to be an EMF resource URI (e.g. using the
> 'platform:/resource/projectname/...' protocol)
>
> references models can be obtained using the generated extension
> 'allElements()'. There is also an extension called 'resource(Include)'
> which can be used to get the referenced elements only.
>
> hope that helps,
> Sven
>
> Heinz Häberle schrieb:
>> Is it possible define an include(or import) statement in my own DSL
>> which the generated editor is aware of?
>>
>>
>> example:
>> Taking the statemachine example
>> ( http://effi-blog.blogspot.com/2006/04/textual-dsl-framework- xtext.html
>> ) this shows my intention:
>>
>> file1.mydsl:
>> ================
>> state externalState{....}
>> ================
>>
>> file2.mydsl:
>> ================
>> include "file1.mydsl"
>> state A {
>> myTransition -> externalState
>> }
>> ================
>>
>> externalState is not defined in the second file. But the checker and
>> the editor should still be aware of it.
>>
>> Possible?
>>
>>
>>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
|
|
|
Re: [Xtext] how to define an include statement [message #21321 is a reply to message #19816] |
Mon, 11 August 2008 03:06   |
Eclipse User |
|
|
|
Originally posted by: sven.efftinge.de
Yes, it's possible but it's not as simple.
You can either implement your own linking mechanism, by overwriting the
extensions
allElements()
and
allVisibleElements()
or use the hooks provided by EMF (e.g. register a URIConverter with the
ResourceSet).
Hope that helps,
Sven
regarding F3 : Usually it works. So maybe you want to double check your
setup and if it still doesn't work, file a bug report.
Lorenzo Bettini schrieb:
> I tried this solution and it works fine
>
> however, in my language, I'd like not to specify the complete resource
> URI, for instance, if no path is specified then the current directory (I
> mean the same directory of the file being edited) should be used... is
> it possible to do this somehow?
>
> Moreover, I noticed that while the completion for symbols (i.e., ID)
> defined in another file works perfectly, jumping to the definition of
> that symbol with F3 (or Ctrl+click) does not work...
>
> Sven Efftinge wrote:
>> Hi Heinz,
>>
>> it is possible using the URI token:
>>
>> Statemachine :
>> (includes+=Include)*
>> (states+=State)*;
>>
>> Include :
>> 'include' resource=URI;
>>
>> State :
>> .....
>>
>> The referenced files need to be an EMF resource URI (e.g. using the
>> 'platform:/resource/projectname/...' protocol)
>>
>> references models can be obtained using the generated extension
>> 'allElements()'. There is also an extension called 'resource(Include)'
>> which can be used to get the referenced elements only.
>>
>> hope that helps,
>> Sven
>>
>> Heinz Häberle schrieb:
>>> Is it possible define an include(or import) statement in my own DSL
>>> which the generated editor is aware of?
>>>
>>>
>>> example:
>>> Taking the statemachine example
>>> ( http://effi-blog.blogspot.com/2006/04/textual-dsl-framework- xtext.html
>>> ) this shows my intention:
>>>
>>> file1.mydsl:
>>> ================
>>> state externalState{....}
>>> ================
>>>
>>> file2.mydsl:
>>> ================
>>> include "file1.mydsl"
>>> state A {
>>> myTransition -> externalState
>>> }
>>> ================
>>>
>>> externalState is not defined in the second file. But the checker and
>>> the editor should still be aware of it.
>>>
>>> Possible?
>>>
>>>
>>>
>
>
|
|
|
Re: [Xtext] how to define an include statement [message #21328 is a reply to message #21321] |
Mon, 11 August 2008 07:55   |
Eclipse User |
|
|
|
Actually I was thinking about a much simpler and faster solution which,
by the way, should also be re-usable: it would only be necessary to
prepend to the string (the name of the file) the same prefix of the
current resource.
This should be easy but again I don't know how to do that: would it be
possible to do this while parsing?
I think this would actually be a useful feature not only for me; the
linking mechanisms are good for "import" (in a Java-like sense), while
I'd need something similar to "include" (in the C-like sense), which, as
I said, would be a quite common feature. Furthermore, I saw that there's
no lexical URI rule: it is implemented through a STRING rule after some
post-processing. The same could be done by providing a psuedo LOCALFILE
rule for instance.
Any help would be appreciated :-)
thanks in advance
Sven Efftinge wrote:
> Yes, it's possible but it's not as simple.
> You can either implement your own linking mechanism, by overwriting the
> extensions
>
> allElements()
>
> and
>
> allVisibleElements()
>
any example of this?
> or use the hooks provided by EMF (e.g. register a URIConverter with the
> ResourceSet).
>
again, I didn't find examples...
> Hope that helps,
>
> Sven
>
> regarding F3 : Usually it works. So maybe you want to double check your
> setup and if it still doesn't work, file a bug report.
>
P.S. concerning the fact that F3 or Ctrl+click did not work was due to
the fact that I was using
"/myprojectpath/src/includedfile"
instead of
"platform:resource/myprojectpath/src/includedfile"
but again I think there's an inconsistency here: the first form does not
generate an error while parsing (the included file is found) but no text
hover functionalities works...
> Lorenzo Bettini schrieb:
>> I tried this solution and it works fine
>>
>> however, in my language, I'd like not to specify the complete resource
>> URI, for instance, if no path is specified then the current directory (I
>> mean the same directory of the file being edited) should be used... is
>> it possible to do this somehow?
>>
>> Moreover, I noticed that while the completion for symbols (i.e., ID)
>> defined in another file works perfectly, jumping to the definition of
>> that symbol with F3 (or Ctrl+click) does not work...
>>
>> Sven Efftinge wrote:
>>> Hi Heinz,
>>>
>>> it is possible using the URI token:
>>>
>>> Statemachine :
>>> (includes+=Include)*
>>> (states+=State)*;
>>>
>>> Include :
>>> 'include' resource=URI;
>>>
>>> State :
>>> .....
>>>
>>> The referenced files need to be an EMF resource URI (e.g. using the
>>> 'platform:/resource/projectname/...' protocol)
>>>
>>> references models can be obtained using the generated extension
>>> 'allElements()'. There is also an extension called
>>> 'resource(Include)' which can be used to get the referenced elements
>>> only.
>>>
>>> hope that helps,
>>> Sven
>>>
>>> Heinz Häberle schrieb:
>>>> Is it possible define an include(or import) statement in my own DSL
>>>> which the generated editor is aware of?
>>>>
>>>>
>>>> example:
>>>> Taking the statemachine example
>>>> ( http://effi-blog.blogspot.com/2006/04/textual-dsl-framework- xtext.html
>>>> ) this shows my intention:
>>>>
>>>> file1.mydsl:
>>>> ================
>>>> state externalState{....}
>>>> ================
>>>>
>>>> file2.mydsl:
>>>> ================
>>>> include "file1.mydsl"
>>>> state A {
>>>> myTransition -> externalState
>>>> }
>>>> ================
>>>>
>>>> externalState is not defined in the second file. But the checker and
>>>> the editor should still be aware of it.
>>>>
>>>> Possible?
>>>>
>>>>
>>>>
>>
>>
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
|
|
| | |
Goto Forum:
Current Time: Thu Jul 10 00:41:31 EDT 2025
Powered by FUDForum. Page generated in 0.04255 seconds
|