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

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.




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.




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


Please sign in to leave a comment.