In MPS contstrain means only properties with custom getter/setter methods. So if you want to restrict certain names for a property you have impelement it in the way that allows only values that you want to be set.
If you understood it right try to check whether you generate it (it has to be generated), whether it is called by mps.
for your search scope constraint try something like this:
1. set "can create" section to default (delete code in it)
2. in "create section" write something like this:
*
snode < A > a = enclosingNode . parent < + , concept= A > ;
snodes < BUI > bs = a . BUI ;
if ( bs . isEmpty ( ) ) {
return new EmptySearchScope ( ) ;
}
ISearchScope searchScope = new ( bs . get ( 0 ) ) ;
for ( snode < BUI > b : bs ) {
searchScope . append ( new SubnodesSearchScope ( b . B ) ) ;
}
return searchScope ;
follow please my explanation by lines of code:
1) first, you should find an instance of A, where everything lives . it's the first ancestor of your node which is an instance of concept A.
2) second, collect all BUIs in that A.
3-5) if no BUIs found return an empty scope
6) create a search scope with a single node which has no children (you can choose just any node without children. It's just not to create scope with null node, to avoid NPE. Unfortunalely, in current build you can't successfully attach to EmptySearchScope, as well as create SubnodesSearchScope with null argument).
7-9) for every BUI collected, take it's B and create new SubnodesSearchScope from it. Attach this new scope to our searchScope.
Cyrill made a mistake you have to enter new SubnodesSearchScope(bs.get(0)).
To enter for (x : y) you have to select foreach item in completion menu and choose it. If you choose regular for you'll have regular for in form for (init; cond; iter).
In MPS contstrain means only properties with custom getter/setter methods. So if you want to restrict certain names for a property you have impelement it in the way that allows only values that you want to be set.
If you understood it right try to check whether you generate it (it has to be generated), whether it is called by mps.
I copied one to my project from "agreementLanguage",and changed it's properties and contents.
How to generate it?And how to call it?
To generate it right click on its tree node select generate -> files and wait until it is generated.
And how to call it?
It'll be called when you change a property that is constrained by your constraint for example you can do it in editor.
I tried many times and didn't succeed
The attachment is an simple example:
I want to realise this:
In a solution of A, I choose B1 for B, and in popup menue for C, there is only C1,C2,C3 coming up.
And if I choose B1,B2 for B,(C1,C2,C3,C4,C5,C6 ) is showed. But now there's nothing in the popup menue.
Could you please check it and point out my mistakes?
Thank you in advance,Sir.
Attachment(s):
constrain.rar
for your search scope constraint try something like this:
1. set "can create" section to default (delete code in it)
2. in "create section" write something like this:
*
snode < A > a = enclosingNode . parent < + , concept= A > ;
snodes < BUI > bs = a . BUI ;
if ( bs . isEmpty ( ) ) {
return new EmptySearchScope ( ) ;
}
ISearchScope searchScope = new ( bs . get ( 0 ) ) ;
for ( snode < BUI > b : bs ) {
searchScope . append ( new SubnodesSearchScope ( b . B ) ) ;
}
return searchScope ;
follow please my explanation by lines of code:
1) first, you should find an instance of A, where everything lives . it's the first ancestor of your node which is an instance of concept A.
2) second, collect all BUIs in that A.
3-5) if no BUIs found return an empty scope
6) create a search scope with a single node which has no children (you can choose just any node without children. It's just not to create scope with null node, to avoid NPE. Unfortunalely, in current build you can't successfully attach to EmptySearchScope, as well as create SubnodesSearchScope with null argument).
7-9) for every BUI collected, take it's B and create new SubnodesSearchScope from it. Attach this new scope to our searchScope.
10) return searchScope
Message was edited by:
Cyril Konopko
But how to input
"new ( bs . get ( 0 ) )" and "for ( snode < BUI > b : bs ) " ?
Cyrill made a mistake you have to enter new SubnodesSearchScope(bs.get(0)).
To enter for (x : y) you have to select foreach item in completion menu and choose it. If you choose regular for you'll have regular for in form for (init; cond; iter).
There is still a red wave line below "b.B",but it works.
Our current version of type system unfortunately doesn't completely support generics.