mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor(lsp): add "deno.reloadImportRegistries" as a command (#20823)
This commit is contained in:
parent
2665ca103e
commit
6bbccb72d7
4 changed files with 25 additions and 4 deletions
|
@ -121,7 +121,10 @@ pub fn server_capabilities(
|
|||
color_provider: None,
|
||||
execute_command_provider: Some(ExecuteCommandOptions {
|
||||
commands: if enable_builtin_commands {
|
||||
vec!["deno.cache".into()]
|
||||
vec![
|
||||
"deno.cache".to_string(),
|
||||
"deno.reloadImportRegistries".to_string(),
|
||||
]
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
|
|
|
@ -3035,7 +3035,7 @@ impl tower_lsp::LanguageServer for LanguageServer {
|
|||
let referrer = serde_json::to_value(arguments.next()).unwrap();
|
||||
let referrer: Url = serde_json::from_value(referrer)
|
||||
.map_err(|err| LspError::invalid_params(err.to_string()))?;
|
||||
return self
|
||||
self
|
||||
.cache_request(Some(
|
||||
serde_json::to_value(lsp_custom::CacheParams {
|
||||
referrer: TextDocumentIdentifier { uri: referrer },
|
||||
|
@ -3046,9 +3046,12 @@ impl tower_lsp::LanguageServer for LanguageServer {
|
|||
})
|
||||
.expect("well formed json"),
|
||||
))
|
||||
.await;
|
||||
.await
|
||||
} else if params.command == "deno.reloadImportRegistries" {
|
||||
self.0.write().await.reload_import_registries().await
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
async fn initialize(
|
||||
|
|
|
@ -49,6 +49,9 @@ pub async fn start() -> Result<(), AnyError> {
|
|||
lsp_custom::PERFORMANCE_REQUEST,
|
||||
LanguageServer::performance_request,
|
||||
)
|
||||
// TODO(nayeemrmn): The extension has replaced this with the
|
||||
// `deno.reloadImportRegistries` command as of vscode_deno
|
||||
// 3.26.0 / 2023.10.10. Remove this eventually.
|
||||
.custom_method(
|
||||
lsp_custom::RELOAD_IMPORT_REGISTRIES_REQUEST,
|
||||
LanguageServer::reload_import_registries_request,
|
||||
|
|
|
@ -872,6 +872,18 @@ fn lsp_deno_task() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_reload_import_registries_command() {
|
||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||
let mut client = context.new_lsp_command().build();
|
||||
client.initialize_default();
|
||||
let res = client.write_request(
|
||||
"workspace/executeCommand",
|
||||
json!({ "command": "deno.reloadImportRegistries" }),
|
||||
);
|
||||
assert_eq!(res, json!(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_import_attributes() {
|
||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||
|
|
Loading…
Reference in a new issue