Skip to content

Code intel hover: non-deterministic hover message when two identical ranges point to different result sets

Created by: olafurpg

Reported by @wchau in this discussion here https://github.com/sourcegraph/lsif-java/pull/404#issuecomment-1051354633

To reproduce, refresh the following page multiple times and hover over B in case class B. The hover message changes between refreshes

https://sourcegraph.com/github.com/sourcegraph/sbt-sourcegraph@e2f71270ea518766c65097b1f17e97b55059d792/-/blob/example/foo.scala?L3:13#tab=references

CleanShot 2022-03-01 at 10 25 45

After chatting with @efritz, the relevant place to fix this issue is around this location https://sourcegraph.com/github.com/sourcegraph/sourcegraph@d479784/-/blob/enterprise/internal/codeintel/stores/lsifstore/hover.go?L34#L14:17-14:22

There are different approaches we can use to fix this issue:

  • aggregate hover messages
  • sort hover messages and pick the first one
  • encode the priority of hover messages somehow in the LSIF protocol

I lean towards the second option as the quickest fix and we should consider the third option as we start storing LSIF Typed natively since it should be fairly easy to specify which ranges enclose a synthetic symbol definition (which should have a lower priority compared to non-synthetic symbol definitions).