Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Scope & Type Hierarchy
Scope & Type Hierarchy [message #1517341] Fri, 19 December 2014 07:34 Go to next message
Eclipse UserFriend
My main problem is to understand how to (properly) integrate the index, the type hierarchy and scopes in my dsl.
(I have classes, multiple inheritance and a type hierarchy distributed over several resources)

I found several examples by Lorenzo Bettini (and in his book), but unless I am very mistaken those start a parsing process?

Now I am not violently opposed to parse the super type hierarchy and then putting it all into IResourceScopeCache s, but it feels clunky.

Currently I think of creating a custom IEObjectDescription implementation that contains a field like;
QualifiedName[] supertypes;

Basically is there some reference implementation / example / documentation /strategy of how to do this?

[Updated on: Fri, 19 December 2014 07:37] by Moderator

Re: Scope & Type Hierarchy [message #1517358 is a reply to message #1517341] Fri, 19 December 2014 07:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

is there a specific reason to optimize this?
yes if you simply follow refereces then (all) involved files will be parsed.
unfortunately you give very very very few information on your dsl.

the first question to answer: is it possible to determine the name of the direct supertype of a class by simply having a look at the text of the type
either you have only simple names or dont use imports.
if so it it possible, if not - no chance
the basic idea:

customize IDefaultResourceDescriptionStrategy to put the parents qualified name(s) to the use data map of the EObjectDescription.

then ihe scoping would query (recursively) the index to find out the transitive closure of all supertypes.



[Updated on: Fri, 19 December 2014 07:54] by Moderator

Re: Scope & Type Hierarchy [message #1517449 is a reply to message #1517358] Fri, 19 December 2014 09:01 Go to previous messageGo to next message
Eclipse UserFriend
As for the reason, my dsl can also specify instances.

So a possible scenario might be 100 class declarations, 100 interface declarations and 200 enumeration declarations and >10000 (generated/exported) instance/object declarations, distributed over several files / projects.

class x {}
class y extends x {
  attr x : Int;
  assoc father: y;
}
object yyy_000001 instanceof y {
  attr x = 4;
}
object xyyx_0000014 instanceof y {
  father = yyy_000001;
}


Finding the supertype(s) of something is not really a problem.

Quote:

customize IDefaultResourceDescriptionStrategy to put the parents qualified name(s) to the use data map of the EObjectDescription.

then the scoping would query (recursively) the index to find out the transitive closure of all supertypes.


Thank you, mostly I thought that it might be possible to use the IContainer.getExportedObjectsByObject or some similar existing mechanism for some magic along this line

Scope scope_ClassDeclaration(ClassDeclaration decl )
{
   Scope superscope = Scope.Empty
   for( URI supertype : decl.supertypes )
      superscope.union( ?cache?.getScope( supertype )  )
   return superscope.shadowedBy( decl.members )
}


[Updated on: Fri, 19 December 2014 09:10] by Moderator

Re: Scope & Type Hierarchy [message #1517455 is a reply to message #1517449] Fri, 19 December 2014 09:07 Go to previous message
Eclipse UserFriend
yes you can use the index to get all exportet obejcts at this place,
but you have to traverse these and find suitable cases

but if you need the scope for fields anyway this wont help
because then you would have to add the info which field is in which type to the index as well.
Previous Topic:How to create an XML schema for my grammar
Next Topic:Custom persistence with Xtext
Goto Forum:
  


Current Time: Tue Oct 28 02:23:03 EDT 2025

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

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

Back to the top