Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportUri and scoping(ImportUri and scoping)
ImportUri and scoping [message #1008374] Tue, 12 February 2013 08:29 Go to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 48
Registered: May 2011
Member
Hi All,

I got some problems with using importuri.

As per the documentation , i understand the scoping.

Anyway let me explain my problem.

1. MyDsl looks somewhat like this.

SI:
include+=Include*
types+=Type*
enums+=Enum*
consts+=Constant*

Include : 'include' importuri=STRING;

Type : 'type' name=ID '{'
'}';

Enum : 'enum' name=ID '{'
'}';

Constant: 'const' name=ID type=[TypeOrEnum] defaultValue=STRING;

TypeOrEnum : Type | Enum;

2. Now I have
test1.dsl
type type1 {
}

type type2 {
}

enum enum1 {
}

test2.dsl
include "test1.dsl"
const PI type1 "3.14"
The above line is not resolved as type1 is not visible.

3. After reading some posts, I came to know about ImportUriScoping.
So i changed the workflow as shown
before:
// scoping and exporting API
// fragment = scoping.ImportURIScopingFragment {}
// fragment = exporting.SimpleNamesFragment {}

// scoping and exporting API
fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.QualifiedNamesFragment {}
fragment = builder.BuilderIntegrationFragment {}
Now:
I changed to
// scoping and exporting API
fragment = scoping.ImportURIScopingFragment {}
fragment = exporting.SimpleNamesFragment {}

// scoping and exporting API
//fragment = scoping.ImportNamespacesScopingFragment {}
//fragment = exporting.QualifiedNamesFragment {}
//fragment = builder.BuilderIntegrationFragment {}
After doing the above change , now i am able to see type1 in the content assist.

But the problem is i am able to see all the types/ enums which are present in the files
i.e test3.dsl can also access type1 but it is not being imported at all.
why this behaviour.

In this case it is so weird, i also get some errors telling type1 is not resolved, not in red indicator, instead in grey color

So what should i do inorder to get only the types of imported files available??

Thanks in advance
Re: ImportUri and scoping [message #1008515 is a reply to message #1008374] Tue, 12 February 2013 19:34 Go to previous messageGo to next message
Hao Xie is currently offline Hao XieFriend
Messages: 68
Registered: January 2013
Member
You may want to try with

fragment = exporting.QualifiedNamesFragment {}
Re: ImportUri and scoping [message #1009009 is a reply to message #1008515] Thu, 14 February 2013 09:42 Go to previous messageGo to next message
Girish Kumar is currently offline Girish KumarFriend
Messages: 48
Registered: May 2011
Member
No it doesn't works..
Re: ImportUri and scoping [message #1010762 is a reply to message #1008374] Mon, 18 February 2013 07:43 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
1) 'importURI' is case sensitive. Naming a the property 'importuri' will
not have any effect.
2) What does test3 import?

Am 12.02.13 09:29, schrieb Girish Kumar:
> Hi All,
>
> I got some problems with using importuri.
>
> As per the documentation , i understand the scoping.
>
> Anyway let me explain my problem.
>
> 1. MyDsl looks somewhat like this.
>
> SI:
> include+=Include*
> types+=Type*
> enums+=Enum*
> consts+=Constant*
>
> Include : 'include' importuri=STRING;
>
> Type : 'type' name=ID '{'
> '}';
>
> Enum : 'enum' name=ID '{'
> '}';
>
> Constant: 'const' name=ID type=[TypeOrEnum] defaultValue=STRING;
>
> TypeOrEnum : Type | Enum;
>
> 2. Now I have test1.dsl
> type type1 {
> }
>
> type type2 {
> }
>
> enum enum1 {
> }
>
> test2.dsl
> include "test1.dsl"
> const PI type1 "3.14"
> The above line is not resolved as type1 is not visible.
>
> 3. After reading some posts, I came to know about ImportUriScoping.
> So i changed the workflow as shown
> before:
> // scoping and exporting API
> // fragment = scoping.ImportURIScopingFragment {}
> // fragment = exporting.SimpleNamesFragment {}
> // scoping and exporting API fragment =
> scoping.ImportNamespacesScopingFragment {}
> fragment = exporting.QualifiedNamesFragment {}
> fragment = builder.BuilderIntegrationFragment {}
> Now:
> I changed to // scoping and exporting API
> fragment = scoping.ImportURIScopingFragment {}
> fragment = exporting.SimpleNamesFragment {}
> // scoping and exporting API //fragment =
> scoping.ImportNamespacesScopingFragment {}
> //fragment = exporting.QualifiedNamesFragment {}
> //fragment = builder.BuilderIntegrationFragment {}
> After doing the above change , now i am able to see type1 in the content
> assist.
>
> But the problem is i am able to see all the types/ enums which are
> present in the files
> i.e test3.dsl can also access type1 but it is not being imported at all.
> why this behaviour.
>
> In this case it is so weird, i also get some errors telling type1 is not
> resolved, not in red indicator, instead in grey color
>
> So what should i do inorder to get only the types of imported files
> available??
>
> Thanks in advance


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


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Node model reconciler and editing domain
Next Topic:XMI resource to xText resource
Goto Forum:
  


Current Time: Thu Apr 18 08:05:46 GMT 2024

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

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

Back to the top