Setting a scope for children of a node


I want to set the outer scope in which I can see references to some nodes. If I understand the scopes tutorial correctly, overriding the getScope() method changes the scope of the node it's defined in. But what I want to do is that every children I declare for the node should only be visible inside the node (and other children of the node), and not outside of it. Example: in the image below x and y are visible everywhere, but I want to set it so that they are only visible in their parent (so in this case, only in the line above the cursor).


To clarify, my structure is as below. I want x and y to only be visible in the "all quantified statement" concept which contains these variables, and nowhere else.



Well, this is up to the getScope() method in a ScopeProvider that wraps your "term equals atomic statement" to not add these variables to the scope.

To clarify, the ScopeProvider wrapping the "references" is what matters. If no ancestor ScopeProvider is found for a reference, all variables are added to the scope.


Thanks! I did it!

The Scopes tutorial did tell me all I needed to know in the end, but your comment helped me understand the base concept, and then it was smooth sailing from there.

So what I did: I made my Sheet concept a ScopeProvider, and added my constants & functions & predicates (which are globally declared before usage) to the scope:



(This also solved my problem of references visible from another sheet, which I haven't tried fixing yet)

Then I set a referent constraint for my reference concept so that its scope is inherited (like the scopes tutorial tells you to), and finally I changed my AQuantifiedStatement to "enrich" the parent scope:



Thank you!


I'm happy to hear that you succeeded!




Please sign in to leave a comment.