Access to parent in behaviour-constructor Follow
Hi,
I would like to generate some unique-id for a node. To do that, I want to access the parent concept in the constructor(behaviour) of a concept.
But it is null!
What to do?
I would like to generate some unique-id for a node. To do that, I want to access the parent concept in the constructor(behaviour) of a concept.
But it is null!
What to do?
Please sign in to leave a comment.
already had that idea on my own.
But the problem is, that I want to save the unique id in the model, so it doesn't change.
I tried this in the getter:
But it throws an exception. Probably I'm not allowed to change the identifier here.
(Why is there nothing red in the editor then)...
Exception:
jetbrains.mps.smodel.IllegalModelChangeError : registered node can only be modified inside undoable command or in 'loading' model [textSymbols] TextSymbol <no name>[8642124865149417439] in [...].sandbox.sandbox
Had to import plugin-language to constraints-model.
EDIT:
Another alternative is to use a node-factory.
So the question is still actual, why can't we get a reference to the parent in the constructor?
Technically, we can add a "probable" parent to the constructor. But we cannot guarantee when it will be available so it doesn't make sense.