// TODO: use this instead of calculating everything in completion
use this instead of calculating everything in completion
use this instead of calculating everything in completion
async fn completion_resolve(&self, item: lsp::CompletionItem) -> Result<lsp::CompletionItem, Error> {
        if let Some(idx_val) = item.data.as_ref().and_then(|x| x.as_u64()) {
            let pool = self.get_cloned_pool().await?;
            let idx = PoolIndex::new(idx_val as u32);
            let fun = pool.function(idx)?;
            let name = pool.def_name(idx)?;
            let pretty_name = name.split(';').next().unwrap_or(&name);
            let mut snippet = String::new();
            for (i, param_idx) in fun.parameters.iter().enumerate() {
                let name = pool.def_name(*param_idx)?;
                if i != 0 {
                    write!(snippet, ", ").unwrap();
                }
                write!(snippet, "${{{}:{}}}", i + 1, name).unwrap();
            }
            let detail = util::render_function(idx, true, &pool)?;
            let item = lsp::CompletionItem {
                label: format!("{}(⠤)", pretty_name),
                kind: Some(lsp::CompletionItemKind::METHOD),
                insert_text: Some(format!("{}({})", pretty_name, snippet)),
                insert_text_format: Some(lsp::InsertTextFormat::SNIPPET),
                detail: Some(detail),
                ..lsp::CompletionItem::default()
            };
            Ok(item)
        } else {
            Ok(item)
        }
    }
async fn completion_resolve ( & self , item : lsp :: CompletionItem ) -> Result < lsp :: CompletionItem , Error > { if let Some ( idx_val ) = item . data . as_ref ( ) . and_then ( | x | x . as_u64 ( ) ) { let pool = self . get_cloned_pool ( ) . await ? ; let idx = PoolIndex :: new ( idx_val as u32 ) ; let fun = pool . function ( idx ) ? ; let name = pool . def_name ( idx ) ? ; let pretty_name = name . split ( ';' ) . next ( ) . unwrap_or ( & name ) ; let mut snippet = String :: new ( ) ; for ( i , param_idx ) in fun . parameters . iter ( ) . enumerate ( ) { let name = pool . def_name ( * param_idx ) ? ; if i != 0 { write ! ( snippet " " ) . unwrap ( ) ; } write ! ( snippet " " i 1 name ) . unwrap ( ) ; } let detail = util :: render_function ( idx , true , & pool ) ? ; let item = lsp :: CompletionItem { label : format ! ( " etty_name), kind : Some ( lsp :: CompletionItemKind :: METHOD ) , insert_text : Some ( format ! ( " " pretty_name snippet ) ) , insert_text_format : Some ( lsp :: InsertTextFormat :: SNIPPET ) , detail : Some ( detail ) , .. lsp :: CompletionItem :: default ( ) } ; Ok ( item ) } else { Ok ( item ) } }
TODO: use this instead of calculating everything in completion
TODO : use this instead of calculating everything in completion
&self
item
lsp::CompletionItem