Skip to content

Conversation

toinehartman
Copy link
Member

@toinehartman toinehartman commented Jul 24, 2025

This fixes #268, by changing the lookup of ranges such that type hints/definitions will be shown for the smallest possible tree.

  • Use a tree-based data structure based on containment instead of ordering for TreeMapLookup.
  • Remove duplicate function for checking Range containment.

Building on this, I have been working a revised data structure that relies on containment instead of ordering. Since that requires more testing and checking guarantees/invariants, it now lives on a separate branch: https://github.com/usethesource/rascal-language-servers/tree/fix/range-lookup.

@toinehartman toinehartman self-assigned this Jul 24, 2025
@toinehartman toinehartman force-pushed the fix/268-hover-complex-expressions branch from 092d614 to 2f5819f Compare July 24, 2025 15:26
@toinehartman toinehartman force-pushed the fix/268-hover-complex-expressions branch from a1cca21 to 6628510 Compare July 29, 2025 12:30
@toinehartman toinehartman added the bug Something isn't working label Aug 6, 2025
@toinehartman toinehartman force-pushed the fix/268-hover-complex-expressions branch from 6628510 to 4a52dd8 Compare August 11, 2025 07:39
@DavyLandman
Copy link
Member

Building on this, I have been working a revised data structure that relies on containment instead of ordering. Since that requires more testing and checking guarantees/invariants, it now lives on a separate branch: https://github.com/usethesource/rascal-language-servers/tree/fix/range-lookup.

I started out with such a structure, and I think I remember I ran into the problem of overlapping ranges and how to store them in such a tree in a way that you don't need to always go "left" and "right" in the tree. And primarily, I didn't want to keep around a complex data structure if we could get it to fit into a regular map.

An alternative strategy that @jurgenvinju has proposed in the past is to use the parse tree, and use code similar to the focus list building/semantic token highlighter.

But that has the downside that we would be iterating over the tree towards the leaf, and then depth first doing a map lookup in the list of hovers/definitions/... for every parent of the leaf untill we find a match. So not taking the shape of three into account during lookup.

Copy link

@DavyLandman DavyLandman enabled auto-merge (squash) August 13, 2025 07:46
@DavyLandman DavyLandman merged commit 885e94b into main Aug 13, 2025
16 of 19 checks passed
@toinehartman toinehartman deleted the fix/268-hover-complex-expressions branch August 13, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hover help makes no sense with slightly more complex expressions
2 participants