How to filter concepts in the comletion menu?


I'm just starting to learn MPS. I apologize if this is a repeated question.

I have a concept of "Table":

concept Table extends BaseConcept
attribute: Attribute[0..n];

where Attribute

concept Attribute extends BaseConcept

type: IBaseType[1]


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

Comment actions Permalink
Official 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.




Comment actions Permalink

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.



Comment actions Permalink

Thanks to your support, my question is solved). Thanks

Comment actions Permalink

I'm trying to do about same, but fail.


CountryReference has country:Country[1]

concept ProductOfferingPriceUsageFilter extends BaseConcept 
countries : CountryReference[0..n]

I want to filter suggested countries in completion window to those not already referenced from ProductOfferingPriceUsageFilter.

I've read this, and tried this:

concepts constraints Country { 
can be child (node, parentNode, childConcept, link)->boolean {

But still every Country available in the model pop up

Comment actions Permalink

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:

Comment actions Permalink

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.

concepts constraints CountryReference { 
link {country}
referent set handler <none>
scope (referenceNode, contextNode, containmentLink, position, linkTarget)->Scope {
sequence<node<Country>> available = contextNode.model.nodes(Country).where({~candidate =>
contextNode as ProductOfferingPriceUsageFilter.countries.findFirst({~exist => :eq: candidate;

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?


Please sign in to leave a comment.