scopes

Hi I'm trying to the scopes right for my domains language. (Similar to entity example).
Domains can inherit from one another, but I want to prevent getting cyclic inheritance.

So I have set up a constraint on my Domain concept setting the constraint for the base-reference to inherited

link {base}
    referent set handler:<none>
    scope:
        search for Domein
    presentation :
        <no presentation>
;

now I'm stuck on how to implement the ScopeProvider in Domain_Behavior.

It seems that I'm missing a way to obtain the default scope for Domains. i.e. the scope taht contains all Domains in the current and imported model. If I got that, I can use a FilteringScope to exlude the current domain and all Domains that inherit from it (recursively).

A clue anyone?
5 comments
Comment actions Permalink
Hm, maybe you should not use 'inherited' but 'reference scope' in scope context menu. Then implement the abstract Scope class from model jetbrains.mps.scope (implementing getAvailableElements should be enough, I ever return null in the other methods). And you should also import the org.jetbrains.annotations model for @Nullable and @NotNull annotations.
0
Comment actions Permalink
Ok, I get that, but my problem remains that I cant think of a way to obtain
all Domains in the current and imported models. How do I get access to
those?


On Sat, Jun 15, 2013 at 11:03 PM, Jens Nerche - Meta Programming System <
jetforum@jetbrains.com> wrote:

* Meta Programming System<http://forum.jetbrains.com/forum/Meta-Programming-System>
* > * scopes<http://forum.jetbrains.com/thread/Meta-Programming-System-839>
* 5:03 pm<http://forum.jetbrains.com/thread/Meta-Programming-System-839?message=Meta-Programming-System-839-1>  Jens
Nerche <http://forum.jetbrains.com/user/jensnerche>

Hm, maybe you should not use 'inherited' but 'reference scope' in scope
context menu. Then implement the abstract Scope class from model
jetbrains.mps.scope (implementing getAvailableElements should be enough, I
ever return null in the other methods). And you should also import the
org.jetbrains.annotations model for @Nullable and @NotNull annotations.

   Gert Veldhuijzen van Zanten<http://forum.jetbrains.com/user/Gert%20Veldhuijzen%20van%20Zanten>@ Jun
14 <http://forum.jetbrains.com/thread/Meta-Programming-System-839>

Hi I'm trying to the scopes right for my domains language. (Similar to
entity example).
Domains can inherit from one another, but I want to prevent getting cyclic
inheritance.

So I have set up a constraint on my Domain concept setting the constraint
for the base-reference to inherited

link {base}
referent set handler:<none>
scope:
search for Domein
presentation :
<no presentation>
;

now I'm stuck on how to implement the ScopeProvider in Domain_Behavior.

It seems that I'm missing a way to obtain the default scope for Domains.
i.e. the scope taht contains all Domains in the current and imported model.
If I got that, I can use a FilteringScope to exlude the current domain and
all Domains that inherit from it (recursively).

A clue anyone?

  JetBrains Forum | Build #171 (Jun/07/2013 10:26AM) | Feedback<http://confluence.jetbrains.net/display/JETF/Feedback>




--
Gert Veldhuijzen van Zanten
06 - 40992488
0
Comment actions Permalink
Ok, I get that, but my problem remains that I cant think of a way to obtain all Domains in the current and imported models. How do I get access to those?
0
Comment actions Permalink
I figured it out:
It is indeed easier to use a search scope, rather than an inherited scope.
This is the code:

link {base}
    referent set handler:<none>
    scope:
        (model, exists, contextNode, contextRole, position, scope, referenceNode, linkTarget, enclosingNode, containingLink, operationContext)->Scope {
            ListScope.forNamedElements(model.rootsIncludingImported(scope , Domein).where({~it => !(isSubtype(it.type :< contextNode.type)); }));
        }
    presentation :
        <no presentation>
;

What I was missing was the use of model.rootsInclusingImported and the fact that it takes an IScope argument rather than a Scope argument.
0
Comment actions Permalink
search scope is deprecated, that's why I suggested reference scope. Your code works also with jetbrains.mps.scope.Scope.
0

Please sign in to leave a comment.