Skip to main content



      Home
Home » Modeling » EMF » [EMF Query 2]Parameter in XText query
[EMF Query 2]Parameter in XText query [message #651824] Tue, 01 February 2011 12:46 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
[SOLVED]Re: [EMF Query 2]Parameter in XText query [message #652133 is a reply to message #651824] Wed, 02 February 2011 13:16 Go to previous message
Eclipse UserFriend
Nice,
I understand (even if I can't manage to test it for now)

For other: you need to use '?' in the query and use public static Query transform(MQLquery query, Object[] replacableValues)
Previous Topic:[CDO] NPEx when setLayoutConstraint on GMF editors
Next Topic:[EMF Query 2]Strange stacktrace at shutdown
Goto Forum:
  


Current Time: Wed Jul 23 05:11:17 EDT 2025

Powered by FUDForum. Page generated in 0.27825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top