Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:13 Go to next message
Jan Jansen is currently offline Jan JansenFriend
Messages: 17
Registered: October 2018
Junior Member
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 12:14]

Report message to a 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 12:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14668
Registered: July 2009
Senior Member
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)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 31 March 2021 13:00]

Report message to a 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 08:54 Go to previous messageGo to next message
Jan Jansen is currently offline Jan JansenFriend
Messages: 17
Registered: October 2018
Junior Member
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 09:18 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14668
Registered: July 2009
Senior Member
KEYWORD_CImpl is not a keyword. its a construct from your dsl.
so you should really provide some insights on the grammar


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 01 April 2021 09:25]

Report message to a moderator

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


Current Time: Fri Apr 26 18:52:19 GMT 2024

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

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

Back to the top