[EMF Query 2]Parameter in XText query [message #651824] |
Tue, 01 February 2011 12:46  |
Eclipse User |
|
|
|
Hi,
I would like to have a parameter in the query that I wrote using Xtext.
For instance in my .query file:
smyQueryName:
from XXX as xxx
in resources{${myVariable}}
select xxx
I would like to replace ${myVariable} by the URI of the resource
Regards,
|
|
|
Re: [EMF Query 2]Parameter in XText query [message #651921 is a reply to message #651824] |
Wed, 02 February 2011 00:04   |
Eclipse User |
|
|
|
HI Aurelien,
Answers below
Aurelien Pupier wrote on Tue, 01 February 2011 12:46 | Hi,
I would like to have a parameter in the query that I wrote using Xtext.
For instance in my .query file:
smyQueryName:
from XXX as xxx
in resources{${myVariable}}
select xxx
I would like to replace ${myVariable} by the URI of the resource
Regards,
|
You can pass parameter to the XText strings.
Please have a look at the org.eclipse.emf.query2.syntax.test.TestTransformation class where you can see a test method named testSelectPar2AsParameter whose query takes paramteres.
We have an API which actually transforms the XText AST to Query2 AST by accepting parameters.
/**
* For queries accepting arguments. Each ? in where clause of the query is
* replaced with object in Object[] replacableValues ? in query is replaced
* in order of element in Object[] replacableValues. User can pass values
* has following: transform(query, new Object[] { new Integer(200), new
* String(""), new Double(20.0), new Long(20000000000), new Boolean(true) }
* );
*
* @param query
* @param replacableValues
* @return {@link Query}
*/
public static Query transform(MQLquery query, Object[] replacableValues)
cheers,
Saurav
|
|
|
|
Powered by
FUDForum. Page generated in 0.27825 seconds