mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
parent
6d2656fd56
commit
7d78f58187
11 changed files with 628 additions and 2 deletions
|
@ -196,6 +196,13 @@ impl LanguageServer {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn inlay_hint(
|
||||
&self,
|
||||
params: InlayHintParams,
|
||||
) -> LspResult<Option<Vec<InlayHint>>> {
|
||||
self.0.lock().await.inlay_hint(params).await
|
||||
}
|
||||
|
||||
pub async fn virtual_text_document(
|
||||
&self,
|
||||
params: Option<Value>,
|
||||
|
@ -2896,6 +2903,50 @@ impl Inner {
|
|||
)
|
||||
}
|
||||
|
||||
async fn inlay_hint(
|
||||
&self,
|
||||
params: InlayHintParams,
|
||||
) -> LspResult<Option<Vec<InlayHint>>> {
|
||||
let specifier = self.url_map.normalize_url(¶ms.text_document.uri);
|
||||
let workspace_settings = self.config.get_workspace_settings();
|
||||
if !self.is_diagnosable(&specifier)
|
||||
|| !self.config.specifier_enabled(&specifier)
|
||||
|| !workspace_settings.enabled_inlay_hints()
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mark = self.performance.mark("inlay_hint", Some(¶ms));
|
||||
let asset_or_doc = self.get_asset_or_document(&specifier)?;
|
||||
let line_index = asset_or_doc.line_index();
|
||||
let range = tsc::TextSpan::from_range(¶ms.range, line_index.clone())
|
||||
.map_err(|err| {
|
||||
error!("Failed to convert range to text_span: {}", err);
|
||||
LspError::internal_error()
|
||||
})?;
|
||||
let req = tsc::RequestMethod::ProvideInlayHints((
|
||||
specifier.clone(),
|
||||
range,
|
||||
(&workspace_settings).into(),
|
||||
));
|
||||
let maybe_inlay_hints: Option<Vec<tsc::InlayHint>> = self
|
||||
.ts_server
|
||||
.request(self.snapshot(), req)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Unable to get inlay hints: {}", err);
|
||||
LspError::internal_error()
|
||||
})?;
|
||||
let maybe_inlay_hints = maybe_inlay_hints.map(|hints| {
|
||||
hints
|
||||
.iter()
|
||||
.map(|hint| hint.to_lsp(line_index.clone()))
|
||||
.collect()
|
||||
});
|
||||
self.performance.measure(mark);
|
||||
Ok(maybe_inlay_hints)
|
||||
}
|
||||
|
||||
async fn reload_import_registries(&mut self) -> LspResult<Option<Value>> {
|
||||
fs_util::remove_dir_all_if_exists(&self.module_registries_location)
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue