MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / build_selection_range

Function build_selection_range

src/selection_range.rs:74–91  ·  view source on GitHub ↗

Build a `SelectionRange` linked list from a list of spans sorted outermost-first.

(content: &str, spans: &[(u32, u32)])

Source from the content-addressed store, hash-verified

72/// Build a `SelectionRange` linked list from a list of spans sorted
73/// outermost-first.
74fn build_selection_range(content: &str, spans: &[(u32, u32)]) -> SelectionRange {
75 if spans.is_empty() {
76 let range = Range::new(Position::new(0, 0), Position::new(0, 0));
77 return SelectionRange {
78 range,
79 parent: None,
80 };
81 }
82
83 // Start from the outermost and wrap inward.
84 let mut current = to_selection_range(content, spans[0], None);
85
86 for &span in &spans[1..] {
87 current = to_selection_range(content, span, Some(current));
88 }
89
90 current
91}
92
93fn to_selection_range(
94 content: &str,

Callers 1

Calls 2

to_selection_rangeFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected