Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Hover on keywords in nested structure does not seem to work
Hover on keywords in nested structure does not seem to work [message #1839898] Wed, 31 March 2021 08:13 Go to next message
Eclipse UserFriend
I managed to get hovers on keywords working following this tutorial: https://blogs.itemis.com/en/xtext-usability-hovers-on-keywords with a few additional changes since we do not make use of xbase classes.

One example of one of our models would look like the following:

keyword_a asdf {
    keyword_b {
        keyword_c {
             keyword_d {
             }
        }
    }
}


The hover implementation from the previously mentioned blog post only works for us until keyword_b. When hovering over keyword_c or keyword_d is not triggered, it does not call the hoverText() method:
    def hoverText(Keyword k) {
        val result = switch (k) {
            case keyword_a: HoverTexts.KEYWORD_A
            case keyword_b: HoverTexts.KEYWORD_B
            case keyword_c: HoverTexts.KEYWORD_C
            case keyword_d: HoverTexts.KEYWORD_D
        }
        return result
    }


I've looked through the previous topics regarding hover texts using the search functionality, but I did not encounter anything similar to this issue unfortunately. If anyone could shed some light on the issue that would be fantastic!

[Updated on: Wed, 31 March 2021 08:14] by Moderator

Re: Hover on keywords in nested structure does not seem to work [message #1839899 is a reply to message #1839898] Wed, 31 March 2021 08:45 Go to previous messageGo to next message
Eclipse UserFriend
i propose to debug the difference between the both cases.
besides that a complete example would help (one that can e.g. be git cloned)

[Updated on: Wed, 31 March 2021 09:00] by Moderator

Re: Hover on keywords in nested structure does not seem to work [message #1839922 is a reply to message #1839899] Thu, 01 April 2021 04:54 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Thank you for your answer.

Unfortunately I cannot provide a complete example, since our project is confidential and quite large. I was unable to reproduce it in a smaller test project unfortunately.

We may have found the cause but we're unsure (we have a workaround for now anyway).
The cause seems to be that the keywords for which the hover does not work do not have an ID attached to them (ID as defined in org.eclipse.xtext.common.Terminals). This seems to be the only difference between working and non-working keywords.

Our workaround is as follows:
if (o instanceof Keyword)
    return hoverTexts.hover((Keyword) o);
if (o instanceof KEYWORD_CImpl) //debugging showed it to be that type
    return hoverTexts.hover((KEYWORD_CImpl) o);


Where for the non-working keywords we have overloads that take KEYWORD_CImpl as parameter, instead of Keywords.
Re: Hover on keywords in nested structure does not seem to work [message #1839923 is a reply to message #1839922] Thu, 01 April 2021 05:18 Go to previous message
Eclipse UserFriend
KEYWORD_CImpl is not a keyword. its a construct from your dsl.
so you should really provide some insights on the grammar

[Updated on: Thu, 01 April 2021 05:25] by Moderator

Previous Topic:discouraged access to org.eclipse.xtext.ui.wizard.template contents
Next Topic:Two dsl in one project
Goto Forum:
  


Current Time: Sat Jul 05 17:19:07 EDT 2025

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

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

Back to the top