test rust lsp
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
use anyhow::Result;
|
||||
use analysis::ProcIndex;
|
||||
use lsp_types as lsp;
|
||||
use text::DocumentStore;
|
||||
|
||||
pub fn document_symbol(
|
||||
docs: &DocumentStore,
|
||||
index: &ProcIndex,
|
||||
uri: &lsp::Uri
|
||||
) -> Result<Option<lsp::DocumentSymbolResponse>> {
|
||||
let Some(doc) = docs.get(uri) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(procs) = index.get(uri) else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let mut symbols = Vec::new();
|
||||
for p in procs {
|
||||
let range = doc.byte_range_to_lsp_range(p.byte_start, p.byte_end);
|
||||
symbols.push(lsp::DocumentSymbol {
|
||||
name: p.name.clone(),
|
||||
detail: Some(format!("proc {}", p.params.join(" "))),
|
||||
kind: lsp::SymbolKind::FUNCTION,
|
||||
range,
|
||||
selection_range: range,
|
||||
children: None,
|
||||
tags: None,
|
||||
deprecated: None,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(Some(lsp::DocumentSymbolResponse::Nested(symbols)))
|
||||
}
|
||||
Reference in New Issue
Block a user