custom aspects: accessing aspect source language

The custom aspects implemented in 3.3 is nice, and the cookbook is pretty good to show how to access the runtime of the a new custom aspect.

I am wondering how to access root nodes of the aspect from other aspects. For instance, in the editor, I want to reference root nodes defined in a custom aspect of the same language.
How would I get a reference to the source of the custom aspect, not its runtime?

More specifically, I have:

Language
- editor aspect
    editor cell model
     here I need to reference R1. Not sure how to write the scope to show only root nodes of a certain kind in the custom aspect.

- custom aspect
   Root node R1
5 comments
For now, there's only a primitive way:
editorModel.getModule().getModels().where(it.isAspectModel(YourAspect)).selectMany(it.roots<aspectConcept>)
prettyPrint();
Surely it needs and will be improved further.

Regards,
Mihail
0
Thanks for the pointer Mihail. I am trying to do this inside a constraint aspect or behavior of a language that extends the editor language (EditorCellModel sub-concept). When I try the code fragment you suggested, I am not able to do this:

this.model.module.model.where({~it =>
it. isAspectModel unknown here.
model m = it.<operation>; });

I reach a point where isAspectModel is not defined on the model. I see isAspectModel on an object of type model, but what the iterator is is not that and a cast does not seem possible.

It appears that the iterator is a ModelReference instance, and I am not sure how to resolve the reference to a model.
0
Maybe he meant LanguageAspectSupport.isAspectModel(model)?
This class also contains another useful method:

LanguageAspectSupport.getAspectModels(module)
prettyPrint();
0

> The custom aspects implemented in 3.3 is nice, and the cookbook is pretty good to show how to access the runtime of the a new custom aspect.

 

Can someone please direct me to any documentation about these custom aspects?

Greatest thanks in advance!

 

P.S.

Do I understand it right, that this feature allows me to declare "an aspect" in my language, so users later can create "models of this aspect" in their solutions, when using my language?

It would be awesome.

0

Yes, custom aspects extend the language definition capabilities the way you describe.

I think you are looking for https://confluence.jetbrains.com/display/MPSD33/Custom+Aspect and https://confluence.jetbrains.com/display/MPSD33/Custom+language+aspect+cookbook

Vaclav

 

 

0

Please sign in to leave a comment.