Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » scoping/linking with relative ids
scoping/linking with relative ids [message #756329] Sat, 12 November 2011 04:10 Go to next message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
I'm building an eclipse editor for TaskJuggler. It has a 'relative id' to resolve references. Here is sample:

task global "Top middle task" {
    task bottom2 "Global SubTask"
}

task top "Top Task" {
    task middle1 "First SubTask" {
        depends !!global.bottom2  # resolves to "Global SubTask"
        task bottom1 "First SubSubTask"
    }
    task middle2 "Second SubTask" {
        task moreBottom "most bottom task" {
           task mostBottom "real bottom task" {
              depends !!!middle1.bottom1  # resolves to "First SubSubTask"
           }
        }
    }
}


The problem for me:
1) I have no idea what I am doing.

2) My scopes need to know how far they are from the reference. For example, the scope at 'top' needs to know that it is 3 steps away from 'depends' in 'mostBottom'. When linker service presents !!!middle1.bottom1 to a scope, only 'top' scope would resolve the referenced task.

3) TaskJuggler has import feature; I didn't want to implement scopes in a way that prevented me from using xtext's import solution.

I'm not at all sure I solved this in the right way. I would like to pass this by you. This is an overview, the source code is at github.

1) I extended ImportedNamespaceAwareLocalScopeProvider to override its getScope method. My version counts the number of recursive getScope calls, each representing one step away from the reference.

2) I extended ImportNormalizer (used by ImportScope) and SelectableBasedScope so I could add a field 'steps'. My ImportNormalizer.resolve(QualifiedName relativeName) and my SelectableBasedScope.getLocalElementsByName(QualifiedName name) use 'step'. In each case, the number of '!' that appear in the QualifiedName must match the 'steps' value. 'steps' comes from the current recursion count of getScope (see 1).

3) A few other tiny stuff: a) my own qualified name provider, b) binding my ImportedNamespaceAwareLocalScopeProvider, ...

Thanks for listening.

[Updated on: Sat, 12 November 2011 04:14]

Report message to a moderator

Re: scoping/linking with relative ids [message #756866 is a reply to message #756329] Tue, 15 November 2011 11:44 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
@1: I beg to differ: seems to me like you pretty well know what you're doing Wink Seems to be a good solution to me - if there's a better one, Sven c.s. would've told you in the meantime...

Re: scoping/linking with relative ids [message #757376 is a reply to message #756866] Fri, 18 November 2011 04:11 Go to previous message
John J. Franey is currently offline John J. FraneyFriend
Messages: 55
Registered: July 2009
Member
Thanks.
Previous Topic:update site for Xdoc
Next Topic:Create new file wizard in context project menu -> new
Goto Forum:
  


Current Time: Fri Apr 19 16:07:41 GMT 2024

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

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

Back to the top