diff --git a/.pnp.cjs b/.pnp.cjs index 4c34ac84..231346b7 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -21,6 +21,10 @@ const RAW_RUNTIME_STATE = "name": "@osmium-libs/ast-extractor",\ "reference": "workspace:libs/ast-extractor"\ },\ + {\ + "name": "@osmium-libs/foundry-wrapper",\ + "reference": "workspace:libs/foundry-wrapper"\ + },\ {\ "name": "@osmium-libs/lsp-handler",\ "reference": "workspace:libs/lsp-handler"\ @@ -62,6 +66,7 @@ const RAW_RUNTIME_STATE = "ignorePatternData": "(^(?:\\\\.yarn\\\\/sdks(?:\\\\/(?!\\\\.{1,2}(?:\\\\/|$))(?:(?:(?!(?:^|\\\\/)\\\\.{1,2}(?:\\\\/|$)).)*?)|$))$)",\ "fallbackExclusionList": [\ ["@osmium-libs/ast-extractor", ["workspace:libs/ast-extractor"]],\ + ["@osmium-libs/foundry-wrapper", ["workspace:libs/foundry-wrapper"]],\ ["@osmium-libs/lsp-handler", ["workspace:libs/lsp-handler"]],\ ["@osmium-libs/lsp-launcher", ["workspace:libs/lsp-launcher"]],\ ["@osmium-libs/lsp-server-wrapper", ["workspace:libs/lsp-server-wrapper"]],\ @@ -342,6 +347,15 @@ const RAW_RUNTIME_STATE = "linkType": "SOFT"\ }]\ ]],\ + ["@osmium-libs/foundry-wrapper", [\ + ["workspace:libs/foundry-wrapper", {\ + "packageLocation": "./libs/foundry-wrapper/",\ + "packageDependencies": [\ + ["@osmium-libs/foundry-wrapper", "workspace:libs/foundry-wrapper"]\ + ],\ + "linkType": "SOFT"\ + }]\ + ]],\ ["@osmium-libs/lsp-handler", [\ ["workspace:libs/lsp-handler", {\ "packageLocation": "./libs/lsp-handler/",\ diff --git a/libs/foundry-wrapper/Cargo.lock b/libs/foundry-wrapper/Cargo.lock new file mode 100644 index 00000000..6fa66b36 --- /dev/null +++ b/libs/foundry-wrapper/Cargo.lock @@ -0,0 +1,419 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anstream" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "clap" +version = "4.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "osmium-libs-foundry-wrapper" +version = "0.1.0" +dependencies = [ + "clap", + "glob", + "serde", + "serde_json", + "thiserror", + "which", +] + +[[package]] +name = "proc-macro2" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustix" +version = "0.38.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "which" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/libs/foundry-wrapper/Cargo.toml b/libs/foundry-wrapper/Cargo.toml new file mode 100644 index 00000000..acc4194d --- /dev/null +++ b/libs/foundry-wrapper/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "osmium-libs-foundry-wrapper" +version = "0.1.0" +edition = "2021" +authors = ["Astrodevs-Labs"] +description = "Foundry abstractions for all extensions" +license = "GPL-3.0-or-later" +repository = "https://github.com/astrodevs-labs/osmium" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +glob = "0.3.1" +clap = "4.4.8" +thiserror = "1.0.50" +which = "5.0" +serde = { version = "1.0.149", features = ["derive"] } +serde_json = "1.0.108" diff --git a/libs/foundry-wrapper/LICENSE.txt b/libs/foundry-wrapper/LICENSE.txt new file mode 100644 index 00000000..5dc6b429 --- /dev/null +++ b/libs/foundry-wrapper/LICENSE.txt @@ -0,0 +1,675 @@ + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/libs/foundry-wrapper/package.json b/libs/foundry-wrapper/package.json new file mode 100644 index 00000000..995e5e7a --- /dev/null +++ b/libs/foundry-wrapper/package.json @@ -0,0 +1,10 @@ +{ + "name": "@osmium-libs/foundry-wrapper", + "scripts": { + "build": "cargo build --release", + "format": "cargo fmt --check --all", + "test": "cargo test", + "lint": "cargo clippy --all-targets --all-features -- -D warnings", + "publish": "cargo package && cargo publish" + } +} diff --git a/libs/foundry-wrapper/src/compiler.rs b/libs/foundry-wrapper/src/compiler.rs new file mode 100644 index 00000000..8dfbf367 --- /dev/null +++ b/libs/foundry-wrapper/src/compiler.rs @@ -0,0 +1,74 @@ +use crate::{ + error::Error, + types::ProjectCompileOutput, + utils::{ + check_executable_argument, find_forge_executable, find_projects_paths, normalize_path, + }, +}; +use std::process::Command; + +#[derive(Debug)] +struct CompilerInner { + root_path: String, + workspaces: Vec, + executable_path: String, +} + +#[derive(Debug)] +pub struct Compiler { + inner: CompilerInner, +} + +impl Compiler { + pub fn new_with_executable_check() -> Result { + let executable_path = find_forge_executable()?; + check_executable_argument(executable_path.to_str().unwrap_or_default())?; + Ok(Self { + inner: CompilerInner { + root_path: String::new(), + workspaces: Vec::new(), + executable_path: executable_path.to_str().unwrap_or_default().to_string(), + }, + }) + } + + fn find_closest_workspace(&self, file_path: &str) -> Option { + let filepath = normalize_path(file_path); + self.inner + .workspaces + .iter() + .filter(|path| filepath.starts_with(path.as_str())) + .max_by_key(|path| path.len()) + .map(|path| path.to_string()) + } + + pub fn load_workspace(&mut self, root_folder: String) -> Result<(), Error> { + let paths = find_projects_paths(&root_folder)?; + for path in paths { + if let Some(path) = path.to_str() { + self.inner.workspaces.push(normalize_path(path)); + } + } + self.inner.root_path = root_folder; + Ok(()) + } + + pub fn reload_project_for_file(&mut self, _: &str) -> Result<(), Error> { + Ok(()) + } + + pub fn compile(&mut self, file_path: &str) -> Result<(String, ProjectCompileOutput), Error> { + let workspace_path = self + .find_closest_workspace(file_path) + .ok_or_else(|| Error::InvalidFilePath(file_path.to_string()))?; + let json = Command::new(&self.inner.executable_path) + .current_dir(&workspace_path) + .arg("compile") + .arg("--format-json") + .output() + .map_err(Error::ExecutableError)?; + let output_str = String::from_utf8_lossy(&json.stdout); + let compile_output: ProjectCompileOutput = serde_json::from_str(&output_str)?; + Ok((workspace_path, compile_output)) + } +} diff --git a/libs/foundry-wrapper/src/error.rs b/libs/foundry-wrapper/src/error.rs new file mode 100644 index 00000000..13736e48 --- /dev/null +++ b/libs/foundry-wrapper/src/error.rs @@ -0,0 +1,25 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum Error { + #[error("Workspace loading error: {0}")] + InvalidRootPath(#[from] glob::PatternError), + + #[error("Invalid file path: {0}")] + InvalidFilePath(String), + + #[error("Executable error: foundry executable not found")] + FoundryExecutableNotFound, + + #[error("Invalid foundry version: does not support --format-json")] + InvalidFoundryVersion, + + #[error("Executable error: {0}")] + ExecutableError(std::io::Error), + + #[error("No executable build-info file: {0}")] + NoExecutableBuildInfoFile(String), + + #[error("Invalid json output: {0}")] + InvalidJsonOutput(#[from] serde_json::Error), +} diff --git a/libs/foundry-wrapper/src/lib.rs b/libs/foundry-wrapper/src/lib.rs new file mode 100644 index 00000000..e7db777d --- /dev/null +++ b/libs/foundry-wrapper/src/lib.rs @@ -0,0 +1,10 @@ +mod utils; + +mod types; +pub use types::*; + +mod compiler; +pub use compiler::*; + +mod error; +pub use error::*; diff --git a/libs/foundry-wrapper/src/types.rs b/libs/foundry-wrapper/src/types.rs new file mode 100644 index 00000000..cbd1b12c --- /dev/null +++ b/libs/foundry-wrapper/src/types.rs @@ -0,0 +1,123 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ProjectCompileOutput { + errors: Vec, +} + +impl ProjectCompileOutput { + pub fn get_errors(&self) -> &Vec { + self.errors.as_ref() + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CompilationError { + #[serde(rename = "sourceLocation")] + source_location: Option, + #[serde(rename = "type")] + typ: String, + component: String, + severity: String, + #[serde(rename = "errorCode")] + error_code: String, + message: String, + #[serde(rename = "formattedMessage")] + formatted_message: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +struct SourceLocation { + file: String, + start: i32, + end: i32, +} + +impl CompilationError { + pub fn get_message(&self) -> String { + self.message.clone() + } + + pub fn get_file_path(&self) -> Option { + Some(self.source_location.clone()?.file.clone()) + } + + pub fn get_start_idx(&self) -> Option { + Some(self.source_location.clone()?.start) + } + + pub fn get_end_idx(&self) -> Option { + Some(self.source_location.clone()?.end) + } + + pub fn get_start_position(&self, source_content: &str) -> Option { + let idx = self.get_start_idx()?; + Position::from_index(idx, source_content) + } + + pub fn get_end_position(&self, source_content: &str) -> Option { + let idx = self.get_end_idx()?; + Position::from_index(idx, source_content) + } + + pub fn get_range(&self, source_content: &str) -> Option { + Some(Range { + start: self.get_start_position(source_content)?, + end: self.get_end_position(source_content)?, + }) + } + + pub fn get_severity(&self) -> Severity { + self.severity.clone().into() + } +} + +/** + * Position of error, 0 based indexes + */ +#[derive(Clone, Debug)] +pub struct Position { + pub line: u32, + pub column: u32, +} + +impl Position { + pub fn from_index(idx: i32, source: &str) -> Option { + let mut idx: usize = idx as usize; + for (i, l) in source.split('\n').enumerate() { + let line_length = l.len() + if l.ends_with('\r') { 2 } else { 1 }; + if idx < line_length { + return Some(Self { + line: i as u32, + column: idx as u32, + }); + } + idx -= line_length + } + None + } +} + +#[derive(Clone, Debug)] +pub struct Range { + pub start: Position, + pub end: Position, +} + +#[derive(Clone, Debug)] +pub enum Severity { + Error, + Warning, + Info, +} + +impl From for Severity { + fn from(severity: String) -> Self { + match severity { + s if s.to_uppercase() == "ERROR" => Self::Error, + s if s.to_uppercase() == "WARNING" => Self::Warning, + s if s.to_uppercase() == "INFO" => Self::Info, + _ => Self::Info, + } + } +} diff --git a/libs/foundry-wrapper/src/utils.rs b/libs/foundry-wrapper/src/utils.rs new file mode 100644 index 00000000..da523b06 --- /dev/null +++ b/libs/foundry-wrapper/src/utils.rs @@ -0,0 +1,5 @@ +mod executable; +pub use executable::*; + +mod path; +pub use path::*; diff --git a/libs/foundry-wrapper/src/utils/executable.rs b/libs/foundry-wrapper/src/utils/executable.rs new file mode 100644 index 00000000..32fd70dc --- /dev/null +++ b/libs/foundry-wrapper/src/utils/executable.rs @@ -0,0 +1,20 @@ +use crate::Error; +use std::path::PathBuf; + +pub fn find_forge_executable() -> Result { + which::which("forge").map_err(|_| Error::FoundryExecutableNotFound) +} + +pub fn check_executable_argument(executable_path: &str) -> Result<(), Error> { + let output = std::process::Command::new(executable_path) + .arg("compile") + .arg("--format-json") + .output() + .map_err(Error::ExecutableError)?; + + let stderr_str = String::from_utf8_lossy(&output.stderr); + if stderr_str.contains("unexpected argument '--format-json'") { + return Err(Error::InvalidFoundryVersion); + } + Ok(()) +} diff --git a/libs/foundry-wrapper/src/utils/path.rs b/libs/foundry-wrapper/src/utils/path.rs new file mode 100644 index 00000000..87277f6b --- /dev/null +++ b/libs/foundry-wrapper/src/utils/path.rs @@ -0,0 +1,21 @@ +use glob::glob; +use std::path::PathBuf; + +pub fn find_projects_paths(root_path: &str) -> Result, glob::PatternError> { + let pattern = format!("{}/**/foundry.toml", root_path); + let filespaths = glob(&pattern)? + .filter_map(|path| path.ok()) + .collect::>(); + + // remove foundry.toml at the end of the filepath + Ok(filespaths + .iter() + .map(|path| path.parent().unwrap().to_path_buf()) + .collect()) +} + +pub fn normalize_path(path: &str) -> String { + path.replace('\\', "/") + .replace("//", "/") + .replace("\\\\", "/") +} diff --git a/libs/lsp-handler/src/dispatcher.rs b/libs/lsp-handler/src/dispatcher.rs index e1826e93..cd596129 100644 --- a/libs/lsp-handler/src/dispatcher.rs +++ b/libs/lsp-handler/src/dispatcher.rs @@ -988,11 +988,11 @@ impl Dispatcher { } impl Handler for Dispatcher { - fn initialize(&self, params: InitializeParams) -> Result { + fn initialize(&mut self, params: InitializeParams) -> Result { let mut res = vec![]; self.connection .log_message(MessageType::INFO, "Dispatcher initializing"); - for handler in &self.handlers { + for handler in &mut self.handlers { res.push(handler.initialize(params.clone())); } let res: Vec = res.iter().filter_map(|i| i.clone().ok()).collect(); @@ -1252,45 +1252,45 @@ impl Handler for Dispatcher { Ok(result) } - fn initialized(&self, params: InitializedParams) { + fn initialized(&mut self, params: InitializedParams) { self.connection .log_message(MessageType::INFO, "Dispatcher initialized"); - for handler in &self.handlers { + for handler in &mut self.handlers { handler.initialized(params); } } - fn shutdown(&self) -> Result<()> { - for handler in &self.handlers { + fn shutdown(&mut self) -> Result<()> { + for handler in &mut self.handlers { let _ = handler.shutdown(); } Ok(()) } - fn did_open(&self, params: DidOpenTextDocumentParams) { - for handler in &self.handlers { + fn did_open(&mut self, params: DidOpenTextDocumentParams) { + for handler in &mut self.handlers { handler.did_open(params.clone()); } } - fn did_change(&self, params: DidChangeTextDocumentParams) { - for handler in &self.handlers { + fn did_change(&mut self, params: DidChangeTextDocumentParams) { + for handler in &mut self.handlers { handler.did_change(params.clone()); } } - fn will_save(&self, params: WillSaveTextDocumentParams) { - for handler in &self.handlers { + fn will_save(&mut self, params: WillSaveTextDocumentParams) { + for handler in &mut self.handlers { handler.will_save(params.clone()); } } fn will_save_wait_until( - &self, + &mut self, params: WillSaveTextDocumentParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.will_save_wait_until(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1299,23 +1299,23 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn did_save(&self, params: DidSaveTextDocumentParams) { - for handler in &self.handlers { + fn did_save(&mut self, params: DidSaveTextDocumentParams) { + for handler in &mut self.handlers { handler.did_save(params.clone()); } } - fn did_close(&self, params: DidCloseTextDocumentParams) { - for handler in &self.handlers { + fn did_close(&mut self, params: DidCloseTextDocumentParams) { + for handler in &mut self.handlers { handler.did_close(params.clone()); } } fn goto_declaration( - &self, + &mut self, params: GotoDeclarationParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.goto_declaration(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1325,10 +1325,10 @@ impl Handler for Dispatcher { } fn goto_definition( - &self, + &mut self, params: GotoDefinitionParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.goto_definition(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1338,10 +1338,10 @@ impl Handler for Dispatcher { } fn goto_type_definition( - &self, + &mut self, params: GotoTypeDefinitionParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.goto_type_definition(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1351,10 +1351,10 @@ impl Handler for Dispatcher { } fn goto_implementation( - &self, + &mut self, params: GotoImplementationParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.goto_implementation(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1363,9 +1363,9 @@ impl Handler for Dispatcher { Ok(None) } - fn references(&self, params: ReferenceParams) -> Result>> { + fn references(&mut self, params: ReferenceParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.references(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1375,11 +1375,11 @@ impl Handler for Dispatcher { } fn prepare_call_hierarchy( - &self, + &mut self, params: CallHierarchyPrepareParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.prepare_call_hierarchy(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1389,11 +1389,11 @@ impl Handler for Dispatcher { } fn incoming_calls( - &self, + &mut self, params: CallHierarchyIncomingCallsParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.incoming_calls(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1403,11 +1403,11 @@ impl Handler for Dispatcher { } fn outgoing_calls( - &self, + &mut self, params: CallHierarchyOutgoingCallsParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.outgoing_calls(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1417,11 +1417,11 @@ impl Handler for Dispatcher { } fn prepare_type_hierarchy( - &self, + &mut self, params: TypeHierarchyPrepareParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.prepare_type_hierarchy(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1431,11 +1431,11 @@ impl Handler for Dispatcher { } fn supertypes( - &self, + &mut self, params: TypeHierarchySupertypesParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.supertypes(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1445,11 +1445,11 @@ impl Handler for Dispatcher { } fn subtypes( - &self, + &mut self, params: TypeHierarchySubtypesParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.subtypes(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1459,11 +1459,11 @@ impl Handler for Dispatcher { } fn document_highlight( - &self, + &mut self, params: DocumentHighlightParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.document_highlight(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1472,9 +1472,9 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn document_link(&self, params: DocumentLinkParams) -> Result>> { + fn document_link(&mut self, params: DocumentLinkParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.document_link(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1483,8 +1483,8 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn document_link_resolve(&self, params: DocumentLink) -> Result { - for handler in &self.handlers { + fn document_link_resolve(&mut self, params: DocumentLink) -> Result { + for handler in &mut self.handlers { let res = handler.document_link_resolve(params.clone()); if res.is_ok() { return res; @@ -1493,8 +1493,8 @@ impl Handler for Dispatcher { Err(Error::new(ErrorCode::MethodNotFound)) } - fn hover(&self, params: HoverParams) -> Result> { - for handler in &self.handlers { + fn hover(&mut self, params: HoverParams) -> Result> { + for handler in &mut self.handlers { let res = handler.hover(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1503,9 +1503,9 @@ impl Handler for Dispatcher { Ok(None) } - fn code_lens(&self, params: CodeLensParams) -> Result>> { + fn code_lens(&mut self, params: CodeLensParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.code_lens(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1514,8 +1514,8 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn code_lens_resolve(&self, params: CodeLens) -> Result { - for handler in &self.handlers { + fn code_lens_resolve(&mut self, params: CodeLens) -> Result { + for handler in &mut self.handlers { let res = handler.code_lens_resolve(params.clone()); if res.is_ok() { return res; @@ -1524,9 +1524,9 @@ impl Handler for Dispatcher { Err(Error::new(ErrorCode::MethodNotFound)) } - fn folding_range(&self, params: FoldingRangeParams) -> Result>> { + fn folding_range(&mut self, params: FoldingRangeParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.folding_range(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1535,9 +1535,12 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn selection_range(&self, params: SelectionRangeParams) -> Result>> { + fn selection_range( + &mut self, + params: SelectionRangeParams, + ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.selection_range(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1547,10 +1550,10 @@ impl Handler for Dispatcher { } fn document_symbol( - &self, + &mut self, params: DocumentSymbolParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.document_symbol(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1560,10 +1563,10 @@ impl Handler for Dispatcher { } fn semantic_tokens_full( - &self, + &mut self, params: SemanticTokensParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.semantic_tokens_full(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1573,10 +1576,10 @@ impl Handler for Dispatcher { } fn semantic_tokens_full_delta( - &self, + &mut self, params: SemanticTokensDeltaParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.semantic_tokens_full_delta(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1586,10 +1589,10 @@ impl Handler for Dispatcher { } fn semantic_tokens_range( - &self, + &mut self, params: SemanticTokensRangeParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.semantic_tokens_range(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1598,9 +1601,9 @@ impl Handler for Dispatcher { Ok(None) } - fn inline_value(&self, params: InlineValueParams) -> Result>> { + fn inline_value(&mut self, params: InlineValueParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.inline_value(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1609,9 +1612,9 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn inlay_hint(&self, params: InlayHintParams) -> Result>> { + fn inlay_hint(&mut self, params: InlayHintParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.inlay_hint(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1620,8 +1623,8 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn inlay_hint_resolve(&self, params: InlayHint) -> Result { - for handler in &self.handlers { + fn inlay_hint_resolve(&mut self, params: InlayHint) -> Result { + for handler in &mut self.handlers { let res = handler.inlay_hint_resolve(params.clone()); if res.is_ok() { return res; @@ -1630,9 +1633,9 @@ impl Handler for Dispatcher { Err(Error::new(ErrorCode::MethodNotFound)) } - fn moniker(&self, params: MonikerParams) -> Result>> { + fn moniker(&mut self, params: MonikerParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.moniker(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1641,8 +1644,8 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn completion(&self, params: CompletionParams) -> Result> { - for handler in &self.handlers { + fn completion(&mut self, params: CompletionParams) -> Result> { + for handler in &mut self.handlers { let res = handler.completion(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1651,8 +1654,8 @@ impl Handler for Dispatcher { Ok(None) } - fn completion_resolve(&self, params: CompletionItem) -> Result { - for handler in &self.handlers { + fn completion_resolve(&mut self, params: CompletionItem) -> Result { + for handler in &mut self.handlers { let res = handler.completion_resolve(params.clone()); if res.is_ok() { return res; @@ -1662,10 +1665,10 @@ impl Handler for Dispatcher { } fn diagnostic( - &self, + &mut self, params: DocumentDiagnosticParams, ) -> Result { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.diagnostic(params.clone()); if res.is_ok() { return res; @@ -1675,10 +1678,10 @@ impl Handler for Dispatcher { } fn workspace_diagnostic( - &self, + &mut self, params: WorkspaceDiagnosticParams, ) -> Result { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.workspace_diagnostic(params.clone()); if res.is_ok() { return res; @@ -1687,8 +1690,8 @@ impl Handler for Dispatcher { Err(Error::new(ErrorCode::MethodNotFound)) } - fn signature_help(&self, params: SignatureHelpParams) -> Result> { - for handler in &self.handlers { + fn signature_help(&mut self, params: SignatureHelpParams) -> Result> { + for handler in &mut self.handlers { let res = handler.signature_help(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1697,8 +1700,8 @@ impl Handler for Dispatcher { Ok(None) } - fn code_action(&self, params: CodeActionParams) -> Result> { - for handler in &self.handlers { + fn code_action(&mut self, params: CodeActionParams) -> Result> { + for handler in &mut self.handlers { let res = handler.code_action(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1707,8 +1710,8 @@ impl Handler for Dispatcher { Ok(None) } - fn code_action_resolve(&self, params: CodeAction) -> Result { - for handler in &self.handlers { + fn code_action_resolve(&mut self, params: CodeAction) -> Result { + for handler in &mut self.handlers { let res = handler.code_action_resolve(params.clone()); if res.is_ok() { return res; @@ -1717,9 +1720,9 @@ impl Handler for Dispatcher { Err(Error::new(ErrorCode::MethodNotFound)) } - fn document_color(&self, params: DocumentColorParams) -> Result> { + fn document_color(&mut self, params: DocumentColorParams) -> Result> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.document_color(params.clone()); if let Ok(val) = res { text_edit.extend(val); @@ -1729,11 +1732,11 @@ impl Handler for Dispatcher { } fn color_presentation( - &self, + &mut self, params: ColorPresentationParams, ) -> Result> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.color_presentation(params.clone()); if let Ok(val) = res { text_edit.extend(val); @@ -1742,9 +1745,9 @@ impl Handler for Dispatcher { Ok(text_edit) } - fn formatting(&self, params: DocumentFormattingParams) -> Result>> { + fn formatting(&mut self, params: DocumentFormattingParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.formatting(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1754,11 +1757,11 @@ impl Handler for Dispatcher { } fn range_formatting( - &self, + &mut self, params: DocumentRangeFormattingParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.range_formatting(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1768,11 +1771,11 @@ impl Handler for Dispatcher { } fn on_type_formatting( - &self, + &mut self, params: DocumentOnTypeFormattingParams, ) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.on_type_formatting(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1781,8 +1784,8 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn rename(&self, params: RenameParams) -> Result> { - for handler in &self.handlers { + fn rename(&mut self, params: RenameParams) -> Result> { + for handler in &mut self.handlers { let res = handler.rename(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1792,10 +1795,10 @@ impl Handler for Dispatcher { } fn prepare_rename( - &self, + &mut self, params: TextDocumentPositionParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.prepare_rename(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1805,10 +1808,10 @@ impl Handler for Dispatcher { } fn linked_editing_range( - &self, + &mut self, params: LinkedEditingRangeParams, ) -> Result> { - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.linked_editing_range(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1817,9 +1820,9 @@ impl Handler for Dispatcher { Ok(None) } - fn symbol(&self, params: WorkspaceSymbolParams) -> Result>> { + fn symbol(&mut self, params: WorkspaceSymbolParams) -> Result>> { let mut text_edit: Vec = vec![]; - for handler in &self.handlers { + for handler in &mut self.handlers { let res = handler.symbol(params.clone()); if let Ok(Some(val)) = res { text_edit.extend(val); @@ -1828,8 +1831,8 @@ impl Handler for Dispatcher { Ok(Some(text_edit)) } - fn symbol_resolve(&self, params: WorkspaceSymbol) -> Result { - for handler in &self.handlers { + fn symbol_resolve(&mut self, params: WorkspaceSymbol) -> Result { + for handler in &mut self.handlers { let res = handler.symbol_resolve(params.clone()); if res.is_ok() { return res; @@ -1838,20 +1841,20 @@ impl Handler for Dispatcher { Err(Error::new(ErrorCode::MethodNotFound)) } - fn did_change_configuration(&self, params: DidChangeConfigurationParams) { - for handler in &self.handlers { + fn did_change_configuration(&mut self, params: DidChangeConfigurationParams) { + for handler in &mut self.handlers { handler.did_change_configuration(params.clone()); } } - fn did_change_workspace_folders(&self, params: DidChangeWorkspaceFoldersParams) { - for handler in &self.handlers { + fn did_change_workspace_folders(&mut self, params: DidChangeWorkspaceFoldersParams) { + for handler in &mut self.handlers { handler.did_change_workspace_folders(params.clone()); } } - fn will_create_files(&self, params: CreateFilesParams) -> Result> { - for handler in &self.handlers { + fn will_create_files(&mut self, params: CreateFilesParams) -> Result> { + for handler in &mut self.handlers { let res = handler.will_create_files(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1860,14 +1863,14 @@ impl Handler for Dispatcher { Ok(None) } - fn did_create_files(&self, params: CreateFilesParams) { - for handler in &self.handlers { + fn did_create_files(&mut self, params: CreateFilesParams) { + for handler in &mut self.handlers { handler.did_create_files(params.clone()); } } - fn will_rename_files(&self, params: RenameFilesParams) -> Result> { - for handler in &self.handlers { + fn will_rename_files(&mut self, params: RenameFilesParams) -> Result> { + for handler in &mut self.handlers { let res = handler.will_rename_files(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1876,14 +1879,14 @@ impl Handler for Dispatcher { Ok(None) } - fn did_rename_files(&self, params: RenameFilesParams) { - for handler in &self.handlers { + fn did_rename_files(&mut self, params: RenameFilesParams) { + for handler in &mut self.handlers { handler.did_rename_files(params.clone()); } } - fn will_delete_files(&self, params: DeleteFilesParams) -> Result> { - for handler in &self.handlers { + fn will_delete_files(&mut self, params: DeleteFilesParams) -> Result> { + for handler in &mut self.handlers { let res = handler.will_delete_files(params.clone()); if let Ok(Some(_)) = res { return res; @@ -1892,20 +1895,20 @@ impl Handler for Dispatcher { Ok(None) } - fn did_delete_files(&self, params: DeleteFilesParams) { - for handler in &self.handlers { + fn did_delete_files(&mut self, params: DeleteFilesParams) { + for handler in &mut self.handlers { handler.did_delete_files(params.clone()); } } - fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) { - for handler in &self.handlers { + fn did_change_watched_files(&mut self, params: DidChangeWatchedFilesParams) { + for handler in &mut self.handlers { handler.did_change_watched_files(params.clone()); } } - fn execute_command(&self, params: ExecuteCommandParams) -> Result> { - for handler in &self.handlers { + fn execute_command(&mut self, params: ExecuteCommandParams) -> Result> { + for handler in &mut self.handlers { let res = handler.execute_command(params.clone()); if let Ok(Some(_)) = res { return res; diff --git a/libs/lsp-handler/src/handler.rs b/libs/lsp-handler/src/handler.rs index 75eaaea4..e534782d 100644 --- a/libs/lsp-handler/src/handler.rs +++ b/libs/lsp-handler/src/handler.rs @@ -21,7 +21,7 @@ pub trait Handler { /// /// This method is guaranteed to only execute once. If the client sends this request to the /// server again, the server will respond with JSON-RPC error code `-32600` (invalid request). - fn initialize(&self, params: InitializeParams) -> Result; + fn initialize(&mut self, params: InitializeParams) -> Result; /// The [`initialized`] notification is sent from the client to the server after the client /// received the result of the initialize request but before the client sends anything else. @@ -30,7 +30,7 @@ pub trait Handler { /// /// The server can use the `initialized` notification, for example, to dynamically register /// capabilities with the client. - fn initialized(&self, params: InitializedParams) { + fn initialized(&mut self, params: InitializedParams) { let _ = params; } @@ -45,7 +45,7 @@ pub trait Handler { /// /// This method is guaranteed to only execute once. If the client sends this request to the /// server again, the server will respond with JSON-RPC error code `-32600` (invalid request). - fn shutdown(&self) -> Result<()>; + fn shutdown(&mut self) -> Result<()>; // Document Synchronization @@ -57,7 +57,7 @@ pub trait Handler { /// The document's truth is now managed by the client and the server must not try to read the /// document’s truth using the document's URI. "Open" in this sense means it is managed by the /// client. It doesn't necessarily mean that its content is presented in an editor. - fn did_open(&self, params: DidOpenTextDocumentParams) { + fn did_open(&mut self, params: DidOpenTextDocumentParams) { let _ = params; log("Got a textDocument/didOpen notification, but it is not implemented"); } @@ -69,7 +69,7 @@ pub trait Handler { /// /// This notification will contain a distinct version tag and a list of edits made to the /// document for the server to interpret. - fn did_change(&self, params: DidChangeTextDocumentParams) { + fn did_change(&mut self, params: DidChangeTextDocumentParams) { let _ = params; log("Got a textDocument/didChange notification, but it is not implemented"); } @@ -78,7 +78,7 @@ pub trait Handler { /// document is actually saved. /// /// [`textDocument/willSave`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_willSave - fn will_save(&self, params: WillSaveTextDocumentParams) { + fn will_save(&mut self, params: WillSaveTextDocumentParams) { let _ = params; log("Got a textDocument/willSave notification, but it is not implemented"); } @@ -94,7 +94,7 @@ pub trait Handler { /// Please note that clients might drop results if computing the text edits took too long or if /// a server constantly fails on this request. This is done to keep the save fast and reliable. fn will_save_wait_until( - &self, + &mut self, params: WillSaveTextDocumentParams, ) -> Result>> { let _ = params; @@ -106,7 +106,7 @@ pub trait Handler { /// document was saved in the client. /// /// [`textDocument/didSave`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_didSave - fn did_save(&self, params: DidSaveTextDocumentParams) { + fn did_save(&mut self, params: DidSaveTextDocumentParams) { let _ = params; log("Got a textDocument/didSave notification, but it is not implemented"); } @@ -118,7 +118,7 @@ pub trait Handler { /// /// The document's truth now exists where the document's URI points to (e.g. if the document's /// URI is a file URI, the truth now exists on disk). - fn did_close(&self, params: DidCloseTextDocumentParams) { + fn did_close(&mut self, params: DidCloseTextDocumentParams) { let _ = params; log("Got a textDocument/didClose notification, but it is not implemented"); } @@ -143,7 +143,7 @@ pub trait Handler { /// InitializeParams::capabilities::text_document::declaration::link_support /// ``` fn goto_declaration( - &self, + &mut self, params: GotoDeclarationParams, ) -> Result> { let _ = params; @@ -167,7 +167,7 @@ pub trait Handler { /// InitializeParams::capabilities::text_document::definition::link_support /// ``` fn goto_definition( - &self, + &mut self, params: GotoDefinitionParams, ) -> Result> { let _ = params; @@ -193,7 +193,7 @@ pub trait Handler { /// InitializeParams::capabilities::text_document::type_definition::link_support /// ``` fn goto_type_definition( - &self, + &mut self, params: GotoTypeDefinitionParams, ) -> Result> { let _ = params; @@ -219,7 +219,7 @@ pub trait Handler { /// InitializeParams::capabilities::text_document::implementation::link_support /// ``` fn goto_implementation( - &self, + &mut self, params: GotoImplementationParams, ) -> Result> { let _ = params; @@ -232,7 +232,7 @@ pub trait Handler { /// /// [`textDocument/references`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_references - fn references(&self, params: ReferenceParams) -> Result>> { + fn references(&mut self, params: ReferenceParams) -> Result>> { let _ = params; log("Got a textDocument/references request, but it is not implemented"); Err(Error::method_not_found()) @@ -257,7 +257,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. fn prepare_call_hierarchy( - &self, + &mut self, params: CallHierarchyPrepareParams, ) -> Result>> { let _ = params; @@ -278,7 +278,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. fn incoming_calls( - &self, + &mut self, params: CallHierarchyIncomingCallsParams, ) -> Result>> { let _ = params; @@ -299,7 +299,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. fn outgoing_calls( - &self, + &mut self, params: CallHierarchyOutgoingCallsParams, ) -> Result>> { let _ = params; @@ -324,7 +324,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0. fn prepare_type_hierarchy( - &self, + &mut self, params: TypeHierarchyPrepareParams, ) -> Result>> { let _ = params; @@ -344,7 +344,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0. fn supertypes( - &self, + &mut self, params: TypeHierarchySupertypesParams, ) -> Result>> { let _ = params; @@ -364,7 +364,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0. fn subtypes( - &self, + &mut self, params: TypeHierarchySubtypesParams, ) -> Result>> { let _ = params; @@ -383,7 +383,7 @@ pub trait Handler { /// This request differs slightly from `textDocument/references` in that this one is allowed to /// be more fuzzy. fn document_highlight( - &self, + &mut self, params: DocumentHighlightParams, ) -> Result>> { let _ = params; @@ -408,7 +408,7 @@ pub trait Handler { /// ```text /// InitializeParams::capabilities::text_document::document_link::tooltip_support /// ``` - fn document_link(&self, params: DocumentLinkParams) -> Result>> { + fn document_link(&mut self, params: DocumentLinkParams) -> Result>> { let _ = params; log("Got a textDocument/documentLink request, but it is not implemented"); Err(Error::method_not_found()) @@ -421,7 +421,7 @@ pub trait Handler { /// /// A document link is a range in a text document that links to an internal or external /// resource, like another text document or a web site. - fn document_link_resolve(&self, params: DocumentLink) -> Result { + fn document_link_resolve(&mut self, params: DocumentLink) -> Result { let _ = params; log("Got a documentLink/resolve request, but it is not implemented"); Err(Error::method_not_found()) @@ -434,7 +434,7 @@ pub trait Handler { /// /// Such hover information typically includes type signature information and inline /// documentation for the symbol at the given text document position. - fn hover(&self, params: HoverParams) -> Result> { + fn hover(&mut self, params: HoverParams) -> Result> { let _ = params; log("Got a textDocument/hover request, but it is not implemented"); Err(Error::method_not_found()) @@ -445,7 +445,7 @@ pub trait Handler { /// /// [`textDocument/codeLens`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens - fn code_lens(&self, params: CodeLensParams) -> Result>> { + fn code_lens(&mut self, params: CodeLensParams) -> Result>> { let _ = params; log("Got a textDocument/codeLens request, but it is not implemented"); Err(Error::method_not_found()) @@ -456,7 +456,7 @@ pub trait Handler { /// /// [`codeLens/resolve`]: https://microsoft.github.io/language-server-protocol/specification#codeLens_resolve - fn code_lens_resolve(&self, params: CodeLens) -> Result { + fn code_lens_resolve(&mut self, params: CodeLens) -> Result { let _ = params; log("Got a codeLens/resolve request, but it is not implemented"); Err(Error::method_not_found()) @@ -471,7 +471,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.10.0. - fn folding_range(&self, params: FoldingRangeParams) -> Result>> { + fn folding_range(&mut self, params: FoldingRangeParams) -> Result>> { let _ = params; log("Got a textDocument/foldingRange request, but it is not implemented"); Err(Error::method_not_found()) @@ -490,7 +490,10 @@ pub trait Handler { /// /// This request was introduced in specification version 3.15.0. - fn selection_range(&self, params: SelectionRangeParams) -> Result>> { + fn selection_range( + &mut self, + params: SelectionRangeParams, + ) -> Result>> { let _ = params; log("Got a textDocument/selectionRange request, but it is not implemented"); Err(Error::method_not_found()) @@ -510,7 +513,7 @@ pub trait Handler { /// document. fn document_symbol( - &self, + &mut self, params: DocumentSymbolParams, ) -> Result> { let _ = params; @@ -535,7 +538,7 @@ pub trait Handler { /// This request was introduced in specification version 3.16.0. fn semantic_tokens_full( - &self, + &mut self, params: SemanticTokensParams, ) -> Result> { let _ = params; @@ -556,7 +559,7 @@ pub trait Handler { /// This request was introduced in specification version 3.16.0. fn semantic_tokens_full_delta( - &self, + &mut self, params: SemanticTokensDeltaParams, ) -> Result> { let _ = params; @@ -582,7 +585,7 @@ pub trait Handler { /// This request was introduced in specification version 3.16.0. fn semantic_tokens_range( - &self, + &mut self, params: SemanticTokensRangeParams, ) -> Result> { let _ = params; @@ -600,7 +603,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0. - fn inline_value(&self, params: InlineValueParams) -> Result>> { + fn inline_value(&mut self, params: InlineValueParams) -> Result>> { let _ = params; log("Got a textDocument/inlineValue request, but it is not implemented"); Err(Error::method_not_found()) @@ -616,7 +619,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0 - fn inlay_hint(&self, params: InlayHintParams) -> Result>> { + fn inlay_hint(&mut self, params: InlayHintParams) -> Result>> { let _ = params; log("Got a textDocument/inlayHint request, but it is not implemented"); Err(Error::method_not_found()) @@ -645,7 +648,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0 - fn inlay_hint_resolve(&self, params: InlayHint) -> Result { + fn inlay_hint_resolve(&mut self, params: InlayHint) -> Result { let _ = params; log("Got a inlayHint/resolve request, but it is not implemented"); Err(Error::method_not_found()) @@ -675,7 +678,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. - fn moniker(&self, params: MonikerParams) -> Result>> { + fn moniker(&mut self, params: MonikerParams) -> Result>> { let _ = params; log("Got a textDocument/moniker request, but it is not implemented"); Err(Error::method_not_found()) @@ -700,7 +703,7 @@ pub trait Handler { /// must be provided in the `textDocument/completion` response and must not be changed during /// resolve. - fn completion(&self, params: CompletionParams) -> Result> { + fn completion(&mut self, params: CompletionParams) -> Result> { let _ = params; log("Got a textDocument/completion request, but it is not implemented"); Err(Error::method_not_found()) @@ -711,7 +714,7 @@ pub trait Handler { /// /// [`completionItem/resolve`]: https://microsoft.github.io/language-server-protocol/specification#completionItem_resolve - fn completion_resolve(&self, params: CompletionItem) -> Result { + fn completion_resolve(&mut self, params: CompletionItem) -> Result { let _ = params; log("Got a completionItem/resolve request, but it is not implemented"); Err(Error::method_not_found()) @@ -733,7 +736,7 @@ pub trait Handler { /// This request was introduced in specification version 3.17.0. fn diagnostic( - &self, + &mut self, params: DocumentDiagnosticParams, ) -> Result { let _ = params; @@ -771,7 +774,7 @@ pub trait Handler { /// This request was introduced in specification version 3.17.0. fn workspace_diagnostic( - &self, + &mut self, params: WorkspaceDiagnosticParams, ) -> Result { let _ = params; @@ -784,7 +787,7 @@ pub trait Handler { /// /// [`textDocument/signatureHelp`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_signatureHelp - fn signature_help(&self, params: SignatureHelpParams) -> Result> { + fn signature_help(&mut self, params: SignatureHelpParams) -> Result> { let _ = params; log("Got a textDocument/signatureHelp request, but it is not implemented"); Err(Error::method_not_found()) @@ -844,7 +847,7 @@ pub trait Handler { /// information. However it allows them to better group code action, for example, into /// corresponding menus (e.g. all refactor code actions into a refactor menu). - fn code_action(&self, params: CodeActionParams) -> Result> { + fn code_action(&mut self, params: CodeActionParams) -> Result> { let _ = params; log("Got a textDocument/codeAction request, but it is not implemented"); Err(Error::method_not_found()) @@ -862,7 +865,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. - fn code_action_resolve(&self, params: CodeAction) -> Result { + fn code_action_resolve(&mut self, params: CodeAction) -> Result { let _ = params; log("Got a codeAction/resolve request, but it is not implemented"); Err(Error::method_not_found()) @@ -883,7 +886,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.6.0. - fn document_color(&self, params: DocumentColorParams) -> Result> { + fn document_color(&mut self, params: DocumentColorParams) -> Result> { let _ = params; log("Got a textDocument/documentColor request, but it is not implemented"); Err(Error::method_not_found()) @@ -907,7 +910,7 @@ pub trait Handler { /// resolve request for the [`textDocument/documentColor`](Self::document_color) request. fn color_presentation( - &self, + &mut self, params: ColorPresentationParams, ) -> Result> { let _ = params; @@ -920,7 +923,7 @@ pub trait Handler { /// /// [`textDocument/formatting`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting - fn formatting(&self, params: DocumentFormattingParams) -> Result>> { + fn formatting(&mut self, params: DocumentFormattingParams) -> Result>> { let _ = params; log("Got a textDocument/formatting request, but it is not implemented"); Err(Error::method_not_found()) @@ -932,7 +935,7 @@ pub trait Handler { /// [`textDocument/rangeFormatting`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_rangeFormatting fn range_formatting( - &self, + &mut self, params: DocumentRangeFormattingParams, ) -> Result>> { let _ = params; @@ -946,7 +949,7 @@ pub trait Handler { /// [`textDocument/onTypeFormatting`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_onTypeFormatting fn on_type_formatting( - &self, + &mut self, params: DocumentOnTypeFormattingParams, ) -> Result>> { let _ = params; @@ -960,7 +963,7 @@ pub trait Handler { /// /// [`textDocument/rename`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_rename - fn rename(&self, params: RenameParams) -> Result> { + fn rename(&mut self, params: RenameParams) -> Result> { let _ = params; log("Got a textDocument/rename request, but it is not implemented"); Err(Error::method_not_found()) @@ -976,7 +979,7 @@ pub trait Handler { /// This request was introduced in specification version 3.12.0. fn prepare_rename( - &self, + &mut self, params: TextDocumentPositionParams, ) -> Result> { let _ = params; @@ -1001,7 +1004,7 @@ pub trait Handler { /// This request was introduced in specification version 3.16.0. fn linked_editing_range( - &self, + &mut self, params: LinkedEditingRangeParams, ) -> Result> { let _ = params; @@ -1028,7 +1031,7 @@ pub trait Handler { /// Servers can only use this new model if clients advertise support for it via the /// `workspace.symbol.resolve_support` capability. - fn symbol(&self, params: WorkspaceSymbolParams) -> Result>> { + fn symbol(&mut self, params: WorkspaceSymbolParams) -> Result>> { let _ = params; log("Got a workspace/symbol request, but it is not implemented"); Err(Error::method_not_found()) @@ -1045,7 +1048,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.17.0. - fn symbol_resolve(&self, params: WorkspaceSymbol) -> Result { + fn symbol_resolve(&mut self, params: WorkspaceSymbol) -> Result { let _ = params; log("Got a workspaceSymbol/resolve request, but it is not implemented"); Err(Error::method_not_found()) @@ -1056,7 +1059,7 @@ pub trait Handler { /// /// [`workspace/didChangeConfiguration`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeConfiguration - fn did_change_configuration(&self, params: DidChangeConfigurationParams) { + fn did_change_configuration(&mut self, params: DidChangeConfigurationParams) { let _ = params; log("Got a workspace/didChangeConfiguration notification, but it is not implemented"); } @@ -1075,7 +1078,7 @@ pub trait Handler { /// This notification is also sent if the server has registered itself to receive this /// notification. - fn did_change_workspace_folders(&self, params: DidChangeWorkspaceFoldersParams) { + fn did_change_workspace_folders(&mut self, params: DidChangeWorkspaceFoldersParams) { let _ = params; log("Got a workspace/didChangeWorkspaceFolders notification, but it is not implemented"); } @@ -1094,7 +1097,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. - fn will_create_files(&self, params: CreateFilesParams) -> Result> { + fn will_create_files(&mut self, params: CreateFilesParams) -> Result> { let _ = params; log("Got a workspace/willCreateFiles request, but it is not implemented"); Err(Error::method_not_found()) @@ -1105,7 +1108,7 @@ pub trait Handler { /// /// [`workspace/didCreateFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didCreateFiles - fn did_create_files(&self, params: CreateFilesParams) { + fn did_create_files(&mut self, params: CreateFilesParams) { let _ = params; log("Got a workspace/didCreateFiles notification, but it is not implemented"); } @@ -1124,7 +1127,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. - fn will_rename_files(&self, params: RenameFilesParams) -> Result> { + fn will_rename_files(&mut self, params: RenameFilesParams) -> Result> { let _ = params; log("Got a workspace/willRenameFiles request, but it is not implemented"); Err(Error::method_not_found()) @@ -1135,7 +1138,7 @@ pub trait Handler { /// /// [`workspace/didRenameFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didRenameFiles - fn did_rename_files(&self, params: RenameFilesParams) { + fn did_rename_files(&mut self, params: RenameFilesParams) { let _ = params; log("Got a workspace/didRenameFiles notification, but it is not implemented"); } @@ -1155,7 +1158,7 @@ pub trait Handler { /// /// This request was introduced in specification version 3.16.0. - fn will_delete_files(&self, params: DeleteFilesParams) -> Result> { + fn will_delete_files(&mut self, params: DeleteFilesParams) -> Result> { let _ = params; log("Got a workspace/willDeleteFiles request, but it is not implemented"); Err(Error::method_not_found()) @@ -1166,7 +1169,7 @@ pub trait Handler { /// /// [`workspace/didDeleteFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didDeleteFiles - fn did_delete_files(&self, params: DeleteFilesParams) { + fn did_delete_files(&mut self, params: DeleteFilesParams) { let _ = params; log("Got a workspace/didDeleteFiles notification, but it is not implemented"); } @@ -1180,7 +1183,7 @@ pub trait Handler { /// mechanism. This can be done here or in the [`initialized`](Self::initialized) method using /// [`Client::register_capability`](crate::Client::register_capability). - fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) { + fn did_change_watched_files(&mut self, params: DidChangeWatchedFilesParams) { let _ = params; log("Got a workspace/didChangeWatchedFiles notification, but it is not implemented"); } @@ -1193,7 +1196,7 @@ pub trait Handler { /// In most cases, the server creates a [`WorkspaceEdit`] structure and applies the changes to /// the workspace using `Client::apply_edit()` before returning from this function. - fn execute_command(&self, params: ExecuteCommandParams) -> Result> { + fn execute_command(&mut self, params: ExecuteCommandParams) -> Result> { let _ = params; log("Got a workspace/executeCommand request, but it is not implemented"); Err(Error::method_not_found()) diff --git a/toolchains/solidity/core/Cargo.lock b/toolchains/solidity/core/Cargo.lock index 0e67b6a5..d377d620 100644 --- a/toolchains/solidity/core/Cargo.lock +++ b/toolchains/solidity/core/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "1.1.2" @@ -33,30 +48,30 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -65,6 +80,50 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "auto_impl" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -77,6 +136,21 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -85,9 +159,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.8" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -95,9 +169,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -114,7 +188,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -137,7 +211,7 @@ checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" dependencies = [ "is-terminal", "lazy_static", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -159,14 +233,33 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "errno" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -178,12 +271,110 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "foundry-compiler-server" +version = "0.3.0" +dependencies = [ + "osmium-libs-foundry-wrapper", + "tokio", + "tower-lsp", +] + +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + [[package]] name = "glob" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "heck" version = "0.4.1" @@ -196,6 +387,21 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + [[package]] name = "idna" version = "0.5.0" @@ -214,7 +420,7 @@ checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -248,9 +454,19 @@ dependencies = [ [[package]] name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + +[[package]] +name = "lock_api" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] [[package]] name = "log" @@ -289,12 +505,63 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "osmium-libs-foundry-wrapper" +version = "0.1.0" +dependencies = [ + "clap", + "glob", + "serde", + "serde_json", + "thiserror", + "which", +] + [[package]] name = "osmium-libs-lsp-server-wrapper" version = "0.2.0" @@ -312,11 +579,34 @@ version = "0.1.2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", "syn-solidity", "thiserror", ] +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + [[package]] name = "paste" version = "1.0.14" @@ -329,12 +619,62 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.70" @@ -353,6 +693,15 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "regex" version = "1.10.2" @@ -382,17 +731,23 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustix" -version = "0.38.25" +version = "0.38.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -401,6 +756,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "serde" version = "1.0.193" @@ -418,7 +779,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -440,7 +801,41 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", ] [[package]] @@ -475,6 +870,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.39" @@ -495,7 +901,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -515,7 +921,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -533,6 +939,110 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-lsp" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ba052b54a6627628d9b3c34c176e7eda8359b7da9acd497b9f20998d118508" +dependencies = [ + "async-trait", + "auto_impl", + "bytes", + "dashmap", + "futures", + "httparse", + "lsp-types", + "memchr", + "serde", + "serde_json", + "tokio", + "tokio-util", + "tower", + "tower-lsp-macros", + "tracing", +] + +[[package]] +name = "tower-lsp-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.40" @@ -552,7 +1062,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -603,13 +1113,47 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "which" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf3ea8596f3a0dd5980b46430f2058dfe2c36a27ccfbb1845d6fbfcd9ba6e14" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -618,13 +1162,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -633,38 +1192,80 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/toolchains/solidity/core/Cargo.toml b/toolchains/solidity/core/Cargo.toml index 23f0a5f8..eaf3e245 100644 --- a/toolchains/solidity/core/Cargo.toml +++ b/toolchains/solidity/core/Cargo.toml @@ -18,4 +18,5 @@ rustdoc-args = ["--cfg", "docsrs"] extension = { version = "0.1.0", path = "crates/extension", default-features = false } solidhunter = { version = "0.2.1", path = "crates/solidhunter", default-features = false } linter-cli = { version = "0.2.0", path = "crates/linter-cli", default-features = false } -linter-server = { version = "0.1.0", path = "crates/linter-server", default-features = false } \ No newline at end of file +linter-server = { version = "0.1.0", path = "crates/linter-server", default-features = false } +foundry-compiler-server = { version = "0.1.0", path = "crates/foundry-compiler-server", default-features = false } \ No newline at end of file diff --git a/toolchains/solidity/core/crates/foundry-compiler-server/Cargo.toml b/toolchains/solidity/core/crates/foundry-compiler-server/Cargo.toml new file mode 100644 index 00000000..da0beb7e --- /dev/null +++ b/toolchains/solidity/core/crates/foundry-compiler-server/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "foundry-compiler-server" +version.workspace = true +edition.workspace = true +authors.workspace = true +license.workspace = true +exclude.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +osmium-libs-foundry-wrapper = { path = "../../../../../libs/foundry-wrapper" } +tower-lsp = "0.20.0" +tokio = { version = "1.34.0", features = ["full"] } \ No newline at end of file diff --git a/toolchains/solidity/core/crates/foundry-compiler-server/Makefile b/toolchains/solidity/core/crates/foundry-compiler-server/Makefile new file mode 100644 index 00000000..1f0381e6 --- /dev/null +++ b/toolchains/solidity/core/crates/foundry-compiler-server/Makefile @@ -0,0 +1,3 @@ +build: + cargo build + cp ../../target/debug/foundry-server ../../../extension/dist \ No newline at end of file diff --git a/toolchains/solidity/core/crates/foundry-compiler-server/src/affected_files_store.rs b/toolchains/solidity/core/crates/foundry-compiler-server/src/affected_files_store.rs new file mode 100644 index 00000000..daf0354f --- /dev/null +++ b/toolchains/solidity/core/crates/foundry-compiler-server/src/affected_files_store.rs @@ -0,0 +1,48 @@ +use std::collections::HashMap; + +#[derive(Debug)] +pub struct AffectedFilesStore { + projects_files: HashMap>, +} + +impl AffectedFilesStore { + pub fn new() -> Self { + Self { + projects_files: HashMap::new(), + } + } + + pub fn add_project_file(&mut self, project_path: String, file: String) { + if let Some(files) = self.projects_files.get_mut(&project_path) { + if !files.contains(&file) { + files.push(file); + } + } else { + self.projects_files.insert(project_path, vec![file]); + } + } + + /** + * This function returns the list of files that previously raised an error and are not raising it anymore. + * It also updates the list of files that are raising an error. + * @param {Vec} raised_files List of files that are raising an error + * @param {String} project_path Project path + * @returns {Vec} List of files that are not raising an error anymore + */ + pub fn fill_affected_files( + &mut self, + raised_files: Vec, + project_path: &str, + ) -> Vec { + let mut affected_files = Vec::new(); + if let Some(project_files) = self.projects_files.get_mut(project_path) { + project_files.retain(|file| !raised_files.contains(file)); + affected_files = project_files.clone(); + project_files.extend(raised_files); + } else { + self.projects_files + .insert(project_path.to_string(), raised_files); + } + affected_files + } +} diff --git a/toolchains/solidity/core/crates/foundry-compiler-server/src/main.rs b/toolchains/solidity/core/crates/foundry-compiler-server/src/main.rs new file mode 100644 index 00000000..ab431df6 --- /dev/null +++ b/toolchains/solidity/core/crates/foundry-compiler-server/src/main.rs @@ -0,0 +1,408 @@ +use osmium_libs_foundry_wrapper::{CompilationError, Compiler, Error, ProjectCompileOutput}; +use std::collections::HashMap; +use std::fmt::Debug; +use std::path::{Path, PathBuf}; +use tokio::sync::Mutex; +use tower_lsp::jsonrpc::Result; +use tower_lsp::lsp_types::*; +use tower_lsp::{Client, LanguageServer, LspService, Server}; +mod utils; +use utils::{convert_severity, get_root_path, normalized_slash_path, slashify_path}; +mod affected_files_store; +use affected_files_store::AffectedFilesStore; + +#[derive(Debug)] +struct State { + compiler: Option, + initialized: bool, + affected_files: AffectedFilesStore, +} + +#[derive(Debug)] +struct Backend { + client: Client, + state: Mutex, +} + +#[tower_lsp::async_trait] +impl LanguageServer for Backend { + async fn initialize(&self, params: InitializeParams) -> Result { + self.client + .log_message(MessageType::INFO, "Foundry server initializing!") + .await; + if let Some(root_path) = get_root_path(params.clone()) { + self.client + .log_message( + MessageType::INFO, + &format!( + "Foundry server initializing with workspace path: {:?}", + root_path + ), + ) + .await; + let _ = self.load_workspace(root_path).await; + } else { + self.client + .log_message( + MessageType::INFO, + "Foundry server not initialized : no workspace path!", + ) + .await; + } + Ok(InitializeResult { + server_info: None, + capabilities: ServerCapabilities { + text_document_sync: Some(TextDocumentSyncCapability::Kind( + TextDocumentSyncKind::FULL, + )), + ..ServerCapabilities::default() + }, + }) + } + + async fn initialized(&self, _: InitializedParams) { + self.client + .log_message(MessageType::INFO, "Foundry server initialized!") + .await; + } + + async fn did_open(&self, params: DidOpenTextDocumentParams) { + self.client + .log_message( + MessageType::INFO, + format!("file opened!: {:}", params.text_document.uri), + ) + .await; + let _ = self + .compile(normalized_slash_path(params.text_document.uri.path())) + .await; + } + + async fn did_save(&self, params: DidSaveTextDocumentParams) { + self.client + .log_message( + MessageType::INFO, + format!("file changed!: {:}", params.text_document.uri), + ) + .await; + let _ = self + .compile(normalized_slash_path(params.text_document.uri.path())) + .await; + } + + async fn shutdown(&self) -> Result<()> { + Ok(()) + } +} + +impl Backend { + pub async fn load_workspace(&self, path: String) -> std::result::Result<(), ()> { + let mut state = self.state.lock().await; + match Compiler::new_with_executable_check() { + Ok(compiler) => state.compiler = Some(compiler), + Err(Error::FoundryExecutableNotFound) => { + self.client + .show_message(MessageType::WARNING, "Foundry executable not found. Please install foundry and restart the extension.") + .await; + return Err(()); + } + Err(Error::InvalidFoundryVersion) => { + self.client + .show_message(MessageType::WARNING, "Foundry executable version is not compatible with this extension. Please update foundry and restart the extension.") + .await; + return Err(()); + } + Err(err) => { + self.client + .log_message( + MessageType::ERROR, + &format!("Foundry server failed to initialize: {:?}", err), + ) + .await; + return Err(()); + } + } + if let Err(err) = state.compiler.as_mut().unwrap().load_workspace(path) { + self.client + .log_message( + MessageType::ERROR, + &format!("Foundry server failed to initialize: {:?}", err), + ) + .await; + return Err(()); + } else { + state.initialized = true; + self.client + .log_message(MessageType::INFO, "Foundry server initialized!") + .await; + } + Ok(()) + } + + /** + * This function initializes the workspace if it is not already initialized. + * @param {&str} filepath Filepath to compile + * @returns {Result<(), ()>} Result of the initialization + */ + async fn initialize_if_not(&self, filepath: &str) -> std::result::Result<(), ()> { + let state = self.state.lock().await; + + if !state.initialized { + drop(state); // unlock the mutex before calling load_workspace + + self.client + .log_message(MessageType::INFO, "Foundry server initializing!") + .await; + let folder_path = Path::new(filepath) + .parent() + .unwrap() + .to_str() + .unwrap() + .to_string(); + self.load_workspace(folder_path).await? + } + Ok(()) + } + + pub async fn compile(&self, filepath: String) -> std::result::Result<(), ()> { + self.initialize_if_not(&filepath).await?; + let mut state = self.state.lock().await; + + self.client + .log_message(MessageType::INFO, "Foundry server compiling!") + .await; + + match state.compiler.as_mut().unwrap().compile(&filepath) { + Ok((project_path, output)) => { + /*self.client + .log_message(MessageType::INFO, format!("Compile errors: {:?}", output.get_errors())) + .await;*/ + drop(state); + self.publish_errors_diagnostics(slashify_path(&project_path), filepath, output) + .await; + } + Err(err) => { + self.client + .log_message( + MessageType::ERROR, + format!("error while compiling: {:?}", err), + ) + .await; + } + } + Ok(()) + } + + /** + * Generate and publish diagnostics from compilation errors + * @param {String} project_path Project path + * @param {String} filepath Filepath to compile + * @param {ProjectCompileOutput} output Compilation output + */ + pub async fn publish_errors_diagnostics( + &self, + project_path: String, + filepath: String, + output: ProjectCompileOutput, + ) { + let mut raised_diagnostics = HashMap::>::new(); + + for error in output.get_errors() { + // Generate diagnostic from compilation error + let (affected_file, diagnostic) = + match self.extract_diagnostic(error, &project_path).await { + Some(diagnostic) => diagnostic, + None => continue, + }; + + // Add diagnostic to the hashmap + let url = match affected_file.to_str() { + Some(source_path) => slashify_path(source_path), + None => continue, + }; + if !raised_diagnostics.contains_key(&url) { + raised_diagnostics.insert(url.clone(), vec![diagnostic]); + } else { + raised_diagnostics.get_mut(&url).unwrap().push(diagnostic); + } + } + + self.reset_not_affected_files(project_path, filepath, &raised_diagnostics) + .await; + for (uri, diags) in raised_diagnostics.iter() { + if let Ok(url) = Url::parse(&format!("file://{}", &uri)) { + self.client + .publish_diagnostics(url, diags.clone(), None) + .await; + } else { + self.client + .log_message( + MessageType::ERROR, + format!("error, cannot parse file uri : {}", uri), + ) + .await; + } + } + } + + /** + * Extract diagnostic from compilation error + * @param {CompilationError} compilation_error Compilation error + * @param {String} project_path Project path + * @returns {Option<(PathBuf, Diagnostic)>} Diagnostic + * @returns {None} If the diagnostic cannot be extracted + */ + async fn extract_diagnostic( + &self, + compilation_error: &CompilationError, + project_path: &str, + ) -> Option<(PathBuf, Diagnostic)> { + eprintln!("Compilation error: {:?}", compilation_error); + let (source_content_filepath, range) = match self + .extract_diagnostic_range(project_path, compilation_error) + .await + { + Some((source_content_filepath, range)) => (source_content_filepath, range), + None => return None, + }; + let diagnostic = Diagnostic { + range: Range { + start: Position { + line: range.start.line, + character: range.start.column, + }, + end: Position { + line: range.end.line, + character: range.end.column, + }, + }, + severity: Some(convert_severity(compilation_error.get_severity())), + code: None, + code_description: None, + source: Some("osmium-solidity-foundry-compiler".to_string()), + message: compilation_error.get_message(), + related_information: None, + tags: None, + data: None, + }; + Some((source_content_filepath, diagnostic)) + } + + /** + * Extract diagnostic range from compilation error's source location + * Open the file and get the range from the source location + * @param {String} project_path Project path + * @param {CompilationError} error Compilation error + * @returns {Option<(PathBuf, osmium_libs_foundry_wrapper::Range)>} Diagnostic range + * @returns {None} If the diagnostic range cannot be extracted + */ + async fn extract_diagnostic_range( + &self, + project_path: &str, + error: &CompilationError, + ) -> Option<(PathBuf, osmium_libs_foundry_wrapper::Range)> { + let source_content_filepath = match error.get_file_path() { + Some(source_path) => { + let mut complete_path = Path::new(project_path).to_path_buf(); + complete_path.push(source_path); + complete_path + } + None => { + self.client + .log_message( + MessageType::ERROR, + format!("error, cannot get filepath: {:?}", error), + ) + .await; + return None; + } + }; + let source_content = match std::fs::read_to_string(&source_content_filepath) { + Ok(content) => content, + Err(err) => { + self.client + .log_message( + MessageType::ERROR, + format!( + "error, cannot read file: {:?}, error: {:?}", + &source_content_filepath, err + ), + ) + .await; + return None; + } + }; + let range = match error.get_range(&source_content) { + Some(range) => range, + None => { + self.client + .log_message( + MessageType::ERROR, + format!("error, cannot get range: {:?}", error), + ) + .await; + return None; + } + }; + Some((source_content_filepath, range)) + } + + /** + * This function resets the diagnostics of the files that are not raising an error anymore. + * @param {String} project_path Project path + * @param {String} filepath Filepath to compile + * @param {HashMap>} raised_diagnostics Raised diagnostics + */ + async fn reset_not_affected_files( + &self, + project_path: String, + filepath: String, + raised_diagnostics: &HashMap>, + ) { + let mut state = self.state.lock().await; + + state + .affected_files + .add_project_file(project_path.clone(), filepath.clone()); + let raised_files = raised_diagnostics.keys().cloned().collect::>(); + let without_diagnostics = state + .affected_files + .fill_affected_files(raised_files, &project_path); + + self.client + .log_message( + MessageType::INFO, + format!("files without diagnostic: {:?}", without_diagnostics), + ) + .await; + + for file in without_diagnostics.iter() { + if let Ok(url) = Url::parse(&format!("file://{}", &file)) { + self.client.publish_diagnostics(url, vec![], None).await; + } else { + self.client + .log_message( + MessageType::ERROR, + format!("error, cannot parse file uri : {}", file), + ) + .await; + } + } + } +} + +#[tokio::main] +async fn main() { + let stdin = tokio::io::stdin(); + let stdout = tokio::io::stdout(); + + let (service, socket) = LspService::new(|client| Backend { + client, + state: Mutex::new(State { + compiler: None, + initialized: false, + affected_files: AffectedFilesStore::new(), + }), + }); + Server::new(stdin, stdout, socket).serve(service).await; +} diff --git a/toolchains/solidity/core/crates/foundry-compiler-server/src/utils.rs b/toolchains/solidity/core/crates/foundry-compiler-server/src/utils.rs new file mode 100644 index 00000000..9c3f0598 --- /dev/null +++ b/toolchains/solidity/core/crates/foundry-compiler-server/src/utils.rs @@ -0,0 +1,63 @@ +use osmium_libs_foundry_wrapper::Severity; +use tower_lsp::lsp_types::{DiagnosticSeverity, InitializeParams}; + +/** + * This function returns the first workspace path from the InitializeParams. + * If there is no workspace path, it returns the root path. + * @returns {Option} Normalized path + */ +pub fn get_root_path(params: InitializeParams) -> Option { + if let Some(folder) = params.workspace_folders?.get(0) { + return Some(normalize_path(folder.uri.path())); + } else if let Some(root_uri) = params.root_uri { + return Some(normalize_path(root_uri.path())); + } + None +} + +pub fn convert_severity(severity: Severity) -> DiagnosticSeverity { + match severity { + Severity::Error => DiagnosticSeverity::ERROR, + Severity::Warning => DiagnosticSeverity::WARNING, + Severity::Info => DiagnosticSeverity::INFORMATION, + } +} + +/** + * This function normalizes the path for Windows. + * VSCode send the path starting with /%3A/ instead of {letter}:/ + * @param {&str} path Path to normalize + * @returns {String} Normalized path + */ +#[cfg(target_family = "windows")] +pub fn normalize_path(path: &str) -> String { + let mut path = path.replace("%3A/", "://"); + path.remove(0); + path.to_string() +} + +/** + * This function normalizes the path for Linux and MacOS. Nothing to do. + * @param {&str} path Path to normalize + * @returns {String} Normalized path + */ +#[cfg(not(target_family = "windows"))] +pub fn normalize_path(path: &str) -> String { + path.to_string() +} + +/** + * This function replaces all backslashes and double-slahes with slashes. + * This is useful for Windows paths. + * @param {&str} path Path to slashify + * @returns {String} Slashified path + */ +pub fn slashify_path(path: &str) -> String { + path.replace('\\', "/") + .replace("\\\\", "/") + .replace("//", "/") +} + +pub fn normalized_slash_path(path: &str) -> String { + slashify_path(&normalize_path(path)) +} diff --git a/toolchains/solidity/extension/src/extension.ts b/toolchains/solidity/extension/src/extension.ts index 4818d265..9d60596e 100644 --- a/toolchains/solidity/extension/src/extension.ts +++ b/toolchains/solidity/extension/src/extension.ts @@ -5,32 +5,30 @@ import * as path from 'path'; import { workspace, ExtensionContext } from 'vscode'; -import { TextDecoder } from 'util'; - +[] import { LanguageClient, - LanguageClientOptions, - ServerOptions, - TransportKind } from 'vscode-languageclient/node'; import { createLinterClient } from './linter'; - +import { createFoundryCompilerClient } from './foundry-compiler'; let linterClient: LanguageClient; +let foundryCompilerClient: LanguageClient; export async function activate(context: ExtensionContext) { linterClient = createLinterClient(context); + foundryCompilerClient = createFoundryCompilerClient(context); - // Push the disposable to the context's subscriptions so that the - // client can be deactivated on extension deactivation context.subscriptions.push(linterClient); - + context.subscriptions.push(foundryCompilerClient); + const folders = workspace.workspaceFolders; if (folders) { const files = await workspace.findFiles('**/*.sol', `${folders[0].uri.fsPath}/**`); files.forEach(file => { - workspace.openTextDocument(file); + if (!file.path.includes('forge-std')) + workspace.openTextDocument(file); }); } diff --git a/toolchains/solidity/extension/src/foundry-compiler.ts b/toolchains/solidity/extension/src/foundry-compiler.ts new file mode 100644 index 00000000..b43a9c27 --- /dev/null +++ b/toolchains/solidity/extension/src/foundry-compiler.ts @@ -0,0 +1,50 @@ +import * as path from 'path'; +import { workspace, ExtensionContext } from "vscode"; +import { + LanguageClient, + LanguageClientOptions, + ServerOptions, + TransportKind +} from 'vscode-languageclient/node'; +import * as os from 'os'; + +export function createFoundryCompilerClient(context: ExtensionContext): LanguageClient { + // The server is implemented in node + const serverBinary = context.asAbsolutePath( + path.join('dist', + os.platform().startsWith("win") ? 'foundry-compiler-server.exe' : 'foundry-compiler-server') + ); + + // If the extension is launched in debug mode then the debug server options are used + // Otherwise the run options are used[] + const serverOptions: ServerOptions = { + run: { command: serverBinary, transport: TransportKind.stdio }, + debug: { + command: serverBinary, + transport: TransportKind.stdio, + } + }; + + // Options to control the language client + const clientOptions: LanguageClientOptions = { + // Register the server for plain text documents + documentSelector: [{ scheme: 'file', language: 'solidity' }], + synchronize: { + // Notify the server about file changes to '.clientrc files contained in the workspace + fileEvents: workspace.createFileSystemWatcher('**/.solidhunter.json') + } + }; + + // Create the language client and start the client. + const client = new LanguageClient( + 'osmium-solidity-foundry-compiler', + 'Osmium Solidity Foundry Compiler Language Server', + serverOptions, + clientOptions + ); + + // Start the client. This will also launch the server + client.start(); + + return client; +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 969a9881..0f8218f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -207,6 +207,12 @@ __metadata: languageName: unknown linkType: soft +"@osmium-libs/foundry-wrapper@workspace:libs/foundry-wrapper": + version: 0.0.0-use.local + resolution: "@osmium-libs/foundry-wrapper@workspace:libs/foundry-wrapper" + languageName: unknown + linkType: soft + "@osmium-libs/lsp-handler@workspace:libs/lsp-handler": version: 0.0.0-use.local resolution: "@osmium-libs/lsp-handler@workspace:libs/lsp-handler"