- Mihail Muhin
- 01/15/10
Igor,
You can go to module properties-> model roots. For every model root, a "manager" class can be specified. It is used for storing/reading models (look at solutions MPS.Classpath and JDK).
But this functionality will be deprecated, because it was introduced for our internal purposes and is very hard to use. We are working now on re-implementing it as MPS language aspect (so that every language could have a kind of "persistence" aspect). There is a chance that it will be available in version 1.2.
Regards,
Mihail
- Igor Karpov
- 01/18/10
I'm trying to implement my own persistence adapter, and something is apparently missing in my code.
Could you help me out, please?
Let's say my language is:
concept Person:
property root: true
child others: PersonReference 0..n
concept PersonReference
reference person: Person 1
So, I've implemented a simple ModelRootManager that should create the SModel programmatically.
This ModelRootManage, I think, I can use the generated classes for my language.
Then, in the method loadModel, I am constructing the SModel, and populate it with my data.
I use generated methods Person.newInstance(), PersonReference.newInstance(), addOthers(Person)
Finally, I add all Person instances as roots to the model:
sModel.addRoot(person).
That seems to work, but not very good.
First, as I use generated classes in my ModelRootManager, I must tell MPS to use them for my solution.
I've tried adding the reference to generated classes directory to Solution Properties|Classpath, but MPS doesn't find classes when loading the solution.
The solution uses my language, also.
So I've added the reference to generated classes right into mps.bat (I guess it's bad..)
MPS was able to load the solution, and I can see Persons, each with references to other persons, but these references are red cells.
However, I'm able to navigate thru these references. Searching for references to given Person does not find anything, however.
Could you advise, how do I specify the classpath to use with my solution in this case? Hopefully, it will solve the problem with red cell and search.
Thanks.
- Mihail Muhin
- 01/18/10
Igor,
MPS 1.1 loads ModelRootManagers with system classloader, so there's no "correct" way to use classes, that are not inside of MPS in your MRM (if they are not found in system classpath, MPS will not be able to load them). The situation will be fixed in the release that will contain custom persistence feature.
I think that red references is not the same problem. If you could send me your project, I would take a look at it and try to help you with this.
Sincerely,
Mihail
- Mihail Muhin
- 01/18/10
- Igor Karpov
- 01/18/10
I've attached my project
| myproject.zip ( 0B ) |
- Mihail Muhin
- 01/19/10
Igor,
This happens because you create not valid model - modelId for it is not specified.
For this code to work, create your model like this:
SModelReference modelReference = new SModelReference(new SModelFqName("persons", ""), SModelId.generate());
After this change, it works well.
The code that shows error is here:
jetbrains.mps.lang.editor.cellProviders.AbstractReferentCellProvider#createCell_internal
Regards,
Mihail
- Igor Karpov
- 01/19/10
It helped, thanks!
I suspected that SModel is bad, but I don't know how to use it yet.
One thing that still does not work is search. Do you have any idea why is it not working?
- Mihail Muhin
- 01/19/10
One more remark - when you'll use it in real project, model id should be the same on diffirent loads (because it is used in MPS references).
Mihail