lsp: Add container_name to lsp::Symbol (#46822)
Some language servers include local symbols (e.g., local variables, parameters) in workspace symbol results. Without the `containerName` information, these symbols lack context information, making it difficult to distinguish them from top-level definitions and hindering efficient symbol lookup. This change exposes the `container_name` field from LSP [`SymbolInformation`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#symbolInformation) to the extension API, allowing language server extensions to access `symbol.container_name` in `label_for_symbol` and provide meaningful context when rendering symbol labels. Note: The `container_name `field is added to all extension API versions because they seem to share the same underlying Rust types via wasmtime bindgen. The field is optional, so existing extensions would remain compatible as far as I understand. Closes #ISSUE Release Notes: - Added `container_name` field to `lsp::Symbol`, accessible via the extension API's `label_for_symbol` function --------- Co-authored-by: MrSubidubi <finn@zed.dev>
This commit is contained in:
1 parent
a71aa4ecf9
commit
4563b5ac4f
18 files changed
+268
-90
No files matched your search
@@ -8,7 +8,7 @@ use futures::{AsyncBufReadExt, StreamExt as _};
|
||||
use gpui::{App, AsyncApp, SharedString, Task};
|
||||
use http_client::github::{AssetKind, GitHubLspBinaryVersion, latest_github_release};
|
||||
use language::language_settings::language_settings;
|
||||
use language::{ContextLocation, DynLspInstaller, LanguageToolchainStore, LspInstaller};
|
||||
use language::{ContextLocation, DynLspInstaller, LanguageToolchainStore, LspInstaller, Symbol};
|
||||
use language::{ContextProvider, LspAdapter, LspAdapterDelegate};
|
||||
use language::{LanguageName, ManifestName, ManifestProvider, ManifestQuery};
|
||||
use language::{Toolchain, ToolchainList, ToolchainLister, ToolchainMetadata};
|
||||
@@ -550,11 +550,11 @@ impl LspAdapter for PyrightLspAdapter {
|
||||
|
||||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp::SymbolKind,
|
||||
symbol: &language::Symbol,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
let name = &symbol.name;
|
||||
let (text, filter_range, display_range) = match symbol.kind {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("def {}():\n", name);
|
||||
let filter_range = 4..4 + name.len();
|
||||
@@ -1708,11 +1708,11 @@ impl LspAdapter for PyLspAdapter {
|
||||
|
||||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp::SymbolKind,
|
||||
symbol: &language::Symbol,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
let name = &symbol.name;
|
||||
let (text, filter_range, display_range) = match symbol.kind {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("def {}():\n", name);
|
||||
let filter_range = 4..4 + name.len();
|
||||
@@ -2000,11 +2000,11 @@ impl LspAdapter for BasedPyrightLspAdapter {
|
||||
|
||||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp::SymbolKind,
|
||||
symbol: &Symbol,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
let name = &symbol.name;
|
||||
let (text, filter_range, display_range) = match symbol.kind {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("def {}():\n", name);
|
||||
let filter_range = 4..4 + name.len();
|
||||
|
||||
Reference in new issue
Block a user