From 2127a4990e06c8adf2c0b25cba2852ed4a5f09cf Mon Sep 17 00:00:00 2001 From: Ashley Coleman Date: Fri, 23 Feb 2024 16:15:21 -0800 Subject: [PATCH] refresh PR to current standards --- .wakemanifest | 1 + rust/test-lsp-wake/Cargo.lock | 839 +++++++++++++++++++++++++++++++++ rust/test-lsp-wake/build.wake | 23 + rust/test-lsp-wake/src/main.rs | 373 ++++++++------- 4 files changed, 1067 insertions(+), 169 deletions(-) create mode 100644 rust/test-lsp-wake/Cargo.lock create mode 100644 rust/test-lsp-wake/build.wake diff --git a/.wakemanifest b/.wakemanifest index a03546af8..423bbe3c9 100644 --- a/.wakemanifest +++ b/.wakemanifest @@ -3,6 +3,7 @@ extensions/vscode/vscode.wake rust/log_viewer/build.wake rust/rsc/postgres-tests.wake rust/rsc/rsc.wake +rust/test-lsp-wake/build.wake share/wake/lib/core/boolean.wake share/wake/lib/core/double.wake share/wake/lib/core/integer.wake diff --git a/rust/test-lsp-wake/Cargo.lock b/rust/test-lsp-wake/Cargo.lock new file mode 100644 index 000000000..af882a7f1 --- /dev/null +++ b/rust/test-lsp-wake/Cargo.lock @@ -0,0 +1,839 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "async-trait" +version = "0.1.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "auto_impl" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "hermit-abi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "lsp-types" +version = "0.94.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66bfd44a06ae10647fe3f8214762e9369fd4248df1350924b4ef9e770a85ea1" +dependencies = [ + "bitflags", + "serde", + "serde_json", + "serde_repr", + "url", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "serde_json" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "socket2" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "test-lsp-wake" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "tokio", + "tower-lsp", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-lsp" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b38fb0e6ce037835174256518aace3ca621c4f96383c56bb846cfc11b341910" +dependencies = [ + "async-trait", + "auto_impl", + "bytes", + "dashmap", + "futures", + "httparse", + "lsp-types", + "memchr", + "serde", + "serde_json", + "tokio", + "tokio-util", + "tower", + "tower-lsp-macros", + "tracing", +] + +[[package]] +name = "tower-lsp-macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34723c06344244474fdde365b76aebef8050bf6be61a935b91ee9ff7c4e91157" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.3", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" +dependencies = [ + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" diff --git a/rust/test-lsp-wake/build.wake b/rust/test-lsp-wake/build.wake new file mode 100644 index 000000000..abfe038d2 --- /dev/null +++ b/rust/test-lsp-wake/build.wake @@ -0,0 +1,23 @@ +# Copyright 2024 SiFive, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You should have received a copy of LICENSE.Apache2 along with +# this software. If not, you may obtain a copy at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package build_wake + +from wake import _ +from rust import _ + +export def buildLspWakeTest Unit = + makeCargoExecutable "test-lsp-wake" "rust/test-lsp-wake" + | rmapPass (cargoBuildWith (defaultCargoToolchain Unit)) diff --git a/rust/test-lsp-wake/src/main.rs b/rust/test-lsp-wake/src/main.rs index 2b21fb358..33864a64e 100644 --- a/rust/test-lsp-wake/src/main.rs +++ b/rust/test-lsp-wake/src/main.rs @@ -1,7 +1,9 @@ use tower_lsp::lsp_types::*; -use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, Lines}; -use tokio::process::{ChildStdin, ChildStdout, Command}; +use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; +use tokio::process::{ChildStdin, Command}; +use tokio::sync::mpsc::{channel, Receiver}; +use tokio::time::timeout; use tower_lsp::lsp_types::notification::{ DidChangeTextDocument, DidOpenTextDocument, Exit, Initialized, PublishDiagnostics, @@ -29,20 +31,6 @@ where .finish() } -async fn write_request( - stdin: &mut ChildStdin, - id: tower_lsp::jsonrpc::Id, - params: R::Params, -) -> Result -where - R: tower_lsp::lsp_types::request::Request, - R::Params: serde::Serialize, - R::Result: serde::de::DeserializeOwned, -{ - let req = make_request::(id, params); - stdin.write(jrpc_serialize(req).as_bytes()).await -} - fn make_notification(params: R::Params) -> tower_lsp::jsonrpc::Request where R: tower_lsp::lsp_types::notification::Notification, @@ -53,103 +41,183 @@ where .finish() } -async fn write_notification( - stdin: &mut ChildStdin, - params: R::Params, -) -> Result -where - R: tower_lsp::lsp_types::notification::Notification, - R::Params: serde::Serialize, -{ - let req = make_notification::(params); - stdin.write(jrpc_serialize(req).as_bytes()).await +struct LSPServer { + send: ChildStdin, + receive: Receiver, + peek: Option, } -async fn read_notification( - reader: &mut Lines>, -) -> std::io::Result -where - R: tower_lsp::lsp_types::notification::Notification, - R::Params: serde::Serialize, -{ - let Some(_length) = reader.next_line().await? else { - todo!(); - }; - let Some(_end_header) = reader.next_line().await? else { - todo!(); - }; - let Some(json) = reader.next_line().await? else { - todo!(); - }; +impl LSPServer { + fn new() -> Result> { + let mut child = Command::new("../../lib/wake/lsp-wake") + .stdout(Stdio::piped()) + .stdin(Stdio::piped()) + .spawn()?; + + let stdin = child + .stdin + .take() + .expect("failed to take child stdin handle"); + + let stdout = child + .stdout + .take() + .expect("failed to take child stdout handle"); + + // Spawn a task to constantly read messages from the server + let (tx, rx) = channel(100); + tokio::spawn(async move { + let mut reader = BufReader::new(stdout).lines(); + loop { + let Ok(_length) = reader.next_line().await else { + panic!("Failed to read length from msg"); + }; + let Ok(_end_header) = reader.next_line().await else { + panic!("Failed to read end header from msg"); + }; + let Ok(Some(json)) = reader.next_line().await else { + panic!("Failed to read json from msg"); + }; + + if let Err(msg) = tx.send(json).await { + panic!("Dropped msg tx: {}", msg); + } + } + }); + + Ok(Self { + send: stdin, + receive: rx, + peek: None, + }) + } - let res: tower_lsp::jsonrpc::Request = serde_json::from_str(&json).unwrap(); - let value = res.params().unwrap(); - let inner: R::Params = serde_json::from_value(value.clone()).unwrap(); - return Ok(inner); -} + async fn write_request( + &mut self, + id: tower_lsp::jsonrpc::Id, + params: R::Params, + ) -> Result + where + R: tower_lsp::lsp_types::request::Request, + R::Params: serde::Serialize, + R::Result: serde::de::DeserializeOwned, + { + let req = make_request::(id, params); + self.send.write(jrpc_serialize(req).as_bytes()).await + } -async fn read_response(reader: &mut Lines>) -> std::io::Result -where - R: tower_lsp::lsp_types::request::Request, - R::Params: serde::Serialize, - R::Result: serde::de::DeserializeOwned, -{ - let _length = reader.next_line().await?; - let _end_header = reader.next_line().await?; - let Some(json) = reader.next_line().await? else { - todo!(); - }; + async fn write_notification(&mut self, params: R::Params) -> Result + where + R: tower_lsp::lsp_types::notification::Notification, + R::Params: serde::Serialize, + { + let req = make_notification::(params); + self.send.write(jrpc_serialize(req).as_bytes()).await + } - let res: tower_lsp::jsonrpc::Response = serde_json::from_str(&json).unwrap(); - let value = res.result().unwrap(); - let inner: R::Result = serde_json::from_value(value.clone()).unwrap(); - return Ok(inner); -} + async fn expect_one(&mut self) -> R::Result + where + R: tower_lsp::lsp_types::request::Request, + R::Params: serde::Serialize, + R::Result: serde::de::DeserializeOwned, + { + let json = match self.peek.take() { + Some(json) => json, + None => { + let Ok(Some(json)) = + timeout(std::time::Duration::from_millis(1000), self.receive.recv()).await + else { + panic!( + "expect_one<{}> failed! No server response within the deadline.", + R::METHOD + ); + }; + json + } + }; + + let res: tower_lsp::jsonrpc::Response = match serde_json::from_str(&json) { + Ok(res) => res, + Err(msg) => panic!( + "expect_one<{}> failed! Could not parse. Reason: {}. In: {}", + R::METHOD, + msg, + json + ), + }; + + let value = match res.into_parts() { + (_, Ok(value)) => value, + (_, Err(msg)) => panic!( + "expect_one<{}> failed! jsonrpc error. Reason: {}. In: {}", + R::METHOD, + msg, + json + ), + }; + + let inner: R::Result = match serde_json::from_value(value.clone()) { + Ok(res) => res, + Err(msg) => panic!( + "expect_one<{}> failed! Could not parse. Reason: {}. In: {}", + R::METHOD, + msg, + json + ), + }; -async fn exchange_request_response( - stdin: &mut ChildStdin, - reader: &mut Lines>, - id: tower_lsp::jsonrpc::Id, - params: R::Params, -) -> std::io::Result -where - R: tower_lsp::lsp_types::request::Request, - R::Params: serde::Serialize, - R::Result: serde::de::DeserializeOwned, -{ - write_request::(stdin, id, params).await?; - read_response::(reader).await + inner + } + + async fn expect_many(&mut self) -> Vec + where + R: tower_lsp::lsp_types::notification::Notification, + R::Params: serde::Serialize, + { + let mut out = Vec::new(); + + loop { + let json = match self.peek.take() { + Some(json) => json, + None => match timeout(std::time::Duration::from_millis(1000), self.receive.recv()) + .await + { + Ok(Some(json)) => json, + _ => break, + }, + }; + + let Ok(res): Result = serde_json::from_str(&json) + else { + panic!("Failed to parse jsonrpc request into expected type"); + }; + + let Some(value) = res.params() else { + self.peek = Some(json); + break; + }; + let Ok(inner): Result = serde_json::from_value(value.clone()) else { + self.peek = Some(json); + break; + }; + + out.push(inner); + } + + out + } } #[tokio::main] async fn main() -> Result<(), Box> { - let mut child = Command::new("../../lib/wake/lsp-wake") - .stdout(Stdio::piped()) - .stdin(Stdio::piped()) - .spawn()?; - - let mut stdin = child - .stdin - .take() - .expect("failed to take child stdin handle"); - - let stdout = child - .stdout - .take() - .expect("failed to take child stdout handle"); + let mut lsp = LSPServer::new()?; - let mut reader = BufReader::new(stdout).lines(); - - let Ok(blah) = std::env::current_dir() else { - todo!(); - }; - let Some(cwd) = blah.to_str() else { - todo!(); + let cwd = std::env::current_dir()?; + let Some(cwd) = cwd.to_str() else { + panic!("Failed to convert cwd to string"); }; - let res = exchange_request_response::( - &mut stdin, - &mut reader, + lsp.write_request::( tower_lsp::jsonrpc::Id::Number(5), InitializeParams { process_id: Some(5), @@ -180,45 +248,37 @@ async fn main() -> Result<(), Box> { ) .await?; - println!("{:?}", res); + let _response = lsp.expect_one::().await; - write_notification::(&mut stdin, InitializedParams {}).await?; + lsp.write_notification::(InitializedParams {}) + .await?; - for n in 1..28 { - let res = read_notification::(&mut reader).await?; - println!("{}: {:?}", n, res); - } + let _responses = lsp.expect_many::().await; let test_wake = Url::parse(format!("file://{}/test.wake", cwd).as_str())?; - write_notification::( - &mut stdin, - DidOpenTextDocumentParams { - text_document: TextDocumentItem { - uri: test_wake.clone(), - language_id: "wake".to_string(), - version: 1, - text: "# comment\n# comment \n\ndef unused = 5".to_string(), - }, + lsp.write_notification::(DidOpenTextDocumentParams { + text_document: TextDocumentItem { + uri: test_wake.clone(), + language_id: "wake".to_string(), + version: 1, + text: "# comment\n# comment \n\ndef unused = 5".to_string(), }, - ) + }) .await?; - write_notification::( - &mut stdin, - DidChangeTextDocumentParams { - text_document: VersionedTextDocumentIdentifier { - uri: test_wake.clone(), - version: 1, - }, - content_changes: [TextDocumentContentChangeEvent { - range: None, - range_length: None, - text: "# comment\n# comment \n\ndef y = 6".to_string(), - }] - .to_vec(), + lsp.write_notification::(DidChangeTextDocumentParams { + text_document: VersionedTextDocumentIdentifier { + uri: test_wake.clone(), + version: 1, }, - ) + content_changes: [TextDocumentContentChangeEvent { + range: None, + range_length: None, + text: "# comment\n# comment \n\ndef y = 6".to_string(), + }] + .to_vec(), + }) .await?; let hover_params = HoverParams { @@ -236,52 +296,27 @@ async fn main() -> Result<(), Box> { }, }; - let res = exchange_request_response::( - &mut stdin, - &mut reader, - tower_lsp::jsonrpc::Id::Number(6), - hover_params.clone(), - ) - .await?; - println!("{:?}", res); + lsp.write_request::(tower_lsp::jsonrpc::Id::Number(6), hover_params.clone()) + .await?; - let res = exchange_request_response::( - &mut stdin, - &mut reader, - tower_lsp::jsonrpc::Id::Number(7), - hover_params.clone(), - ) - .await?; - println!("{:?}", res); + let _response = lsp.expect_one::().await; - write_request::( - &mut stdin, - tower_lsp::jsonrpc::Id::Number(8), - hover_params.clone(), - ) - .await?; + lsp.write_request::(tower_lsp::jsonrpc::Id::Number(7), hover_params.clone()) + .await?; - for n in 1..28 { - let res = read_notification::(&mut reader).await?; - println!("{}: {:?}", n, res); - } + let _response = lsp.expect_one::().await; - let res = read_response::(&mut reader).await?; - println!("{:?}", res); + lsp.write_request::(tower_lsp::jsonrpc::Id::Number(8), hover_params.clone()) + .await?; - let res = exchange_request_response::( - &mut stdin, - &mut reader, - tower_lsp::jsonrpc::Id::Number(9), - (), - ) - .await?; - println!("{:?}", res); + let _responses = lsp.expect_many::().await; + let _response = lsp.expect_one::().await; - write_notification::(&mut stdin, ()).await?; + lsp.write_request::(tower_lsp::jsonrpc::Id::Number(9), ()) + .await?; + let _response = lsp.expect_one::().await; - let status = child.wait().await?; - println!("child exit: {}", status); + lsp.write_notification::(()).await?; Ok(()) }