Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

fix: switch to gen-lsp-types

[gen-lsp-types](https://github.com/ribru17/gen-lsp-types) is an
alternative to the lsp-types crate, with types generated via codegen
from the official LSP Metamodel for correctness and completeness.

lsp-types issues fixed in gen-lsp-types:

- https://github.com/gluon-lang/lsp-types/issues/310
- https://github.com/gluon-lang/lsp-types/issues/308
- https://github.com/gluon-lang/lsp-types/issues/284
- https://github.com/gluon-lang/lsp-types/issues/278
- https://github.com/gluon-lang/lsp-types/issues/277
- https://github.com/gluon-lang/lsp-types/issues/260
- https://github.com/gluon-lang/lsp-types/issues/245
- https://github.com/gluon-lang/lsp-types/issues/93

See: https://github.com/wgsl-analyzer/wgsl-analyzer/pull/1090 and
https://github.com/rust-lang/rust-analyzer/pull/22115

+338 -321
+23 -42
Cargo.lock
··· 339 339 340 340 [[package]] 341 341 name = "bitflags" 342 - version = "1.3.2" 343 - source = "registry+https://github.com/rust-lang/crates.io-index" 344 - checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 345 - 346 - [[package]] 347 - name = "bitflags" 348 342 version = "2.11.1" 349 343 source = "registry+https://github.com/rust-lang/crates.io-index" 350 344 checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" ··· 804 798 source = "registry+https://github.com/rust-lang/crates.io-index" 805 799 checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" 806 800 dependencies = [ 807 - "bitflags 2.11.1", 801 + "bitflags", 808 802 "block2", 809 803 "libc", 810 804 "objc2", ··· 1095 1089 ] 1096 1090 1097 1091 [[package]] 1092 + name = "gen-lsp-types" 1093 + version = "0.5.0" 1094 + source = "registry+https://github.com/rust-lang/crates.io-index" 1095 + checksum = "b4552cb20fa322e0ebc35c2bbbe3eed8ace907bbcedc92aace7a325c9064b80b" 1096 + dependencies = [ 1097 + "serde", 1098 + "serde_json", 1099 + "url", 1100 + ] 1101 + 1102 + [[package]] 1098 1103 name = "generic-array" 1099 1104 version = "0.14.7" 1100 1105 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1155 1160 "fs_extra", 1156 1161 "fslock", 1157 1162 "futures", 1163 + "gen-lsp-types", 1158 1164 "gleam-core", 1159 1165 "gleam-language-server", 1160 1166 "hexpm", ··· 1166 1172 "insta", 1167 1173 "itertools", 1168 1174 "lsp-server", 1169 - "lsp-types", 1170 1175 "opener", 1171 1176 "pretty_assertions", 1172 1177 "pubgrub", ··· 1207 1212 "ecow", 1208 1213 "flate2", 1209 1214 "futures", 1215 + "gen-lsp-types", 1210 1216 "globset", 1211 1217 "hexpm", 1212 1218 "http", ··· 1216 1222 "insta", 1217 1223 "itertools", 1218 1224 "lsp-server", 1219 - "lsp-types", 1220 1225 "num-bigint", 1221 1226 "num-traits", 1222 1227 "pathdiff", ··· 1251 1256 "camino", 1252 1257 "debug-ignore", 1253 1258 "ecow", 1259 + "gen-lsp-types", 1254 1260 "gleam-core", 1255 1261 "hexpm", 1256 1262 "im", 1257 1263 "insta", 1258 1264 "itertools", 1259 1265 "lsp-server", 1260 - "lsp-types", 1261 1266 "serde", 1262 1267 "serde_json", 1263 1268 "strum", ··· 1916 1921 source = "registry+https://github.com/rust-lang/crates.io-index" 1917 1922 checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" 1918 1923 dependencies = [ 1919 - "bitflags 2.11.1", 1924 + "bitflags", 1920 1925 "libc", 1921 1926 "redox_syscall", 1922 1927 ] ··· 1969 1974 ] 1970 1975 1971 1976 [[package]] 1972 - name = "lsp-types" 1973 - version = "0.95.1" 1974 - source = "registry+https://github.com/rust-lang/crates.io-index" 1975 - checksum = "8e34d33a8e9b006cd3fc4fe69a921affa097bae4bb65f76271f4644f9a334365" 1976 - dependencies = [ 1977 - "bitflags 1.3.2", 1978 - "serde", 1979 - "serde_json", 1980 - "serde_repr", 1981 - "url", 1982 - ] 1983 - 1984 - [[package]] 1985 1977 name = "matchers" 1986 1978 version = "0.2.0" 1987 1979 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2060 2052 source = "registry+https://github.com/rust-lang/crates.io-index" 2061 2053 checksum = "5d6d0705320c1e6ba1d912b5e37cf18071b6c2e9b7fa8215a1e8a7651966f5d3" 2062 2054 dependencies = [ 2063 - "bitflags 2.11.1", 2055 + "bitflags", 2064 2056 "cfg-if", 2065 2057 "cfg_aliases", 2066 2058 "libc", ··· 2483 2475 source = "registry+https://github.com/rust-lang/crates.io-index" 2484 2476 checksum = "7c3a14896dfa883796f1cb410461aef38810ea05f2b2c33c5aded3649095fdad" 2485 2477 dependencies = [ 2486 - "bitflags 2.11.1", 2478 + "bitflags", 2487 2479 "memchr", 2488 2480 "pulldown-cmark-escape", 2489 2481 "unicase", ··· 2655 2647 source = "registry+https://github.com/rust-lang/crates.io-index" 2656 2648 checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" 2657 2649 dependencies = [ 2658 - "bitflags 2.11.1", 2650 + "bitflags", 2659 2651 ] 2660 2652 2661 2653 [[package]] ··· 2847 2839 source = "registry+https://github.com/rust-lang/crates.io-index" 2848 2840 checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" 2849 2841 dependencies = [ 2850 - "bitflags 2.11.1", 2842 + "bitflags", 2851 2843 "errno", 2852 2844 "libc", 2853 2845 "linux-raw-sys", ··· 3000 2992 source = "registry+https://github.com/rust-lang/crates.io-index" 3001 2993 checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" 3002 2994 dependencies = [ 3003 - "bitflags 2.11.1", 2995 + "bitflags", 3004 2996 "core-foundation", 3005 2997 "core-foundation-sys", 3006 2998 "libc", ··· 3108 3100 ] 3109 3101 3110 3102 [[package]] 3111 - name = "serde_repr" 3112 - version = "0.1.18" 3113 - source = "registry+https://github.com/rust-lang/crates.io-index" 3114 - checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" 3115 - dependencies = [ 3116 - "proc-macro2", 3117 - "quote", 3118 - "syn", 3119 - ] 3120 - 3121 - [[package]] 3122 3103 name = "serde_spanned" 3123 3104 version = "0.6.9" 3124 3105 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3710 3691 source = "registry+https://github.com/rust-lang/crates.io-index" 3711 3692 checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" 3712 3693 dependencies = [ 3713 - "bitflags 2.11.1", 3694 + "bitflags", 3714 3695 "bytes", 3715 3696 "futures-util", 3716 3697 "http", ··· 4325 4306 source = "registry+https://github.com/rust-lang/crates.io-index" 4326 4307 checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" 4327 4308 dependencies = [ 4328 - "bitflags 2.11.1", 4309 + "bitflags", 4329 4310 ] 4330 4311 4331 4312 [[package]]
+1 -2
Cargo.toml
··· 10 10 "test-output", 11 11 "test-package-compiler", 12 12 "test-project-compiler", 13 - "language-server", 14 13 "hexpm", 15 14 ] 16 15 ··· 52 51 base16 = "0" 53 52 # Language server protocol server plumbing 54 53 lsp-server = "0" 55 - lsp-types = "=0.95.1" 54 + lsp-types = { package = "gen-lsp-types", version = "0.5.0", features = ["url"] } 56 55 # Compact clone-on-write vector & string type 57 56 ecow = "0" 58 57 # Drop in replacement for std::path but with only utf-8
+56 -57
language-server/src/code_action.rs
··· 30 30 use im::HashMap; 31 31 use itertools::Itertools; 32 32 use lsp_types::{ 33 - CodeAction, CodeActionKind, CodeActionParams, CreateFile, CreateFileOptions, 34 - DocumentChangeOperation, DocumentChanges, Position, Range, ResourceOp, TextEdit, Url, 33 + CodeAction, CodeActionKind, CodeActionParams, CreateFile, CreateFileOptions, DocumentChange, 34 + Position, Range, TextEdit, Uri as Url, 35 35 }; 36 36 use vec1::{Vec1, vec1}; 37 37 ··· 66 66 is_preferred: None, 67 67 disabled: None, 68 68 data: None, 69 + tags: None, 69 70 }, 70 71 } 71 72 } ··· 85 86 self 86 87 } 87 88 88 - pub fn document_changes(mut self, changes: DocumentChanges) -> Self { 89 + pub fn document_changes(mut self, changes: Vec<DocumentChange>) -> Self { 89 90 let mut edit = self.action.edit.take().unwrap_or_default(); 90 91 91 92 edit.document_changes = Some(changes); ··· 271 272 272 273 let mut actions = vec![]; 273 274 CodeActionBuilder::new("Remove redundant tuples") 274 - .kind(CodeActionKind::REFACTOR_REWRITE) 275 + .kind(CodeActionKind::RefactorRewrite) 275 276 .changes(self.params.text_document.uri.clone(), self.edits.edits) 276 277 .preferred(true) 277 278 .push_to(&mut actions); ··· 431 432 let uri = &self.params.text_document.uri; 432 433 433 434 CodeActionBuilder::new("Convert to case") 434 - .kind(CodeActionKind::REFACTOR_REWRITE) 435 + .kind(CodeActionKind::RefactorRewrite) 435 436 .changes(uri.clone(), vec![TextEdit { range, new_text }]) 436 437 .preferred(false) 437 438 .push_to(&mut self.actions); ··· 613 614 text_edits.replace(*location, new_text); 614 615 615 616 CodeActionBuilder::new("Convert to case") 616 - .kind(CodeActionKind::QUICKFIX) 617 + .kind(CodeActionKind::QuickFix) 617 618 .changes(uri.clone(), text_edits.edits) 618 619 .preferred(true) 619 620 .push_to(actions); ··· 703 704 } 704 705 let mut action = Vec::with_capacity(1); 705 706 CodeActionBuilder::new("Use label shorthand syntax") 706 - .kind(CodeActionKind::REFACTOR) 707 + .kind(CodeActionKind::Refactor) 707 708 .changes(self.params.text_document.uri.clone(), self.edits.edits) 708 709 .preferred(false) 709 710 .push_to(&mut action); ··· 896 897 897 898 let mut action = Vec::with_capacity(1); 898 899 CodeActionBuilder::new("Fill labels") 899 - .kind(CodeActionKind::QUICKFIX) 900 + .kind(CodeActionKind::QuickFix) 900 901 .changes(self.params.text_document.uri.clone(), self.edits.edits) 901 902 .preferred(true) 902 903 .push_to(&mut action); ··· 1216 1217 }; 1217 1218 1218 1219 CodeActionBuilder::new(title) 1219 - .kind(CodeActionKind::QUICKFIX) 1220 + .kind(CodeActionKind::QuickFix) 1220 1221 .changes(uri.clone(), edits) 1221 1222 .preferred(true) 1222 1223 .push_to(actions); ··· 1367 1368 } 1368 1369 1369 1370 CodeActionBuilder::new("Add missing patterns") 1370 - .kind(CodeActionKind::QUICKFIX) 1371 + .kind(CodeActionKind::QuickFix) 1371 1372 .changes(uri.clone(), edits.edits) 1372 1373 .preferred(true) 1373 1374 .push_to(actions); ··· 1574 1575 }; 1575 1576 1576 1577 CodeActionBuilder::new(title) 1577 - .kind(CodeActionKind::REFACTOR) 1578 + .kind(CodeActionKind::Refactor) 1578 1579 .changes(uri.clone(), self.edits.edits) 1579 1580 .preferred(false) 1580 1581 .push_to(actions); ··· 1615 1616 1616 1617 let mut action = Vec::with_capacity(1); 1617 1618 CodeActionBuilder::new("Annotate all top level definitions") 1618 - .kind(CodeActionKind::REFACTOR_REWRITE) 1619 + .kind(CodeActionKind::RefactorRewrite) 1619 1620 .changes(self.params.text_document.uri.clone(), self.edits.edits) 1620 1621 .preferred(false) 1621 1622 .push_to(&mut action); ··· 2005 2006 "Unqualify {}.{}", 2006 2007 self.qualified_constructor.used_name, self.qualified_constructor.constructor 2007 2008 )) 2008 - .kind(CodeActionKind::REFACTOR) 2009 + .kind(CodeActionKind::Refactor) 2009 2010 .changes(self.params.text_document.uri.clone(), self.edits.edits) 2010 2011 .preferred(false) 2011 2012 .push_to(&mut action); ··· 2508 2509 module_name, 2509 2510 constructor.name, 2510 2511 )) 2511 - .kind(CodeActionKind::REFACTOR) 2512 + .kind(CodeActionKind::Refactor) 2512 2513 .changes(self.params.text_document.uri.clone(), self.edits.edits) 2513 2514 .preferred(false) 2514 2515 .push_to(&mut action); ··· 2881 2882 2882 2883 let mut action = Vec::with_capacity(1); 2883 2884 CodeActionBuilder::new("Convert from `use`") 2884 - .kind(CodeActionKind::REFACTOR_REWRITE) 2885 + .kind(CodeActionKind::RefactorRewrite) 2885 2886 .changes(self.params.text_document.uri.clone(), self.edits.edits) 2886 2887 .preferred(false) 2887 2888 .push_to(&mut action); ··· 3031 3032 3032 3033 let mut action = Vec::with_capacity(1); 3033 3034 CodeActionBuilder::new("Convert to `use`") 3034 - .kind(CodeActionKind::REFACTOR_REWRITE) 3035 + .kind(CodeActionKind::RefactorRewrite) 3035 3036 .changes(self.params.text_document.uri.clone(), self.edits.edits) 3036 3037 .preferred(false) 3037 3038 .push_to(&mut action); ··· 3318 3319 3319 3320 let mut action = Vec::with_capacity(1); 3320 3321 CodeActionBuilder::new("Extract variable") 3321 - .kind(CodeActionKind::REFACTOR_EXTRACT) 3322 + .kind(CodeActionKind::RefactorExtract) 3322 3323 .changes(self.params.text_document.uri.clone(), self.edits.edits) 3323 3324 .preferred(false) 3324 3325 .push_to(&mut action); ··· 4068 4069 4069 4070 let mut action = Vec::with_capacity(1); 4070 4071 CodeActionBuilder::new("Extract constant") 4071 - .kind(CodeActionKind::REFACTOR_EXTRACT) 4072 + .kind(CodeActionKind::RefactorExtract) 4072 4073 .changes(self.params.text_document.uri.clone(), self.edits.edits) 4073 4074 .preferred(false) 4074 4075 .push_to(&mut action); ··· 4259 4260 4260 4261 let mut action = Vec::with_capacity(1); 4261 4262 CodeActionBuilder::new("Expand function capture") 4262 - .kind(CodeActionKind::REFACTOR_REWRITE) 4263 + .kind(CodeActionKind::RefactorRewrite) 4263 4264 .changes(self.params.text_document.uri.clone(), self.edits.edits) 4264 4265 .preferred(false) 4265 4266 .push_to(&mut action); ··· 4572 4573 maybe_import(&mut self.edits, self.module, DECODE_MODULE); 4573 4574 4574 4575 CodeActionBuilder::new("Generate dynamic decoder") 4575 - .kind(CodeActionKind::REFACTOR) 4576 + .kind(CodeActionKind::Refactor) 4576 4577 .preferred(false) 4577 4578 .changes( 4578 4579 self.params.text_document.uri.clone(), ··· 5226 5227 maybe_import(&mut self.edits, self.module, JSON_MODULE); 5227 5228 5228 5229 CodeActionBuilder::new("Generate to-JSON function") 5229 - .kind(CodeActionKind::REFACTOR) 5230 + .kind(CodeActionKind::Refactor) 5230 5231 .preferred(false) 5231 5232 .changes( 5232 5233 self.params.text_document.uri.clone(), ··· 5599 5600 5600 5601 let mut action = Vec::with_capacity(1); 5601 5602 CodeActionBuilder::new(action_title) 5602 - .kind(CodeActionKind::REFACTOR_REWRITE) 5603 + .kind(CodeActionKind::RefactorRewrite) 5603 5604 .changes(self.params.text_document.uri.clone(), self.edits.edits) 5604 5605 .preferred(false) 5605 5606 .push_to(&mut action); ··· 6441 6442 }; 6442 6443 let mut action = Vec::with_capacity(1); 6443 6444 CodeActionBuilder::new("Generate function") 6444 - .kind(CodeActionKind::QUICKFIX) 6445 + .kind(CodeActionKind::QuickFix) 6445 6446 .changes(uri, self.edits.edits) 6446 6447 .preferred(true) 6447 6448 .push_to(&mut action); ··· 6774 6775 6775 6776 let mut action = Vec::with_capacity(1); 6776 6777 CodeActionBuilder::new("Generate variant") 6777 - .kind(CodeActionKind::QUICKFIX) 6778 + .kind(CodeActionKind::QuickFix) 6778 6779 .changes(variant_module, variant_edits) 6779 6780 .preferred(true) 6780 6781 .push_to(&mut action); ··· 7346 7347 7347 7348 let mut action = Vec::with_capacity(1); 7348 7349 CodeActionBuilder::new("Convert to function call") 7349 - .kind(CodeActionKind::REFACTOR_REWRITE) 7350 + .kind(CodeActionKind::RefactorRewrite) 7350 7351 .changes(self.params.text_document.uri.clone(), self.edits.edits) 7351 7352 .preferred(false) 7352 7353 .push_to(&mut action); ··· 7478 7479 self.edits.delete(location); 7479 7480 7480 7481 CodeActionBuilder::new("Inline variable") 7481 - .kind(CodeActionKind::REFACTOR_INLINE) 7482 + .kind(CodeActionKind::RefactorInline) 7482 7483 .changes( 7483 7484 self.params.text_document.uri.clone(), 7484 7485 std::mem::take(&mut self.edits.edits), ··· 7716 7717 7717 7718 let mut action = Vec::with_capacity(1); 7718 7719 CodeActionBuilder::new("Convert to pipe") 7719 - .kind(CodeActionKind::REFACTOR_REWRITE) 7720 + .kind(CodeActionKind::RefactorRewrite) 7720 7721 .changes(self.params.text_document.uri.clone(), self.edits.edits) 7721 7722 .preferred(false) 7722 7723 .push_to(&mut action); ··· 7945 7946 7946 7947 let mut action = Vec::with_capacity(1); 7947 7948 CodeActionBuilder::new("Interpolate string") 7948 - .kind(CodeActionKind::REFACTOR_REWRITE) 7949 + .kind(CodeActionKind::RefactorRewrite) 7949 7950 .changes(self.params.text_document.uri.clone(), self.edits.edits) 7950 7951 .preferred(false) 7951 7952 .push_to(&mut action); ··· 8170 8171 8171 8172 let mut action = Vec::with_capacity(1); 8172 8173 CodeActionBuilder::new("Fill unused fields") 8173 - .kind(CodeActionKind::REFACTOR_REWRITE) 8174 + .kind(CodeActionKind::RefactorRewrite) 8174 8175 .changes(self.params.text_document.uri.clone(), self.edits.edits) 8175 8176 .preferred(false) 8176 8177 .push_to(&mut action); ··· 8268 8269 8269 8270 let mut action = Vec::with_capacity(1); 8270 8271 CodeActionBuilder::new("Remove all `echo`s from this module") 8271 - .kind(CodeActionKind::REFACTOR_REWRITE) 8272 + .kind(CodeActionKind::RefactorRewrite) 8272 8273 .changes(self.params.text_document.uri.clone(), self.edits.edits) 8273 8274 .preferred(false) 8274 8275 .push_to(&mut action); ··· 8529 8530 8530 8531 let mut action = Vec::with_capacity(1); 8531 8532 CodeActionBuilder::new("Wrap in block") 8532 - .kind(CodeActionKind::REFACTOR_EXTRACT) 8533 + .kind(CodeActionKind::RefactorExtract) 8533 8534 .changes(self.params.text_document.uri.clone(), self.edits.edits) 8534 8535 .preferred(false) 8535 8536 .push_to(&mut action); ··· 8638 8639 8639 8640 let mut action = Vec::with_capacity(1); 8640 8641 CodeActionBuilder::new(format!("Use `{}`", replacement.name())) 8641 - .kind(CodeActionKind::REFACTOR_REWRITE) 8642 + .kind(CodeActionKind::RefactorRewrite) 8642 8643 .changes(self.params.text_document.uri.clone(), self.edits.edits) 8643 8644 .preferred(true) 8644 8645 .push_to(&mut action); ··· 8721 8722 8722 8723 let mut action = Vec::with_capacity(1); 8723 8724 CodeActionBuilder::new(format!("Replace with `{replacement}`")) 8724 - .kind(CodeActionKind::REFACTOR_REWRITE) 8725 + .kind(CodeActionKind::RefactorRewrite) 8725 8726 .changes(self.params.text_document.uri.clone(), self.edits.edits) 8726 8727 .preferred(true) 8727 8728 .push_to(&mut action); ··· 8971 8972 8972 8973 let mut action = Vec::with_capacity(1); 8973 8974 CodeActionBuilder::new("Remove unused imports") 8974 - .kind(CodeActionKind::REFACTOR_REWRITE) 8975 + .kind(CodeActionKind::RefactorRewrite) 8975 8976 .changes(self.params.text_document.uri.clone(), self.edits.edits) 8976 8977 .preferred(true) 8977 8978 .push_to(&mut action); ··· 9022 9023 9023 9024 let mut action = Vec::with_capacity(1); 9024 9025 CodeActionBuilder::new("Remove block") 9025 - .kind(CodeActionKind::REFACTOR_REWRITE) 9026 + .kind(CodeActionKind::RefactorRewrite) 9026 9027 .changes(self.params.text_document.uri.clone(), self.edits.edits) 9027 9028 .preferred(true) 9028 9029 .push_to(&mut action); ··· 9139 9140 9140 9141 let mut action = Vec::with_capacity(1); 9141 9142 CodeActionBuilder::new("Remove opaque from private type") 9142 - .kind(CodeActionKind::QUICKFIX) 9143 + .kind(CodeActionKind::QuickFix) 9143 9144 .changes(self.params.text_document.uri.clone(), self.edits.edits) 9144 9145 .preferred(true) 9145 9146 .push_to(&mut action); ··· 9476 9477 9477 9478 let mut action = Vec::with_capacity(1); 9478 9479 CodeActionBuilder::new("Collapse nested case") 9479 - .kind(CodeActionKind::REFACTOR_REWRITE) 9480 + .kind(CodeActionKind::RefactorRewrite) 9480 9481 .changes(self.params.text_document.uri.clone(), self.edits.edits) 9481 9482 .preferred(false) 9482 9483 .push_to(&mut action); ··· 9680 9681 9681 9682 let mut action = Vec::with_capacity(1); 9682 9683 CodeActionBuilder::new("Remove unreachable clauses") 9683 - .kind(CodeActionKind::QUICKFIX) 9684 + .kind(CodeActionKind::QuickFix) 9684 9685 .changes(self.params.text_document.uri.clone(), self.edits.edits) 9685 9686 .preferred(true) 9686 9687 .push_to(&mut action); ··· 9782 9783 9783 9784 let mut action = Vec::with_capacity(1); 9784 9785 CodeActionBuilder::new("Remove redundant record update") 9785 - .kind(CodeActionKind::QUICKFIX) 9786 + .kind(CodeActionKind::QuickFix) 9786 9787 .changes(self.params.text_document.uri.clone(), self.edits.edits) 9787 9788 .preferred(true) 9788 9789 .push_to(&mut action); ··· 9848 9849 9849 9850 let mut action = Vec::with_capacity(1); 9850 9851 CodeActionBuilder::new("Add omitted labels") 9851 - .kind(CodeActionKind::REFACTOR_REWRITE) 9852 + .kind(CodeActionKind::RefactorRewrite) 9852 9853 .changes(self.params.text_document.uri.clone(), self.edits.edits) 9853 9854 .preferred(false) 9854 9855 .push_to(&mut action); ··· 10305 10306 10306 10307 let mut action = Vec::with_capacity(1); 10307 10308 CodeActionBuilder::new("Extract function") 10308 - .kind(CodeActionKind::REFACTOR_EXTRACT) 10309 + .kind(CodeActionKind::RefactorExtract) 10309 10310 .changes(self.params.text_document.uri.clone(), self.edits.edits) 10310 10311 .preferred(false) 10311 10312 .push_to(&mut action); ··· 11326 11327 11327 11328 let mut action = Vec::with_capacity(1); 11328 11329 CodeActionBuilder::new("Merge case branches") 11329 - .kind(CodeActionKind::REFACTOR_REWRITE) 11330 + .kind(CodeActionKind::RefactorRewrite) 11330 11331 .changes(self.params.text_document.uri.clone(), self.edits.edits) 11331 11332 .preferred(false) 11332 11333 .push_to(&mut action); ··· 11562 11563 11563 11564 let mut action = Vec::with_capacity(1); 11564 11565 CodeActionBuilder::new("Add missing type parameter") 11565 - .kind(CodeActionKind::QUICKFIX) 11566 + .kind(CodeActionKind::QuickFix) 11566 11567 .changes(self.params.text_document.uri.clone(), self.edits.edits) 11567 11568 .preferred(true) 11568 11569 .push_to(&mut action); ··· 11659 11660 .replace(location, format!("{}", printer.print_type(&type_))); 11660 11661 11661 11662 CodeActionBuilder::new("Replace `_` with type") 11662 - .kind(CodeActionKind::QUICKFIX) 11663 + .kind(CodeActionKind::QuickFix) 11663 11664 .changes(self.params.text_document.uri.clone(), self.edits.edits) 11664 11665 .preferred(true) 11665 11666 .push_to(&mut action); ··· 11754 11755 .insert(target.location.end, format!("({arguments}) }}")); 11755 11756 11756 11757 CodeActionBuilder::new("Wrap in anonymous function") 11757 - .kind(CodeActionKind::REFACTOR_REWRITE) 11758 + .kind(CodeActionKind::RefactorRewrite) 11758 11759 .changes( 11759 11760 self.params.text_document.uri.clone(), 11760 11761 self.edits.edits.drain(..).collect(), ··· 11935 11936 }); 11936 11937 11937 11938 CodeActionBuilder::new("Remove anonymous function wrapper") 11938 - .kind(CodeActionKind::REFACTOR_REWRITE) 11939 + .kind(CodeActionKind::RefactorRewrite) 11939 11940 .changes(self.params.text_document.uri.clone(), edits.edits) 11940 11941 .push_to(&mut actions); 11941 11942 } ··· 12133 12134 self.module.origin.folder_name(), 12134 12135 unknown_module.name 12135 12136 )) 12136 - .kind(CodeActionKind::QUICKFIX) 12137 - .document_changes(DocumentChanges::Operations(vec![ 12138 - DocumentChangeOperation::Op(ResourceOp::Create(CreateFile { 12139 - uri, 12140 - options: Some(CreateFileOptions { 12141 - overwrite: Some(false), 12142 - ignore_if_exists: Some(true), 12143 - }), 12144 - annotation_id: None, 12145 - })), 12146 - ])) 12137 + .kind(CodeActionKind::QuickFix) 12138 + .document_changes(vec![DocumentChange::CreateFile(CreateFile { 12139 + uri, 12140 + options: Some(CreateFileOptions { 12141 + overwrite: Some(false), 12142 + ignore_if_exists: Some(true), 12143 + }), 12144 + annotation_id: None, 12145 + })]) 12147 12146 .push_to(&mut actions); 12148 12147 } 12149 12148
+24 -24
language-server/src/completer.rs
··· 3 3 use ecow::{EcoString, eco_format}; 4 4 use itertools::Itertools; 5 5 use lsp_types::{ 6 - CompletionItem, CompletionItemKind, CompletionItemLabelDetails, CompletionTextEdit, 6 + CompletionItem, CompletionItemKind, CompletionItemLabelDetails, CompletionItemTextEdit, 7 7 Documentation, MarkupContent, MarkupKind, Position, Range, TextDocumentPositionParams, 8 8 TextEdit, 9 9 }; ··· 208 208 /// > This could also return `None` as sometimes no further edit is actually 209 209 /// > needed! 210 210 /// 211 - fn to_text_edit(&self, new_text: String) -> Option<CompletionTextEdit> { 211 + fn to_text_edit(&self, new_text: String) -> Option<CompletionItemTextEdit> { 212 212 // We need to check if the new text we're adding could actually be 213 213 // a simple addition in the middle of something that is already being 214 214 // typed. ··· 247 247 // This is one of the cases (like the one in the example above) were 248 248 // the label is a more complete version of the text surrounding the 249 249 // cursor. So we replace the entire range. 250 - Some(_) => Some(CompletionTextEdit::Edit(TextEdit { 250 + Some(_) => Some(CompletionItemTextEdit::TextEdit(TextEdit { 251 251 range: self.surrounding_text_range, 252 252 new_text, 253 253 })), 254 254 // In all other cases the completion is never meant to replace text 255 255 // that comes after the cursor. 256 256 // We only replace what comes before it with the new text. 257 - None => Some(CompletionTextEdit::Edit(TextEdit { 257 + None => Some(CompletionItemTextEdit::TextEdit(TextEdit { 258 258 range: self.text_before_cursor_range, 259 259 new_text, 260 260 })), ··· 634 634 .iter() 635 635 .map(|(name, _)| CompletionItem { 636 636 label: name.to_string(), 637 - kind: Some(CompletionItemKind::MODULE), 638 - text_edit: Some(CompletionTextEdit::Edit(TextEdit { 637 + kind: Some(CompletionItemKind::Module), 638 + text_edit: Some(CompletionItemTextEdit::TextEdit(TextEdit { 639 639 range: Range { start, end }, 640 640 new_text: name.to_string(), 641 641 })), ··· 682 682 completions.push(CompletionItem { 683 683 label, 684 684 detail: Some("Type".into()), 685 - kind: Some(CompletionItemKind::CLASS), 685 + kind: Some(CompletionItemKind::Class), 686 686 sort_text, 687 687 ..Default::default() 688 688 }); ··· 920 920 PreludeType::Bool => { 921 921 push_prelude_completion( 922 922 "True", 923 - CompletionItemKind::ENUM_MEMBER, 923 + CompletionItemKind::EnumMember, 924 924 type_::bool(), 925 925 ); 926 926 push_prelude_completion( 927 927 "False", 928 - CompletionItemKind::ENUM_MEMBER, 928 + CompletionItemKind::EnumMember, 929 929 type_::bool(), 930 930 ); 931 931 } 932 932 PreludeType::Nil => { 933 933 push_prelude_completion( 934 934 "Nil", 935 - CompletionItemKind::ENUM_MEMBER, 935 + CompletionItemKind::EnumMember, 936 936 type_::nil(), 937 937 ); 938 938 } 939 939 PreludeType::Result => { 940 940 push_prelude_completion( 941 941 "Ok", 942 - CompletionItemKind::CONSTRUCTOR, 942 + CompletionItemKind::Constructor, 943 943 type_::result(type_::unbound_var(0), type_::unbound_var(0)), 944 944 ); 945 945 push_prelude_completion( 946 946 "Error", 947 - CompletionItemKind::CONSTRUCTOR, 947 + CompletionItemKind::Constructor, 948 948 type_::result(type_::unbound_var(0), type_::unbound_var(0)), 949 949 ); 950 950 } ··· 1219 1219 CompletionItem { 1220 1220 label, 1221 1221 detail, 1222 - kind: Some(CompletionItemKind::FIELD), 1222 + kind: Some(CompletionItemKind::Field), 1223 1223 sort_text, 1224 1224 ..Default::default() 1225 1225 } ··· 1266 1266 1267 1267 CompletionItem { 1268 1268 label: label.clone(), 1269 - kind: Some(CompletionItemKind::KEYWORD), 1269 + kind: Some(CompletionItemKind::Keyword), 1270 1270 detail: None, 1271 1271 label_details: None, 1272 1272 documentation: None, ··· 1298 1298 let type_ = Printer::new().pretty_print(&value.type_, 0); 1299 1299 1300 1300 let kind = Some(match value.variant { 1301 - ValueConstructorVariant::LocalVariable { .. } => CompletionItemKind::VARIABLE, 1302 - ValueConstructorVariant::ModuleConstant { .. } => CompletionItemKind::CONSTANT, 1303 - ValueConstructorVariant::ModuleFn { .. } => CompletionItemKind::FUNCTION, 1304 - ValueConstructorVariant::Record { arity: 0, .. } => CompletionItemKind::ENUM_MEMBER, 1305 - ValueConstructorVariant::Record { .. } => CompletionItemKind::CONSTRUCTOR, 1301 + ValueConstructorVariant::LocalVariable { .. } => CompletionItemKind::Variable, 1302 + ValueConstructorVariant::ModuleConstant { .. } => CompletionItemKind::Constant, 1303 + ValueConstructorVariant::ModuleFn { .. } => CompletionItemKind::Function, 1304 + ValueConstructorVariant::Record { arity: 0, .. } => CompletionItemKind::EnumMember, 1305 + ValueConstructorVariant::Record { .. } => CompletionItemKind::Constructor, 1306 1306 }); 1307 1307 1308 1308 let documentation = value.get_documentation().map(|documentation| { ··· 1333 1333 1334 1334 CompletionItem { 1335 1335 label: label.into(), 1336 - kind: Some(CompletionItemKind::FIELD), 1336 + kind: Some(CompletionItemKind::Field), 1337 1337 detail: Some(type_), 1338 1338 sort_text: Some(sort_text(CompletionKind::FieldAccessor, label, type_match)), 1339 1339 ..Default::default() ··· 1368 1368 }; 1369 1369 1370 1370 let kind = Some(if type_.type_.is_variable() { 1371 - CompletionItemKind::VARIABLE 1371 + CompletionItemKind::Variable 1372 1372 } else { 1373 - CompletionItemKind::CLASS 1373 + CompletionItemKind::Class 1374 1374 }); 1375 1375 1376 1376 let completion_text = match type_completion_context { ··· 1496 1496 1497 1497 CompletionItem { 1498 1498 label: label.clone(), 1499 - kind: Some(CompletionItemKind::VARIABLE), 1499 + kind: Some(CompletionItemKind::Variable), 1500 1500 detail: Some(type_), 1501 1501 label_details: Some(CompletionItemLabelDetails { 1502 1502 detail: None, ··· 1508 1508 &label, 1509 1509 type_match, 1510 1510 )), 1511 - text_edit: Some(CompletionTextEdit::Edit(TextEdit { 1511 + text_edit: Some(CompletionItemTextEdit::TextEdit(TextEdit { 1512 1512 range: insert_range, 1513 1513 new_text: label.clone(), 1514 1514 })),
+44 -38
language-server/src/engine.rs
··· 26 26 use lsp::CodeAction; 27 27 use lsp_server::ResponseError; 28 28 use lsp_types::{ 29 - self as lsp, DocumentSymbol, FoldingRange, FoldingRangeKind, Hover, HoverContents, 30 - MarkedString, Position, PrepareRenameResponse, Range, SignatureHelp, SymbolKind, SymbolTag, 31 - TextEdit, Url, WorkspaceEdit, 29 + self as lsp, Contents, DocumentSymbol, FoldingRange, FoldingRangeKind, Hover, MarkedString, 30 + MarkupContent, Position, PrepareRenameResult, Range, SignatureHelp, SymbolKind, SymbolTag, 31 + TextEdit, Uri as Url, WorkspaceEdit, 32 32 }; 33 33 use std::{collections::HashSet, sync::Arc}; 34 34 ··· 193 193 194 194 pub fn goto_definition( 195 195 &mut self, 196 - params: lsp::GotoDefinitionParams, 196 + params: lsp::DefinitionParams, 197 197 ) -> Response<Option<lsp::Location>> { 198 198 self.respond(|this| { 199 199 let params = params.text_document_position_params; ··· 214 214 215 215 pub(crate) fn goto_type_definition( 216 216 &mut self, 217 - params: lsp_types::GotoDefinitionParams, 217 + params: lsp_types::TypeDefinitionParams, 218 218 ) -> Response<Vec<lsp::Location>> { 219 219 self.respond(|this| { 220 220 let params = params.text_document_position_params; ··· 571 571 .print_type(&get_function_type(function)) 572 572 .to_string(), 573 573 ), 574 - kind: SymbolKind::FUNCTION, 574 + kind: SymbolKind::Function, 575 575 tags: make_deprecated_symbol_tag(&function.deprecation), 576 576 deprecated: None, 577 577 range: src_span_to_lsp_range(full_function_span, &line_numbers), ··· 603 603 .print_type_without_aliases(&alias.type_) 604 604 .to_string(), 605 605 ), 606 - kind: SymbolKind::CLASS, 606 + kind: SymbolKind::Class, 607 607 tags: make_deprecated_symbol_tag(&alias.deprecation), 608 608 deprecated: None, 609 609 range: src_span_to_lsp_range(full_alias_span, &line_numbers), ··· 643 643 .print_type(&constant.type_) 644 644 .to_string(), 645 645 ), 646 - kind: SymbolKind::CONSTANT, 646 + kind: SymbolKind::Constant, 647 647 tags: make_deprecated_symbol_tag(&constant.deprecation), 648 648 deprecated: None, 649 649 range: src_span_to_lsp_range(full_constant_span, &line_numbers), ··· 737 737 738 738 pub fn prepare_rename( 739 739 &mut self, 740 - params: lsp::TextDocumentPositionParams, 741 - ) -> Response<Option<PrepareRenameResponse>> { 740 + params: lsp::PrepareRenameParams, 741 + ) -> Response<Option<PrepareRenameResult>> { 742 742 self.respond(|this| { 743 - let (lines, found) = match this.node_at_position(&params) { 743 + let (lines, found) = match this.node_at_position(&params.text_document_position_params) 744 + { 744 745 Some(value) => value, 745 746 None => return Ok(None), 746 747 }; 747 748 748 - let Some(current_module) = this.module_for_uri(&params.text_document.uri) else { 749 + let Some(current_module) = 750 + this.module_for_uri(&params.text_document_position_params.text_document.uri) 751 + else { 749 752 return Ok(None); 750 753 }; 751 754 752 755 let success_response = |location| { 753 - Some(PrepareRenameResponse::Range(src_span_to_lsp_range( 756 + Some(PrepareRenameResult::Range(src_span_to_lsp_range( 754 757 location, &lines, 755 758 ))) 756 759 }; 757 760 758 - let byte_index = lines.byte_index(params.position); 761 + let byte_index = lines.byte_index(params.text_document_position_params.position); 759 762 760 763 let referenced = reference_for_ast_node(found, &current_module.name); 761 764 ··· 813 816 params: lsp::RenameParams, 814 817 ) -> Response<Result<Option<WorkspaceEdit>, ResponseError>> { 815 818 self.respond(|this| { 816 - let position = &params.text_document_position; 819 + let position = &params.text_document_position_params; 817 820 818 821 let (lines, found) = match this.node_at_position(position) { 819 822 Some(value) => value, ··· 913 916 params: lsp::ReferenceParams, 914 917 ) -> Response<Option<Vec<lsp::Location>>> { 915 918 self.respond(|this| { 916 - let position = &params.text_document_position; 919 + let position = &params.text_document_position_params; 917 920 918 921 let (lines, found) = match this.node_at_position(position) { 919 922 Some(value) => value, ··· 1120 1123 }; 1121 1124 1122 1125 Some(Hover { 1123 - contents: HoverContents::Scalar(MarkedString::from_markdown(content)), 1126 + contents: Contents::MarkupContent(MarkupContent { 1127 + value: content, 1128 + kind: lsp_types::MarkupKind::Markdown, 1129 + }), 1124 1130 range, 1125 1131 }) 1126 1132 } ··· 1343 1349 .print_type(&argument.type_) 1344 1350 .to_string(), 1345 1351 ), 1346 - kind: SymbolKind::FIELD, 1352 + kind: SymbolKind::Field, 1347 1353 tags: None, 1348 1354 deprecated: None, 1349 1355 range: src_span_to_lsp_range(full_arg_span, line_numbers), ··· 1373 1379 name: constructor.name.to_string(), 1374 1380 detail: None, 1375 1381 kind: if constructor.arguments.is_empty() { 1376 - SymbolKind::ENUM_MEMBER 1382 + SymbolKind::EnumMember 1377 1383 } else { 1378 - SymbolKind::CONSTRUCTOR 1384 + SymbolKind::Constructor 1379 1385 }, 1380 1386 tags: make_deprecated_symbol_tag(&constructor.deprecation), 1381 1387 deprecated: None, ··· 1411 1417 DocumentSymbol { 1412 1418 name: type_.name.to_string(), 1413 1419 detail: None, 1414 - kind: SymbolKind::CLASS, 1420 + kind: SymbolKind::Class, 1415 1421 tags: make_deprecated_symbol_tag(&type_.deprecation), 1416 1422 deprecated: None, 1417 1423 range: src_span_to_lsp_range(full_type_span, line_numbers), ··· 1436 1442 {documentation}" 1437 1443 ); 1438 1444 Hover { 1439 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1445 + contents: Contents::MarkedString(MarkedString::String(contents)), 1440 1446 range: Some(src_span_to_lsp_range(pattern.location(), &line_numbers)), 1441 1447 } 1442 1448 } ··· 1472 1478 {documentation}" 1473 1479 ); 1474 1480 Hover { 1475 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1481 + contents: Contents::MarkedString(MarkedString::String(contents)), 1476 1482 range: Some(src_span_to_lsp_range(fun.location, &line_numbers)), 1477 1483 } 1478 1484 } ··· 1485 1491 let type_ = Printer::new(&module.ast.names).print_type(&argument.type_); 1486 1492 let contents = format!("```gleam\n{type_}\n```"); 1487 1493 Hover { 1488 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1494 + contents: Contents::MarkedString(MarkedString::String(contents)), 1489 1495 range: Some(src_span_to_lsp_range(argument.location, &line_numbers)), 1490 1496 } 1491 1497 } ··· 1513 1519 {documentation}" 1514 1520 ); 1515 1521 Hover { 1516 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1522 + contents: Contents::MarkedString(MarkedString::String(contents)), 1517 1523 range: Some(src_span_to_lsp_range(location, &line_numbers)), 1518 1524 } 1519 1525 } ··· 1527 1533 let type_ = Printer::new(&module.ast.names).print_type(&type_); 1528 1534 let contents = format!("```gleam\n{type_}\n```"); 1529 1535 Hover { 1530 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1536 + contents: Contents::MarkedString(MarkedString::String(contents)), 1531 1537 range: Some(src_span_to_lsp_range(location, &line_numbers)), 1532 1538 } 1533 1539 } ··· 1546 1552 .unwrap_or(&empty_str); 1547 1553 let contents = format!("```gleam\n{type_}\n```\n{documentation}"); 1548 1554 Hover { 1549 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1555 + contents: Contents::MarkedString(MarkedString::String(contents)), 1550 1556 range: Some(src_span_to_lsp_range(constant.location, &line_numbers)), 1551 1557 } 1552 1558 } ··· 1559 1565 let type_ = Printer::new(&module.ast.names).print_type(&constant.type_()); 1560 1566 let contents = format!("```gleam\n{type_}\n```"); 1561 1567 Hover { 1562 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1568 + contents: Contents::MarkedString(MarkedString::String(contents)), 1563 1569 range: Some(src_span_to_lsp_range(constant.location(), &line_numbers)), 1564 1570 } 1565 1571 } ··· 1572 1578 let type_ = Printer::new(&module.ast.names).print_type(&guard.type_()); 1573 1579 let contents = format!("```gleam\n{type_}\n```"); 1574 1580 Hover { 1575 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1581 + contents: Contents::MarkedString(MarkedString::String(contents)), 1576 1582 range: Some(src_span_to_lsp_range(guard.location(), &line_numbers)), 1577 1583 } 1578 1584 } ··· 1585 1591 let type_ = Printer::new(&module.ast.names).print_type(&type_::string()); 1586 1592 let contents = format!("```gleam\n{type_}\n```"); 1587 1593 Hover { 1588 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1594 + contents: Contents::MarkedString(MarkedString::String(contents)), 1589 1595 range: Some(src_span_to_lsp_range(location, lines)), 1590 1596 } 1591 1597 } ··· 1613 1619 {documentation}{link_section}" 1614 1620 ); 1615 1621 Hover { 1616 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1622 + contents: Contents::MarkedString(MarkedString::String(contents)), 1617 1623 range: Some(src_span_to_lsp_range(expression.location(), &line_numbers)), 1618 1624 } 1619 1625 } ··· 1641 1647 {documentation}{link_section}" 1642 1648 ); 1643 1649 Hover { 1644 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1650 + contents: Contents::MarkedString(MarkedString::String(contents)), 1645 1651 range: Some(src_span_to_lsp_range(*location, &line_numbers)), 1646 1652 } 1647 1653 } ··· 1669 1675 {link_section}", 1670 1676 ); 1671 1677 Hover { 1672 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1678 + contents: Contents::MarkedString(MarkedString::String(contents)), 1673 1679 range: Some(src_span_to_lsp_range(location, line_numbers)), 1674 1680 } 1675 1681 } ··· 1684 1690 1685 1691 let contents = format!("```gleam\n{name}\n```\n{documentation}"); 1686 1692 Hover { 1687 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1693 + contents: Contents::MarkedString(MarkedString::String(contents)), 1688 1694 range: Some(src_span_to_lsp_range(type_.full_location(), &line_numbers)), 1689 1695 } 1690 1696 } ··· 1719 1725 1720 1726 let contents = format!("```gleam\n{constructor_doc}\n```\n{documentation}"); 1721 1727 Hover { 1722 - contents: HoverContents::Scalar(MarkedString::String(contents)), 1728 + contents: Contents::MarkedString(MarkedString::String(contents)), 1723 1729 range: Some(src_span_to_lsp_range(constructor.location, &line_numbers)), 1724 1730 } 1725 1731 } ··· 1849 1855 }; 1850 1856 1851 1857 CodeActionBuilder::new("Assign unused Result value to `_`") 1852 - .kind(lsp_types::CodeActionKind::QUICKFIX) 1858 + .kind(lsp_types::CodeActionKind::QuickFix) 1853 1859 .changes(uri.clone(), vec![edit]) 1854 1860 .preferred(true) 1855 1861 .push_to(actions); ··· 1912 1918 }; 1913 1919 1914 1920 CodeActionBuilder::new(format!("Rename to {correction}")) 1915 - .kind(lsp_types::CodeActionKind::QUICKFIX) 1921 + .kind(lsp_types::CodeActionKind::QuickFix) 1916 1922 .changes(uri.clone(), vec![edit]) 1917 1923 .preferred(true) 1918 1924 .push_to(actions); ··· 2011 2017 fn make_deprecated_symbol_tag(deprecation: &Deprecation) -> Option<Vec<SymbolTag>> { 2012 2018 deprecation 2013 2019 .is_deprecated() 2014 - .then(|| vec![SymbolTag::DEPRECATED]) 2020 + .then(|| vec![SymbolTag::Deprecated]) 2015 2021 }
+1 -1
language-server/src/lib.rs
··· 75 75 Result, ast::SrcSpan, build::Target, line_numbers::LineNumbers, manifest::Manifest, 76 76 paths::ProjectPaths, 77 77 }; 78 - use lsp_types::{Position, Range, TextEdit, Url}; 78 + use lsp_types::{Position, Range, TextEdit, Uri as Url}; 79 79 use std::any::Any; 80 80 81 81 #[derive(Debug)]
+31 -31
language-server/src/messages.rs
··· 1 1 use camino::Utf8PathBuf; 2 - use lsp::{ 3 - notification::{DidChangeWatchedFiles, DidOpenTextDocument}, 4 - request::GotoDefinition, 5 - }; 2 + use lsp::{DefinitionRequest, DidChangeWatchedFilesNotification, DidOpenTextDocumentNotification}; 6 3 use lsp_types::{ 7 - self as lsp, 8 - notification::{DidChangeTextDocument, DidCloseTextDocument, DidSaveTextDocument}, 9 - request::{ 10 - CodeActionRequest, Completion, DocumentSymbolRequest, FoldingRangeRequest, Formatting, 11 - GotoTypeDefinition, HoverRequest, PrepareRenameRequest, References, Rename, 12 - SignatureHelpRequest, 13 - }, 4 + self as lsp, CodeActionRequest, CompletionRequest, DidChangeTextDocumentNotification, 5 + DidCloseTextDocumentNotification, DidSaveTextDocumentNotification, DocumentFormattingRequest, 6 + DocumentSymbolRequest, FoldingRangeRequest, HoverRequest, PrepareRenameRequest, 7 + ReferencesRequest, RenameRequest, SignatureHelpRequest, TextDocumentContentChangeEvent, 8 + TypeDefinitionRequest, 14 9 }; 15 10 use std::time::Duration; 16 11 ··· 24 19 pub enum Request { 25 20 Format(lsp::DocumentFormattingParams), 26 21 Hover(lsp::HoverParams), 27 - GoToDefinition(lsp::GotoDefinitionParams), 28 - GoToTypeDefinition(lsp::GotoDefinitionParams), 22 + GoToDefinition(lsp::DefinitionParams), 23 + GoToTypeDefinition(lsp::TypeDefinitionParams), 29 24 Completion(lsp::CompletionParams), 30 25 CodeAction(lsp::CodeActionParams), 31 26 SignatureHelp(lsp::SignatureHelpParams), 32 27 DocumentSymbol(lsp::DocumentSymbolParams), 33 28 FoldingRange(lsp::FoldingRangeParams), 34 - PrepareRename(lsp::TextDocumentPositionParams), 29 + PrepareRename(lsp::PrepareRenameParams), 35 30 Rename(lsp::RenameParams), 36 31 FindReferences(lsp::ReferenceParams), 37 32 } ··· 41 36 let id = request.id.clone(); 42 37 match request.method.as_str() { 43 38 "textDocument/formatting" => { 44 - let params = cast_request::<Formatting>(request); 39 + let params = cast_request::<DocumentFormattingRequest>(request); 45 40 Some(Message::Request(id, Request::Format(params))) 46 41 } 47 42 "textDocument/hover" => { ··· 49 44 Some(Message::Request(id, Request::Hover(params))) 50 45 } 51 46 "textDocument/definition" => { 52 - let params = cast_request::<GotoDefinition>(request); 47 + let params = cast_request::<DefinitionRequest>(request); 53 48 Some(Message::Request(id, Request::GoToDefinition(params))) 54 49 } 55 50 "textDocument/completion" => { 56 - let params = cast_request::<Completion>(request); 51 + let params = cast_request::<CompletionRequest>(request); 57 52 Some(Message::Request(id, Request::Completion(params))) 58 53 } 59 54 "textDocument/codeAction" => { ··· 73 68 Some(Message::Request(id, Request::FoldingRange(params))) 74 69 } 75 70 "textDocument/rename" => { 76 - let params = cast_request::<Rename>(request); 71 + let params = cast_request::<RenameRequest>(request); 77 72 Some(Message::Request(id, Request::Rename(params))) 78 73 } 79 74 "textDocument/prepareRename" => { ··· 81 76 Some(Message::Request(id, Request::PrepareRename(params))) 82 77 } 83 78 "textDocument/typeDefinition" => { 84 - let params = cast_request::<GotoTypeDefinition>(request); 79 + let params = cast_request::<TypeDefinitionRequest>(request); 85 80 Some(Message::Request(id, Request::GoToTypeDefinition(params))) 86 81 } 87 82 "textDocument/references" => { 88 - let params = cast_request::<References>(request); 83 + let params = cast_request::<ReferencesRequest>(request); 89 84 Some(Message::Request(id, Request::FindReferences(params))) 90 85 } 91 86 _ => None, ··· 113 108 fn extract(notification: lsp_server::Notification) -> Option<Message> { 114 109 match notification.method.as_str() { 115 110 "textDocument/didOpen" => { 116 - let params = cast_notification::<DidOpenTextDocument>(notification); 111 + let params = cast_notification::<DidOpenTextDocumentNotification>(notification); 117 112 let notification = Notification::SourceFileOpened { 118 113 path: super::path(&params.text_document.uri), 119 114 text: params.text_document.text, ··· 121 116 Some(Message::Notification(notification)) 122 117 } 123 118 "textDocument/didChange" => { 124 - let params = cast_notification::<DidChangeTextDocument>(notification); 119 + let params = cast_notification::<DidChangeTextDocumentNotification>(notification); 120 + let TextDocumentContentChangeEvent::TextDocumentContentChangeWholeDocument(change) = 121 + params.content_changes.into_iter().next_back()? 122 + else { 123 + return None; 124 + }; 125 125 let notification = Notification::SourceFileChangedInMemory { 126 - path: super::path(&params.text_document.uri), 127 - text: params.content_changes.into_iter().next_back()?.text, 126 + path: super::path(&params.text_document.text_document_identifier.uri), 127 + text: change.text, 128 128 }; 129 129 Some(Message::Notification(notification)) 130 130 } 131 131 "textDocument/didSave" => { 132 - let params = cast_notification::<DidSaveTextDocument>(notification); 132 + let params = cast_notification::<DidSaveTextDocumentNotification>(notification); 133 133 let notification = Notification::SourceFileSaved { 134 134 path: super::path(&params.text_document.uri), 135 135 }; 136 136 Some(Message::Notification(notification)) 137 137 } 138 138 "textDocument/didClose" => { 139 - let params = cast_notification::<DidCloseTextDocument>(notification); 139 + let params = cast_notification::<DidCloseTextDocumentNotification>(notification); 140 140 let notification = Notification::SourceFileClosed { 141 141 path: super::path(&params.text_document.uri), 142 142 }; 143 143 Some(Message::Notification(notification)) 144 144 } 145 145 "workspace/didChangeWatchedFiles" => { 146 - let params = cast_notification::<DidChangeWatchedFiles>(notification); 146 + let params = cast_notification::<DidChangeWatchedFilesNotification>(notification); 147 147 let notification = Notification::ConfigFileChanged { 148 148 path: super::path(&params.changes.into_iter().next_back()?.uri), 149 149 }; ··· 263 263 264 264 fn cast_request<R>(request: lsp_server::Request) -> R::Params 265 265 where 266 - R: lsp::request::Request, 266 + R: lsp::Request, 267 267 R::Params: serde::de::DeserializeOwned, 268 268 { 269 - let (_, params) = request.extract(R::METHOD).expect("cast request"); 269 + let (_, params) = request.extract(R::METHOD.as_str()).expect("cast request"); 270 270 params 271 271 } 272 272 273 273 fn cast_notification<N>(notification: lsp_server::Notification) -> N::Params 274 274 where 275 - N: lsp::notification::Notification, 275 + N: lsp::Notification, 276 276 N::Params: serde::de::DeserializeOwned, 277 277 { 278 278 notification 279 - .extract::<N::Params>(N::METHOD) 279 + .extract::<N::Params>(N::METHOD.as_str()) 280 280 .expect("cast notification") 281 281 }
+12 -10
language-server/src/progress.rs
··· 1 1 use debug_ignore::DebugIgnore; 2 2 use lsp_types::{ 3 - InitializeParams, NumberOrString, ProgressParams, ProgressParamsValue, WorkDoneProgress, 4 - WorkDoneProgressBegin, WorkDoneProgressCreateParams, WorkDoneProgressEnd, 3 + InitializeParams, LspAny, ProgressParams, ProgressToken, WorkDoneProgressBegin, 4 + WorkDoneProgressCreateParams, WorkDoneProgressEnd, 5 5 }; 6 6 7 7 const DOWNLOADING_TOKEN: &str = "downloading-dependencies"; ··· 35 35 } 36 36 } 37 37 38 - fn send_notification(&self, token: &str, work_done: WorkDoneProgress) { 38 + fn send_notification(&self, token: &str, work_done: LspAny) { 39 39 let params = ProgressParams { 40 - token: NumberOrString::String(token.to_string()), 41 - value: ProgressParamsValue::WorkDone(work_done), 40 + token: ProgressToken::String(token.to_string()), 41 + value: work_done, 42 42 }; 43 43 let notification = lsp_server::Notification { 44 44 method: "$/progress".into(), ··· 72 72 } 73 73 } 74 74 75 - fn end_message() -> WorkDoneProgress { 76 - WorkDoneProgress::End(WorkDoneProgressEnd { message: None }) 75 + fn end_message() -> LspAny { 76 + serde_json::to_value(WorkDoneProgressEnd { message: None }) 77 + .expect("Failed to serialize WorkDoneProgressEnd") 77 78 } 78 79 79 - fn begin_message(title: &str) -> WorkDoneProgress { 80 - WorkDoneProgress::Begin(WorkDoneProgressBegin { 80 + fn begin_message(title: &str) -> LspAny { 81 + serde_json::to_value(WorkDoneProgressBegin { 81 82 title: title.into(), 82 83 cancellable: Some(false), 83 84 message: None, 84 85 percentage: None, 85 86 }) 87 + .expect("Failed to serialize WorkDoneProgressBegin") 86 88 } 87 89 88 90 fn create_token(token: &str, connection: &lsp_server::Connection) { 89 91 let params = WorkDoneProgressCreateParams { 90 - token: NumberOrString::String(token.into()), 92 + token: ProgressToken::String(token.into()), 91 93 }; 92 94 let request = lsp_server::Request { 93 95 id: format!("create-token--{token}").into(),
+16 -4
language-server/src/rename.rs
··· 2 2 3 3 use ecow::EcoString; 4 4 use lsp_server::ResponseError; 5 - use lsp_types::{Range, RenameParams, TextEdit, Url, WorkspaceEdit}; 5 + use lsp_types::{Range, RenameParams, TextEdit, Uri as Url, WorkspaceEdit}; 6 6 7 7 use gleam_core::{ 8 8 analyse::name, ··· 76 76 return RenameOutcome::InvalidName { name: new_name }; 77 77 } 78 78 79 - let uri = params.text_document_position.text_document.uri.clone(); 79 + let uri = params 80 + .text_document_position_params 81 + .text_document 82 + .uri 83 + .clone(); 80 84 let mut edits = TextEdits::new(line_numbers); 81 85 82 86 let references = ··· 292 296 293 297 RenameOutcome::Renamed { 294 298 edit: workspace_edit( 295 - params.text_document_position.text_document.uri.clone(), 299 + params 300 + .text_document_position_params 301 + .text_document 302 + .uri 303 + .clone(), 296 304 edits.edits, 297 305 ), 298 306 } ··· 342 350 return RenameOutcome::InvalidName { name: new_name }; 343 351 } 344 352 345 - let uri = params.text_document_position.text_document.uri.clone(); 353 + let uri = params 354 + .text_document_position_params 355 + .text_document 356 + .uri 357 + .clone(); 346 358 let mut edits = TextEdits::new(line_numbers); 347 359 348 360 let mut finder = reference::FindModuleNameReferences {
+45 -37
language-server/src/server.rs
··· 18 18 }; 19 19 use lsp_server::ResponseError; 20 20 use lsp_types::{ 21 - self as lsp, HoverProviderCapability, InitializeParams, Position, PublishDiagnosticsParams, 22 - Range, RenameOptions, TextEdit, Url, 21 + self as lsp, InitializeParams, Position, PublishDiagnosticsParams, Range, RenameOptions, 22 + TextEdit, Uri as Url, 23 23 }; 24 24 use serde_json::Value as Json; 25 25 use std::collections::{HashMap, HashSet}; ··· 224 224 fn publish_messages(&self, messages: Vec<Diagnostic>) { 225 225 for message in messages { 226 226 let params = lsp::ShowMessageParams { 227 - typ: match message.level { 228 - Level::Error => lsp::MessageType::ERROR, 229 - Level::Warning => lsp::MessageType::WARNING, 227 + kind: match message.level { 228 + Level::Error => lsp::MessageType::Error, 229 + Level::Warning => lsp::MessageType::Warning, 230 230 }, 231 231 message: message.text, 232 232 }; ··· 352 352 353 353 fn goto_definition( 354 354 &mut self, 355 - params: lsp::GotoDefinitionParams, 355 + params: lsp::DefinitionParams, 356 356 ) -> (Result<Json, ResponseError>, Feedback) { 357 357 let path = super::path(&params.text_document_position_params.text_document.uri); 358 358 self.respond_with_engine(path, |engine| engine.goto_definition(params)) ··· 360 360 361 361 fn goto_type_definition( 362 362 &mut self, 363 - params: lsp_types::GotoDefinitionParams, 363 + params: lsp_types::TypeDefinitionParams, 364 364 ) -> (Result<Json, ResponseError>, Feedback) { 365 365 let path = super::path(&params.text_document_position_params.text_document.uri); 366 366 self.respond_with_engine(path, |engine| engine.goto_type_definition(params)) ··· 370 370 &mut self, 371 371 params: lsp::CompletionParams, 372 372 ) -> (Result<Json, ResponseError>, Feedback) { 373 - let path = super::path(&params.text_document_position.text_document.uri); 373 + let path = super::path(&params.text_document_position_params.text_document.uri); 374 374 375 375 let src = match self.io.read(&path) { 376 376 Ok(src) => src.into(), 377 377 Err(error) => return self.path_error_response(path, error), 378 378 }; 379 379 self.respond_with_engine(path, |engine| { 380 - engine.completion(params.text_document_position, src) 380 + engine.completion(params.text_document_position_params, src) 381 381 }) 382 382 } 383 383 ··· 415 415 416 416 fn prepare_rename( 417 417 &mut self, 418 - params: lsp::TextDocumentPositionParams, 418 + params: lsp::PrepareRenameParams, 419 419 ) -> (Result<Json, ResponseError>, Feedback) { 420 - let path = super::path(&params.text_document.uri); 420 + let path = super::path(&params.text_document_position_params.text_document.uri); 421 421 self.respond_with_engine(path, |engine| engine.prepare_rename(params)) 422 422 } 423 423 424 424 fn rename(&mut self, params: lsp::RenameParams) -> (Result<Json, ResponseError>, Feedback) { 425 - let path = super::path(&params.text_document_position.text_document.uri); 425 + let path = super::path(&params.text_document_position_params.text_document.uri); 426 426 self.fallible_respond_with_engine( 427 427 path, 428 428 |engine: &mut LanguageServerEngine<IO, ConnectionProgressReporter<'a>>| { ··· 435 435 &mut self, 436 436 params: lsp_types::ReferenceParams, 437 437 ) -> (Result<Json, ResponseError>, Feedback) { 438 - let path = super::path(&params.text_document_position.text_document.uri); 438 + let path = super::path(&params.text_document_position_params.text_document.uri); 439 439 self.respond_with_engine(path, |engine| engine.find_references(params)) 440 440 } 441 441 ··· 496 496 497 497 fn initialisation_handshake(connection: &lsp_server::Connection) -> InitializeParams { 498 498 let server_capabilities = lsp::ServerCapabilities { 499 - text_document_sync: Some(lsp::TextDocumentSyncCapability::Options( 499 + text_document_sync: Some( 500 500 lsp::TextDocumentSyncOptions { 501 501 open_close: Some(true), 502 - change: Some(lsp::TextDocumentSyncKind::FULL), 502 + change: Some(lsp::TextDocumentSyncKind::Full), 503 503 will_save: None, 504 504 will_save_wait_until: None, 505 - save: Some(lsp::TextDocumentSyncSaveOptions::SaveOptions( 505 + save: Some( 506 506 lsp::SaveOptions { 507 507 include_text: Some(false), 508 - }, 509 - )), 510 - }, 511 - )), 508 + } 509 + .into(), 510 + ), 511 + } 512 + .into(), 513 + ), 512 514 selection_range_provider: None, 513 - hover_provider: Some(HoverProviderCapability::Simple(true)), 515 + hover_provider: Some(true.into()), 514 516 completion_provider: Some(lsp::CompletionOptions { 515 517 resolve_provider: None, 516 518 trigger_characters: Some(vec![".".into()]), ··· 527 529 work_done_progress: None, 528 530 }, 529 531 }), 530 - definition_provider: Some(lsp::OneOf::Left(true)), 531 - type_definition_provider: Some(lsp::TypeDefinitionProviderCapability::Simple(true)), 532 + definition_provider: Some(true.into()), 533 + type_definition_provider: Some(true.into()), 532 534 implementation_provider: None, 533 - references_provider: Some(lsp::OneOf::Left(true)), 535 + references_provider: Some(true.into()), 534 536 document_highlight_provider: None, 535 - document_symbol_provider: Some(lsp::OneOf::Left(true)), 537 + document_symbol_provider: Some(true.into()), 536 538 workspace_symbol_provider: None, 537 - code_action_provider: Some(lsp::CodeActionProviderCapability::Simple(true)), 539 + code_action_provider: Some(true.into()), 538 540 code_lens_provider: None, 539 - document_formatting_provider: Some(lsp::OneOf::Left(true)), 541 + document_formatting_provider: Some(true.into()), 540 542 document_range_formatting_provider: None, 541 543 document_on_type_formatting_provider: None, 542 - rename_provider: Some(lsp::OneOf::Right(RenameOptions { 543 - prepare_provider: Some(true), 544 - work_done_progress_options: lsp::WorkDoneProgressOptions { 545 - work_done_progress: None, 546 - }, 547 - })), 544 + rename_provider: Some( 545 + RenameOptions { 546 + prepare_provider: Some(true), 547 + work_done_progress_options: lsp::WorkDoneProgressOptions { 548 + work_done_progress: None, 549 + }, 550 + } 551 + .into(), 552 + ), 548 553 document_link_provider: None, 549 554 color_provider: None, 550 - folding_range_provider: Some(lsp::FoldingRangeProviderCapability::Simple(true)), 555 + folding_range_provider: Some(true.into()), 551 556 declaration_provider: None, 552 557 execute_command_provider: None, 553 558 workspace: None, ··· 560 565 inline_value_provider: None, 561 566 inlay_hint_provider: None, 562 567 diagnostic_provider: None, 568 + type_hierarchy_provider: None, 569 + notebook_document_sync: None, 570 + inline_completion_provider: None, 563 571 }; 564 572 let server_capabilities_json = 565 573 serde_json::to_value(server_capabilities).expect("server_capabilities_serde"); ··· 573 581 574 582 fn diagnostic_to_lsp(diagnostic: Diagnostic) -> Vec<lsp::Diagnostic> { 575 583 let severity = match diagnostic.level { 576 - Level::Error => lsp::DiagnosticSeverity::ERROR, 577 - Level::Warning => lsp::DiagnosticSeverity::WARNING, 584 + Level::Error => lsp::DiagnosticSeverity::Error, 585 + Level::Warning => lsp::DiagnosticSeverity::Warning, 578 586 }; 579 587 let hint = diagnostic.hint; 580 588 let mut text = diagnostic.title; ··· 626 634 match hint { 627 635 Some(hint) => { 628 636 let hint = lsp::Diagnostic { 629 - severity: Some(lsp::DiagnosticSeverity::HINT), 637 + severity: Some(lsp::DiagnosticSeverity::Hint), 630 638 message: hint, 631 639 // Some editors require this kind of "link" to group diagnostics. 632 640 // For example, in Zed "go to next diagnostic" would move you from
+5 -4
language-server/src/signature_help.rs
··· 5 5 6 6 use ecow::EcoString; 7 7 use lsp_types::{ 8 - Documentation, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel, SignatureHelp, 9 - SignatureInformation, 8 + ActiveParameter, Documentation, MarkupContent, MarkupKind, ParameterInformation, 9 + ParameterInformationLabel, SignatureHelp, SignatureInformation, 10 10 }; 11 11 12 12 use gleam_core::{ ··· 142 142 let active_parameter = active_parameter_index(arity, supplied_arguments, index_to_label) 143 143 // If we don't want to highlight any arg in the suggestion we have to 144 144 // explicitly provide an out of bound index. 145 - .or(Some(arity)); 145 + .or(Some(arity)) 146 + .map(ActiveParameter::Int); 146 147 147 148 Some(SignatureHelp { 148 149 signatures: vec![SignatureInformation { ··· 266 267 } 267 268 signature.push_str(&printer.print_type(argument)); 268 269 let arg_end = signature.len(); 269 - let label = ParameterLabel::LabelOffsets([arg_start as u32, arg_end as u32]); 270 + let label = ParameterInformationLabel::Tuple((arg_start as u32, arg_end as u32)); 270 271 271 272 parameter_informations.push(ParameterInformation { 272 273 label,
+1 -1
language-server/src/tests.rs
··· 21 21 22 22 use camino::{Utf8Path, Utf8PathBuf}; 23 23 use itertools::Itertools; 24 - use lsp_types::{Position, TextDocumentIdentifier, TextDocumentPositionParams, Url}; 24 + use lsp_types::{Position, TextDocumentIdentifier, TextDocumentPositionParams, Uri as Url}; 25 25 26 26 use gleam_core::{ 27 27 Result,
+16 -27
language-server/src/tests/action.rs
··· 1 1 use itertools::Itertools; 2 2 use lsp_types::{ 3 - CodeActionContext, CodeActionParams, DocumentChangeOperation, DocumentChanges, 4 - PartialResultParams, Position, ResourceOp, Url, WorkDoneProgressParams, 3 + CodeActionContext, CodeActionParams, DocumentChange, PartialResultParams, Position, Uri as Url, 4 + WorkDoneProgressParams, 5 5 }; 6 6 7 7 use super::*; ··· 117 117 } 118 118 } 119 119 120 - fn format_code_action_file_operations<'a>(actions: &[lsp_types::CodeAction]) -> String { 120 + fn format_code_action_file_operations(actions: &[lsp_types::CodeAction]) -> String { 121 121 // Display path the same on linux or windows so tests don't fail between targets 122 122 let normalized_path = |uri: &Url| { 123 123 format!( ··· 137 137 actions 138 138 .iter() 139 139 .filter_map(|action| { 140 - if let Some(DocumentChanges::Operations(operations)) = action 140 + action 141 141 .edit 142 142 .as_ref() 143 143 .and_then(|edit| edit.document_changes.as_ref()) 144 - { 145 - Some(operations) 146 - } else { 147 - None 148 - } 149 144 }) 150 - .flat_map(|operations| { 151 - operations.into_iter().filter_map(|op| match op { 152 - DocumentChangeOperation::Op(op) => Some(op), 153 - DocumentChangeOperation::Edit(_) => None, 154 - }) 155 - }) 156 - .map(|op| match op { 157 - ResourceOp::Create(create) => { 158 - format!("- Create {}", normalized_path(&create.uri)) 145 + .flatten() 146 + .filter_map(|op| match op { 147 + DocumentChange::CreateFile(create) => { 148 + Some(format!("- Create {}", normalized_path(&create.uri))) 159 149 } 160 - ResourceOp::Rename(rename) => { 161 - format!( 162 - "- Rename {} to {}", 163 - normalized_path(&rename.old_uri), 164 - normalized_path(&rename.new_uri) 165 - ) 150 + DocumentChange::RenameFile(rename) => Some(format!( 151 + "- Rename {} to {}", 152 + normalized_path(&rename.old_uri), 153 + normalized_path(&rename.new_uri) 154 + )), 155 + DocumentChange::DeleteFile(delete) => { 156 + Some(format!("- Delete {}", normalized_path(&delete.uri))) 166 157 } 167 - ResourceOp::Delete(delete) => { 168 - format!("- Delete {}", normalized_path(&delete.uri)) 169 - } 158 + DocumentChange::TextDocumentEdit(_) => None, 170 159 }) 171 160 .join("\n") 172 161 }
+5 -2
language-server/src/tests/completion.rs
··· 29 29 .unwrap_or_else(|| panic!("no completion with value `{value}`")); 30 30 31 31 let mut edits = vec![]; 32 - if let Some(lsp_types::CompletionTextEdit::Edit(edit)) = &completion.text_edit { 32 + if let Some(lsp_types::CompletionItemTextEdit::TextEdit(edit)) = &completion.text_edit { 33 33 edits.push(edit.clone()); 34 34 } 35 35 apply_code_edit(src, edits) ··· 98 98 kind, 99 99 detail, 100 100 documentation, 101 + #[allow(deprecated)] 101 102 deprecated, 102 103 preselect, 103 104 sort_text, ··· 111 112 commit_characters, 112 113 data, 113 114 tags, 115 + text_edit_text, 114 116 } in completions 115 117 { 116 118 assert!(deprecated.is_none()); ··· 123 125 assert!(commit_characters.is_none()); 124 126 assert!(data.is_none()); 125 127 assert!(tags.is_none()); 128 + assert!(text_edit_text.is_none()); 126 129 127 130 buffer.push_str(&label); 128 131 ··· 167 170 }; 168 171 169 172 if let Some(text_edit) = text_edit { 170 - let lsp_types::CompletionTextEdit::Edit(e) = text_edit else { 173 + let lsp_types::CompletionItemTextEdit::TextEdit(e) = text_edit else { 171 174 panic!("unexpected text edit in test {text_edit:?}"); 172 175 }; 173 176 buffer.push_str("\n edits:");
+5 -7
language-server/src/tests/definition.rs
··· 1 - use lsp_types::{ 2 - GotoDefinitionParams, Location, Position, Range, Url, request::GotoTypeDefinitionParams, 3 - }; 1 + use lsp_types::{DefinitionParams, Location, Position, Range, TypeDefinitionParams, Uri as Url}; 4 2 5 3 use super::*; 6 4 7 5 fn definition(tester: &TestProject<'_>, position: Position) -> Option<Location> { 8 6 tester.at(position, |engine, param, _| { 9 - let params = GotoDefinitionParams { 7 + let params = DefinitionParams { 10 8 text_document_position_params: param, 11 9 work_done_progress_params: Default::default(), 12 10 partial_result_params: Default::default(), ··· 24 22 25 23 fn type_definition(tester: &TestProject<'_>, position: Position) -> Vec<Location> { 26 24 tester.at(position, |engine, param, _| { 27 - let params = GotoTypeDefinitionParams { 25 + let params = TypeDefinitionParams { 28 26 text_document_position_params: param, 29 27 work_done_progress_params: Default::default(), 30 28 partial_result_params: Default::default(), ··· 430 428 .add_hex_module("example_module", dep) 431 429 .positioned_with_io(Position::new(3, 20)); 432 430 433 - let params = GotoDefinitionParams { 431 + let params = DefinitionParams { 434 432 text_document_position_params: position_param.clone(), 435 433 work_done_progress_params: Default::default(), 436 434 partial_result_params: Default::default(), ··· 504 502 .add_dep_module("example_module", dep) 505 503 .positioned_with_io(Position::new(3, 20)); 506 504 507 - let params = GotoDefinitionParams { 505 + let params = DefinitionParams { 508 506 text_document_position_params: position_param.clone(), 509 507 work_done_progress_params: Default::default(), 510 508 partial_result_params: Default::default(),
+2 -1
language-server/src/tests/folding_range.rs
··· 15 15 }) 16 16 } 17 17 18 - fn kind_name(kind: &Option<FoldingRangeKind>) -> &'static str { 18 + fn kind_name(kind: &Option<FoldingRangeKind>) -> &str { 19 19 match kind { 20 20 Some(FoldingRangeKind::Imports) => "imports", 21 21 Some(FoldingRangeKind::Comment) => "comment", 22 22 Some(FoldingRangeKind::Region) => "region", 23 + Some(FoldingRangeKind::Custom(any)) => &any, 23 24 None => "none", 24 25 } 25 26 }
+10 -6
language-server/src/tests/hover.rs
··· 1 - use lsp_types::{Hover, HoverContents, HoverParams, MarkedString, Position, Range}; 1 + use lsp_types::{Contents, Hover, HoverParams, MarkedString, Position, Range}; 2 2 3 3 use super::*; 4 4 ··· 49 49 buffer 50 50 } 51 51 52 - fn pretty_hover_contents(contents: HoverContents) -> String { 52 + fn pretty_hover_contents(contents: Contents) -> String { 53 53 let (kind, content) = match contents { 54 - HoverContents::Scalar(marked_string) => ("markdown", pretty_marked_string(marked_string)), 55 - HoverContents::Array(marked_strings) => ( 54 + Contents::MarkedString(marked_string) => ("markdown", pretty_marked_string(marked_string)), 55 + Contents::MarkedStringList(marked_strings) => ( 56 56 "markdown array", 57 57 marked_strings 58 58 .into_iter() 59 59 .map(pretty_marked_string) 60 60 .join("\n\n"), 61 61 ), 62 - HoverContents::Markup(lsp_types::MarkupContent { kind, value }) => match kind { 62 + Contents::MarkupContent(lsp_types::MarkupContent { kind, value }) => match kind { 63 63 lsp_types::MarkupKind::PlainText => ("plaintext", value), 64 64 lsp_types::MarkupKind::Markdown => ("markdown", value), 65 65 }, ··· 70 70 fn pretty_marked_string(marked_string: MarkedString) -> String { 71 71 match marked_string { 72 72 MarkedString::String(string) => string, 73 - MarkedString::LanguageString(lsp_types::LanguageString { language, value }) => { 73 + #[allow(deprecated)] 74 + MarkedString::MarkedStringWithLanguage(lsp_types::MarkedStringWithLanguage { 75 + language, 76 + value, 77 + }) => { 74 78 format!("```{language}\n{value}\n```") 75 79 } 76 80 }
+1 -1
language-server/src/tests/reference.rs
··· 13 13 ) -> Option<HashMap<String, Vec<Range>>> { 14 14 let locations = tester.at(position, |engine, params, _| { 15 15 let params = ReferenceParams { 16 - text_document_position: TextDocumentPositionParams { 16 + text_document_position_params: TextDocumentPositionParams { 17 17 text_document: params.text_document, 18 18 position, 19 19 },
+15 -7
language-server/src/tests/rename.rs
··· 1 1 use std::collections::HashMap; 2 2 3 3 use lsp_types::{ 4 - Position, Range, RenameParams, TextDocumentPositionParams, Url, WorkDoneProgressParams, 4 + Position, PrepareRenameParams, PrepareRenamePlaceholder, Range, RenameParams, 5 + TextDocumentPositionParams, Uri as Url, WorkDoneProgressParams, 5 6 }; 6 7 7 8 use super::{TestProject, find_position_of, hover}; ··· 16 17 position: Position, 17 18 ) -> Result<Option<(Range, lsp_types::WorkspaceEdit)>, String> { 18 19 let prepare_rename_response = tester.at(position, |engine, params, _| { 19 - let params = TextDocumentPositionParams { 20 - text_document: params.text_document, 21 - position, 20 + let params = PrepareRenameParams { 21 + text_document_position_params: TextDocumentPositionParams { 22 + text_document: params.text_document, 23 + position, 24 + }, 25 + work_done_progress_params: WorkDoneProgressParams { 26 + work_done_token: None, 27 + }, 22 28 }; 23 29 engine.prepare_rename(params).result.unwrap() 24 30 }); 25 31 26 32 let range = match prepare_rename_response { 27 - Some(lsp_types::PrepareRenameResponse::Range(range)) => range, 28 - Some(lsp_types::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => range, 33 + Some(lsp_types::PrepareRenameResult::Range(range)) => range, 34 + Some(lsp_types::PrepareRenameResult::PrepareRenamePlaceholder( 35 + PrepareRenamePlaceholder { range, .. }, 36 + )) => range, 29 37 _ => return Ok(None), 30 38 }; 31 39 32 40 let outcome = tester.at(position, |engine, params, _| { 33 41 let params = RenameParams { 34 - text_document_position: TextDocumentPositionParams { 42 + text_document_position_params: TextDocumentPositionParams { 35 43 text_document: params.text_document, 36 44 position, 37 45 },
+5 -4
language-server/src/tests/signature_help.rs
··· 1 1 use super::*; 2 2 use lsp_types::{ 3 - ParameterInformation, ParameterLabel, SignatureHelp, SignatureHelpParams, SignatureInformation, 3 + ActiveParameter, ParameterInformation, ParameterInformationLabel, SignatureHelp, 4 + SignatureHelpParams, SignatureInformation, 4 5 }; 5 6 6 7 fn signature_help(tester: TestProject<'_>, position: Position) -> Option<SignatureHelp> { ··· 42 43 }; 43 44 44 45 let label = match active_parameter { 45 - None => label.to_string(), 46 - Some(i) => match parameters.get(i as usize) { 46 + None | Some(ActiveParameter::Null) => label.to_string(), 47 + Some(ActiveParameter::Int(i)) => match parameters.get(i as usize) { 47 48 None => label.to_string(), 48 49 Some(ParameterInformation { 49 - label: ParameterLabel::LabelOffsets([start, end]), 50 + label: ParameterInformationLabel::Tuple((start, end)), 50 51 .. 51 52 }) => { 52 53 let spaces = " ".repeat(*start as usize);
+12 -9
language-server/src/tests/snapshots/gleam_language_server__tests__completion__completions_for_an_import_not_from_dev_dependency_in_test.snap
··· 9 9 kind: Some( 10 10 Module, 11 11 ), 12 + tags: None, 12 13 detail: None, 13 14 documentation: None, 14 15 deprecated: None, ··· 19 20 insert_text_format: None, 20 21 insert_text_mode: None, 21 22 text_edit: Some( 22 - Edit( 23 + TextEdit( 23 24 TextEdit { 24 25 range: Range { 25 26 start: Position { ··· 35 36 }, 36 37 ), 37 38 ), 39 + text_edit_text: None, 38 40 additional_text_edits: None, 41 + commit_characters: None, 39 42 command: None, 40 - commit_characters: None, 41 43 data: None, 42 - tags: None, 43 44 }, 44 45 CompletionItem { 45 46 label: "example_module", ··· 47 48 kind: Some( 48 49 Module, 49 50 ), 51 + tags: None, 50 52 detail: None, 51 53 documentation: None, 52 54 deprecated: None, ··· 57 59 insert_text_format: None, 58 60 insert_text_mode: None, 59 61 text_edit: Some( 60 - Edit( 62 + TextEdit( 61 63 TextEdit { 62 64 range: Range { 63 65 start: Position { ··· 73 75 }, 74 76 ), 75 77 ), 78 + text_edit_text: None, 76 79 additional_text_edits: None, 77 - command: None, 78 80 commit_characters: None, 81 + command: None, 79 82 data: None, 80 - tags: None, 81 83 }, 82 84 CompletionItem { 83 85 label: "indirect_module", ··· 85 87 kind: Some( 86 88 Module, 87 89 ), 90 + tags: None, 88 91 detail: None, 89 92 documentation: None, 90 93 deprecated: None, ··· 95 98 insert_text_format: None, 96 99 insert_text_mode: None, 97 100 text_edit: Some( 98 - Edit( 101 + TextEdit( 99 102 TextEdit { 100 103 range: Range { 101 104 start: Position { ··· 111 114 }, 112 115 ), 113 116 ), 117 + text_edit_text: None, 114 118 additional_text_edits: None, 115 - command: None, 116 119 commit_characters: None, 120 + command: None, 117 121 data: None, 118 - tags: None, 119 122 }, 120 123 ]
+8 -6
language-server/src/tests/snapshots/gleam_language_server__tests__completion__completions_for_an_import_while_in_test.snap
··· 9 9 kind: Some( 10 10 Module, 11 11 ), 12 + tags: None, 12 13 detail: None, 13 14 documentation: None, 14 15 deprecated: None, ··· 19 20 insert_text_format: None, 20 21 insert_text_mode: None, 21 22 text_edit: Some( 22 - Edit( 23 + TextEdit( 23 24 TextEdit { 24 25 range: Range { 25 26 start: Position { ··· 35 36 }, 36 37 ), 37 38 ), 39 + text_edit_text: None, 38 40 additional_text_edits: None, 39 - command: None, 40 41 commit_characters: None, 42 + command: None, 41 43 data: None, 42 - tags: None, 43 44 }, 44 45 CompletionItem { 45 46 label: "test_helper", ··· 47 48 kind: Some( 48 49 Module, 49 50 ), 51 + tags: None, 50 52 detail: None, 51 53 documentation: None, 52 54 deprecated: None, ··· 57 59 insert_text_format: None, 58 60 insert_text_mode: None, 59 61 text_edit: Some( 60 - Edit( 62 + TextEdit( 61 63 TextEdit { 62 64 range: Range { 63 65 start: Position { ··· 73 75 }, 74 76 ), 75 77 ), 78 + text_edit_text: None, 76 79 additional_text_edits: None, 77 - command: None, 78 80 commit_characters: None, 81 + command: None, 79 82 data: None, 80 - tags: None, 81 83 }, 82 84 ]