From 58ef3cafc86a6c45f4b55c293e7c9aaff6b9db55 Mon Sep 17 00:00:00 2001 From: LSTM-Kirigaya <1193466151@qq.com> Date: Tue, 8 Oct 2024 17:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=20vhdl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 571 ++++++++++++++++----------------- Cross.toml | 2 + build_all.sh | 14 + src/completion/vhdl.rs | 368 +++++++++------------ src/core/vhdl_parser.rs | 35 +- src/definition/mod.rs | 57 ++++ src/definition/vhdl.rs | 63 ++-- src/document_highlight/mod.rs | 11 +- src/document_highlight/vhdl.rs | 78 +++-- src/document_symbol/vhdl.rs | 106 +----- src/hover/vhdl.rs | 301 +++++++++++++++-- src/sources.rs | 70 +++- sv-parser | 2 +- vhdl-parser | 2 +- 14 files changed, 976 insertions(+), 704 deletions(-) create mode 100644 Cross.toml create mode 100644 build_all.sh diff --git a/Cargo.lock b/Cargo.lock index 753b42b..0312eca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,24 +4,24 @@ version = 3 [[package]] name = "addr2line" -version = "0.19.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -101,13 +101,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] @@ -116,42 +116,41 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] [[package]] name = "auto_impl" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.79", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -171,9 +170,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" @@ -183,21 +182,24 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytecount" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" [[package]] name = "bytes" -version = "1.4.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cc" -version = "1.0.79" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -207,14 +209,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "winapi", + "windows-targets 0.52.6", ] [[package]] @@ -234,9 +236,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ "clap_builder", "clap_derive", @@ -244,33 +246,33 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.10.0", + "strsim 0.11.1", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" @@ -280,9 +282,9 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crossbeam-deque" @@ -311,12 +313,12 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "dashmap" -version = "5.5.0" +version = "5.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6943ae99c34386c84a470c499d3414f66502a41340aa895406e0d2e4a207b91d" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -399,9 +401,9 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enum-map" @@ -420,7 +422,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] @@ -431,9 +433,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "flexi_logger" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a250587a211932896a131f214a4f64c047b826ce072d2018764e5ff5141df8fa" +checksum = "4aecae2cdf1c33e1c83896a37cc155e207a6358c915795932c338126e8eb3392" dependencies = [ "chrono", "glob", @@ -451,9 +453,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -466,9 +468,9 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -480,9 +482,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -490,44 +492,44 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -543,9 +545,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -554,9 +556,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -566,9 +568,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "heck" @@ -579,12 +587,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -600,30 +602,24 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -637,9 +633,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -647,12 +643,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -672,30 +668,30 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libredox" @@ -703,15 +699,15 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "libc", ] [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -719,9 +715,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lsp-types" @@ -738,9 +734,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minimal-lexical" @@ -750,11 +746,11 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -860,37 +856,27 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.9", - "libc", -] - [[package]] name = "object" -version = "0.30.3" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "option-ext" @@ -919,15 +905,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -944,35 +930,35 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1012,18 +998,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1087,11 +1073,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] @@ -1107,9 +1093,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -1119,9 +1105,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -1130,9 +1116,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remove_dir_all" @@ -1145,9 +1131,9 @@ dependencies = [ [[package]] name = "ropey" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53ce7a2c43a32e50d666e33c5a80251b31147bb4b49024bcab11fb6f20c671ed" +checksum = "93411e420bcd1a75ddd1dc3caf18c23155eda2c090631a85af21ba19e97093b5" dependencies = [ "smallvec", "str_indices", @@ -1155,21 +1141,21 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1188,44 +1174,45 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.109" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] @@ -1239,9 +1226,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.25" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ "indexmap", "itoa", @@ -1251,10 +1238,16 @@ dependencies = [ ] [[package]] -name = "slab" -version = "0.4.8" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -1273,9 +1266,9 @@ checksum = "3468939e48401c4fe3cdf5e5cef50951c2808ed549d1467fde249f1fcb602634" [[package]] name = "str_indices" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f026164926842ec52deb1938fae44f83dfdb82d0a5b0270c5bd5935ab74d6dd" +checksum = "e9557cb6521e8d009c51a8666f09356f4b817ba9ba0981a305bd86aee47bd35c" [[package]] name = "strsim" @@ -1285,9 +1278,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "structopt" @@ -1332,7 +1325,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] @@ -1369,7 +1362,7 @@ name = "sv-parser-macros" version = "0.13.3" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] @@ -1420,9 +1413,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1450,29 +1443,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1485,40 +1478,37 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ - "autocfg", "backtrace", - "num_cpus", "pin-project-lite", "tokio-macros", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -1544,9 +1534,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -1571,9 +1561,9 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-lsp" @@ -1606,22 +1596,21 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1629,68 +1618,68 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unsafe-libyaml" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "url" -version = "2.4.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1712,15 +1701,15 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vhdl_lang" version = "0.83.0" dependencies = [ - "clap 4.4.18", + "clap 4.5.19", "dirs", "dunce", "enum-map", @@ -1743,14 +1732,14 @@ name = "vhdl_lang_macros" version = "0.83.0" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.79", ] [[package]] name = "walkdir" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -1764,34 +1753,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1799,22 +1789,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "winapi" @@ -1834,11 +1824,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1848,12 +1838,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -1871,7 +1861,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -1891,18 +1890,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1913,9 +1912,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -1925,9 +1924,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1937,15 +1936,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1955,9 +1954,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1967,9 +1966,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -1979,9 +1978,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1991,9 +1990,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..39ae375 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,2 @@ +[target.x86_64-apple-darwin] +image = "ghcr.io/shepherdjerred/macos-cross-compiler:latest" \ No newline at end of file diff --git a/build_all.sh b/build_all.sh new file mode 100644 index 0000000..cf50976 --- /dev/null +++ b/build_all.sh @@ -0,0 +1,14 @@ +# linux amd64 +cargo build --release +# linux aarch64 +cross build --release --target aarch64-unknown-linux-gnu +# windows amd64 +cross build --release --target x86_64-pc-windows-gnu +# windows aarch64 +cargo xwin build --release --target aarch64-pc-windows-msvc +# MacOS amd64 +export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=rust-lld +cross build --release --target x86_64-apple-darwin +# MacOS aarch64 +export CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=rust-lld +cross build --release --target aarch64-apple-darwin diff --git a/src/completion/vhdl.rs b/src/completion/vhdl.rs index b9bfff2..f90efb0 100644 --- a/src/completion/vhdl.rs +++ b/src/completion/vhdl.rs @@ -1,231 +1,181 @@ -use std::{path::PathBuf, str::FromStr}; - +#[allow(unused)] use log::info; +use ropey::{Rope, RopeSlice}; use tower_lsp::lsp_types::*; -use vhdl_lang::{ast::{Designator, ObjectClass}, kind_str, AnyEntKind, Design, EntRef, InterfaceEnt, Overloaded}; -use crate::{server::LSPServer, utils::{from_lsp_pos, to_escape_path}}; +#[allow(unused)] +use crate::{server::LSPServer, sources::LSPSupport, utils::get_language_id_by_uri}; /// Called when the client requests a completion. /// This function looks in the source code to find suitable options and then returns them pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option { let doc = ¶ms.text_document_position; + let uri = ¶ms.text_document_position.text_document.uri; // let pos = doc.position; + // let language_id = get_language_id_by_uri(uri); - let file_id = server.srcs.get_id(&doc.text_document.uri).to_owned(); + let file_id = server.srcs.get_id(uri).to_owned(); server.srcs.wait_parse_ready(file_id, false); - let projects = server.srcs.design_file_map.read().ok()?; + let file = server.srcs.get_file(file_id)?; + let file = file.read().ok()?; + let line_text = file.text.line(doc.position.line as usize); + let token = get_completion_token( + &file.text, + line_text.clone(), + doc.position, + ); - let path = match PathBuf::from_str(&doc.text_document.uri.path()) { - Ok(path) => path, - Err(error) => { - info!("error happen in : {:?}", error); - return None; - } - }; - let escape_path = to_escape_path(&path); + // info!("trigger completion token: {}", token); + // let line_text = file.text.line(pos.line as usize); - let project = match projects.get("VHDLProject") { - Some(project) => project, - None => return None - }; - - // let source = project.get_source(&escape_path)?; - - let binding = escape_path; - let file = binding.as_path(); - // 1) get source position, and source file - let Some(source) = project.get_source(file) else { - // Do not enable completions for files that are not part of the project - - return Some(CompletionResponse::List(CompletionList { - ..Default::default() - })); - }; - let cursor = from_lsp_pos(params.text_document_position.position); - // 2) Optimization chance: go to last recognizable token before the cursor. For example: - // - Any primary unit (e.g. entity declaration, package declaration, ...) - // => keyword `entity`, `package`, ... - // - Any secondary unit (e.g. package body, architecture) - // => keyword `architecture`, ... - - // 3) Run the parser until the point of the cursor. Then exit with possible completions - let options = project - .list_completion_options(&source, cursor) - .into_iter() - .map(|item| completion_item_to_lsp_item(server, item)) - .collect(); - Some(CompletionResponse::List(CompletionList { - items: options, - is_incomplete: true, - })) -} - -fn completion_item_to_lsp_item( - #[allow(unused)] - server: &LSPServer, - item: vhdl_lang::CompletionItem, -) -> CompletionItem { - match item { - vhdl_lang::CompletionItem::Simple(ent) => entity_to_completion_item(ent), - vhdl_lang::CompletionItem::Work => CompletionItem { - label: "work".to_string(), - detail: Some("work library".to_string()), - kind: Some(CompletionItemKind::MODULE), - insert_text: Some("work".to_string()), - ..Default::default() - }, - vhdl_lang::CompletionItem::Formal(ent) => { - let mut item = entity_to_completion_item(ent); - // TODO: Confirm vscode support - // if server.client_supports_snippets() { - item.insert_text_format = Some(InsertTextFormat::SNIPPET); - item.insert_text = Some(format!("{} => $1,", item.insert_text.unwrap())); + let response = match ¶ms.context { + Some(context) => match context.trigger_kind { + // CompletionTriggerKind::TRIGGER_CHARACTER => { + // let trigger_character = context.trigger_character.clone().unwrap(); + // match trigger_character.as_str() { + // "." => { + // info!("trigger dot completion"); + // get_dot_completion(server, &line_text, uri, &pos, &language_id) + // }, + // "$" => Some(CompletionList { + // is_incomplete: false, + // items: server.sys_tasks.clone(), + // }), + // "`" => Some(CompletionList { + // is_incomplete: false, + // items: server.directives.clone(), + // }), + // "/" => { + // info!("trigger include"); + // include_path_completion(&doc.text_document.uri, &line_text, pos) + // }, + // "\"" => { + // info!("trigger include"); + // include_path_completion(&doc.text_document.uri, &line_text, pos) + // } + // _ => None, + // } // } - item - } - vhdl_lang::CompletionItem::Overloaded(desi, count) => CompletionItem { - label: desi.to_string(), - detail: Some(format!("+{count} overloaded")), - kind: match desi { - Designator::Identifier(_) => Some(CompletionItemKind::FUNCTION), - Designator::OperatorSymbol(_) => Some(CompletionItemKind::OPERATOR), - _ => None, - }, - insert_text: Some(desi.to_string()), - ..Default::default() + // CompletionTriggerKind::TRIGGER_FOR_INCOMPLETE_COMPLETIONS => None, + CompletionTriggerKind::INVOKED => { + let mut comps = server.srcs.get_completions( + &token, + file.text.pos_to_byte(&doc.position), + &doc.text_document.uri, + )?; + + // complete keywords + comps.items.extend::>( + server.key_comps + .iter() + .filter(|x| x.label.starts_with(&token)) + .cloned() + .collect(), + ); + Some(comps) + } + _ => None, }, - vhdl_lang::CompletionItem::Keyword(kind) => CompletionItem { - label: kind_str(kind).to_string(), - detail: Some(kind_str(kind).to_string()), - insert_text: Some(kind_str(kind).to_string()), - kind: Some(CompletionItemKind::KEYWORD), - ..Default::default() - }, - vhdl_lang::CompletionItem::Instantiation(ent, architectures) => { - let work_name = "work"; - - let library_names = if let Some(lib_name) = ent.library_name() { - vec![work_name.to_string(), lib_name.name().to_string()] - } else { - vec![work_name.to_string()] - }; - let (region, is_component_instantiation) = match ent.kind() { - AnyEntKind::Design(Design::Entity(_, region)) => (region, false), - AnyEntKind::Component(region) => (region, true), - // should never happen but better return some value instead of crashing - _ => return entity_to_completion_item(ent), - }; - // TODO: Confirm vscode support - let template = if true { // if server.client_supports_snippets() { - let mut line = if is_component_instantiation { - format!("${{1:{}_inst}}: {}", ent.designator, ent.designator) - } else { - format!( - "${{1:{}_inst}}: entity ${{2|{}|}}.{}", - ent.designator, - library_names.join(","), - ent.designator - ) - }; - if architectures.len() > 1 { - line.push_str("(${3|"); - for (i, architecture) in architectures.iter().enumerate() { - line.push_str(&architecture.designator().to_string()); - if i != architectures.len() - 1 { - line.push(',') - } - } - line.push_str("|})"); + None => { + let trigger = prev_char(&file.text, &doc.position); + match trigger { + // '.' => Some(server.srcs.get_dot_completions( + // token.trim_end_matches('.'), + // file.text.pos_to_byte(&doc.position), + // &doc.text_document.uri, + // )?), + // '$' => Some(CompletionList { + // is_incomplete: false, + // items: server.sys_tasks.clone(), + // }), + // '`' => Some(CompletionList { + // is_incomplete: false, + // items: server.directives.clone(), + // }), + _ => { + let mut comps = server.srcs.get_completions( + &token, + file.text.pos_to_byte(&doc.position), + &doc.text_document.uri, + )?; + comps.items.extend::>( + server.key_comps + .iter() + .filter(|x| x.label.starts_with(&token)) + .cloned() + .collect(), + ); + Some(comps) } - let (ports, generics) = region.ports_and_generics(); - let mut idx = 4; - let mut interface_ent = |elements: Vec, purpose: &str| { - line += &*format!("\n {} map(\n", purpose); - for (i, generic) in elements.iter().enumerate() { - line += &*format!( - " {} => ${{{}:{}}}", - generic.designator, idx, generic.designator - ); - idx += 1; - if i != elements.len() - 1 { - line += "," - } - line += "\n"; - } - line += ")"; - }; - if !generics.is_empty() { - interface_ent(generics, "generic"); - } - if !ports.is_empty() { - interface_ent(ports, "port"); - } - line += ";"; - line - } else { - format!("{}", ent.designator) - }; - CompletionItem { - label: format!("{} instantiation", ent.designator), - insert_text: Some(template), - insert_text_format: Some(InsertTextFormat::SNIPPET), - kind: Some(CompletionItemKind::MODULE), - ..Default::default() } } - vhdl_lang::CompletionItem::Attribute(attribute) => CompletionItem { - label: format!("{attribute}"), - detail: Some(format!("{attribute}")), - insert_text: Some(format!("{attribute}")), - kind: Some(CompletionItemKind::REFERENCE), - ..Default::default() - }, - } + }; + // eprintln!("comp response: {}", now.elapsed().as_millis()); + Some(CompletionResponse::List(response?)) } -fn entity_to_completion_item(ent: EntRef) -> CompletionItem { - CompletionItem { - label: ent.designator.to_string(), - detail: Some(ent.describe()), - kind: Some(entity_kind_to_completion_kind(ent.kind())), - data: serde_json::to_value(ent.id.to_raw()).ok(), - insert_text: Some(ent.designator.to_string()), - ..Default::default() - } -} - - -fn entity_kind_to_completion_kind(kind: &AnyEntKind) -> CompletionItemKind { - match kind { - AnyEntKind::ExternalAlias { .. } | AnyEntKind::ObjectAlias { .. } => { - CompletionItemKind::FIELD +fn prev_char(text: &Rope, pos: &Position) -> char { + let char_idx = text.pos_to_char(pos); + if char_idx > 0 { + for i in (0..char_idx).rev() { + let res = text.char(i); + if !res.is_whitespace() { + return res; + } } - AnyEntKind::File(_) | AnyEntKind::InterfaceFile(_) => CompletionItemKind::FILE, - AnyEntKind::Component(_) => CompletionItemKind::MODULE, - AnyEntKind::Attribute(_) => CompletionItemKind::REFERENCE, - AnyEntKind::Overloaded(overloaded) => match overloaded { - Overloaded::SubprogramDecl(_) - | Overloaded::Subprogram(_) - | Overloaded::UninstSubprogramDecl(..) - | Overloaded::UninstSubprogram(..) - | Overloaded::InterfaceSubprogram(_) => CompletionItemKind::FUNCTION, - Overloaded::EnumLiteral(_) => CompletionItemKind::ENUM_MEMBER, - Overloaded::Alias(_) => CompletionItemKind::FIELD, - }, - AnyEntKind::Type(_) => CompletionItemKind::TYPE_PARAMETER, - AnyEntKind::ElementDeclaration(_) => CompletionItemKind::FIELD, - AnyEntKind::Concurrent(_) => CompletionItemKind::MODULE, - AnyEntKind::Sequential(_) => CompletionItemKind::MODULE, - AnyEntKind::Object(object) => match object.class { - ObjectClass::Signal => CompletionItemKind::EVENT, - ObjectClass::Constant => CompletionItemKind::CONSTANT, - ObjectClass::Variable | ObjectClass::SharedVariable => CompletionItemKind::VARIABLE, - }, - AnyEntKind::LoopParameter(_) => CompletionItemKind::MODULE, - AnyEntKind::PhysicalLiteral(_) => CompletionItemKind::UNIT, - AnyEntKind::DeferredConstant(_) => CompletionItemKind::CONSTANT, - AnyEntKind::Library => CompletionItemKind::MODULE, - AnyEntKind::Design(_) => CompletionItemKind::MODULE, - AnyEntKind::View(_) => CompletionItemKind::INTERFACE, + ' ' + } else { + ' ' } } + +fn get_completion_token(text: &Rope, line: RopeSlice, pos: Position) -> String { + let mut token = String::new(); + let mut line_iter = line.chars(); + for _ in 0..(line.utf16_cu_to_char(pos.character as usize)) { + line_iter.next(); + } + let mut c = line_iter.prev(); + //TODO: make this a regex + while c.is_some() + && (c.unwrap().is_alphanumeric() + || c.unwrap() == '_' + || c.unwrap() == '.' + || c.unwrap() == '[' + || c.unwrap() == ']') + { + token.push(c.unwrap()); + c = line_iter.prev(); + } + let mut result: String = token.chars().rev().collect(); + if result.contains('[') { + let l_bracket_offset = result.find('[').unwrap_or(result.len()); + result.replace_range(l_bracket_offset.., ""); + } + if &result == "." { + // probably a instantiation, the token should be what we're instatiating + let mut char_iter = text.chars(); + let mut token = String::new(); + for _ in 0..text.pos_to_char(&pos) { + char_iter.next(); + } + let mut c = char_iter.prev(); + + // go to the last semicolon + while c.is_some() && (c.unwrap() != ';') { + c = char_iter.prev(); + } + // go the the start of the next symbol + while c.is_some() && !(c.unwrap().is_alphanumeric() || c.unwrap() == '_') { + c = char_iter.next(); + } + // then extract the next symbol + while c.is_some() && (c.unwrap().is_alphanumeric() || c.unwrap() == '_') { + token.push(c.unwrap()); + c = char_iter.next(); + } + token + } else { + result + } +} + diff --git a/src/core/vhdl_parser.rs b/src/core/vhdl_parser.rs index 7f763d0..7321b59 100644 --- a/src/core/vhdl_parser.rs +++ b/src/core/vhdl_parser.rs @@ -68,6 +68,7 @@ pub fn make_fast_from_design_file(design_file: &DesignFile) -> Option) -> Vec { let mut modules = Vec::new(); + let mut last_module_name = String::new(); let mut instance_type = HashSet::new(); let mut i = 0; @@ -97,7 +98,7 @@ fn parse_tokens(tokens: Vec) -> Vec { tokens[end].pos.range.end }; let module = Module { - name: entity_name, + name: entity_name.to_string(), params: Vec::new(), ports: Vec::new(), instances: Vec::new(), @@ -112,6 +113,7 @@ fn parse_tokens(tokens: Vec) -> Vec { } } }; + last_module_name = entity_name.to_string(); modules.push(module); } } @@ -140,7 +142,7 @@ fn parse_tokens(tokens: Vec) -> Vec { tokens[end].pos.range.end }; let module = Module { - name, + name: name.to_string(), params: Vec::new(), ports: Vec::new(), instances: Vec::new(), @@ -155,6 +157,7 @@ fn parse_tokens(tokens: Vec) -> Vec { } } }; + last_module_name = name.to_string(); modules.push(module); } } @@ -214,7 +217,9 @@ fn parse_tokens(tokens: Vec) -> Vec { } } }; - modules.last_mut().unwrap().instances.push(instance); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.instances.push(instance); + } } else if kind_str(tokens[i+1].kind) == "entity" { let instance = Instance { name: get_value(&tokens[i-1]), @@ -232,7 +237,9 @@ fn parse_tokens(tokens: Vec) -> Vec { } } }; - modules.last_mut().unwrap().instances.push(instance); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.instances.push(instance); + } i += 1; } else { let name = get_value(&tokens[i-1]); @@ -261,7 +268,9 @@ fn parse_tokens(tokens: Vec) -> Vec { } } }; - modules.last_mut().unwrap().instances.push(instance); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.instances.push(instance); + } } } } @@ -271,9 +280,13 @@ fn parse_tokens(tokens: Vec) -> Vec { if is_map { let start = params.first().unwrap().range.start.clone(); let end = params.last().unwrap().range.start.clone(); - modules.last_mut().unwrap().instances.last_mut().unwrap().instparams = Some(Range { start, end }); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.instances.last_mut().unwrap().instparams = Some(Range { start, end });; + } } else { - modules.last_mut().unwrap().params.extend(params); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.params.extend(params); + } } i = next_index; } @@ -283,9 +296,13 @@ fn parse_tokens(tokens: Vec) -> Vec { if is_map { let start = ports.first().unwrap().range.start.clone(); let end = ports.last().unwrap().range.start.clone(); - modules.last_mut().unwrap().instances.last_mut().unwrap().instports = Some(Range { start, end }); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.instances.last_mut().unwrap().instports = Some(Range { start, end }); + } } else { - modules.last_mut().unwrap().ports.extend(ports); + if let Some(module) = modules.iter_mut().find(|module| module.name == last_module_name) { + module.ports.extend(ports); + } } i = next_index; } diff --git a/src/definition/mod.rs b/src/definition/mod.rs index 161a866..81f5712 100644 --- a/src/definition/mod.rs +++ b/src/definition/mod.rs @@ -1,8 +1,10 @@ +use crate::core::hdlparam::{self, FastHdlparam}; use crate::utils::get_language_id_by_uri; use crate::server::LSPServer; #[allow(unused)] use log::info; +use ropey::Rope; use sv_parser::*; use tower_lsp::lsp_types::*; @@ -199,3 +201,58 @@ pub fn get_scopes_from_syntax_tree(syntax_tree: &SyntaxTree, url: &Url) -> Optio Some(global_scope) } +pub fn get_scopes_from_vhdl_fast(fast: &FastHdlparam, text: &Rope, url: &Url) -> Option { + let mut scopes: Vec> = Vec::new(); + let mut global_scope: GenericScope = GenericScope::new(url); + global_scope.ident = String::from("global"); + + for module in &fast.content { + let mut scope: GenericScope = GenericScope::new(url); + scope.ident = module.name.clone(); + let mut module_range = module.range.clone(); + module_range.affine(-1, -1); + scope.start = position_to_byte_idx(text, &module_range.start); + scope.end = position_to_byte_idx(text, &module_range.end); + scope.byte_idx = scope.start + 7; + + for parameter in &module.params { + let mut def = GenericDec::new(url); + def.ident = parameter.name.clone(); + let mut parameter_range = parameter.range.clone(); + parameter_range.affine(-1, -1); + def.byte_idx = position_to_byte_idx(text, ¶meter_range.start); + def.completion_kind = CompletionItemKind::TYPE_PARAMETER; + def.symbol_kind = SymbolKind::TYPE_PARAMETER; + scope.defs.push(Box::new(def)); + } + for port in &module.ports { + let mut port_def = PortDec::new(url); + port_def.ident = port.name.clone(); + let mut port_range = port.range.clone(); + port_range.affine(-1, -1); + port_def.byte_idx = position_to_byte_idx(text, &port_range.start); + port_def.type_str = port.dir_type.clone(); + scope.defs.push(Box::new(port_def)); + } + for inst in &module.instances { + let mut instance = ModInst::new(url); + instance.ident = inst.name.clone(); + let mut inst_range = inst.range.clone(); + inst_range.affine(-1, -1); + instance.byte_idx = position_to_byte_idx(text, &inst_range.start); + instance.type_str = inst.inst_type.clone(); + instance.mod_ident = inst.inst_type.clone(); + + scope.defs.push(Box::new(instance)); + } + scopes.push(Box::new(scope)); + } + + global_scope.scopes.append(&mut scopes); + Some(global_scope) +} + +fn position_to_byte_idx(text: &Rope, pos: &hdlparam::Position) -> usize { + let char = text.line_to_char(pos.line as usize) + pos.character as usize; + text.char_to_byte(char) +} diff --git a/src/definition/vhdl.rs b/src/definition/vhdl.rs index 34ad699..f21ca87 100644 --- a/src/definition/vhdl.rs +++ b/src/definition/vhdl.rs @@ -1,33 +1,52 @@ -use std::{path::PathBuf, str::FromStr}; - +#[allow(unused)] use log::info; use tower_lsp::lsp_types::*; -use crate::{server::LSPServer, utils::{from_lsp_pos, srcpos_to_location, to_escape_path}}; +use crate::{server::LSPServer, sources::LSPSupport, utils::get_definition_token}; + +use super::{Definition, Scope}; pub fn goto_vhdl_definition(server: &LSPServer, params: &GotoDefinitionParams) -> Option { - let uri = ¶ms.text_document_position_params.text_document.uri; + let doc = ¶ms.text_document_position_params.text_document.uri; let pos = params.text_document_position_params.position; - let file_id = server.srcs.get_id(&uri).to_owned(); + let file_id = server.srcs.get_id(doc).to_owned(); server.srcs.wait_parse_ready(file_id, false); - let projects = server.srcs.design_file_map.read().ok()?; + let file = server.srcs.get_file(file_id)?; + let file = file.read().ok()?; - let path = match PathBuf::from_str(uri.path()) { - Ok(path) => path, - Err(error) => { - info!("error happen in : {:?}", error); - return None; - } - }; - let escape_path = to_escape_path(&path); + let line_text = file.text.line(pos.line as usize); + let token: String = get_definition_token(&line_text, pos); - let project = match projects.get("VHDLProject") { - Some(project) => project, - None => return None - }; + // // match include + // if let Some(definition) = goto_include_definition(doc, &line_text, pos) { + // return Some(definition); + // } - let source = project.get_source(&escape_path)?; + // // match macro + // if let Some(definition) = goto_macro_definition(server, &line_text, pos) { + // return Some(definition); + // } - let ent = project.find_definition(&source, from_lsp_pos(pos))?; - let location = srcpos_to_location(ent.decl_pos()?); - Some(GotoDefinitionResponse::Scalar(location)) + // match instance + + let scope_tree = server.srcs.scope_tree.read().ok()?; + + // // match position port & param + // if let Some(definition) = goto_position_port_param_definition(server, &line_text, doc, pos) { + // return Some(definition); + // } + + // // match module name + // if let Some(definition) = goto_module_declaration_definition(server, &token) { + // return Some(definition); + // } + + let byte_idx = file.text.pos_to_byte(&pos); + let global_scope = scope_tree.as_ref()?; + let def = global_scope.get_definition(&token, byte_idx, doc)?; + + let def_pos = file.text.byte_to_pos(def.byte_idx()); + Some(GotoDefinitionResponse::Scalar(Location::new( + def.url(), + Range::new(def_pos, def_pos), + ))) } \ No newline at end of file diff --git a/src/document_highlight/mod.rs b/src/document_highlight/mod.rs index a4b9fdf..3823bd8 100644 --- a/src/document_highlight/mod.rs +++ b/src/document_highlight/mod.rs @@ -21,10 +21,13 @@ impl LSPServer { let language_id = get_language_id_by_uri(&uri); match language_id.as_str() { - "vhdl" => vhdl::document_highlight( - self, - ¶ms.text_document_position_params - ), + // "vhdl" => vhdl::document_highlight( + // self, + // &token, + // &file, + // pos, + // &uri + // ), "verilog" | "systemverilog" => sv::document_highlight( self, diff --git a/src/document_highlight/vhdl.rs b/src/document_highlight/vhdl.rs index b357896..d863bbf 100644 --- a/src/document_highlight/vhdl.rs +++ b/src/document_highlight/vhdl.rs @@ -1,45 +1,55 @@ -use std::{path::PathBuf, str::FromStr}; - use log::info; +use sv_parser::{RefNode, SyntaxTree}; use tower_lsp::lsp_types::*; -use crate::{server::LSPServer, utils::{from_lsp_pos, to_escape_path, to_lsp_range}}; +use crate::{definition::{get_ident, Scope}, server::LSPServer, sources::{LSPSupport, ParseIR, Source}}; pub fn document_highlight( server: &LSPServer, - params: &TextDocumentPositionParams + token: &str, + file: &Source, + pos: Position, + uri: &Url ) -> Option> { - let uri = ¶ms.text_document.uri; - let file_id = server.srcs.get_id(&uri).to_owned(); - server.srcs.wait_parse_ready(file_id, false); - let projects = server.srcs.design_file_map.read().ok()?; + let scope_tree = server.srcs.scope_tree.read().ok()?; - let path = match PathBuf::from_str(uri.path()) { - Ok(path) => path, - Err(error) => { - info!("error happen in : {:?}", error); - return None; + // use the byte_idx of the definition if possible, otherwise use the cursor + let byte_idx = + match scope_tree + .as_ref()? + .get_definition(token, file.text.pos_to_byte(&pos), uri) + { + Some(def) => def.byte_idx, + None => file.text.pos_to_byte(&pos), + }; + let syntax_tree = file.parse_ir.as_ref()?; + match syntax_tree { + ParseIR::SyntaxTree(syntax_tree) => { + let references = all_identifiers(&syntax_tree, &token); + Some( + scope_tree + .as_ref()? + .document_highlights(&uri, &file.text, references, byte_idx), + ) + }, + _ => { + info!("error happen in [vhdl_document_highlight]"); + None } - }; - let escape_path = to_escape_path(&path); + } +} - let project = match projects.get("VHDLProject") { - Some(project) => project, - None => return None - }; - - let source = project.get_source(&escape_path)?; - - let ent = project.find_declaration(&source, from_lsp_pos(params.position))?; - - Some( - project - .find_all_references_in_source(&source, ent) - .iter() - .map(|pos| DocumentHighlight { - range: to_lsp_range(pos.range()), - kind: Some(DocumentHighlightKind::TEXT), - }) - .collect(), - ) +/// return all identifiers in a syntax tree matching a given token +fn all_identifiers(syntax_tree: &SyntaxTree, token: &str) -> Vec<(String, usize)> { + let mut idents: Vec<(String, usize)> = Vec::new(); + for node in syntax_tree { + if let RefNode::Identifier(_) = node { + + let (ident, byte_idx) = get_ident(syntax_tree, node); + if ident == token { + idents.push((ident, byte_idx)); + } + } + } + idents } \ No newline at end of file diff --git a/src/document_symbol/vhdl.rs b/src/document_symbol/vhdl.rs index e909ebb..74792d8 100644 --- a/src/document_symbol/vhdl.rs +++ b/src/document_symbol/vhdl.rs @@ -1,105 +1,19 @@ +#[allow(unused)] use log::info; use tower_lsp::lsp_types::*; -use crate::{server::LSPServer, utils::to_lsp_range}; -use crate::utils::{to_escape_path, to_symbol_kind}; - -use std::path::PathBuf; -use std::str::FromStr; -use vhdl_lang::{EntHierarchy, Token}; +use crate::{definition::Scope, server::LSPServer}; pub fn document_symbol(server: &LSPServer, params: &DocumentSymbolParams) -> Option { + // info!("enter document symbol"); + let uri = ¶ms.text_document.uri; let file_id = server.srcs.get_id(&uri).to_owned(); server.srcs.wait_parse_ready(file_id, false); - let projects = server.srcs.design_file_map.read().ok()?; + let file = server.srcs.get_file(file_id)?; + let file = file.read().ok()?; + let scope_tree = server.srcs.scope_tree.read().ok()?; - let path = match PathBuf::from_str(uri.path()) { - Ok(path) => path, - Err(error) => { - info!("error happen in : {:?}", error); - return None; - } - }; - let escape_path = to_escape_path(&path); - - let project = match projects.get("VHDLProject") { - Some(project) => project, - None => return None - }; - - let source = project.get_source(&escape_path)?; - - // Some files are mapped to multiple libraries, only use the first library for document symbols - let library_name = project - .library_mapping_of(&source) - .into_iter() - .next()?; - - // TODO: Confirm vscode support - // if server.client_has_hierarchical_document_symbol_support() { - fn to_document_symbol( - EntHierarchy { ent, children }: EntHierarchy, - ctx: &Vec, - ) -> DocumentSymbol { - // Use the declaration position, if it exists, - // else the position of the first source range token. - // The latter is applicable for unnamed elements, e.g., processes or loops. - let selection_pos = ent.decl_pos().unwrap_or(ent.src_span.start_token.pos(ctx)); - let src_range = ent.src_span.pos(ctx).range(); - #[allow(deprecated)] - DocumentSymbol { - name: ent.describe(), - kind: to_symbol_kind(ent.kind()), - tags: None, - detail: None, - selection_range: to_lsp_range(selection_pos.range), - range: to_lsp_range(src_range), - children: if !children.is_empty() { - Some( - children - .into_iter() - .map(|hierarchy| to_document_symbol(hierarchy, ctx)) - .collect(), - ) - } else { - None - }, - deprecated: None, - } - } - - Some(DocumentSymbolResponse::Nested( - project - .document_symbols(&library_name, &source) - .into_iter() - .map(|(hierarchy, tokens)| to_document_symbol(hierarchy, tokens)) - .collect(), - )) - // } else { - // #[allow(clippy::ptr_arg)] - // fn to_symbol_information(ent: EntRef, ctx: &Vec) -> SymbolInformation { - // let selection_pos = ent.decl_pos().unwrap_or(ent.src_span.start_token.pos(ctx)); - // #[allow(deprecated)] - // SymbolInformation { - // name: ent.describe(), - // kind: to_symbol_kind(ent.kind()), - // tags: None, - // location: srcpos_to_location(selection_pos), - // deprecated: None, - // container_name: ent.parent_in_same_source().map(|ent| ent.describe()), - // } - // } - - // Some(DocumentSymbolResponse::Flat( - // project - // .document_symbols(&library_name, &source) - // .into_iter() - // .flat_map(|(a, ctx)| { - // a.into_flat() - // .into_iter() - // .map(|hierarchy| to_symbol_information(hierarchy, ctx)) - // }) - // .collect(), - // )) - // } + Some(DocumentSymbolResponse::Nested( + scope_tree.as_ref()?.document_symbols(uri, &file.text), + )) } \ No newline at end of file diff --git a/src/hover/vhdl.rs b/src/hover/vhdl.rs index ec30007..2d7a180 100644 --- a/src/hover/vhdl.rs +++ b/src/hover/vhdl.rs @@ -1,43 +1,288 @@ -use std::{path::PathBuf, str::FromStr}; +use std::{path::PathBuf, str::FromStr, sync::RwLockReadGuard}; use log::info; +use regex::Regex; +use ropey::Rope; use tower_lsp::lsp_types::*; -use crate::server::LSPServer; +use crate::{core::hdlparam::{Instance, Module}, definition::{Definition, DefinitionType, GenericDec, Scope}, hover::{BracketMatchResult, BracketMatcher}, server::LSPServer, sources::LSPSupport}; -use super::{from_lsp_pos, to_escape_path}; +use super::{feature::hover_format_digit, get_definition_token, get_language_id_by_uri, to_escape_path}; pub fn hover(server: &LSPServer, params: &HoverParams) -> Option { - let uri = ¶ms.text_document_position_params.text_document.uri; - let pos = params.text_document_position_params.position; - let file_id = server.srcs.get_id(&uri).to_owned(); + let doc = ¶ms.text_document_position_params.text_document.uri; + let pos: Position = params.text_document_position_params.position; + let file_id: usize = server.srcs.get_id(doc).to_owned(); server.srcs.wait_parse_ready(file_id, false); - let projects = server.srcs.design_file_map.read().ok()?; + let file: std::sync::Arc> = server.srcs.get_file(file_id)?; + let file: std::sync::RwLockReadGuard<'_, crate::sources::Source> = file.read().ok()?; + + let line_text = file.text.line(pos.line as usize); + let token: String = get_definition_token(&line_text, pos); + let language_id = get_language_id_by_uri(doc); - let path = match PathBuf::from_str(uri.path()) { - Ok(path) => path, - Err(error) => { - info!("error happen in : {:?}", error); + // // match `include + // if let Some(hover) = hover_include(doc, &line_text, pos, &language_id) { + // return Some(hover); + // } + + // // match macro + // if let Some(hover) = hover_macro(server, &line_text, pos, &language_id) { + // return Some(hover); + // } + + let scope_tree = server.srcs.scope_tree.read().ok()?; + let global_scope = scope_tree.as_ref().unwrap(); + + let symbol_definition: GenericDec = global_scope + .get_definition(&token, file.text.pos_to_byte(&pos), doc)?; + + // // match positional port param + // if let Some(hover) = hover_position_port_param(server, &line_text, doc, pos, &language_id) { + // return Some(hover); + // } + + // // match module name + // if let Some(hover) = hover_module_declaration(server, &token, &symbol_definition, &language_id) { + // return Some(hover); + // } + + // match 正常 symbol + if let Some(hover) = hover_common_symbol(server, &token, &symbol_definition, &file, doc, pos, &language_id) { + return Some(hover); + } + + // match digit 5'b00110 + if let Some(hover) = hover_format_digit(&line_text, pos, &language_id) { + return Some(hover); + } + + None +} + +fn make_hover_with_comment(doc: &Rope, line: usize, language_id: &str, exclude_code: bool) -> Option { + if line == 0 { + let language_string = LanguageString { + language: language_id.to_string(), + value: doc.line(line).to_string() + }; + let markdown = MarkedString::LanguageString(language_string); + + return Some(Hover { + contents: HoverContents::Scalar(markdown), + range: None, + }); + } + let mut hover: Vec = Vec::new(); + let mut multiline: bool = false; + let mut valid: bool = true; + let mut current: String = doc.line(line).to_string(); + + let ltrim: String = " ".repeat(current.len() - current.trim_start().len()); + let mut line_idx = line; + + // 寻找周围的注释 + while valid { + hover.push(current.clone()); + line_idx -= 1; + valid = false; + if line_idx > 0 { + current = doc.line(line_idx).to_string(); + let currentl = current.clone().trim_start().to_owned(); + let currentr = current.clone().trim_end().to_owned(); + if currentl.starts_with("/*") && currentr.ends_with("*/") { + valid = true; + } else if currentr.ends_with("*/") { + multiline = true; + valid = true; + } else if currentl.starts_with("/*") { + multiline = false; + valid = true; + } else { + valid = currentl.starts_with("--") || multiline; + } + } + } + hover.reverse(); + + let multi_space_regex = Regex::new(r"\s+").unwrap(); + let line_handler = |line: &str| -> String { + let line = multi_space_regex.replace_all(line.trim(), " "); + let mut line = line.into_owned(); + + if line.starts_with("/*") { + line = line.strip_prefix("/*").unwrap().trim().to_string(); + } else if line.starts_with("--") { + line = line.strip_prefix("--").unwrap().trim().to_string(); + } + + if line.ends_with("*/") { + line = line.strip_suffix("*/").unwrap().trim().to_string(); + } + + return format!("{}\n", line); + }; + + let line_comment_extractor = |line: &str| -> Option<(String, String)> { + let line = line.trim(); + if line.contains("--") { + let comment_start = line.split_once("--"); + match comment_start { + Some((code, comment)) => { + let code = code.trim().to_string(); + let comment = comment.trim().to_string(); + Some((code, comment)) + }, + None => None + } + } else if line.contains("/*") { + let comment_start = line.split_once("/*"); + match comment_start { + Some((code, comment)) => { + let code = code.trim().to_string(); + let comment = comment.trim().strip_suffix("*/").unwrap_or("").to_string(); + Some((code, comment)) + }, + None => None + } + } else { return None; } }; - let escape_path = to_escape_path(&path); - let project = match projects.get("VHDLProject") { - Some(project) => project, - None => return None + // 所有的 markdown + let mut comment_markdowns = Vec::::new(); + + for (line_no, line_text) in hover.iter().enumerate() { + let line_hover = if let Some(stripped) = line_text.strip_prefix(<rim) { + line_handler(stripped) + } else { + line_handler(&line_text) + }; + + if line_no == hover.len() - 1 { + // 最后一个为定义所在的一行 + if let Some((code, comment)) = line_comment_extractor(&line_text) { + comment_markdowns.push(MarkedString::LanguageString(LanguageString { + language: language_id.to_string(), + value: code + })); + comment_markdowns.insert(0, MarkedString::String(comment.trim().to_string())); + } else { + // 这行只有代码,没有注释 + comment_markdowns.push(MarkedString::LanguageString(LanguageString { + language: language_id.to_string(), + value: line_hover + })); + } + } else { + // 否则,都是上方的注释 + comment_markdowns.push(MarkedString::String(line_hover.trim().to_string())); + } + } + + // 合并其中的 markdown + let mut merge_markdowns = Vec::::new(); + let mut string_buffer = String::new(); + for (_, md) in comment_markdowns.iter().enumerate() { + match md { + MarkedString::String(markdown_string) => { + string_buffer.push_str(format!("{}\n", markdown_string.trim()).as_str()); + } + MarkedString::LanguageString(code) => { + if !string_buffer.is_empty() { + merge_markdowns.push(MarkedString::String(string_buffer.to_string())); + string_buffer.clear(); + } + + if !exclude_code { + merge_markdowns.push(MarkedString::LanguageString(code.to_owned())); + } + } + } + } + + if comment_markdowns.len() > 0 { + return Some(Hover { + contents: HoverContents::Array(merge_markdowns), + range: None + }); + } + + None +} + + + +fn hover_common_symbol( + #[allow(unused)] + server: &LSPServer, + #[allow(unused)] + token: &String, + symbol_definition: &GenericDec, + file: &RwLockReadGuard<'_, crate::sources::Source>, + doc: &Url, + #[allow(unused)] + pos: Position, + language_id: &String +) -> Option { + // 根据 symbol 的类别进行额外的判断 + match symbol_definition.def_type { + DefinitionType::ModuleInstantiation => { + let hdlparam = server.srcs.hdl_param.clone(); + let pathbuf = PathBuf::from_str(doc.path()).unwrap(); + let pathbuf = to_escape_path(&pathbuf); + let path_string = pathbuf.to_str().unwrap().replace("\\", "/"); + + let find_name_condition = |_: &Module, instance: &Instance| { + symbol_definition.ident == instance.name + }; + + + if let Some(instance) = hdlparam.walk_instantiation(&path_string, find_name_condition) { + info!("instance {:?}", instance); + let def_line = file.text.byte_to_line(symbol_definition.byte_idx()); + let mut markdown_comment = match make_hover_with_comment(&file.text, def_line, &language_id, true) { + Some(hover) => { + match hover.contents { + HoverContents::Array(array) => array, + _ => Vec::::new() + } + }, + None => Vec::::new() + }; + + // 扫描到右括号 + let mut current_line = def_line; + let mut buffer = String::new(); + let len_lines = file.text.len_lines(); + let mut matcher = BracketMatcher::new(); + + loop { + if current_line >= len_lines { + break; + } + let line_text = file.text.line(current_line).to_string(); + buffer.push_str(&line_text); + match matcher.consume_string(&line_text) { + BracketMatchResult::Invalid | BracketMatchResult::Complete => break, + BracketMatchResult::Valid => {} + } + + current_line += 1; + } + markdown_comment.push(MarkedString::LanguageString(LanguageString { + language: language_id.to_string(), + value: buffer + })); + + return Some(Hover { contents: HoverContents::Array(markdown_comment), range: None }); + } + } + + _ => {} }; - let source = project.get_source(&escape_path)?; + let def_line = file.text.byte_to_line(symbol_definition.byte_idx()); + make_hover_with_comment(&file.text, def_line, &language_id, false) +} - let ent = project.find_declaration(&source, from_lsp_pos(pos))?; - - let value = project.format_declaration(ent)?; - - Some(Hover { - contents: HoverContents::Markup(MarkupContent { - kind: MarkupKind::Markdown, - value: format!("```vhdl\n{value}\n```"), - }), - range: None, - }) -} \ No newline at end of file diff --git a/src/sources.rs b/src/sources.rs index f6a440f..b0df08e 100644 --- a/src/sources.rs +++ b/src/sources.rs @@ -4,6 +4,7 @@ use crate::core::vhdl_parser::make_fast_from_design_file; use crate::core::vhdl_parser::vhdl_parse; use crate::definition::def_types::*; use crate::definition::get_scopes_from_syntax_tree; +use crate::definition::get_scopes_from_vhdl_fast; use crate::diagnostics::{get_diagnostics, is_hidden}; use crate::server::LSPServer; use crate::utils::to_escape_path; @@ -12,7 +13,6 @@ use log::info; use log::{debug, error}; use pathdiff::diff_paths; use ropey::{Rope, RopeSlice}; -use vhdl_lang::MessagePrinter; use std::cmp::min; use std::collections::HashMap; use std::env::current_dir; @@ -129,7 +129,7 @@ pub struct Source { pub enum ParseIR { /// 基于 vhdl-parser 的IR,存放 VHDL #[allow(unused)] - VHDLProject(vhdl_lang::Project), + DesignFile(vhdl_lang::ast::DesignFile), /// 存放 sv 的 IR SyntaxTree(sv_parser::SyntaxTree) } @@ -248,7 +248,6 @@ impl Sources { })); let source_handle = source.clone(); let scope_handle = self.scope_tree.clone(); - let design_file_handle = self.design_file_map.clone(); let hdl_param_handle = self.hdl_param.clone(); let inc_dirs = self.include_dirs.clone(); @@ -270,8 +269,10 @@ impl Sources { match language_id.as_str() { "vhdl" => { vhdl_parser_pipeline( - &design_file_handle, + &source_handle, + &scope_handle, &hdl_param_handle, + &text, uri, ); }, @@ -601,8 +602,10 @@ pub fn sv_parser_pipeline( } pub fn vhdl_parser_pipeline( - design_file_handle: &Arc>>, + source_handle: &Arc>, + scope_handle: &Arc>>, hdl_param_handle: &Arc, + doc: &Rope, uri: &Url ) { let path = match PathBuf::from_str(uri.path()) { @@ -618,19 +621,58 @@ pub fn vhdl_parser_pipeline( info!("error happen in [vhdl_parser_pipeline], escape_path_string is empty"); return; } - if let Some(design_file) = vhdl_parse(&escape_path) { - let mut design_files = design_file_handle.write().unwrap(); + + let mut file = source_handle.write().unwrap(); + + let mut scope_tree = if let Some(design_file) = vhdl_parse(&escape_path) { + //let mut design_files = design_file_handle.write().unwrap(); + if let Some(fast) = make_fast_from_design_file(&design_file) { - hdl_param_handle.update_fast(escape_path_string.to_string(), fast); - } - let mut msg_printer = MessagePrinter::default(); - if let Some(project) = design_files.get_mut("VHDLProject") { - project.digital_lsp_update_config(&escape_path, &mut msg_printer); + let parse_ir = ParseIR::DesignFile(design_file); + file.parse_ir = Some(parse_ir); + hdl_param_handle.update_fast(escape_path_string.to_string(), fast.clone()); + let scope_tree = get_scopes_from_vhdl_fast(&fast, doc, uri); + scope_tree } else { - let project = vhdl_lang::Project::new_without_config(&escape_path, &mut msg_printer); - design_files.insert("VHDLProject".to_string(), project); + None } + + // let mut msg_printer = MessagePrinter::default(); + // if let Some(project) = design_files.get_mut("VHDLProject") { + // project.digital_lsp_update_config(&escape_path, &mut msg_printer); + // } else { + // let project = vhdl_lang::Project::new_without_config(&escape_path, &mut msg_printer); + // design_files.insert("VHDLProject".to_string(), project); + // } + } else { + file.parse_ir = None; + None + }; + drop(file); + + + info!("finish parse {:?}", uri.to_string()); + + // 更新 global_scope,用于 sv 的解析 + // global_scope 为全局最大的那个 scope,它的 scopes 和 defs 下的元素和每一个文件一一对应 + let mut global_scope = scope_handle.write().unwrap(); + match &mut *global_scope { + Some(scope) => match &mut scope_tree { + Some(tree) => { + // 更新所有 uri 为当前 uri 的文件结构 + scope.defs.retain(|x| &x.url() != uri); + scope.scopes.retain(|x| &x.url() != uri); + + scope.defs.append(&mut tree.defs); + scope.scopes.append(&mut tree.scopes); + } + None => (), + }, + // 使用 scope_tree 来更新全局的 scope + None => *global_scope = scope_tree, } + // eprintln!("{:#?}", *global_scope); + drop(global_scope); } //TODO: add bounds checking for utf8<->utf16 conversions diff --git a/sv-parser b/sv-parser index 1e390e0..21f3e49 160000 --- a/sv-parser +++ b/sv-parser @@ -1 +1 @@ -Subproject commit 1e390e0f4429b5004e63327b64d5095775ef27b5 +Subproject commit 21f3e497e88a108d15be75ea7e2f0f1a409c6e1d diff --git a/vhdl-parser b/vhdl-parser index 8593bef..e8e7466 160000 --- a/vhdl-parser +++ b/vhdl-parser @@ -1 +1 @@ -Subproject commit 8593beff8c21bd3d3e417ac893b9f317f5386070 +Subproject commit e8e746628785df31545fd465489dc75eba5a6c10