|
|
|
|
|
|
Re: ScopeProvider with imported Xcore [message #1385761 is a reply to message #1385711] |
Wed, 11 June 2014 05:56 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
Florian,
Comments below.
On 10/06/2014 5:56 PM, Florian König wrote:
> Hi Christian,
>
> Thanks for your suggestion! I tried that and changed some things, like this:
>
> import "http ://www.eclipse.org/emf/2002/Ecore" as ecore
>
> Import: 'import' importedNamespace=FqnWithWildCard;
> FqnWithWildCard: Fqn('.*')?;
> Fqn:ID('.'ID)*;
>
> Select: 'select' class=[ecore::EClass | Fqn] name=ID;
>
> This works, now I can select the classes I created in Xcore :)
> Like this:
> selection test
> {
> select org.test.RailCab
> }
>
> But I got two new Problems:
>
>
> I get a lot of items I can put in there (and my Xcore classes even without an import), but I only want to have those I imported earlier in my import section. How can I do that?
>
> When I select my RailCab class like the example above, I get this error: Quote:
>> Couldn't resolve reference to EClass 'org.test.RailCab'.
>
>
> How can I fix these?
>
> @Ed: Thanks to you too, but I don't really know how I can do that... Could you be a bit more specific?
I can only suggest you look at the Xcore grammar. I don't really know
your ultimate intent, but something to keep in mind. Xext grammar
language uses Ecore directly and relies on imports that specify the
nsURI of the Ecore model and then further relies on the index to index
all the *.ecore models, including *.xcore representations. But Ecore
models don't know about a fully qualified name just the name of the
package and the name of the classifiers (and structural features/enum
literals). So I'd not expect that approach to let you specify names
like org.test.RailCab. Xcore relies on indexing of all *.genmodel,
including *.xcore representations, and a GenClassifier knows about fully
qualified names in the sense of the generated Java code. So if you rely
on Xcore, you likely want your reference to be to a GenClassifier (or
perhaps more restrictively to be a GenClass). So try that instead of
EClass in your grammar.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: ScopeProvider with imported Xcore [message #1385796 is a reply to message #1385792] |
Wed, 11 June 2014 09:19 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
Hallvard,
That would be the work of
org.eclipse.xtext.ecore.EcoreQualifiedNameProvider. I know that
org.eclipse.emf.codegen.ecore.xtext.GenModelQualifiedNameProvider does a
good job giving the actual name you'll see when you generate the code,
but for Ecore, you can only get up to the EPackage and that's not
generally a qualified name. I suppose, if you included parent packages
all the way up to "org" it would give a qualified name, but otherwise,
it's not ideal. And besides, if the focus on on referencing Xcore, then
there is a GenModel and the information is definitely well supported for
that (and would also work for a normal *.genmodel)...
On 11/06/2014 10:53 AM, Hallvard Trætteberg wrote:
> Just a comment on using qualified names for EClasses. Doesn't the
> standard QualifiedNameProvider create qualified names from the name
> features of ENamedElements up to the root. Hence, most elements in an
> Ecore model will get the qualified name you'd expect.
>
> Hallvard
>
> On 11.06.14 07:56, Ed Merks wrote:
>> But Ecore
>> models don't know about a fully qualified name just the name of the
>> package and the name of the classifiers (and structural features/enum
>> literals). So I'd not expect that approach to let you specify names
>> like org.test.RailCab. Xcore relies on indexing of all *.genmodel,
>> including *.xcore representations, and a GenClassifier knows about fully
>> qualified names in the sense of the generated Java code. So if you rely
>> on Xcore, you likely want your reference to be to a GenClassifier (or
>> perhaps more restrictively to be a GenClass). So try that instead of
>> EClass in your grammar.
>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02442 seconds