Can't figure out MPS error: "Child in the role X.Y does not belong to the concept X"

236 Views Asked by At

I'm new to MPS, so this may be a stupid question, but I can't find a solution anywhere.

I'm defining two DSLs, where the first one is going to depend on the second.
I've defined a portion of the first language and so far so good.
I have a bunch of Concepts going, some Editors, Constraints etc.

I've created a model with an example node where I view what I've made.

Now I'm working on the second language and I went about exactly the same way as with the first.
I created a Concept that can be root. It's called 'Module'.
Then I defined an Interface Concept, called 'IModuleContent' and gave it to 'Module' as a child, calling it 'content' and setting the cardinality to [0..n].
Then I defined another Concept called 'Interface' that inherits from 'IModuleContent'. I gave the two Concepts Editors, which are basically just curly brackets for now.
In my example model I create a new node from my new language. It gives me my root, a 'Module'. Because it's a named concept I give it a name. Then, inside the module's curly brackets I declare a new 'Interface'.
Together, it looks like this:

Module printeri {
  Interface printer {
  }
}

This all pretty much works, except that after giving 'Module' an instance of 'Interface' (so 'printer') as a variable, it gets underlined in red and the error reads:

"Child in the role Module.content does not belong to the concept Module"

However, I'm pretty sure that it does. All the concepts are in the structure of the new language and I believe everything is inherited the right way. I did practically the same thing in my first language and that works fine.
What's going on here?

EDIT: should have specified that I'm on version 2020.3

2

There are 2 best solutions below

0
On BEST ANSWER

you can goto "File -> Invalidate Caches and Restart" if you think MPS behaves strange. For me it looks like you did some changes, e.g. creating the "Module" node in youre examples and then change the structure like removing "content"-child and re-adding it. The problem here is that MPS does not resolves id-based and not name-based. By removing and re-adding a member definition you change the id. MPS is able to handle such changes in to a certain degree, e.g. by just pressing "F5" to refresh the editor. You can also click on the node and open the intentions menu via "ALT+ENTER" investigate the options suggested there.

Hope this background knowledge helps you a little bit with future problems :)

Best regards Heiko

there seems to be a bug in the comment feature here, hi removes the "Hi Noah"

0
On

Okay, so it seems that the error has magically disappeared overnight.

Yesterday I closed MPS for the day and opened it again this morning.
Code completion wasn't working. Very annoying. So I restarted MPS.

On the second try code completion was working and the error from before was gone.
It seems like MPS may be a little unstable.

So yeah, for anyone running into the same issue:
Try the good old 'turn it off and on again' method.