Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » no content assist proposal for XExpression
no content assist proposal for XExpression [message #1451287] Thu, 23 October 2014 16:01 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in one of our Xbase based DSL we have this rule

Specification:
parameterType=JvmTypeReference
'->'
expression = XExpression
;

which the inferrer transforms into a method

specification.toMethod(methodName, returnType) [
parameters += specification.toParameter(
"it", specification.parameterType
)
body = specification.expression
]

and everything works, e.g.,

EClass -> name

the problems are in the content assist, since

EClass -> { <get proposals here, including "name"

but

EClass -> <no proposals but keywords

Since the XExpression is still null (while in the first case you have an
XBlockExpression), the Xbase proposal provider cannot resolve any type
(from what I understand with debugging). It used to work instead in
older versions of Xtext (at least in 2.4, where the Xbase's typesystem
hadn't changed yet).

Something similar happens in the "template" language from the 7 language
examples, e.g., with this input

<!--«
param title = "No Title"
param author = "No Author"
param description = "No Description"
param other = { < here you get proposals for title, author, etc.

but

<!--«
param title = "No Title"
param author = "No Author"
param description = "No Description"
param other = < no proposals but keywords

any suggestion on how to fix this? Or can it be considered a bug?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: no content assist proposal for XExpression [message #1451300 is a reply to message #1451287] Thu, 23 October 2014 16:22 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3101
Registered: July 2009
Senior Member
Hi Lorenzo,

looks like this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=446408

Could you please add your finding there?

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: no content assist proposal for XExpression [message #1451309 is a reply to message #1451300] Thu, 23 October 2014 16:42 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 23/10/2014 18:22, Sebastian Zarnekow wrote:
> Hi Lorenzo,
>
> looks like this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=446408
>
> Could you please add your finding there?
>

Hi Sebastian

I guess the problem is not that the XExpression is mandatory, but the
fact that it is an XExpression and not an XBlockExpression. I added my
findings there, hope that helps :)

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: no content assist proposal for XExpression [message #1451410 is a reply to message #1451309] Thu, 23 October 2014 19:50 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3101
Registered: July 2009
Senior Member
Hi Lorenzo,

I don't think that it's related to the optional syntax, too. It's just
that the parser will not have created an expression thus the type
computation was not done for that location which in turn will lead to an
empty scope for the particular method (that doesn't have a body yet). If
you use the block expression, the parser will create an instance after
the { was seen thus a scope was recorded.
We'll see what can be done about it.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: no content assist proposal for XExpression [message #1731560 is a reply to message #1451410] Fri, 06 May 2016 19:10 Go to previous message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Glad I found this.

I have the same problem.

Is there any new advice for handling this?

I have "faked it" for some entries in my grammar, by adding bits to grammar rules which "force" the parser down a certain path:

e.g.
Specification:
   parameterType=JvmTypeReference
   expression = SpecificationExpression
;

// uses XBlockExpression for context and content assist
SpecificationExpression returns xbase::XBlockExpression: 
   {xbase::XBlockExpression}

   // Move the literal constant here to "force" into the rule  
   '->'

   // only supports a single expression
   'expressions+=XExpression
;


However, I have cases where I can't use this trick since there is no applicable literal, such as:


PropertyDefinition:
   'property' name=ID type=JvmTypeReference
;

// Rule which should get content assist, but doesn't
PropretyReference:
   property=[PropertyDefinition] expression=PropertyReferenceExpression
;

// Attempt to use the trick from above without a literal
PropertyReferenceExpression returns xbase::XBlockExpression: 
   {xbase::XBlockExpression}
   expressions+=XExpression
;


Unfortunately, without the literal to force the building of the expression, this trick doesn't work.

Any advice for handling this?

Thanks yet again!

Previous Topic:Xtext grammar
Next Topic:Check if EObject is fully parsed
Goto Forum:
  


Current Time: Fri Nov 15 03:26:06 GMT 2019

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

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

Back to the top