How to filter concepts in the comletion menu?
Hello!
I'm just starting to learn MPS. I apologize if this is a repeated question.
I have a concept of "Table":
1)
concept Table extends BaseConcept
....
child:
attribute: Attribute[0..n];
2)
where Attribute
concept Attribute extends BaseConcept
child:
type: IBaseType[1]
where,
IBaseType is a interface concept. It have a virtual method isSimpleType()->bool
3) In concept Attribute I use a check to illuminate isSimpleType() = false
4) Questions: how can I filtering in comletion menu concepts
whose implementation of the method isSimpleType() return true;
I studied tutorial "calculator", understand it to use the ideas in this example, I have to change the structure of concepts?
Is there a solution for my architecture?
Thank you for your attention
Please sign in to leave a comment.
Hi Fam,
I suppose that isSimpleType() is static, so its implementations don't depend on node instance (don't use "this" expression), so you can call it on concepts.
If so, what you want to do is filter substitute menu of IBaseType.
For that you can create default menu for IBaseType and say that in that menu there will be subconcepts of IBaseType, but filtered.
See picture attached.
If you have questions, don't hesitate to ask.
Best,
Semen
Hi Fam,
One way to do it is to use a Substitution Action.
Create one for your Attribute concept.
In the condition on top, you make sure to only apply your actions to Attributes you care about (might just be all of them in your language).
Then, you have a bunch of actions to choose from (see confluence link above). If you want to prohibit certain items of your completion menu (I think in MPS it is called "substitution menu"), you would have to "remove defaults" first, i.e. removing all, and then selectively add all you want to see.
In order to call you method "isSimpleType()" you need the "add custom items". In the query, you should be able to call "isSimpleType()" on the "currentTargetNode" and return false if you want to prohibit it.
Let me know if you need some sample to get started.
Best,
Robert
Thanks to your support, my question is solved). Thanks
I'm trying to do about same, but fail.
Country
CountryReference has country:Country[1]
I want to filter suggested countries in completion window to those not already referenced from ProductOfferingPriceUsageFilter.
I've read this, and tried this:
But still every Country available in the model pop up
You are trying to restrict the target of references, not the parent-child relationship between ProductOfferingPriceUsageFilter and Countryreference. So this is a problem of scoping rather than "can be child". You need to specify the scope for CountryReference, perhaps something like this:
Vaclav Pech, thank you so much for your time and openness ;)
On CountryReference add Constraints|Concept constraints
shift-shift-shit: Add Model Import "scope" -- Scope classes became available.
Made me happy:
(No country that was referred to in POPUFilter is listed in this scope)
I feel this can be further shortened by using FilteringScope helper class. But I could not find any example of in-place overriding of methods. Is there any?