diff --git a/Cargo.lock b/Cargo.lock index 8df834de..42dffc15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -198,8 +198,8 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "cairo-lang-casm" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-utils", "indoc", @@ -211,8 +211,8 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "anyhow", "cairo-lang-defs", @@ -236,16 +236,16 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -260,8 +260,8 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -271,8 +271,8 @@ dependencies = [ [[package]] name = "cairo-lang-doc" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -291,8 +291,8 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-utils", "good_lp", @@ -300,8 +300,8 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -315,8 +315,8 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -334,8 +334,8 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -387,8 +387,8 @@ checksum = "c49906d6b1c215e5814be7c5c65ecf2328898b335bee8c2409ec07cfb5530daf" [[package]] name = "cairo-lang-parser" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -406,8 +406,8 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -425,12 +425,12 @@ dependencies = [ [[package]] name = "cairo-lang-primitive-token" version = "1.0.0" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" [[package]] name = "cairo-lang-proc-macros" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "quote", @@ -439,8 +439,8 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -451,8 +451,8 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -470,14 +470,15 @@ dependencies = [ "num-bigint", "num-traits", "rust-analyzer-salsa", + "sha3", "smol_str", "toml", ] [[package]] name = "cairo-lang-sierra" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "anyhow", "cairo-lang-utils", @@ -502,8 +503,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -517,8 +518,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -532,8 +533,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -555,8 +556,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -575,8 +576,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -584,8 +585,8 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -613,8 +614,8 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -635,8 +636,8 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -651,8 +652,8 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "genco", "xshell", @@ -660,8 +661,8 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -686,8 +687,8 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -698,21 +699,24 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.9.1" -source = "git+https://github.com/starkware-libs/cairo?rev=0b86ece404b0922b76caca5d07a94ed41407f174#0b86ece404b0922b76caca5d07a94ed41407f174" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?branch=spr%2Fmain%2Ff0989263#1ef8c32301848eba0a366dd59581dc016bf97629" dependencies = [ + "env_logger", "hashbrown 0.14.5", "indexmap 2.6.0", "itertools 0.12.1", + "log", "num-bigint", "num-traits", "schemars", "serde", + "time", ] [[package]] name = "cairo-language-server" -version = "2.9.1" +version = "2.9.2" dependencies = [ "anyhow", "assert_fs", @@ -954,6 +958,15 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1062,6 +1075,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", + "regex", ] [[package]] @@ -1073,6 +1087,7 @@ dependencies = [ "anstream", "anstyle", "env_filter", + "humantime", "log", ] @@ -1312,6 +1327,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "icu_collections" version = "1.5.0" @@ -1827,6 +1848,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.46" @@ -1845,6 +1872,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -1983,6 +2019,12 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "precomputed-hash" version = "0.1.1" @@ -2283,12 +2325,13 @@ dependencies = [ [[package]] name = "scarb-proc-macro-server-types" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb73a7fb2681885d05a1d918f95b179c034fb5d5a57adfbb718f36946fe5ade" +source = "git+https://github.com/software-mansion/scarb?branch=integraledelebesgue%2Fcrate-plugins#dd4e8f49fe29ae4ea21347bc48f3c1102761eab1" dependencies = [ "cairo-lang-macro", + "cairo-lang-utils", "serde", "serde_json", + "smol_str", ] [[package]] @@ -2646,6 +2689,39 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +dependencies = [ + "deranged", + "itoa", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" diff --git a/Cargo.toml b/Cargo.toml index 2aa26d74..42613a5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,12 @@ [package] name = "cairo-language-server" -version = "2.9.1" +version = "2.9.2" edition = "2021" -authors = ["Software Mansion ", "StarkWare "] +authors = [ + "Software Mansion ", + "StarkWare ", +] description = "The Cairo Language Server" license = "Apache-2.0" repository = "https://github.com/software-mansion/cairols" @@ -48,7 +51,10 @@ cairo-lang-test-plugin = "*" cairo-lang-utils = "*" convert_case = "0.6.0" crossbeam = "0.8.4" -governor = { version = "0.7.0", default-features = false, features = ["std", "quanta"] } +governor = { version = "0.7.0", default-features = false, features = [ + "std", + "quanta", +] } indent = "0.1.1" indoc = "2" itertools = "0.13.0" @@ -57,7 +63,7 @@ lsp-server = "0.7.7" lsp-types = "=0.95.0" salsa = { package = "rust-analyzer-salsa", version = "0.17.0-pre.6" } scarb-metadata = "1.13" -scarb-proc-macro-server-types = "0.1" +scarb-proc-macro-server-types = { git = "https://github.com/software-mansion/scarb", branch = "integraledelebesgue/crate-plugins" } scarb-stable-hash = "1" serde = { version = "1", default-features = false, features = ["derive"] } serde_json = "1.0.116" @@ -86,34 +92,34 @@ test-log = "0.2.16" # on some of them directly. # This ensures no duplicate instances of Cairo crates are pulled in by mistake. [patch.crates-io] -cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-doc = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-eq-solver = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-parser = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-proc-macros = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-sierra-ap-change = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-sierra-gas = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-sierra-type-size = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-syntax-codegen = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "0b86ece404b0922b76caca5d07a94ed41407f174" } +cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-doc = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-eq-solver = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-parser = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-proc-macros = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-sierra-ap-change = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-sierra-gas = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-sierra-type-size = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-syntax-codegen = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } +cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", branch = "spr/main/f0989263" } # The profile used for CI in pull requests. # External dependencies are built with optimisation enabled, diff --git a/src/ide/hover/render/definition.rs b/src/ide/hover/render/definition.rs index 9163dd5b..7ba5be44 100644 --- a/src/ide/hover/render/definition.rs +++ b/src/ide/hover/render/definition.rs @@ -1,4 +1,5 @@ use cairo_lang_defs::db::DefsGroup; +use cairo_lang_defs::plugin::InlineMacroExprPlugin; use cairo_lang_doc::db::DocGroup; use cairo_lang_filesystem::ids::FileId; use cairo_lang_syntax::node::TypedSyntaxNode; @@ -45,8 +46,15 @@ pub fn definition( SymbolDef::Variable(var) => fenced_code_block(&var.signature(db)), SymbolDef::ExprInlineMacro(macro_name) => { + let crate_id = db.file_modules(file_id).ok()?.first()?.owning_crate(db); + let mut md = fenced_code_block(macro_name); - if let Some(doc) = db.inline_macro_plugins().get(macro_name)?.documentation() { + if let Some(doc) = db + .crate_inline_macro_plugins(crate_id) + .get(macro_name) + .map(|&id| db.lookup_intern_inline_macro_plugin(id))? + .documentation() + { md += RULE; md += &doc; } diff --git a/src/ide/macros/expand.rs b/src/ide/macros/expand.rs index 3123d242..e56027a9 100644 --- a/src/ide/macros/expand.rs +++ b/src/ide/macros/expand.rs @@ -2,7 +2,7 @@ use std::collections::VecDeque; use std::sync::Arc; use cairo_lang_defs::db::DefsGroup; -use cairo_lang_defs::plugin::MacroPluginMetadata; +use cairo_lang_defs::plugin::{InlineMacroExprPlugin, MacroPlugin, MacroPluginMetadata}; use cairo_lang_diagnostics::DiagnosticsBuilder; use cairo_lang_filesystem::db::FilesGroup; use cairo_lang_filesystem::ids::{FileId, FileKind, FileLongId, VirtualFile}; @@ -39,7 +39,7 @@ pub fn expand_macro(db: &AnalysisDatabase, params: &TextDocumentPositionParams) let metadata = MacroPluginMetadata { cfg_set: &cfg_set, - declared_derives: &db.declared_derives(), + declared_derives: &db.declared_derives(crate_id), allowed_features: &Default::default(), edition, }; @@ -98,11 +98,14 @@ fn expanded_macro_files( let mut module_queue = VecDeque::from([(module_file, vec![item])]); let mut files = VecDeque::new(); + let crate_id = db.file_modules(module_file).ok()?.first()?.owning_crate(db); + while let Some((module_file, item_asts)) = module_queue.pop_front() { files.push_back(module_file); for item_ast in item_asts { - for plugin in db.macro_plugins() { + for &plugin_id in db.crate_macro_plugins(crate_id).iter() { + let plugin = db.lookup_intern_macro_plugin(plugin_id); let result = plugin.generate_code(db.upcast(), item_ast.clone(), metadata); if let Some(generated) = result.code { @@ -251,7 +254,9 @@ fn expand_inline_macros_in_single_file( output: &mut String, mut config: FileProcessorConfig, ) -> Option<()> { - let plugins = db.inline_macro_plugins(); + let crate_id = db.file_modules(file).ok()?.first()?.owning_crate(db); + + let plugins = db.crate_inline_macro_plugins(crate_id); if config.macros.is_empty() { append_file_with_header(db, file, &config.content, output); @@ -260,7 +265,8 @@ fn expand_inline_macros_in_single_file( for node in config.macros.into_iter().rev() { let inline_macro = ExprInlineMacro::from_syntax_node(db, node.clone()); let code = plugins - .get(&inline_macro.path(db).as_syntax_node().get_text_without_trivia(db))? + .get(&inline_macro.path(db).as_syntax_node().get_text_without_trivia(db)) + .map(|&id| db.lookup_intern_inline_macro_plugin(id))? .generate_code(db, &inline_macro, metadata) .code? .content; diff --git a/src/lang/db/mod.rs b/src/lang/db/mod.rs index 7edfc65e..2bba8202 100644 --- a/src/lang/db/mod.rs +++ b/src/lang/db/mod.rs @@ -1,24 +1,30 @@ use std::sync::Arc; -use cairo_lang_defs::db::{DefsDatabase, DefsGroup, try_ext_as_virtual_impl}; -use cairo_lang_defs::plugin::{InlineMacroExprPlugin, MacroPlugin}; +use cairo_lang_defs::db::{ + DefsDatabase, DefsGroup, DefsGroupEx, init_defs_group, try_ext_as_virtual_impl, +}; +use cairo_lang_defs::ids::{InlineMacroExprPluginId, MacroPluginId}; use cairo_lang_doc::db::DocDatabase; use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; use cairo_lang_filesystem::db::{ AsFilesGroupMut, ExternalFiles, FilesDatabase, FilesGroup, init_files_group, }; -use cairo_lang_filesystem::ids::VirtualFile; +use cairo_lang_filesystem::ids::{CrateId, VirtualFile}; use cairo_lang_lowering::db::{LoweringDatabase, LoweringGroup, init_lowering_group}; use cairo_lang_lowering::utils::InliningStrategy; use cairo_lang_parser::db::{ParserDatabase, ParserGroup}; -use cairo_lang_semantic::db::{SemanticDatabase, SemanticGroup}; +use cairo_lang_semantic::db::{ + PluginSuiteInput, SemanticDatabase, SemanticGroup, SemanticGroupEx, init_semantic_group, +}; +use cairo_lang_semantic::ids::AnalyzerPluginId; use cairo_lang_semantic::inline_macros::get_default_plugin_suite; -use cairo_lang_semantic::plugin::{AnalyzerPlugin, PluginSuite}; +use cairo_lang_semantic::plugin::{InternedPluginSuite, PluginSuite}; use cairo_lang_starknet::starknet_plugin_suite; use cairo_lang_syntax::node::db::{SyntaxDatabase, SyntaxGroup}; use cairo_lang_test_plugin::test_plugin_suite; use cairo_lang_utils::Upcast; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; +use itertools::Itertools; use salsa::{Database, Durability}; pub use self::semantic::*; @@ -52,6 +58,8 @@ impl AnalysisDatabase { let mut db = Self { storage: Default::default() }; init_files_group(&mut db); + init_defs_group(&mut db); + init_semantic_group(&mut db); init_lowering_group(&mut db, InliningStrategy::Default); // proc-macro-server can be restarted many times but we want to keep these data across // multiple server starts, so init it once per database, not per server. @@ -73,7 +81,9 @@ impl AnalysisDatabase { acc.add(suite); acc }); - db.apply_plugin_suite(plugin_suite); + + let plugin_suite = db.intern_plugin_suite(plugin_suite); + db.set_default_plugins_from_suite(plugin_suite); db } @@ -98,24 +108,18 @@ impl AnalysisDatabase { self.salsa_runtime_mut().synthetic_write(Durability::LOW); } - /// Shortcut for settings compiler plugins from a [`PluginSuite`]. - fn apply_plugin_suite(&mut self, plugin_suite: PluginSuite) { - self.set_macro_plugins(plugin_suite.plugins); - self.set_inline_macro_plugins(plugin_suite.inline_macro_plugins.into()); - self.set_analyzer_plugins(plugin_suite.analyzer_plugins); - } - - /// Updates the plugin list in the database. + /// Updates the plugin list in the database for each crate. /// /// This function modifies the database by removing plugins specified in `plugins_to_remove`, /// adding plugins from `plugins_to_add`, and retaining all other existing plugins. Plugins are - /// considered identical based on their [`Arc`] reference. - pub fn replace_plugin_suite( + /// considered identical based on their Salsa short ID equality (`Arc::ptr_eq` under the hood). + pub fn replace_crate_plugin_suite( &mut self, - plugins_to_remove: PluginSuite, - plugins_to_add: PluginSuite, + crate_id: CrateId, + plugins_to_remove: &InternedPluginSuite, + plugins_to_add: InternedPluginSuite, ) { - self.with_plugins_mut(move |macro_plugins, analyzer_plugins, inline_macro_plugins| { + self.with_plugins_mut(crate_id, |macro_plugins, analyzer_plugins, inline_macro_plugins| { remove_plugin_suite( plugins_to_remove, macro_plugins, @@ -126,69 +130,72 @@ impl AnalysisDatabase { }) } - /// Removes plugin suit from database. - pub fn remove_plugin_suite(&mut self, plugins: PluginSuite) { - self.with_plugins_mut(move |macro_plugins, analyzer_plugins, inline_macro_plugins| { + /// Removes the plugins from [`InternedPluginSuite`] for a crate with [`CrateId`]. + pub fn remove_crate_plugin_suite(&mut self, crate_id: CrateId, plugins: &InternedPluginSuite) { + self.with_plugins_mut(crate_id, |macro_plugins, analyzer_plugins, inline_macro_plugins| { remove_plugin_suite(plugins, macro_plugins, analyzer_plugins, inline_macro_plugins) }) } /// Adds plugin suit to database. - pub fn add_plugin_suite(&mut self, plugins: PluginSuite) { - self.with_plugins_mut(move |macro_plugins, analyzer_plugins, inline_macro_plugins| { - add_plugin_suite(plugins, macro_plugins, analyzer_plugins, inline_macro_plugins) - }) + pub fn add_crate_plugin_suite(&mut self, crate_id: CrateId, plugins: InternedPluginSuite) { + self.with_plugins_mut( + crate_id, + move |macro_plugins, analyzer_plugins, inline_macro_plugins| { + add_plugin_suite(plugins, macro_plugins, analyzer_plugins, inline_macro_plugins) + }, + ) } fn with_plugins_mut( &mut self, + crate_id: CrateId, action: impl FnOnce( - &mut Vec>, - &mut Vec>, - &mut OrderedHashMap>, + &mut Vec, + &mut Vec, + &mut OrderedHashMap, ), ) { - let mut macro_plugins = self.macro_plugins(); - let mut analyzer_plugins = self.analyzer_plugins(); - let mut inline_macro_plugins = Arc::unwrap_or_clone(self.inline_macro_plugins()); + let mut macro_plugins = self.crate_macro_plugins(crate_id).to_vec(); + let mut analyzer_plugins = self.crate_analyzer_plugins(crate_id).to_vec(); + let mut inline_macro_plugins = + Arc::unwrap_or_clone(self.crate_inline_macro_plugins(crate_id)); action(&mut macro_plugins, &mut analyzer_plugins, &mut inline_macro_plugins); - self.set_macro_plugins(macro_plugins); - self.set_analyzer_plugins(analyzer_plugins); - self.set_inline_macro_plugins(Arc::new(inline_macro_plugins)); + self.set_override_crate_macro_plugins( + crate_id, + macro_plugins.into_iter().collect::>(), + ); + self.set_override_crate_analyzer_plugins( + crate_id, + analyzer_plugins.into_iter().collect::>(), + ); + self.set_override_crate_inline_macro_plugins(crate_id, Arc::new(inline_macro_plugins)); } } fn remove_plugin_suite( - plugins: PluginSuite, - macro_plugins: &mut Vec>, - analyzer_plugins: &mut Vec>, - inline_macro_plugins: &mut OrderedHashMap>, + plugins: &InternedPluginSuite, + macro_plugins: &mut Vec, + analyzer_plugins: &mut Vec, + inline_macro_plugins: &mut OrderedHashMap, ) { - macro_plugins.retain(|plugin| { - plugins.plugins.iter().all(|previous_plugin| !Arc::ptr_eq(previous_plugin, plugin)) - }); - analyzer_plugins.retain(|plugin| { - plugins.analyzer_plugins.iter().all(|previous_plugin| !Arc::ptr_eq(previous_plugin, plugin)) - }); - inline_macro_plugins.retain(|_, plugin| { - plugins - .inline_macro_plugins - .iter() - .all(|(_, previous_plugin)| !Arc::ptr_eq(previous_plugin, plugin)) - }); + macro_plugins.retain(|plugin| !plugins.macro_plugins.contains(plugin)); + analyzer_plugins.retain(|plugin| !plugins.analyzer_plugins.contains(plugin)); + inline_macro_plugins + .retain(|_, plugin| !plugins.inline_macro_plugins.values().contains(plugin)); } fn add_plugin_suite( - plugins: PluginSuite, - macro_plugins: &mut Vec>, - analyzer_plugins: &mut Vec>, - inline_macro_plugins: &mut OrderedHashMap>, + plugins: InternedPluginSuite, + macro_plugins: &mut Vec, + analyzer_plugins: &mut Vec, + inline_macro_plugins: &mut OrderedHashMap, ) { - macro_plugins.extend(plugins.plugins); - analyzer_plugins.extend(plugins.analyzer_plugins); - inline_macro_plugins.extend(plugins.inline_macro_plugins); + macro_plugins.extend_from_slice(&plugins.macro_plugins); + analyzer_plugins.extend_from_slice(&plugins.analyzer_plugins); + inline_macro_plugins.extend(Arc::unwrap_or_clone(plugins.inline_macro_plugins)); } impl salsa::Database for AnalysisDatabase {} diff --git a/src/lang/db/swapper.rs b/src/lang/db/swapper.rs index 0a898a14..359d9c34 100644 --- a/src/lang/db/swapper.rs +++ b/src/lang/db/swapper.rs @@ -101,9 +101,99 @@ impl AnalysisDatabaseSwapper { /// Copies current proc macro state into new db. fn migrate_proc_macro_state(&self, new_db: &mut AnalysisDatabase, old_db: &AnalysisDatabase) { - new_db.set_macro_plugins(old_db.macro_plugins()); - new_db.set_inline_macro_plugins(old_db.inline_macro_plugins()); - new_db.set_analyzer_plugins(old_db.analyzer_plugins()); + new_db.set_default_macro_plugins( + old_db + .default_macro_plugins() + .iter() + .map(|&id| new_db.intern_macro_plugin(old_db.lookup_intern_macro_plugin(id))) + .collect::>(), + ); + + new_db.set_default_analyzer_plugins( + old_db + .default_analyzer_plugins() + .iter() + .map(|&id| new_db.intern_analyzer_plugin(old_db.lookup_intern_analyzer_plugin(id))) + .collect::>(), + ); + + new_db.set_default_inline_macro_plugins(Arc::new( + old_db + .default_inline_macro_plugins() + .iter() + .map(|(name, &id)| { + ( + name.clone(), + new_db.intern_inline_macro_plugin( + old_db.lookup_intern_inline_macro_plugin(id), + ), + ) + }) + .collect::>(), + )); + + new_db.set_macro_plugin_overrides(Arc::new( + old_db + .macro_plugin_overrides() + .iter() + .map(|(&crate_id, plugins)| { + ( + crate_id, + plugins + .iter() + .map(|&id| { + new_db.intern_macro_plugin(old_db.lookup_intern_macro_plugin(id)) + }) + .collect(), + ) + }) + .collect(), + )); + + new_db.set_analyzer_plugin_overrides(Arc::new( + old_db + .analyzer_plugin_overrides() + .iter() + .map(|(&crate_id, plugins)| { + ( + crate_id, + plugins + .iter() + .map(|&id| { + new_db.intern_analyzer_plugin( + old_db.lookup_intern_analyzer_plugin(id), + ) + }) + .collect(), + ) + }) + .collect(), + )); + + new_db.set_inline_macro_plugin_overrides(Arc::new( + old_db + .inline_macro_plugin_overrides() + .iter() + .map(|(&crate_id, plugins)| { + ( + crate_id, + Arc::new( + plugins + .iter() + .map(|(name, &id)| { + ( + name.clone(), + new_db.intern_inline_macro_plugin( + old_db.lookup_intern_inline_macro_plugin(id), + ), + ) + }) + .collect(), + ), + ) + }) + .collect(), + )); new_db.set_proc_macro_client_status(old_db.proc_macro_client_status()); diff --git a/src/lang/proc_macros/controller.rs b/src/lang/proc_macros/controller.rs index 6ba8c842..56c6d782 100644 --- a/src/lang/proc_macros/controller.rs +++ b/src/lang/proc_macros/controller.rs @@ -4,7 +4,10 @@ use std::sync::Arc; use std::time::Duration; use anyhow::{Context, Result, anyhow}; -use cairo_lang_semantic::plugin::PluginSuite; +use cairo_lang_filesystem::ids::CrateId; +use cairo_lang_semantic::db::PluginSuiteInput; +use cairo_lang_semantic::plugin::InternedPluginSuite; +use cairo_lang_utils::ordered_hash_map::{Entry, OrderedHashMap}; use crossbeam::channel::{Receiver, Sender}; use governor::clock::QuantaClock; use governor::state::{InMemoryState, NotKeyed}; @@ -52,7 +55,7 @@ const RESPONSE_RATE_LIMITER_PERIOD_SEC: u64 = 3; pub struct ProcMacroClientController { scarb: ScarbToolchain, notifier: Notifier, - plugin_suite: Option, + crate_plugin_suites: OrderedHashMap, initialization_retries: RateLimiter, response_resolving_limiter: RateLimiter, channels: ProcMacroChannels, @@ -67,7 +70,7 @@ impl ProcMacroClientController { Self { scarb, notifier, - plugin_suite: Default::default(), + crate_plugin_suites: Default::default(), initialization_retries: RateLimiter::direct( Quota::with_period(Duration::from_secs( RESTART_RATE_LIMITER_PERIOD_SEC / RESTART_RATE_LIMITER_RETRIES as u64, @@ -111,8 +114,8 @@ impl ProcMacroClientController { // Otherwise we can get messages from old client after initialization of new one. self.channels.clear_all(); - if let Some(plugin_suite) = self.plugin_suite.take() { - db.remove_plugin_suite(plugin_suite); + for (&crate_id, plugins) in self.crate_plugin_suites.iter() { + db.remove_crate_plugin_suite(crate_id, plugins); } self.try_initialize(db, config); @@ -140,16 +143,26 @@ impl ProcMacroClientController { return; }; - let new_plugin_suite = proc_macro_plugin_suite(defined_macros); + let new_crate_plugin_suites = proc_macro_plugin_suite(defined_macros); - // Store current plugins for identity comparison, so we can remove them if we - // restart proc-macro-server. - let previous_plugin_suite = self.plugin_suite.replace(new_plugin_suite.clone()); + for (package_name, plugin_suite) in new_crate_plugin_suites { + let crate_id: CrateId = CrateId::plain(db, package_name.as_str()); + let plugin_suite = db.intern_plugin_suite(plugin_suite); - if let Some(previous_plugin_suite) = previous_plugin_suite { - db.replace_plugin_suite(previous_plugin_suite, new_plugin_suite); - } else { - db.add_plugin_suite(new_plugin_suite); + match self.crate_plugin_suites.entry(crate_id) { + Entry::Occupied(mut entry) => { + db.replace_crate_plugin_suite( + crate_id, + entry.get(), + plugin_suite.clone(), + ); + entry.insert(plugin_suite); + } + Entry::Vacant(entry) => { + db.add_crate_plugin_suite(crate_id, plugin_suite.clone()); + entry.insert(plugin_suite); + } + } } db.set_proc_macro_client_status(ClientStatus::Ready(client)); diff --git a/src/lang/proc_macros/plugins/mod.rs b/src/lang/proc_macros/plugins/mod.rs index 9bdc83a0..aeedeff1 100644 --- a/src/lang/proc_macros/plugins/mod.rs +++ b/src/lang/proc_macros/plugins/mod.rs @@ -2,32 +2,43 @@ use std::sync::Arc; use cairo_lang_defs::plugin::{InlineMacroExprPlugin, MacroPlugin}; use cairo_lang_semantic::plugin::PluginSuite; +use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use downcast::unsafe_downcast_ref; use scarb::inline::inline_macro_generate_code; use scarb::regular::macro_generate_code; use scarb_proc_macro_server_types::methods::defined_macros::DefinedMacrosResponse; +use smol_str::SmolStr; mod downcast; // TODO(#6666) Evict this module when this is possible. mod scarb; -/// Creates [`PluginSuite`] for macros supported by proc-macro-server. -pub fn proc_macro_plugin_suite(defined_macros: DefinedMacrosResponse) -> PluginSuite { - let mut plugin_suite = PluginSuite::default(); +/// Creates a mapping between Scarb package names and [`PluginSuite`]s of macros +/// supported by the proc-macro-server, used by those packages. +pub fn proc_macro_plugin_suite( + defined_macros: DefinedMacrosResponse, +) -> OrderedHashMap { + defined_macros + .crate_macro_info + .into_iter() + .map(|(package_name, package_macros)| { + let mut plugin_suite = PluginSuite::default(); - plugin_suite.add_plugin_ex(Arc::new(ProcMacroPlugin { - defined_attributes: defined_macros.attributes, - defined_derives: defined_macros.derives, - defined_executable_attributes: defined_macros.executables, - })); + plugin_suite.add_plugin_ex(Arc::new(ProcMacroPlugin { + defined_attributes: package_macros.attributes, + defined_derives: package_macros.derives, + defined_executable_attributes: package_macros.executables, + })); - let inline_plugin = Arc::new(InlineProcMacroPlugin); + let inline_plugin = Arc::new(InlineProcMacroPlugin); - for inline_macro in defined_macros.inline_macros { - plugin_suite.add_inline_macro_plugin_ex(&inline_macro, inline_plugin.clone()); - } + for inline_macro in package_macros.inline_macros { + plugin_suite.add_inline_macro_plugin_ex(&inline_macro, inline_plugin.clone()); + } - plugin_suite + (package_name, PluginSuite::from(plugin_suite)) + }) + .collect() } /// Macro plugin that searches for proc macros and forwards their resolution to the