Skip to content

OpenDeclarationHyperlinkDetector.detectHyperlinks() handles invalid responses inappropriately, poisoning possibly good results #1169

@will-lauer

Description

@will-lauer

I'm attempting to integrate the Golang LSP (gopls) with eclipse using LSP4E and encountered a problem with hyperlinks. It looks like the current implementation of OpenDeclarationHyperlinkDetector.detectHyperlinks() makes requests for Definitions, Declarations, TypeDefinitions, and Implementations and then merges the results into a single list. Unfortunately, if any of these calls returns an error, the whole call to detectHyperlinks() fails. In the case of gopls, I'm seeing cases when trying to drill down on a function call (named Execute) where Definition and Declaration return good results, but TypeDefinition returns the error "no type definition for Execute" instead of an empty list and Implementations returns the error "Execute is a function, not a method" instead of an empty list.

Looking at this, I think a more appropriate implementation of the merge of the 4 lists of hyperlinks would be to ignore any errors and take only from the successful calls, thus keeping failures from poisoning the overall result.

I'm using version 0.18.12.202408150719 with Eclipse 2024-12 (4.34) and testing with gopls "golang.org/x/tools/gopls v0.17.1"

A simple "hello world" go program that exhibits the problem is

package main

import (
	"fmt"
)

func main() {
	Execute()
}

func Execute() {
	fmt.Println("hello world")
}

when drilling down on Execute in the main function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions