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

Function push_unique_location

src/util.rs:2095–2112  ·  view source on GitHub ↗

Push a location only if it is not already present (deduplication).

(
    locations: &mut Vec<Location>,
    uri: &Url,
    start: Position,
    end: Position,
)

Source from the content-addressed store, hash-verified

2093
2094/// Push a location only if it is not already present (deduplication).
2095pub fn push_unique_location(
2096 locations: &mut Vec<Location>,
2097 uri: &Url,
2098 start: Position,
2099 end: Position,
2100) {
2101 let already_present = locations.iter().any(|l| {
2102 l.uri == *uri
2103 && l.range.start.line == start.line
2104 && l.range.start.character == start.character
2105 });
2106 if !already_present {
2107 locations.push(Location {
2108 uri: uri.clone(),
2109 range: Range { start, end },
2110 });
2111 }
2112}
2113
2114#[cfg(test)]
2115mod tests {

Calls 3

iterMethod · 0.80
pushMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected