Skip to content

Organize hover responses in a predictable way for ease of use #390

Closed

Description

@turkeylurkey

I have a file called microprofile-config.properties and it contains

injected.value2=Injected value2
value=lookup value

com.example.demo.client.Service/mp-rest/url=http://localhost:9081/data/client/service
serviceb.url=http://localhost:9081/data/protected

When I hover over the word "Service" I can get two different results in the IDE. Two different language servers respond and it seems random which result is displayed first. Sometimes an empty page is displayed as page 1 and other content on page 2.
image
image
Sometimes the page with all the content is first and the blank one is second.
image

I think the responses should be sorted in some deterministic way so the user can rely on seeing things a certain way. Even if it is as simple as alphabetical order by name of language server it should be consistent over a reasonable period of time. Obviously as language servers start and stop the order could change but it should be consistent while a certain collection of LS are running.

Also, one language server responded with

[Trace - 16:48:07] Received response 'textDocument/hover - (9)' in 6ms.
Result: {
  "contents": {
    "kind": "plaintext",
    "value": ""
  }
}

Fixed I think we should check value for null or empty string and not even return a message in that case.

Activity

  1. angelozerr commented on Jun 26, 2024

    @angelozerr
    Contributor

    I think we should check value for null or empty string and not even return a message in that case.

    It should work like this by using

    and there is a test about this usecase

    Are you sure the empty hover comes from an another language server? You mean that your Jakarta LS contribuet to microprofile-config.properties?

    Coud youshare your 2 LSP traces withe the two hover.

  2. aparnamichael commented on Jun 27, 2024

    @aparnamichael

    @angelozerr

    These are the traces from the language servers.

    Liberty config LS:

    [Trace - 15:17:10] Sending request 'textDocument/hover - (13)'.
    Params: {
    "textDocument": {
    "uri": "file:///Users/aparnacmichael/Documents/Devex/Codebase/liberty-tools-intellij/src/test/resources/projects/gradle/sampleGradleMPLSApp/src/main/resources/META-INF/microprofile-config.properties"
    },
    "position": {
    "line": 5,
    "character": 9
    }
    }

    [Trace - 15:17:10] Received response 'textDocument/hover - (13)' in 1ms.
    Result: {
    "contents": {
    "kind": "plaintext",
    "value": ""
    }
    }

    Microprofile LS:

    [Trace - 15:17:10] Sending request 'textDocument/hover - (21)'.
    Params: {
    "textDocument": {
    "uri": "file:///Users/aparnacmichael/Documents/Devex/Codebase/liberty-tools-intellij/src/test/resources/projects/gradle/sampleGradleMPLSApp/src/main/resources/META-INF/microprofile-config.properties"
    },
    "position": {
    "line": 5,
    "character": 9
    }
    }

    [Trace - 15:17:10] Received response 'textDocument/hover - (21)' in 2ms.
    Result: {
    "contents": {
    "kind": "markdown",
    "value": "io.openliberty.mp.sample.client.Service/mp-rest/url\n\nThe base URL to use for this service, the equivalent of the baseUrl method.\r\nThis property (or */mp-rest/uri) is considered required, however implementations may have other ways to define these URLs/URIs.\n\n * Type: java.lang.String\n * Value: http://localhost:9081/data/client/service"
    },
    "range": {
    "start": {
    "line": 5,
    "character": 0
    },
    "end": {
    "line": 5,
    "character": 51
    }
    }
    }

    Video for your reference.

    LSPconsole.Rsponse.mov
  3. angelozerr commented on Jun 27, 2024

    @angelozerr
    Contributor

    Thanks @aparnamichael for your answer.

    I don't know when I will have time to study this issue since now I'm very busy with our IJ Quarkus to create a release as soon as some bug fixes will be done.

  4. turkeylurkey commented on Jun 27, 2024

    @turkeylurkey
    ContributorAuthor

    It looks like this line should catch it.

    The test you refer to is for "kind": "markdown", so it is not applicable in this case. Your plaintext test case has a non-empty string.

  5. angelozerr commented on Jun 27, 2024

    @angelozerr
    Contributor

    Any PR with test are welcome!

  6. turkeylurkey commented on Jun 27, 2024

    @turkeylurkey
    ContributorAuthor

    I think your tests are unit tests and don't hit LSPDocumentationHelper.

    Also, we have been using 06/15 and I believe the code from 06/18 fixes the problem with the empty message.

    This means we don't have a use case that shows multiple messages for a hover situation but if we did the messages would be in a random order. So the first part of this issue is still in play.

  7. angelozerr commented on Jun 27, 2024

    @angelozerr
    Contributor

    If I understand correctly your comment if there are several ls which provide non empty hover, LSP4IJ need to sort them.

  8. turkeylurkey commented on Jun 27, 2024

    @turkeylurkey
    ContributorAuthor

    That's right, the user will be more comfortable seeing them in a predictable order.

  9. angelozerr commented on Jun 28, 2024

    @angelozerr
    Contributor

    It means that we need to provide an extension point to sort.

    I think we should wait for having a concrete usecase to implement that

  10. turkeylurkey commented on Jun 28, 2024

    @turkeylurkey
    ContributorAuthor

    That sounds like a good idea but I'd hate for it to become so complex that the basic function is not implemented.

    That said, we no longer have a use case so this is not high priority for us.

  11. angelozerr commented on Jun 29, 2024

    @angelozerr
    Contributor

    An another simple idea is to sort hover by server name.

    That said, we no longer have a use case so this is not high priority for us.

    Indeed let's waiting for a concrete usecase to discuss again about that.

  12. added
    enhancement
    on Jul 2, 2024
  13. angelozerr commented on Aug 8, 2024

    @angelozerr
    Contributor

    @turkeylurkey what about sorting hover results by language server display name?

  14. turkeylurkey commented on Aug 8, 2024

    @turkeylurkey
    ContributorAuthor

    Yes, that sounds good. I just want it to be organized and repeatable in any given session. And simpler is better.

  15. added a commit that references this issue on Nov 21, 2026
    c409a90
  16. added this to the 0.30.2 milestone on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhover

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions