Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportNamespace scoping problem(ImportNamespace scoping does not work with qualifiedNameWithWildcard)
ImportNamespace scoping problem [message #1739037] Wed, 27 July 2016 06:55 Go to next message
Kevin K. is currently offline Kevin K.Friend
Messages: 3
Registered: July 2016
Junior Member
Hi guys!

Almost as in the 15 Minutes Tutorial I created a grammar for my DSL. As you can see, I used the EMF for modeling the meta-model.
If I declare an import like the code in the following lines, the scope works, but I can't use a wildcard-import (anyPkg.*):
Import:
	'Import' importedNamespace = [TypeLibrary|QualifiedName] ';';

by the way I understand why the wildcard import won't work Laughing

In opposit to the last declaration, the scope does not work in the following declaration, but the wildcard-import does:
Import:
	'Import' importedNamespace = QualifiedNameWithWildcard ';';


Well, this is my code example where the problem exists:
generate domainModel "DomainModel"

//...

domainModel:
	(elements += Import)*
	elements += TypeLibrary
;

Import:
	'Import' importedNamespace = QualifiedNameWithWildcard ';';

TypeLibrary returns TypeLibrary:
	'TypeLibrary' name = QualifiedName
	'{'
		(elements += (Type1|Type2|Type3))*
	'};'
;

// (Type rules)


And now my target is to make it possible to import types as well as packages with the functionality of scoping. I'm very sorry if I misunderstood the tutorial but I just started working with this awesome plugin.
So I'd be very happy when you could help me or give me a hint how i can solve the problem or find a solution fitting to it.

Thank you for dealing with my problem!
Re: ImportNamespace scoping problem [message #1739116 is a reply to message #1739037] Wed, 27 July 2016 15:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14699
Registered: July 2009
Senior Member
can you share your complete grammar and test model

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ImportNamespace scoping problem [message #1739408 is a reply to message #1739116] Mon, 01 August 2016 05:42 Go to previous messageGo to next message
Kevin K. is currently offline Kevin K.Friend
Messages: 3
Registered: July 2016
Junior Member
Sorry for the delay.

I attached my project folders. Well, the model of my main project has to be protected, because it concerns safety-critical infrastructure.
So I created another example project where the problem is the same. Don't mind about the strange package/class identifiers, I just did this quickly.

The problem once again in a short version:
importedNamespace = [TypeLibrary|QualifiedName]:
The editor provides a Scope with all packages.

importedNamespace = QualifiedName(withWildcard):
I can import packages but there is no scope provided.

If the combination is not possible, I would be very happy if somebody could give me a reference showing how to work arround this problem.

Thank you!
Re: ImportNamespace scoping problem [message #1739411 is a reply to message #1739408] Mon, 01 August 2016 06:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14699
Registered: July 2009
Senior Member
sry importedNamespace = QualifiedNameWithWildcard works for me.
what do you mean by code provided?
scope for the import?

if you want importedNamespace = [TypeLibrary|QualifiedName]:

you have to adapt

org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.internalGetImportedNamespaceResolvers(EObject, boolean)

and use nodemodelutils to retrieve the text.
and create a wildcard import for that text


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ImportNamespace scoping problem [message #1739415 is a reply to message #1739411] Mon, 01 August 2016 07:43 Go to previous messageGo to next message
Kevin K. is currently offline Kevin K.Friend
Messages: 3
Registered: July 2016
Junior Member
Using importedNamespace = [TypeLibrary|QualifiedName] was just a work around for me.
When I use importedNamespace = QualifiedNameWithWildcard, i can import packages as well classes BUT if I write import I don't get all possibile imports listed.
The project I am working on has a high variety of packages and classes so such a list is very important.

So what I want is an appearance in editor like this when I start typing a library name:
Import M...
|MainLib.SubLib1...................|
|MainLib.SubLib2...................|
|MainLib.SubLib2.SubClass..|

And I currently just get this appearance (without classes) by using importedNamespace = [TypeLibrary|QualifiedName].
Finally, I also want to import classes, not only packages.
Re: ImportNamespace scoping problem [message #1739417 is a reply to message #1739415] Mon, 01 August 2016 08:08 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14699
Registered: July 2009
Senior Member
i cannot follow you on this. you have to implement that yourself. i gave you some hints how to deal with
importedNamespace = [TypeLibrary|QualifiedName]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:JvmTypeReference isAssignable
Next Topic:XText netbeans support
Goto Forum:
  


Current Time: Sat Jul 27 11:16:56 GMT 2024

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

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

Back to the top