Boolean properties and queries
I've extended TheSimplestConcept by a new property "bold : boolean". In my
HelloWorldConsole ClassConcept the main method looks like this:
StringBuffer buffer = new StringBuffer ( ) ;
if ( true ) {
buffer . append ( " * " ) ;
}
System . out . println ( buffer . toString ( ) ) ;
Now I place the caret in the "true" (BTW, the caret should disappear, when
the focus is somewhere else) and press Ctrl-Shift-M, in the occuring context
menu I select "add/remove property macro". In the Inspector I press
Ctrl-Space, select "New query method" and enter the query method ID "bold".
This creates following new method in Queries.java:
public static String propertyMacro_bold(SNode sourceNode,
SNode templateNode,
PropertyDeclaration property,
ITemplateGenerator generator) { }
Unfortunately this returns String instead of the expected boolean, so I
can't simply use that code:
return ((TheSimplestConcept)sourceNode).getBold();
How should I create a boolean query the right way?
Tom
Please sign in to leave a comment.
hi,
for boolean query return "true" or "false"
for integer query return string as "0", "234" etc.
igor
have submitted request regarding caret
http://www.jetbrains.net/jira/browse/MPS-568
igor.