diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-10-24 21:27:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-24 21:27:27 +0100 |
commit | a7bd0cf7a890eff0133242d09e71b2783350fd23 (patch) | |
tree | 62ed1dfa6a29853f466e3822a16904a2a74f22c6 /cli/tests/integration/lsp_tests.rs | |
parent | 8f065a60e79e221a6ce7f6ce06c3022a85edb56a (diff) |
perf(lsp): cleanup workspace settings scopes (#20937)
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 211 |
1 files changed, 70 insertions, 141 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 85e55ee81..42cd11b3d 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -1024,23 +1024,23 @@ fn lsp_import_attributes() { client.initialize(|builder| { builder.set_import_map("data:application/json;utf8,{\"imports\": { \"example\": \"https://deno.land/x/example/mod.ts\" }}"); }); - - client.did_open_with_config( - json!({ - "textDocument": { - "uri": "file:///a/test.json", - "languageId": "json", - "version": 1, - "text": "{\"a\":1}" - } - }), - &json!({ "deno": { + client.change_configuration(json!({ + "deno": { "enable": true, "codeLens": { - "test": true - } - } }), - ); + "test": true, + }, + }, + })); + + client.did_open(json!({ + "textDocument": { + "uri": "file:///a/test.json", + "languageId": "json", + "version": 1, + "text": "{\"a\":1}", + }, + })); let diagnostics = client.did_open(json!({ "textDocument": { @@ -1380,17 +1380,15 @@ fn lsp_hover_disabled() { client.initialize(|builder| { builder.set_deno_enable(false); }); - client.did_open_with_config( - json!({ - "textDocument": { - "uri": "file:///a/file.ts", - "languageId": "typescript", - "version": 1, - "text": "console.log(Date.now());\n" - } - }), - &json!({ "deno": { "enable": false } }), - ); + client.change_configuration(json!({ "deno": { "enable": false } })); + client.did_open(json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": "console.log(Date.now());\n", + }, + })); let res = client.write_request( "textDocument/hover", @@ -3794,24 +3792,22 @@ fn lsp_code_lens_test_disabled() { "test": false }))); }); - client - .did_open_with_config( - json!({ - "textDocument": { - "uri": "file:///a/file.ts", - "languageId": "typescript", - "version": 1, - "text": "const { test } = Deno;\nconst { test: test2 } = Deno;\nconst test3 = Deno.test;\n\nDeno.test(\"test a\", () => {});\nDeno.test({\n name: \"test b\",\n fn() {},\n});\ntest({\n name: \"test c\",\n fn() {},\n});\ntest(\"test d\", () => {});\ntest2({\n name: \"test e\",\n fn() {},\n});\ntest2(\"test f\", () => {});\ntest3({\n name: \"test g\",\n fn() {},\n});\ntest3(\"test h\", () => {});\n" - } - }), - // disable test code lens - &json!({ "deno": { - "enable": true, - "codeLens": { - "test": false - } - } }), - ); + client.change_configuration(json!({ + "deno": { + "enable": true, + "codeLens": { + "test": false, + }, + }, + })); + client.did_open(json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": "const { test } = Deno;\nconst { test: test2 } = Deno;\nconst test3 = Deno.test;\n\nDeno.test(\"test a\", () => {});\nDeno.test({\n name: \"test b\",\n fn() {},\n});\ntest({\n name: \"test c\",\n fn() {},\n});\ntest(\"test d\", () => {});\ntest2({\n name: \"test e\",\n fn() {},\n});\ntest2(\"test f\", () => {});\ntest3({\n name: \"test g\",\n fn() {},\n});\ntest3(\"test h\", () => {});\n" + }, + })); let res = client.write_request( "textDocument/codeLens", json!({ @@ -3820,7 +3816,7 @@ fn lsp_code_lens_test_disabled() { } }), ); - assert_eq!(res, json!([])); + assert_eq!(res, json!(null)); client.shutdown(); } @@ -4898,22 +4894,12 @@ fn lsp_cache_on_save() { ); let mut client = context.new_lsp_command().build(); client.initialize_default(); - client.write_notification( - "workspace/didChangeConfiguration", - json!({ - "settings": {} - }), - ); - let settings = json!({ + client.change_configuration(json!({ "deno": { "enable": true, "cacheOnSave": true, }, - }); - // one for the workspace - client.handle_configuration_request(&settings); - // one for the specifier - client.handle_configuration_request(&settings); + })); let diagnostics = client.did_open(json!({ "textDocument": { @@ -5592,23 +5578,16 @@ fn lsp_quote_style_from_workspace_settings() { ); let mut client = context.new_lsp_command().build(); client.initialize_default(); - client.write_notification( - "workspace/didChangeConfiguration", - json!({ - "settings": {} - }), - ); - let settings = json!({ + client.change_configuration(json!({ + "deno": { + "enable": true, + }, "typescript": { "preferences": { "quoteStyle": "single", }, }, - }); - // one for the workspace - client.handle_configuration_request(&settings); - // one for the specifier - client.handle_configuration_request(&settings); + })); let code_action_params = json!({ "textDocument": { @@ -5792,7 +5771,7 @@ fn lsp_code_actions_deadlock() { let large_file_text = fs::read_to_string(testdata_path().join("lsp").join("large_file.txt")) .unwrap(); - client.did_open_raw(json!({ + client.did_open(json!({ "textDocument": { "uri": "file:///a/file.ts", "languageId": "javascript", @@ -5800,7 +5779,6 @@ fn lsp_code_actions_deadlock() { "text": large_file_text, } })); - client.handle_configuration_request(&json!({ "deno": { "enable": true } })); client.write_request( "textDocument/semanticTokens/full", json!({ @@ -5809,7 +5787,6 @@ fn lsp_code_actions_deadlock() { } }), ); - client.read_diagnostics(); client.write_notification( "textDocument/didChange", json!({ @@ -8901,17 +8878,11 @@ fn lsp_configuration_did_change() { "text": "import * as a from \"http://localhost:4545/x/a@\"" } })); - client.write_notification( - "workspace/didChangeConfiguration", - json!({ - "settings": {} - }), - ); - let settings = json!({ "deno": { + client.change_configuration(json!({ "deno": { "enable": true, "codeLens": { "implementations": true, - "references": true + "references": true, }, "importMap": null, "lint": true, @@ -8922,16 +8893,12 @@ fn lsp_configuration_did_change() { "paths": true, "imports": { "hosts": { - "http://localhost:4545/": true - } - } + "http://localhost:4545/": true, + }, + }, }, - "unstable": false - } }); - // one for the workspace - client.handle_configuration_request(&settings); - // one for the specifier - client.handle_configuration_request(&settings); + "unstable": false, + } })); let list = client.get_completion_list( "file:///a/file.ts", @@ -8997,13 +8964,7 @@ fn lsp_completions_complete_function_calls() { "text": "[]." } })); - client.write_notification( - "workspace/didChangeConfiguration", - json!({ - "settings": {} - }), - ); - let settings = json!({ + client.change_configuration(json!({ "deno": { "enable": true, }, @@ -9012,11 +8973,7 @@ fn lsp_completions_complete_function_calls() { "completeFunctionCalls": true, }, }, - }); - // one for the workspace - client.handle_configuration_request(&settings); - // one for the specifier - client.handle_configuration_request(&settings); + })); let list = client.get_completion_list( "file:///a/file.ts", @@ -10099,22 +10056,12 @@ fn lsp_node_modules_dir() { "{ \"nodeModulesDir\": true, \"lock\": false }\n", ); let refresh_config = |client: &mut LspClient| { - client.write_notification( - "workspace/didChangeConfiguration", - json!({ - "settings": { - "enable": true, - "config": "./deno.json", - } - }), - ); - - let settings = json!({ "deno": { + client.change_configuration(json!({ "deno": { "enable": true, "config": "./deno.json", "codeLens": { "implementations": true, - "references": true + "references": true, }, "importMap": null, "lint": false, @@ -10123,14 +10070,10 @@ fn lsp_node_modules_dir() { "completeFunctionCalls": false, "names": true, "paths": true, - "imports": {} - }, - "unstable": false - } }); - // one for the workspace - client.handle_configuration_request(&settings); - // one for the specifier - client.handle_configuration_request(&settings); + "imports": {}, + }, + "unstable": false, + } })); }; refresh_config(&mut client); @@ -10228,22 +10171,12 @@ fn lsp_vendor_dir() { "{ \"vendor\": true, \"lock\": false }\n", ); let refresh_config = |client: &mut LspClient| { - client.write_notification( - "workspace/didChangeConfiguration", - json!({ - "settings": { - "enable": true, - "config": "./deno.json", - } - }), - ); - - let settings = json!({ "deno": { + client.change_configuration(json!({ "deno": { "enable": true, "config": "./deno.json", "codeLens": { "implementations": true, - "references": true + "references": true, }, "importMap": null, "lint": false, @@ -10252,14 +10185,10 @@ fn lsp_vendor_dir() { "completeFunctionCalls": false, "names": true, "paths": true, - "imports": {} - }, - "unstable": false - } }); - // one for the workspace - client.handle_configuration_request(&settings); - // one for the specifier - client.handle_configuration_request(&settings); + "imports": {}, + }, + "unstable": false, + } })); }; refresh_config(&mut client); |