Why does my custom scope not work?
Hi,
so I'm trying to implement some scoping (like in the MPS Calculator example - my XXXReference also is of type Expression, so it's merely the same). However, now I'm fighting against the annoying problem, that MPS always takes any kind of expression, available in the scope of my solution, as a possible candidate for a reference, but I do not want that! So I tried to solve it using inherited scope, reference scope and also the deprecated variant search scope. I was able to include my own stuff in the drop down menu for referencing, however, MPS won't let me remove the other stuff it puts in the drop down menu (which should not be there). Currently, my assumption is that reference scope kinda should allow me to build up the scope from scratch, as I only return the scope I created, and search scope joins a default scope (from where?) with the one I created. Am I right or totally off track? Or isn't there any way to somehow remove such existing, other Expression from the drop down menu? I also tried to constrain it with can be parent, which actually also did not work (still all kinds of Expression possible).
More specific:
I have a concept Operation which itself has Parameters (another concept). An operation may by annotated with Pre-/Postconditions (own concepts extending NodeAttribute). Each Pre-/Postcondition has one child of type Expression. And it's exactly inside this expression where I only want to refer to the parameters of the operation the pre-/postcondition is annotating, but nothing else.
Any ideas or hints?
Thanks in advance,
phil
so I'm trying to implement some scoping (like in the MPS Calculator example - my XXXReference also is of type Expression, so it's merely the same). However, now I'm fighting against the annoying problem, that MPS always takes any kind of expression, available in the scope of my solution, as a possible candidate for a reference, but I do not want that! So I tried to solve it using inherited scope, reference scope and also the deprecated variant search scope. I was able to include my own stuff in the drop down menu for referencing, however, MPS won't let me remove the other stuff it puts in the drop down menu (which should not be there). Currently, my assumption is that reference scope kinda should allow me to build up the scope from scratch, as I only return the scope I created, and search scope joins a default scope (from where?) with the one I created. Am I right or totally off track? Or isn't there any way to somehow remove such existing, other Expression from the drop down menu? I also tried to constrain it with can be parent, which actually also did not work (still all kinds of Expression possible).
More specific:
I have a concept Operation which itself has Parameters (another concept). An operation may by annotated with Pre-/Postconditions (own concepts extending NodeAttribute). Each Pre-/Postcondition has one child of type Expression. And it's exactly inside this expression where I only want to refer to the parameters of the operation the pre-/postcondition is annotating, but nothing else.
Any ideas or hints?
Thanks in advance,
phil
Please sign in to leave a comment.
but first, what has substituting to do with creating references?
suppose I have a concept named A and a concept enabling references to this concept A, named AReference. Now why does MPS generate a method signature (sorry for calling it that way, but I don't know how to else call it) that looks like ...->join(ISearchScope | sequence<node<AReference>>) if using 'search scope (I know it's deprecated, but nevertheless, I think it still should work). Should the signature look like something ...->join(ISearchScope | sequence<node<A>>)'', as I want to reference instances of concept A and not references to instances of concept A. I'm a little baffled right now.
The concept constraint for AReference has to look like this:
Can you try to be more specific while describing your problem or m.b. you can share sample project with us to ensure we are solving the problem you have.
SimpleRoleScope.forNamedElements(contextNode.ancestor<concept = Operation>.parameterList, link/ParameterList : parameters/);
which in the should end only contain the parameters of the oepration where a condition is added, but nothing else - however, this does not happen. I always see all kinds of JDK types, my own Classes and so on...it's just, I want to remove that stuff and I don't get why MPS puts it all there, also I specifically define the scope contents with the above expression.
There are two ways to remove these entries. You can forbid instances of AbstractClassifierReference inside your pre/postcondition by defining a can be ancestor constraint for your pre/postcondition. The otherway is to use Node Substitute Actions, as I already mentioned.