sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.12k stars 1.29k forks source link

Better fallback provider for code navigation #41979

Open varungandhi-src opened 2 years ago

varungandhi-src commented 2 years ago

Right now, if a language is not recognized, you don't get code navigation even if the file has precise code intel.

olafurpg commented 2 years ago

A good place to start looking is the implementation of emptySourcegraphProviders here https://sourcegraph.com/github.com/sourcegraph/sourcegraph@30811fe1fc80631973fd433042be75bb28c69752/-/blob/client/shared/src/codeintel/legacy-extensions/providers.ts?L39

As long as we can come up with a LanguageSpec, then we can reuse createProviders from here https://sourcegraph.com/-/editor?remote_url=git%40github.com%3Asourcegraph%2Fsourcegraph.git&branch=olafurpg%2Freprolang&file=client%2Fshared%2Fsrc%2Fcodeintel%2Flegacy-extensions%2Fproviders.ts&editor=VSCode&version=2.2.9&start_row=142&start_col=30&end_row=142&end_col=30&utm_campaign=vscode-extension&utm_medium=direct_traffic&utm_source=vscode-extension&utm_content=vsce-commands

Note that this change will have fairly significant implications. Today, the popover doesn't load for YAML/JSON/Dockerfile files and after the change I suspect we'll start displaying definitions/references/hover for random identifiers in those files. I'm not 100% convinced it's a good idea to have a fallback provider.

varungandhi-src commented 2 years ago

We could limit it to precise intel only. However, that's a much more niche use case.

olafurpg commented 2 years ago

Good point. I missed that mention in the description. This should be relatively easy and safe to enable, we just need to refactor the code a bit.