From e170461c9ef00b18ddf65970db12505ba10f2a0b Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:27:26 +0000 Subject: [PATCH 1/5] feat(editor): format symbol and file references in Rust Core (#2015) --- rust/contracts/rust-core-api.md | 1 + rust/crates/core/src/protocol/command.rs | 3 + .../core/src/runtime/dispatcher/editor.rs | 3 + rust/crates/core/src/tests/editor_dispatch.rs | 16 ++ rust/crates/editor/src/lib.rs | 1 + rust/crates/editor/src/reference_location.rs | 212 ++++++++++++++++++ .../editor/copy-reference-location-v1.json | 106 +++++++++ 7 files changed, 342 insertions(+) create mode 100644 rust/crates/editor/src/reference_location.rs create mode 100644 rust/fixtures/editor/copy-reference-location-v1.json diff --git a/rust/contracts/rust-core-api.md b/rust/contracts/rust-core-api.md index b73a629a..1b688d79 100644 --- a/rust/contracts/rust-core-api.md +++ b/rust/contracts/rust-core-api.md @@ -642,6 +642,7 @@ or removing a command fails until the table changes in the same commit. | `lsp.classifyNavigationTarget` | Classify a language-server jump target as workspace, external read-only or rejected | | `lsp.declarationOrUsages` | Decide whether a go-to-declaration gesture opens the declaration or shows its usages | | `editor.lineEdit` | Apply a deterministic line-level text transform and return the replacement plus selection to restore | +| `editor.copyReferenceLocation` | Format a one-based line reference from normalized document symbols; fall back to a file path when no containing symbol exists | | `editor.find` | Find text or plans bounded replacements in a borrowed document | | `editor.preferences.resolve` | Resolve persisted editor presentation preferences | | `editor.recent.reduce` | Reduce and queries bounded recent-file history | diff --git a/rust/crates/core/src/protocol/command.rs b/rust/crates/core/src/protocol/command.rs index ea6e1b28..0001f7ac 100644 --- a/rust/crates/core/src/protocol/command.rs +++ b/rust/crates/core/src/protocol/command.rs @@ -592,6 +592,8 @@ pub enum EditorCommand { /// Applies a deterministic line-level editing transform /// (`editor.lineEdit`). LineEdit, + /// Formats a symbol or file reference for one caret position (`editor.copyReferenceLocation`). + CopyReferenceLocation, /// Finds text or plans bounded replacements in a borrowed document (`editor.find`). Find, /// Resolves persisted editor presentation preferences (`editor.preferences.resolve`). @@ -1316,6 +1318,7 @@ impl CoreCommand { "lsp.classifyNavigationTarget" => Some(Self::Lsp(LspCommand::ClassifyNavigationTarget)), "lsp.declarationOrUsages" => Some(Self::Lsp(LspCommand::DeclarationOrUsages)), "editor.lineEdit" => Some(Self::Editor(EditorCommand::LineEdit)), + "editor.copyReferenceLocation" => Some(Self::Editor(EditorCommand::CopyReferenceLocation)), "editor.find" => Some(Self::Editor(EditorCommand::Find)), "editor.preferences.resolve" => Some(Self::Editor(EditorCommand::PreferencesResolve)), "editor.recent.reduce" => Some(Self::Editor(EditorCommand::RecentReduce)), diff --git a/rust/crates/core/src/runtime/dispatcher/editor.rs b/rust/crates/core/src/runtime/dispatcher/editor.rs index 6ca0f5eb..2dc900e3 100644 --- a/rust/crates/core/src/runtime/dispatcher/editor.rs +++ b/rust/crates/core/src/runtime/dispatcher/editor.rs @@ -21,6 +21,9 @@ pub(super) fn dispatch( EditorCommand::GroupLayoutDropTargets => { plugin_response(id, payload, lithe_editor_layout::drop_targets_command) } + EditorCommand::CopyReferenceLocation => { + plugin_response(id, payload, lithe_editor::reference_location::reference_command) + } EditorCommand::Find => match lithe_editor::find::command(payload, document) { Ok(data) => CoreResponse::success(id, data), Err(error) => CoreResponse::failure(id, error), diff --git a/rust/crates/core/src/tests/editor_dispatch.rs b/rust/crates/core/src/tests/editor_dispatch.rs index 2da5cec5..e6eb5c72 100644 --- a/rust/crates/core/src/tests/editor_dispatch.rs +++ b/rust/crates/core/src/tests/editor_dispatch.rs @@ -135,3 +135,19 @@ fn navigation_history_keeps_only_the_newest_entries() { assert_eq!(forward.len() as u64, limit); assert_eq!(forward[0]["line"], 5); } + +#[test] +fn copy_reference_location_matches_shared_fixture() { + let fixture: Value = serde_json::from_str(include_str!( + "../../../../fixtures/editor/copy-reference-location-v1.json" + )) + .unwrap(); + for case in fixture["cases"].as_array().unwrap() { + let response: Value = serde_json::from_str(&crate::execute_json( + &json!({"command":"editor.copyReferenceLocation","payload":case["request"]}).to_string(), + )) + .unwrap(); + assert_eq!(response["ok"], true, "{}: {response}", case["name"]); + assert_eq!(response["data"], case["expected"], "{}", case["name"]); + } +} diff --git a/rust/crates/editor/src/lib.rs b/rust/crates/editor/src/lib.rs index e520a369..2075d3e7 100644 --- a/rust/crates/editor/src/lib.rs +++ b/rust/crates/editor/src/lib.rs @@ -11,6 +11,7 @@ pub mod navigation_history; pub mod navigation_input; pub mod preferences; pub mod recent; +pub mod reference_location; pub mod recovery; pub mod text_edit_plan; diff --git a/rust/crates/editor/src/reference_location.rs b/rust/crates/editor/src/reference_location.rs new file mode 100644 index 00000000..2ea08d3d --- /dev/null +++ b/rust/crates/editor/src/reference_location.rs @@ -0,0 +1,212 @@ +//! Builds a portable reference for the caret from language-server document symbols. +//! +//! The host owns the document path and actual caret, while Core owns the common +//! formatting and symbol-range selection rule. No language-specific source parsing is +//! performed: unknown or incomplete symbols fall back to an explicit file location. + +use lithe_protocol::{CoreError, ErrorCode}; +use serde::Deserialize; +use serde_json::{json, Value}; + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +struct Request { + path: String, + line: u32, + utf16_column: u32, + #[serde(default)] + symbols: Vec, +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize)] +#[serde(rename_all = "camelCase")] +struct Position { + line: u32, + utf16_column: u32, +} + +#[derive(Deserialize)] +struct Range { + start: Position, + end: Position, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +struct Symbol { + name: String, + kind: u32, + range: Range, + #[serde(default)] + detail: Option, + #[serde(default)] + container_name: Option, + #[serde(default)] + children: Vec, +} + +/// Formats the server's innermost containing symbol, with a one-based source line. +/// A namespace, type or method is used only when the server reports it: the +/// caller never guesses a package or method signature from the file name. +pub fn reference_command(payload: Value) -> Result { + let request: Request = serde_json::from_value(payload).map_err(|_| { + CoreError::new(ErrorCode::InvalidRequest, "Invalid reference location request") + })?; + if request.path.is_empty() { + return Err(CoreError::new( + ErrorCode::InvalidRequest, + "Reference location requires a file path", + )); + } + let line = u64::from(request.line) + 1; + let position = Position { line: request.line, utf16_column: request.utf16_column }; + let symbol = reference_symbol(&request.symbols, position); + let (reference, source) = match symbol { + Some(symbol) => (format!("{symbol}#L{line}"), "symbol"), + None => (format!("{}#L{line}", request.path), "file"), + }; + Ok(json!({"reference":reference, "source":source})) +} + +fn contains(range: &Range, position: Position) -> bool { + range.start <= position && position < range.end +} + +fn extent(range: &Range) -> (u32, u32) { + ( + range.end.line.saturating_sub(range.start.line), + range.end.utf16_column.saturating_sub(range.start.utf16_column), + ) +} + +// Prefer a nested symbol chain over a flat entry, and a smaller enclosing range +// when a server returns overlapping flat SymbolInformation entries. +fn enclosing<'a>(symbols: &'a [Symbol], position: Position) -> Vec<&'a Symbol> { + let mut best = Vec::new(); + let mut best_extent = (u32::MAX, u32::MAX); + for symbol in symbols { + if !contains(&symbol.range, position) { + continue; + } + let mut candidate = vec![symbol]; + candidate.extend(enclosing(&symbol.children, position)); + let span = extent(&symbol.range); + if candidate.len() > best.len() || (candidate.len() == best.len() && span < best_extent) { + best = candidate; + best_extent = span; + } + } + best +} + +fn clean(value: &str) -> Option<&str> { + let value = value.trim(); + (!value.is_empty() && !value.chars().any(char::is_control)).then_some(value) +} + +fn callable_name(symbol: &Symbol) -> Option { + let name = clean(&symbol.name)?; + // LSP implementations may put a method's exact signature in its name, + // or put only the parameter list in detail. Never invent the types. + if name.contains('(') { + return Some(name.to_owned()); + } + if let Some(detail) = symbol.detail.as_deref().and_then(clean) { + if detail.starts_with('(') { + if let Some(end) = detail.find(')') { + return Some(format!("{}{}", name, &detail[..=end])); + } + } + } + Some(name.to_owned()) +} + +fn reference_symbol(symbols: &[Symbol], position: Position) -> Option { + let path = enclosing(symbols, position); + let mut namespaces = Vec::new(); + let mut types = Vec::new(); + let mut callable = None; + for symbol in &path { + let Some(name) = clean(&symbol.name) else { continue }; + match symbol.kind { + // LSP SymbolKind: Module, Namespace, Package + 2 | 3 | 4 => namespaces.push(name.to_owned()), + // Class, Enum, Interface, Struct + 5 | 10 | 11 | 23 => types.push(name.to_owned()), + // Method, Constructor, Function + 6 | 9 | 12 => callable = callable_name(symbol), + _ => {} + } + } + // Flat SymbolInformation includes containerName instead of nested children. + // Use the server's name as-is; it may already be fully qualified. + if types.is_empty() { + if let Some(container) = path.last().and_then(|s| s.container_name.as_deref()).and_then(clean) { + types.push(container.to_owned()); + } + } + let mut owner = namespaces.join("."); + if !types.is_empty() { + if !owner.is_empty() { + owner.push('.'); + } + owner.push_str(&types.join(".")); + } + match (owner.is_empty(), callable) { + (true, None) => None, + (true, Some(method)) => Some(method), + (false, Some(method)) => Some(format!("{owner}#{method}")), + (false, None) => Some(owner), + } +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn server_symbol_tree_and_detail_are_preserved() { + let symbols = json!([{ + "name":"com.example", "kind":4, + "range":{"start":{"line":0,"utf16Column":0},"end":{"line":200,"utf16Column":0}}, + "children":[{ + "name":"DemoClass","kind":5, + "range":{"start":{"line":1,"utf16Column":0},"end":{"line":190,"utf16Column":0}}, + "children":[{ + "name":"goHome","kind":6,"detail":"(String,Integer) : void", + "range":{"start":{"line":130,"utf16Column":0},"end":{"line":144,"utf16Column":0}} + }] + }] + }]); + let data = reference_command(json!({"path":"/tmp/DemoClass.java","line":136,"utf16Column":4,"symbols":symbols})).unwrap(); + assert_eq!(data["reference"], "com.example.DemoClass#goHome(String,Integer)#L137"); + assert_eq!(data["source"], "symbol"); + } + + #[test] + fn missing_or_nonmatching_symbols_fall_back_to_path() { + for symbols in [json!([]), json!([{ + "name":"DemoClass","kind":5, + "range":{"start":{"line":10,"utf16Column":0},"end":{"line":12,"utf16Column":0}} + }])] { + let data = reference_command(json!({"path":"C:/src/DemoClass.java","line":136,"utf16Column":4,"symbols":symbols})).unwrap(); + assert_eq!(data["reference"], "C:/src/DemoClass.java#L137"); + assert_eq!(data["source"], "file"); + } + } + + #[test] + fn flat_method_uses_its_server_container_and_exact_name() { + let symbols = json!([{ + "name":"goHome(String,Integer)","kind":6,"containerName":"DemoClass", + "range":{"start":{"line":6,"utf16Column":0},"end":{"line":9,"utf16Column":0}} + }]); + let data = reference_command(json!({"path":"file.java","line":7,"utf16Column":0,"symbols":symbols})).unwrap(); + assert_eq!(data["reference"], "DemoClass#goHome(String,Integer)#L8"); + } + + #[test] + fn rejects_empty_path_and_invalid_positions() { + assert!(reference_command(json!({"path":"","line":0,"utf16Column":0})).is_err()); + assert!(reference_command(json!({"path":"a.java","line":-1,"utf16Column":0})).is_err()); + } +} diff --git a/rust/fixtures/editor/copy-reference-location-v1.json b/rust/fixtures/editor/copy-reference-location-v1.json new file mode 100644 index 00000000..581abf81 --- /dev/null +++ b/rust/fixtures/editor/copy-reference-location-v1.json @@ -0,0 +1,106 @@ +{ + "cases": [ + { + "name": "method-with-package", + "request": { + "path": "DemoClass.java", + "line": 136, + "utf16Column": 4, + "symbols": [ + { + "name": "com.example", + "kind": 4, + "range": { + "start": { + "line": 0, + "utf16Column": 0 + }, + "end": { + "line": 200, + "utf16Column": 0 + } + }, + "children": [ + { + "name": "DemoClass", + "kind": 5, + "range": { + "start": { + "line": 1, + "utf16Column": 0 + }, + "end": { + "line": 190, + "utf16Column": 0 + } + }, + "children": [ + { + "name": "goHome(String,Integer)", + "kind": 6, + "range": { + "start": { + "line": 130, + "utf16Column": 0 + }, + "end": { + "line": 144, + "utf16Column": 0 + } + } + } + ] + } + ] + } + ] + }, + "expected": { + "reference": "com.example.DemoClass#goHome(String,Integer)#L137", + "source": "symbol" + } + }, + { + "name": "no-language-server", + "request": { + "path": "src/DemoClass.java", + "line": 136, + "utf16Column": 4, + "symbols": [] + }, + "expected": { + "reference": "src/DemoClass.java#L137", + "source": "file" + } + }, + { + "name": "flat-symbol", + "request": { + "path": "source.txt", + "line": 7, + "utf16Column": 0, + "symbols": [ + { + "name": "save(int)", + "kind": 6, + "containerName": "Editor", + "range": { + "start": { + "line": 5, + "utf16Column": 0 + }, + "end": { + "line": 10, + "utf16Column": 0 + } + } + } + ] + }, + "expected": { + "reference": "Editor#save(int)#L8", + "source": "symbol" + } + } + ] +} From d5f4ae0884fb64eefb0d41ff9cd5a0ad1015c0b3 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:34:42 +0000 Subject: [PATCH 2/5] style(editor): apply rustfmt corrections from CI (#2015) --- rust/crates/core/src/protocol/command.rs | 4 +- .../core/src/runtime/dispatcher/editor.rs | 8 +-- rust/crates/core/src/tests/editor_dispatch.rs | 3 +- rust/crates/editor/src/lib.rs | 2 +- rust/crates/editor/src/reference_location.rs | 51 ++++++++++++++----- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/rust/crates/core/src/protocol/command.rs b/rust/crates/core/src/protocol/command.rs index 0001f7ac..0d8ec7a7 100644 --- a/rust/crates/core/src/protocol/command.rs +++ b/rust/crates/core/src/protocol/command.rs @@ -1318,7 +1318,9 @@ impl CoreCommand { "lsp.classifyNavigationTarget" => Some(Self::Lsp(LspCommand::ClassifyNavigationTarget)), "lsp.declarationOrUsages" => Some(Self::Lsp(LspCommand::DeclarationOrUsages)), "editor.lineEdit" => Some(Self::Editor(EditorCommand::LineEdit)), - "editor.copyReferenceLocation" => Some(Self::Editor(EditorCommand::CopyReferenceLocation)), + "editor.copyReferenceLocation" => { + Some(Self::Editor(EditorCommand::CopyReferenceLocation)) + } "editor.find" => Some(Self::Editor(EditorCommand::Find)), "editor.preferences.resolve" => Some(Self::Editor(EditorCommand::PreferencesResolve)), "editor.recent.reduce" => Some(Self::Editor(EditorCommand::RecentReduce)), diff --git a/rust/crates/core/src/runtime/dispatcher/editor.rs b/rust/crates/core/src/runtime/dispatcher/editor.rs index 2dc900e3..a8e4ffbb 100644 --- a/rust/crates/core/src/runtime/dispatcher/editor.rs +++ b/rust/crates/core/src/runtime/dispatcher/editor.rs @@ -21,9 +21,11 @@ pub(super) fn dispatch( EditorCommand::GroupLayoutDropTargets => { plugin_response(id, payload, lithe_editor_layout::drop_targets_command) } - EditorCommand::CopyReferenceLocation => { - plugin_response(id, payload, lithe_editor::reference_location::reference_command) - } + EditorCommand::CopyReferenceLocation => plugin_response( + id, + payload, + lithe_editor::reference_location::reference_command, + ), EditorCommand::Find => match lithe_editor::find::command(payload, document) { Ok(data) => CoreResponse::success(id, data), Err(error) => CoreResponse::failure(id, error), diff --git a/rust/crates/core/src/tests/editor_dispatch.rs b/rust/crates/core/src/tests/editor_dispatch.rs index e6eb5c72..d57aa7f0 100644 --- a/rust/crates/core/src/tests/editor_dispatch.rs +++ b/rust/crates/core/src/tests/editor_dispatch.rs @@ -144,7 +144,8 @@ fn copy_reference_location_matches_shared_fixture() { .unwrap(); for case in fixture["cases"].as_array().unwrap() { let response: Value = serde_json::from_str(&crate::execute_json( - &json!({"command":"editor.copyReferenceLocation","payload":case["request"]}).to_string(), + &json!({"command":"editor.copyReferenceLocation","payload":case["request"]}) + .to_string(), )) .unwrap(); assert_eq!(response["ok"], true, "{}: {response}", case["name"]); diff --git a/rust/crates/editor/src/lib.rs b/rust/crates/editor/src/lib.rs index 2075d3e7..a020b462 100644 --- a/rust/crates/editor/src/lib.rs +++ b/rust/crates/editor/src/lib.rs @@ -11,8 +11,8 @@ pub mod navigation_history; pub mod navigation_input; pub mod preferences; pub mod recent; -pub mod reference_location; pub mod recovery; +pub mod reference_location; pub mod text_edit_plan; pub use line_edit::{line_comment_token, line_edit, LineCommentTokenRequest, LineEditRequest}; diff --git a/rust/crates/editor/src/reference_location.rs b/rust/crates/editor/src/reference_location.rs index 2ea08d3d..24e82b4f 100644 --- a/rust/crates/editor/src/reference_location.rs +++ b/rust/crates/editor/src/reference_location.rs @@ -50,7 +50,10 @@ struct Symbol { /// caller never guesses a package or method signature from the file name. pub fn reference_command(payload: Value) -> Result { let request: Request = serde_json::from_value(payload).map_err(|_| { - CoreError::new(ErrorCode::InvalidRequest, "Invalid reference location request") + CoreError::new( + ErrorCode::InvalidRequest, + "Invalid reference location request", + ) })?; if request.path.is_empty() { return Err(CoreError::new( @@ -59,7 +62,10 @@ pub fn reference_command(payload: Value) -> Result { )); } let line = u64::from(request.line) + 1; - let position = Position { line: request.line, utf16_column: request.utf16_column }; + let position = Position { + line: request.line, + utf16_column: request.utf16_column, + }; let symbol = reference_symbol(&request.symbols, position); let (reference, source) = match symbol { Some(symbol) => (format!("{symbol}#L{line}"), "symbol"), @@ -75,7 +81,10 @@ fn contains(range: &Range, position: Position) -> bool { fn extent(range: &Range) -> (u32, u32) { ( range.end.line.saturating_sub(range.start.line), - range.end.utf16_column.saturating_sub(range.start.utf16_column), + range + .end + .utf16_column + .saturating_sub(range.start.utf16_column), ) } @@ -127,7 +136,9 @@ fn reference_symbol(symbols: &[Symbol], position: Position) -> Option { let mut types = Vec::new(); let mut callable = None; for symbol in &path { - let Some(name) = clean(&symbol.name) else { continue }; + let Some(name) = clean(&symbol.name) else { + continue; + }; match symbol.kind { // LSP SymbolKind: Module, Namespace, Package 2 | 3 | 4 => namespaces.push(name.to_owned()), @@ -141,7 +152,11 @@ fn reference_symbol(symbols: &[Symbol], position: Position) -> Option { // Flat SymbolInformation includes containerName instead of nested children. // Use the server's name as-is; it may already be fully qualified. if types.is_empty() { - if let Some(container) = path.last().and_then(|s| s.container_name.as_deref()).and_then(clean) { + if let Some(container) = path + .last() + .and_then(|s| s.container_name.as_deref()) + .and_then(clean) + { types.push(container.to_owned()); } } @@ -177,17 +192,26 @@ mod tests { }] }] }]); - let data = reference_command(json!({"path":"/tmp/DemoClass.java","line":136,"utf16Column":4,"symbols":symbols})).unwrap(); - assert_eq!(data["reference"], "com.example.DemoClass#goHome(String,Integer)#L137"); + let data = reference_command( + json!({"path":"/tmp/DemoClass.java","line":136,"utf16Column":4,"symbols":symbols}), + ) + .unwrap(); + assert_eq!( + data["reference"], + "com.example.DemoClass#goHome(String,Integer)#L137" + ); assert_eq!(data["source"], "symbol"); } #[test] fn missing_or_nonmatching_symbols_fall_back_to_path() { - for symbols in [json!([]), json!([{ - "name":"DemoClass","kind":5, - "range":{"start":{"line":10,"utf16Column":0},"end":{"line":12,"utf16Column":0}} - }])] { + for symbols in [ + json!([]), + json!([{ + "name":"DemoClass","kind":5, + "range":{"start":{"line":10,"utf16Column":0},"end":{"line":12,"utf16Column":0}} + }]), + ] { let data = reference_command(json!({"path":"C:/src/DemoClass.java","line":136,"utf16Column":4,"symbols":symbols})).unwrap(); assert_eq!(data["reference"], "C:/src/DemoClass.java#L137"); assert_eq!(data["source"], "file"); @@ -200,7 +224,10 @@ mod tests { "name":"goHome(String,Integer)","kind":6,"containerName":"DemoClass", "range":{"start":{"line":6,"utf16Column":0},"end":{"line":9,"utf16Column":0}} }]); - let data = reference_command(json!({"path":"file.java","line":7,"utf16Column":0,"symbols":symbols})).unwrap(); + let data = reference_command( + json!({"path":"file.java","line":7,"utf16Column":0,"symbols":symbols}), + ) + .unwrap(); assert_eq!(data["reference"], "DemoClass#goHome(String,Integer)#L8"); } From 7836c6cbba45620c0eb8a72d8e6152201b56ed3c Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:38:44 +0000 Subject: [PATCH 3/5] fix(editor): satisfy Rust clippy lints on reference formatter (#2015) --- rust/crates/editor/src/reference_location.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/crates/editor/src/reference_location.rs b/rust/crates/editor/src/reference_location.rs index 24e82b4f..88f0974f 100644 --- a/rust/crates/editor/src/reference_location.rs +++ b/rust/crates/editor/src/reference_location.rs @@ -90,7 +90,7 @@ fn extent(range: &Range) -> (u32, u32) { // Prefer a nested symbol chain over a flat entry, and a smaller enclosing range // when a server returns overlapping flat SymbolInformation entries. -fn enclosing<'a>(symbols: &'a [Symbol], position: Position) -> Vec<&'a Symbol> { +fn enclosing(symbols: &[Symbol], position: Position) -> Vec<&Symbol> { let mut best = Vec::new(); let mut best_extent = (u32::MAX, u32::MAX); for symbol in symbols { @@ -141,7 +141,7 @@ fn reference_symbol(symbols: &[Symbol], position: Position) -> Option { }; match symbol.kind { // LSP SymbolKind: Module, Namespace, Package - 2 | 3 | 4 => namespaces.push(name.to_owned()), + 2..=4 => namespaces.push(name.to_owned()), // Class, Enum, Interface, Struct 5 | 10 | 11 | 23 => types.push(name.to_owned()), // Method, Constructor, Function From 9a2dc283561c143a7b4d0695e3ebd41ae19cf5c3 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:45:23 +0000 Subject: [PATCH 4/5] fix(editor): accept nullable LSP symbol children from Go host (#2015) --- rust/crates/editor/src/reference_location.rs | 4 +- .../editor/copy-reference-location-v1.json | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/rust/crates/editor/src/reference_location.rs b/rust/crates/editor/src/reference_location.rs index 88f0974f..c88dc3f7 100644 --- a/rust/crates/editor/src/reference_location.rs +++ b/rust/crates/editor/src/reference_location.rs @@ -42,7 +42,7 @@ struct Symbol { #[serde(default)] container_name: Option, #[serde(default)] - children: Vec, + children: Option>, } /// Formats the server's innermost containing symbol, with a one-based source line. @@ -98,7 +98,7 @@ fn enclosing(symbols: &[Symbol], position: Position) -> Vec<&Symbol> { continue; } let mut candidate = vec![symbol]; - candidate.extend(enclosing(&symbol.children, position)); + candidate.extend(enclosing(symbol.children.as_deref().unwrap_or(&[]), position)); let span = extent(&symbol.range); if candidate.len() > best.len() || (candidate.len() == best.len() && span < best_extent) { best = candidate; diff --git a/rust/fixtures/editor/copy-reference-location-v1.json b/rust/fixtures/editor/copy-reference-location-v1.json index 581abf81..ef0561f5 100644 --- a/rust/fixtures/editor/copy-reference-location-v1.json +++ b/rust/fixtures/editor/copy-reference-location-v1.json @@ -101,6 +101,48 @@ "reference": "Editor#save(int)#L8", "source": "symbol" } + }, + { + "name": "nullable-children-from-go-document-symbol", + "request": { + "path": "/workspace/DemoClass.java", + "line": 0, + "utf16Column": 0, + "symbols": [ + { + "name": "DemoClass", + "kind": 5, + "detail": null, + "tags": null, + "containerName": null, + "children": null, + "range": { + "start": { + "line": 0, + "utf16Column": 0 + }, + "end": { + "line": 1, + "utf16Column": 0 + } + }, + "selectionRange": { + "start": { + "line": 0, + "utf16Column": 0 + }, + "end": { + "line": 0, + "utf16Column": 4 + } + } + } + ] + }, + "expected": { + "reference": "DemoClass#L1", + "source": "symbol" + } } ] } From 9bbd0bd996f90e62801af0b361270011de4c2ea8 Mon Sep 17 00:00:00 2001 From: "lithe-support[bot]" <356900028+lithe-support[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:47:11 +0000 Subject: [PATCH 5/5] style(editor): format nullable LSP symbol child handling per Rust CI --- rust/crates/editor/src/reference_location.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/crates/editor/src/reference_location.rs b/rust/crates/editor/src/reference_location.rs index c88dc3f7..62e6b343 100644 --- a/rust/crates/editor/src/reference_location.rs +++ b/rust/crates/editor/src/reference_location.rs @@ -98,7 +98,10 @@ fn enclosing(symbols: &[Symbol], position: Position) -> Vec<&Symbol> { continue; } let mut candidate = vec![symbol]; - candidate.extend(enclosing(symbol.children.as_deref().unwrap_or(&[]), position)); + candidate.extend(enclosing( + symbol.children.as_deref().unwrap_or(&[]), + position, + )); let span = extent(&symbol.range); if candidate.len() > best.len() || (candidate.len() == best.len() && span < best_extent) { best = candidate;