Extend "Go to Definition" to cover class member definitions.#405
Extend "Go to Definition" to cover class member definitions.#405isc-klu wants to merge 3 commits into
Conversation
|
@isc-klu Can you explain how this addresses the issue? The code looks fine but I am not sure how the automatic symbol reference chat feature definition gets to this code. |
|
It’s not clear from the VSCode documentation what is required for automatic symbol references to work. However, @hsyhhssyy’s comments in #397 suggest that the lack of automatic symbol references for members is related to the following issues:
As noted by @hsyhhssyy, automatic symbol references do work for class symbols. Since we currently don’t support workspace symbols (including for class symbols), the second issue is likely unrelated. With that in mind, I focused on addressing the first issue. Fixing Go to Definition for member definitions also resolves the automatic symbol references problem. Given this, it would be more accurate to position this PR as a fix for Go to Definition, with improved automatic symbol references as a side effect. I’ll update the PR description shortly. |
|
@isc-bsaviano — following up on our discussion about short‑circuiting the special case: my latest commit implements that change. A couple of notes:
|
| ) { | ||
| // This is a class member definition | ||
| const range = findFullRange(params.position.line, parsed, i, symbolstart, symbolend); | ||
| return [ |
There was a problem hiding this comment.
You may want to use classMemberLocationLink() for this. It will need some modification for this special case where we know the definition is in the current class.
There was a problem hiding this comment.
Perhaps you meant findMemberInCurrentClass, which constructs a location link from an already available document, rather than classMemberLocationLink, which first locates the relevant document on a server. Using the latter here would be unnecessary overhead since we already have the document.
Could you check whether the new commit (2bd2ef7) aligns with your expectations?
Fix #397
Go to Definition wasn't working for class member definition. For example, when users presses F12 on
Foobarof the following code, they see "No definition found.” Fixing this issue also extends automatic symbol references to class members.