|
|
|
|
|
Re: Need hover for keyword or block of elements [message #988355 is a reply to message #988345] |
Thu, 29 November 2012 09:49   |
Eclipse User |
|
|
|
Am 29.11.12 14:44, schrieb Aaron Digulla:
> Henrik Lindberg wrote on Thu, 29 November 2012 03:57
>> On 2012-28-11 22:45, Aaron Digulla wrote:
>> > No, the hover building code of Xtext is never called when the mouse is
>> > over a keyword.
>> You can specify for which grammar elements the logic is triggered.
>
>
> hasHover() is not called for elements of type org.eclipse.xtext.Keyword
> - they aren't part of the model. So your code sample doesn't help :(
Hi Aaron,
did you try to set a breakpoint on
DispatchingEObjectTextHover.getHoverInfo(EObject, ITextViewer, IRegion)
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
|
|
Re: Need hover for keyword or block of elements [message #988376 is a reply to message #988371] |
Thu, 29 November 2012 11:25   |
Eclipse User |
|
|
|
On 2012-29-11 17:03, Aaron Digulla wrote:
> Sebastian Zarnekow wrote on Thu, 29 November 2012 15:49
>> did you try to set a breakpoint on
>> DispatchingEObjectTextHover.getHoverInfo(EObject, ITextViewer, IRegion)
>
>
> Yes, it never gets there. In fact,
>
> org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover.getHoverInfo2(ITextViewer,
> IRegion)
>
> isn't called because
>
> org.eclipse.xtext.ui.editor.hover.AbstractEObjectHover.getXtextElementAt(XtextResource,
> int)
>
> returns null for keywords (they don't have a related EObject in the model).
>
>
Actually, the problem is that a check is made if the mouse pointer is in
a position that is inside the region returned by
LocationInFileProvider.getSignificantTextRegion(o). It finds the EObject
as it should.
The significantTextRegion is the region is used in several places to
figure out the "target to link to and highlight". So, solving the issue
by including the keyword in the significant region may lead to
undesirable effects elsewhere (i.e. you want to only select the "name"
or similar ID).
Seems like there is an abstraction missing for hovers.
Fix would be to override and bind your own version of
org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover#getXtextElementAt
And make use of the ILocationInFileProviderExtension interface and ask
for the full region instead of only the significant part.
(Which I think the AbstractEObjectHover should probably do at all times
to allow discrimination of what to show hovers for easier to customize).
- henrik
|
|
|
|
|
Re: Need hover for keyword or block of elements [message #988647 is a reply to message #988631] |
Fri, 30 November 2012 15:35   |
Eclipse User |
|
|
|
It may be worthwile to specialize #getSignificantRegion for your
language if you consider the keyword 'options' to be the significant,
identifying token of your model instance.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 30.11.12 19:16, schrieb Henrik Lindberg:
> On 2012-30-11 17:53, Aaron Digulla wrote:
>> Henrik, can you please open an issue on bugzilla? I'm not deep enough in
>> Xtext to understand everything that you said. :)
>>
>> Ideally, the end result should allow me to create a hover when the mouse
>> is anywhere over
>>
>> options {
>>
>> i.e. the two keywords and the space between them.
>>
>> Thanks!
> You can easily try this out.
> Make a copy of/derive a class from:
> org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover
>
> (don't remember exactly what that class looked like).
> Override #getXtextElementAt method. Instead of asking for the
> "significant region" from the provider, check if this provider
> implements the extended interface I mentioned, if so, you can ask for
> the entire object's region instead of just the "significant" portion.
>
> Then, you bind your specialized DispatchingEObjectTextHover as a
> replacement for what is now bound.
>
> - henrik
|
|
|
Re: Need hover for keyword or block of elements [message #988674 is a reply to message #988647] |
Fri, 30 November 2012 19:43  |
Eclipse User |
|
|
|
On 2012-30-11 21:35, Sebastian Zarnekow wrote:
> It may be worthwile to specialize #getSignificantRegion for your
> language if you consider the keyword 'options' to be the significant,
> identifying token of your model instance.
>
> Regards,
> Sebastian
That too of course, but you may not always want to have everything be
the "significant portion" even if you want that for hovers.
A good way could be to implement your own anyway, and provide both the
significant region (the name of id or whatever), as well as the
additional regions specified by the extended interface.
(that is if I got the intent of the extended interface right :)
Regards
- henrik
|
|
|
Powered by
FUDForum. Page generated in 0.27667 seconds