[Chapel Merge] CLS: fix goto-type-definition on record/class member fields

Branch: refs/heads/main
Revision: 17e564b184d27debd4bea2d112b3f466abde57eb
Author: DanilaFe
Link: CLS: fix goto-type-definition on record/class member fields by DanilaFe · Pull Request #28676 · chapel-lang/chapel · GitHub
Log Message:
CLS: fix goto-type-definition on record/class member fields (#28676)

Closes #28574.

Go to type definition now works when the cursor is on an identifier that
refers to a field accessed via implicit 'this' inside a method.

The root cause was that get_type_def called .type() on the
declaration node returned by get_target_segment_at_position. In
general, this is not easy to use because a) we don't have good support
for "compute type via record", and b) loses information about the
particular instantiation of the record. The reference identifier node
itself carries the resolved type, so use that when possible.

Reviewed by @jabraham17 -- thanks!

Testing

  • CLS tests

Compare: Comparing 6b190ea05b1b33f9c10cc6ae1f60db20c0d024b8...4b9207c614cf22c394365da4681bbdb157c5435d · chapel-lang/chapel · GitHub

Diff:
M tools/chpl-language-server/src/chpl-language-server.py
M tools/chpl-language-server/src/lsp_util.py
M tools/chpl-language-server/test/basic_resolver.py
https://github.com/chapel-lang/chapel/pull/28676.diff