Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

[Backport 5.2] client: Avoid complex tokenization in ref panel code (#58954)#59636

Merged
BolajiOlajide merged 3 commits into
5.2from
vg/matlab-fix
Jan 24, 2024
Merged

[Backport 5.2] client: Avoid complex tokenization in ref panel code (#58954)#59636
BolajiOlajide merged 3 commits into
5.2from
vg/matlab-fix

Conversation

@varungandhi-src

@varungandhi-src varungandhi-src commented Jan 16, 2024

Copy link
Copy Markdown
Contributor

Cherry-pick fix for https://github.com/sourcegraph/sourcegraph/issues/58548 to 5.2 branch

Test plan

  • Double-check the ref panel works correctly on 5.2 branch

The separation of the logic into different functions makes it clearer
what the order of searches is. It also makes it clearer that for some
reason, we're only using the locals information from the SCIP
Document for 'Find references', and not for 'Go to definition'.
Using the SCIP Document for for 'Go to definition' too could avoid
a network request.

(cherry-picked from e955cddec490d0cc2b5eba36be2ec4958ba06bf8)
Previously, we relied on detecting the language from file paths,
then using various regexes associated with the language to identify
token boundaries. However, the code mirror blob view always provides
a full token range, which can be used directly, instead of attempting
to recompute the token boundaries.

For older URLs, we fallback to simple identifiers, which should
work for the vast majority of languages and identifiers.

We cannot yet remove the language detection here because the file
extensions associated with the language are later used for search-based
code navigation.

This patch also makes the language spec optional for search-based
code intel, as we do not have a solution to #56376 which would
guarantee that we always have a language available. If a language
is not available, search-based code intel falls back to searching
other files with the same extension as a best effort guess.

Locally tested for MATLAB code. The ref panel shows up correctly,
unlike the error earlier.

(cherry-picked from c42cad2)
@varungandhi-src varungandhi-src added backports backport/bugfix Standard patches to fix bugs labels Jan 16, 2024
@cla-bot cla-bot Bot added the cla-signed label Jan 16, 2024
@sourcegraph-bot

sourcegraph-bot commented Jan 16, 2024

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@varungandhi-src varungandhi-src changed the base branch from 5.2 to vg/bump-toolchain January 17, 2024 04:22
@varungandhi-src

Copy link
Copy Markdown
Contributor Author

Base automatically changed from vg/bump-toolchain to 5.2 January 17, 2024 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants