diff options
| author | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:19:53 +0100 |
|---|---|---|
| committer | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:20:13 +0100 |
| commit | 7bbca7a1b3f9293d2f5cc5745199bc5f8396f2f0 (patch) | |
| tree | bdb47765991cb973b2cd5481a088fac636bd326c | |
| parent | ca464650eeaca6195891199a93f4f76cf3e7e697 (diff) | |
| parent | e65d48d1fb3d4d91d9dc1148a7a836ff5c9a3c87 (diff) | |
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
1623 files changed, 130529 insertions, 128337 deletions
diff --git a/.cargo/config b/.cargo/config index 560ab3075..f6b0b66bf 100644 --- a/.cargo/config +++ b/.cargo/config | |||
| @@ -3,3 +3,6 @@ xtask = "run --package xtask --bin xtask --" | |||
| 3 | install-ra = "run --package xtask --bin xtask -- install" # for backwards compat | 3 | install-ra = "run --package xtask --bin xtask -- install" # for backwards compat |
| 4 | tq = "test -- -q" | 4 | tq = "test -- -q" |
| 5 | qt = "tq" | 5 | qt = "tq" |
| 6 | |||
| 7 | [target.x86_64-pc-windows-msvc] | ||
| 8 | linker = "rust-lld" | ||
diff --git a/.gitattributes b/.gitattributes index 4cd50e481..7c2f752d6 100644 --- a/.gitattributes +++ b/.gitattributes | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | * text=auto eol=lf | 1 | * text=auto eol=lf |
| 2 | crates/ra_syntax/test_data/** -text eof=LF | 2 | crates/syntax/test_data/** -text eof=LF |
| 3 | # Older git versions try to fix line endings on images, this prevents it. | 3 | # Older git versions try to fix line endings on images, this prevents it. |
| 4 | *.png binary | 4 | *.png binary |
| 5 | *.jpg binary | 5 | *.jpg binary |
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d78a14e2c..73892ddaa 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml | |||
| @@ -1,12 +1,2 @@ | |||
| 1 | # These are supported funding model platforms | 1 | github: rust-analyzer |
| 2 | |||
| 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
| 4 | patreon: # Replace with a single Patreon username | ||
| 5 | open_collective: rust-analyzer | 2 | open_collective: rust-analyzer |
| 6 | ko_fi: # Replace with a single Ko-fi username | ||
| 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
| 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
| 9 | liberapay: # Replace with a single Liberapay username | ||
| 10 | issuehunt: # Replace with a single IssueHunt username | ||
| 11 | otechie: # Replace with a single Otechie username | ||
| 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] | ||
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2acd44012..fb077e28d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml | |||
| @@ -16,20 +16,6 @@ env: | |||
| 16 | RUSTUP_MAX_RETRIES: 10 | 16 | RUSTUP_MAX_RETRIES: 10 |
| 17 | 17 | ||
| 18 | jobs: | 18 | jobs: |
| 19 | # rust-audit: | ||
| 20 | # name: Audit Rust vulnerabilities | ||
| 21 | # runs-on: ubuntu-latest | ||
| 22 | # steps: | ||
| 23 | # - name: Checkout repository | ||
| 24 | # uses: actions/checkout@v2 | ||
| 25 | |||
| 26 | # - uses: actions-rs/[email protected] | ||
| 27 | # with: | ||
| 28 | # crate: cargo-audit | ||
| 29 | # use-tool-cache: true | ||
| 30 | |||
| 31 | # - run: cargo audit | ||
| 32 | |||
| 33 | rust: | 19 | rust: |
| 34 | name: Rust | 20 | name: Rust |
| 35 | runs-on: ${{ matrix.os }} | 21 | runs-on: ${{ matrix.os }} |
| @@ -84,15 +70,14 @@ jobs: | |||
| 84 | - name: Prepare cache | 70 | - name: Prepare cache |
| 85 | run: cargo xtask pre-cache | 71 | run: cargo xtask pre-cache |
| 86 | 72 | ||
| 87 | - name: Prepare cache 2 | 73 | # Weird targets to catch non-portable code |
| 88 | if: matrix.os == 'windows-latest' | 74 | rust-cross: |
| 89 | run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe | 75 | name: Rust Cross |
| 90 | |||
| 91 | # Weird target to catch non-portable code | ||
| 92 | rust-power: | ||
| 93 | name: Rust Power | ||
| 94 | runs-on: ubuntu-latest | 76 | runs-on: ubuntu-latest |
| 95 | 77 | ||
| 78 | env: | ||
| 79 | targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl" | ||
| 80 | |||
| 96 | steps: | 81 | steps: |
| 97 | - name: Checkout repository | 82 | - name: Checkout repository |
| 98 | uses: actions/checkout@v2 | 83 | uses: actions/checkout@v2 |
| @@ -103,7 +88,9 @@ jobs: | |||
| 103 | toolchain: stable | 88 | toolchain: stable |
| 104 | profile: minimal | 89 | profile: minimal |
| 105 | override: true | 90 | override: true |
| 106 | target: 'powerpc-unknown-linux-gnu' | 91 | |
| 92 | - name: Install Rust targets | ||
| 93 | run: rustup target add ${{ env.targets }} | ||
| 107 | 94 | ||
| 108 | - name: Cache cargo directories | 95 | - name: Cache cargo directories |
| 109 | uses: actions/cache@v2 | 96 | uses: actions/cache@v2 |
| @@ -114,14 +101,17 @@ jobs: | |||
| 114 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | 101 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 115 | 102 | ||
| 116 | - name: Check | 103 | - name: Check |
| 117 | run: cargo check --target=powerpc-unknown-linux-gnu --all-targets | 104 | run: | |
| 105 | for target in ${{ env.targets }}; do | ||
| 106 | cargo check --target=$target --all-targets | ||
| 107 | done | ||
| 118 | 108 | ||
| 119 | typescript: | 109 | typescript: |
| 120 | name: TypeScript | 110 | name: TypeScript |
| 121 | strategy: | 111 | strategy: |
| 122 | fail-fast: false | 112 | fail-fast: false |
| 123 | matrix: | 113 | matrix: |
| 124 | os: [ubuntu-latest, windows-latest, macos-latest] | 114 | os: [ubuntu-latest, windows-latest] |
| 125 | 115 | ||
| 126 | runs-on: ${{ matrix.os }} | 116 | runs-on: ${{ matrix.os }} |
| 127 | 117 | ||
diff --git a/Cargo.lock b/Cargo.lock index 08d122e77..1f8e7a29d 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
| @@ -16,15 +16,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 16 | checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" | 16 | checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" |
| 17 | 17 | ||
| 18 | [[package]] | 18 | [[package]] |
| 19 | name = "aho-corasick" | ||
| 20 | version = "0.7.13" | ||
| 21 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 22 | checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" | ||
| 23 | dependencies = [ | ||
| 24 | "memchr", | ||
| 25 | ] | ||
| 26 | |||
| 27 | [[package]] | ||
| 28 | name = "ansi_term" | 19 | name = "ansi_term" |
| 29 | version = "0.12.1" | 20 | version = "0.12.1" |
| 30 | source = "registry+https://github.com/rust-lang/crates.io-index" | 21 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -46,12 +37,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 46 | checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" | 37 | checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" |
| 47 | 38 | ||
| 48 | [[package]] | 39 | [[package]] |
| 40 | name = "arena" | ||
| 41 | version = "0.0.0" | ||
| 42 | |||
| 43 | [[package]] | ||
| 49 | name = "arrayvec" | 44 | name = "arrayvec" |
| 50 | version = "0.5.1" | 45 | version = "0.5.1" |
| 51 | source = "registry+https://github.com/rust-lang/crates.io-index" | 46 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 52 | checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" | 47 | checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" |
| 53 | 48 | ||
| 54 | [[package]] | 49 | [[package]] |
| 50 | name = "assists" | ||
| 51 | version = "0.0.0" | ||
| 52 | dependencies = [ | ||
| 53 | "base_db", | ||
| 54 | "either", | ||
| 55 | "hir", | ||
| 56 | "ide_db", | ||
| 57 | "itertools", | ||
| 58 | "profile", | ||
| 59 | "rustc-hash", | ||
| 60 | "stdx", | ||
| 61 | "syntax", | ||
| 62 | "test_utils", | ||
| 63 | "text_edit", | ||
| 64 | ] | ||
| 65 | |||
| 66 | [[package]] | ||
| 55 | name = "atty" | 67 | name = "atty" |
| 56 | version = "0.2.14" | 68 | version = "0.2.14" |
| 57 | source = "registry+https://github.com/rust-lang/crates.io-index" | 69 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -64,9 +76,9 @@ dependencies = [ | |||
| 64 | 76 | ||
| 65 | [[package]] | 77 | [[package]] |
| 66 | name = "autocfg" | 78 | name = "autocfg" |
| 67 | version = "1.0.0" | 79 | version = "1.0.1" |
| 68 | source = "registry+https://github.com/rust-lang/crates.io-index" | 80 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 69 | checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" | 81 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" |
| 70 | 82 | ||
| 71 | [[package]] | 83 | [[package]] |
| 72 | name = "backtrace" | 84 | name = "backtrace" |
| @@ -89,6 +101,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 89 | checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" | 101 | checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" |
| 90 | 102 | ||
| 91 | [[package]] | 103 | [[package]] |
| 104 | name = "base_db" | ||
| 105 | version = "0.0.0" | ||
| 106 | dependencies = [ | ||
| 107 | "cfg", | ||
| 108 | "profile", | ||
| 109 | "rustc-hash", | ||
| 110 | "salsa", | ||
| 111 | "stdx", | ||
| 112 | "syntax", | ||
| 113 | "test_utils", | ||
| 114 | "tt", | ||
| 115 | "vfs", | ||
| 116 | ] | ||
| 117 | |||
| 118 | [[package]] | ||
| 92 | name = "bitflags" | 119 | name = "bitflags" |
| 93 | version = "1.2.1" | 120 | version = "1.2.1" |
| 94 | source = "registry+https://github.com/rust-lang/crates.io-index" | 121 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -113,9 +140,19 @@ dependencies = [ | |||
| 113 | 140 | ||
| 114 | [[package]] | 141 | [[package]] |
| 115 | name = "cc" | 142 | name = "cc" |
| 116 | version = "1.0.58" | 143 | version = "1.0.59" |
| 117 | source = "registry+https://github.com/rust-lang/crates.io-index" | 144 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 118 | checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" | 145 | checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" |
| 146 | |||
| 147 | [[package]] | ||
| 148 | name = "cfg" | ||
| 149 | version = "0.0.0" | ||
| 150 | dependencies = [ | ||
| 151 | "mbe", | ||
| 152 | "rustc-hash", | ||
| 153 | "syntax", | ||
| 154 | "tt", | ||
| 155 | ] | ||
| 119 | 156 | ||
| 120 | [[package]] | 157 | [[package]] |
| 121 | name = "cfg-if" | 158 | name = "cfg-if" |
| @@ -125,9 +162,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" | |||
| 125 | 162 | ||
| 126 | [[package]] | 163 | [[package]] |
| 127 | name = "chalk-derive" | 164 | name = "chalk-derive" |
| 128 | version = "0.19.0" | 165 | version = "0.23.0" |
| 129 | source = "registry+https://github.com/rust-lang/crates.io-index" | 166 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 130 | checksum = "654c611946ba2629c5028cb7708687af975faf2c29d731824cb294c873df4697" | 167 | checksum = "c3cb438e961fd7f1183dc5e0bdcfd09253bf9b90592cf665d1ce6787d8a4908f" |
| 131 | dependencies = [ | 168 | dependencies = [ |
| 132 | "proc-macro2", | 169 | "proc-macro2", |
| 133 | "quote", | 170 | "quote", |
| @@ -137,9 +174,9 @@ dependencies = [ | |||
| 137 | 174 | ||
| 138 | [[package]] | 175 | [[package]] |
| 139 | name = "chalk-ir" | 176 | name = "chalk-ir" |
| 140 | version = "0.19.0" | 177 | version = "0.23.0" |
| 141 | source = "registry+https://github.com/rust-lang/crates.io-index" | 178 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 142 | checksum = "0a5341fbc654ca886b73b804a36aebf0e621057ccc1a68e9815b5b39b3ac9ae8" | 179 | checksum = "bb332abfcb015b148c6fbab39b1d13282745b0f7f312019dd8e138f5f3f0855d" |
| 143 | dependencies = [ | 180 | dependencies = [ |
| 144 | "chalk-derive", | 181 | "chalk-derive", |
| 145 | "lazy_static", | 182 | "lazy_static", |
| @@ -147,9 +184,9 @@ dependencies = [ | |||
| 147 | 184 | ||
| 148 | [[package]] | 185 | [[package]] |
| 149 | name = "chalk-recursive" | 186 | name = "chalk-recursive" |
| 150 | version = "0.19.0" | 187 | version = "0.23.0" |
| 151 | source = "registry+https://github.com/rust-lang/crates.io-index" | 188 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 152 | checksum = "4484807b155b5a411e6135d330295f9ba5042e2920b8712c6574ca6ea91e9ee5" | 189 | checksum = "e7c7673f10c5fa1acf7fa07d4f4c5917cbcf161ed3a952d14530c79950de32d2" |
| 153 | dependencies = [ | 190 | dependencies = [ |
| 154 | "chalk-derive", | 191 | "chalk-derive", |
| 155 | "chalk-ir", | 192 | "chalk-ir", |
| @@ -160,9 +197,9 @@ dependencies = [ | |||
| 160 | 197 | ||
| 161 | [[package]] | 198 | [[package]] |
| 162 | name = "chalk-solve" | 199 | name = "chalk-solve" |
| 163 | version = "0.19.0" | 200 | version = "0.23.0" |
| 164 | source = "registry+https://github.com/rust-lang/crates.io-index" | 201 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 165 | checksum = "281f82facd2538997fbe52132b1941ed213d266748215c31d15f62a8664429ad" | 202 | checksum = "802de4eff72e5a5d2828e6c07224c74d66949dc6308aff025d0ae2871a11b4eb" |
| 166 | dependencies = [ | 203 | dependencies = [ |
| 167 | "chalk-derive", | 204 | "chalk-derive", |
| 168 | "chalk-ir", | 205 | "chalk-ir", |
| @@ -177,9 +214,9 @@ dependencies = [ | |||
| 177 | 214 | ||
| 178 | [[package]] | 215 | [[package]] |
| 179 | name = "chrono" | 216 | name = "chrono" |
| 180 | version = "0.4.13" | 217 | version = "0.4.15" |
| 181 | source = "registry+https://github.com/rust-lang/crates.io-index" | 218 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 182 | checksum = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6" | 219 | checksum = "942f72db697d8767c22d46a598e01f2d3b475501ea43d0db4f16d90259182d0b" |
| 183 | dependencies = [ | 220 | dependencies = [ |
| 184 | "num-integer", | 221 | "num-integer", |
| 185 | "num-traits", | 222 | "num-traits", |
| @@ -279,15 +316,15 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" | |||
| 279 | 316 | ||
| 280 | [[package]] | 317 | [[package]] |
| 281 | name = "drop_bomb" | 318 | name = "drop_bomb" |
| 282 | version = "0.1.4" | 319 | version = "0.1.5" |
| 283 | source = "registry+https://github.com/rust-lang/crates.io-index" | 320 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 284 | checksum = "69b26e475fd29098530e709294e94e661974c851aed42512793f120fed4e199f" | 321 | checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1" |
| 285 | 322 | ||
| 286 | [[package]] | 323 | [[package]] |
| 287 | name = "either" | 324 | name = "either" |
| 288 | version = "1.5.3" | 325 | version = "1.6.0" |
| 289 | source = "registry+https://github.com/rust-lang/crates.io-index" | 326 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 290 | checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" | 327 | checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f" |
| 291 | 328 | ||
| 292 | [[package]] | 329 | [[package]] |
| 293 | name = "ena" | 330 | name = "ena" |
| @@ -308,19 +345,20 @@ dependencies = [ | |||
| 308 | ] | 345 | ] |
| 309 | 346 | ||
| 310 | [[package]] | 347 | [[package]] |
| 311 | name = "expect" | 348 | name = "expect-test" |
| 312 | version = "0.1.0" | 349 | version = "0.1.0" |
| 350 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 351 | checksum = "a3e383741ea1982866572109d1a8c807bd36aad91fca701489fdca56ef92b3b8" | ||
| 313 | dependencies = [ | 352 | dependencies = [ |
| 314 | "difference", | 353 | "difference", |
| 315 | "once_cell", | 354 | "once_cell", |
| 316 | "stdx", | ||
| 317 | ] | 355 | ] |
| 318 | 356 | ||
| 319 | [[package]] | 357 | [[package]] |
| 320 | name = "filetime" | 358 | name = "filetime" |
| 321 | version = "0.2.11" | 359 | version = "0.2.12" |
| 322 | source = "registry+https://github.com/rust-lang/crates.io-index" | 360 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 323 | checksum = "e500da2fab70bdc43f8f0e0b350a227f31c72311c56aba48f01d5cd62bb0345b" | 361 | checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" |
| 324 | dependencies = [ | 362 | dependencies = [ |
| 325 | "cfg-if", | 363 | "cfg-if", |
| 326 | "libc", | 364 | "libc", |
| @@ -336,9 +374,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" | |||
| 336 | 374 | ||
| 337 | [[package]] | 375 | [[package]] |
| 338 | name = "flate2" | 376 | name = "flate2" |
| 339 | version = "1.0.16" | 377 | version = "1.0.17" |
| 340 | source = "registry+https://github.com/rust-lang/crates.io-index" | 378 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 341 | checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" | 379 | checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" |
| 342 | dependencies = [ | 380 | dependencies = [ |
| 343 | "cfg-if", | 381 | "cfg-if", |
| 344 | "crc32fast", | 382 | "crc32fast", |
| @@ -348,14 +386,14 @@ dependencies = [ | |||
| 348 | 386 | ||
| 349 | [[package]] | 387 | [[package]] |
| 350 | name = "flycheck" | 388 | name = "flycheck" |
| 351 | version = "0.1.0" | 389 | version = "0.0.0" |
| 352 | dependencies = [ | 390 | dependencies = [ |
| 353 | "cargo_metadata", | 391 | "cargo_metadata", |
| 354 | "crossbeam-channel", | 392 | "crossbeam-channel", |
| 355 | "jod-thread", | 393 | "jod-thread", |
| 356 | "log", | 394 | "log", |
| 357 | "ra_toolchain", | ||
| 358 | "serde_json", | 395 | "serde_json", |
| 396 | "toolchain", | ||
| 359 | ] | 397 | ] |
| 360 | 398 | ||
| 361 | [[package]] | 399 | [[package]] |
| @@ -418,9 +456,9 @@ dependencies = [ | |||
| 418 | 456 | ||
| 419 | [[package]] | 457 | [[package]] |
| 420 | name = "hashbrown" | 458 | name = "hashbrown" |
| 421 | version = "0.8.1" | 459 | version = "0.8.2" |
| 422 | source = "registry+https://github.com/rust-lang/crates.io-index" | 460 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 423 | checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" | 461 | checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" |
| 424 | dependencies = [ | 462 | dependencies = [ |
| 425 | "autocfg", | 463 | "autocfg", |
| 426 | ] | 464 | ] |
| @@ -444,6 +482,98 @@ dependencies = [ | |||
| 444 | ] | 482 | ] |
| 445 | 483 | ||
| 446 | [[package]] | 484 | [[package]] |
| 485 | name = "hir" | ||
| 486 | version = "0.0.0" | ||
| 487 | dependencies = [ | ||
| 488 | "arrayvec", | ||
| 489 | "base_db", | ||
| 490 | "either", | ||
| 491 | "hir_def", | ||
| 492 | "hir_expand", | ||
| 493 | "hir_ty", | ||
| 494 | "itertools", | ||
| 495 | "log", | ||
| 496 | "profile", | ||
| 497 | "rustc-hash", | ||
| 498 | "stdx", | ||
| 499 | "syntax", | ||
| 500 | "tt", | ||
| 501 | "url", | ||
| 502 | ] | ||
| 503 | |||
| 504 | [[package]] | ||
| 505 | name = "hir_def" | ||
| 506 | version = "0.0.0" | ||
| 507 | dependencies = [ | ||
| 508 | "anymap", | ||
| 509 | "arena", | ||
| 510 | "base_db", | ||
| 511 | "cfg", | ||
| 512 | "drop_bomb", | ||
| 513 | "either", | ||
| 514 | "expect-test", | ||
| 515 | "fst", | ||
| 516 | "hir_expand", | ||
| 517 | "indexmap", | ||
| 518 | "itertools", | ||
| 519 | "log", | ||
| 520 | "mbe", | ||
| 521 | "once_cell", | ||
| 522 | "profile", | ||
| 523 | "rustc-hash", | ||
| 524 | "smallvec", | ||
| 525 | "stdx", | ||
| 526 | "syntax", | ||
| 527 | "test_utils", | ||
| 528 | "tt", | ||
| 529 | ] | ||
| 530 | |||
| 531 | [[package]] | ||
| 532 | name = "hir_expand" | ||
| 533 | version = "0.0.0" | ||
| 534 | dependencies = [ | ||
| 535 | "arena", | ||
| 536 | "base_db", | ||
| 537 | "either", | ||
| 538 | "log", | ||
| 539 | "mbe", | ||
| 540 | "parser", | ||
| 541 | "profile", | ||
| 542 | "rustc-hash", | ||
| 543 | "syntax", | ||
| 544 | "test_utils", | ||
| 545 | "tt", | ||
| 546 | ] | ||
| 547 | |||
| 548 | [[package]] | ||
| 549 | name = "hir_ty" | ||
| 550 | version = "0.0.0" | ||
| 551 | dependencies = [ | ||
| 552 | "arena", | ||
| 553 | "arrayvec", | ||
| 554 | "base_db", | ||
| 555 | "chalk-ir", | ||
| 556 | "chalk-recursive", | ||
| 557 | "chalk-solve", | ||
| 558 | "ena", | ||
| 559 | "expect-test", | ||
| 560 | "hir_def", | ||
| 561 | "hir_expand", | ||
| 562 | "itertools", | ||
| 563 | "log", | ||
| 564 | "profile", | ||
| 565 | "rustc-hash", | ||
| 566 | "scoped-tls", | ||
| 567 | "smallvec", | ||
| 568 | "stdx", | ||
| 569 | "syntax", | ||
| 570 | "test_utils", | ||
| 571 | "tracing", | ||
| 572 | "tracing-subscriber", | ||
| 573 | "tracing-tree", | ||
| 574 | ] | ||
| 575 | |||
| 576 | [[package]] | ||
| 447 | name = "home" | 577 | name = "home" |
| 448 | version = "0.5.3" | 578 | version = "0.5.3" |
| 449 | source = "registry+https://github.com/rust-lang/crates.io-index" | 579 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -453,6 +583,51 @@ dependencies = [ | |||
| 453 | ] | 583 | ] |
| 454 | 584 | ||
| 455 | [[package]] | 585 | [[package]] |
| 586 | name = "ide" | ||
| 587 | version = "0.0.0" | ||
| 588 | dependencies = [ | ||
| 589 | "assists", | ||
| 590 | "base_db", | ||
| 591 | "cfg", | ||
| 592 | "either", | ||
| 593 | "expect-test", | ||
| 594 | "hir", | ||
| 595 | "ide_db", | ||
| 596 | "indexmap", | ||
| 597 | "itertools", | ||
| 598 | "log", | ||
| 599 | "oorandom", | ||
| 600 | "profile", | ||
| 601 | "pulldown-cmark", | ||
| 602 | "pulldown-cmark-to-cmark", | ||
| 603 | "rustc-hash", | ||
| 604 | "ssr", | ||
| 605 | "stdx", | ||
| 606 | "syntax", | ||
| 607 | "test_utils", | ||
| 608 | "text_edit", | ||
| 609 | ] | ||
| 610 | |||
| 611 | [[package]] | ||
| 612 | name = "ide_db" | ||
| 613 | version = "0.0.0" | ||
| 614 | dependencies = [ | ||
| 615 | "base_db", | ||
| 616 | "either", | ||
| 617 | "fst", | ||
| 618 | "hir", | ||
| 619 | "log", | ||
| 620 | "once_cell", | ||
| 621 | "profile", | ||
| 622 | "rayon", | ||
| 623 | "rustc-hash", | ||
| 624 | "stdx", | ||
| 625 | "syntax", | ||
| 626 | "test_utils", | ||
| 627 | "text_edit", | ||
| 628 | ] | ||
| 629 | |||
| 630 | [[package]] | ||
| 456 | name = "idna" | 631 | name = "idna" |
| 457 | version = "0.2.0" | 632 | version = "0.2.0" |
| 458 | source = "registry+https://github.com/rust-lang/crates.io-index" | 633 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -465,9 +640,9 @@ dependencies = [ | |||
| 465 | 640 | ||
| 466 | [[package]] | 641 | [[package]] |
| 467 | name = "indexmap" | 642 | name = "indexmap" |
| 468 | version = "1.5.0" | 643 | version = "1.5.1" |
| 469 | source = "registry+https://github.com/rust-lang/crates.io-index" | 644 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 470 | checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" | 645 | checksum = "86b45e59b16c76b11bf9738fd5d38879d3bd28ad292d7b313608becb17ae2df9" |
| 471 | dependencies = [ | 646 | dependencies = [ |
| 472 | "autocfg", | 647 | "autocfg", |
| 473 | "hashbrown", | 648 | "hashbrown", |
| @@ -547,15 +722,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" | |||
| 547 | 722 | ||
| 548 | [[package]] | 723 | [[package]] |
| 549 | name = "lazycell" | 724 | name = "lazycell" |
| 550 | version = "1.2.1" | 725 | version = "1.3.0" |
| 551 | source = "registry+https://github.com/rust-lang/crates.io-index" | 726 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 552 | checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" | 727 | checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" |
| 553 | 728 | ||
| 554 | [[package]] | 729 | [[package]] |
| 555 | name = "libc" | 730 | name = "libc" |
| 556 | version = "0.2.74" | 731 | version = "0.2.76" |
| 557 | source = "registry+https://github.com/rust-lang/crates.io-index" | 732 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 558 | checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" | 733 | checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" |
| 559 | 734 | ||
| 560 | [[package]] | 735 | [[package]] |
| 561 | name = "libloading" | 736 | name = "libloading" |
| @@ -568,9 +743,9 @@ dependencies = [ | |||
| 568 | 743 | ||
| 569 | [[package]] | 744 | [[package]] |
| 570 | name = "libmimalloc-sys" | 745 | name = "libmimalloc-sys" |
| 571 | version = "0.1.15" | 746 | version = "0.1.16" |
| 572 | source = "registry+https://github.com/rust-lang/crates.io-index" | 747 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 573 | checksum = "a27252ec1d0c4e0dd6142cbc572da50b363ab56fc334f7aa8fadf295b2e24e74" | 748 | checksum = "677c4be79b14bd72496b87789b702ba02cd1a9f16a59369fe847082fd03efd88" |
| 574 | dependencies = [ | 749 | dependencies = [ |
| 575 | "cmake", | 750 | "cmake", |
| 576 | ] | 751 | ] |
| @@ -595,9 +770,9 @@ dependencies = [ | |||
| 595 | 770 | ||
| 596 | [[package]] | 771 | [[package]] |
| 597 | name = "lsp-server" | 772 | name = "lsp-server" |
| 598 | version = "0.3.3" | 773 | version = "0.3.4" |
| 599 | source = "registry+https://github.com/rust-lang/crates.io-index" | 774 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 600 | checksum = "53b4ace8ebe5d2aff3687ce0ed507f6020d6a47a7de2b0d3d664ea237ffb0c62" | 775 | checksum = "87fce8851309a325974ec76efe7c9d954d152c9ff4fded6520eb3c96d0aa3a96" |
| 601 | dependencies = [ | 776 | dependencies = [ |
| 602 | "crossbeam-channel", | 777 | "crossbeam-channel", |
| 603 | "log", | 778 | "log", |
| @@ -641,6 +816,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 641 | checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" | 816 | checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" |
| 642 | 817 | ||
| 643 | [[package]] | 818 | [[package]] |
| 819 | name = "mbe" | ||
| 820 | version = "0.0.0" | ||
| 821 | dependencies = [ | ||
| 822 | "log", | ||
| 823 | "parser", | ||
| 824 | "rustc-hash", | ||
| 825 | "smallvec", | ||
| 826 | "syntax", | ||
| 827 | "test_utils", | ||
| 828 | "tt", | ||
| 829 | ] | ||
| 830 | |||
| 831 | [[package]] | ||
| 644 | name = "memchr" | 832 | name = "memchr" |
| 645 | version = "2.3.3" | 833 | version = "2.3.3" |
| 646 | source = "registry+https://github.com/rust-lang/crates.io-index" | 834 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -667,9 +855,9 @@ dependencies = [ | |||
| 667 | 855 | ||
| 668 | [[package]] | 856 | [[package]] |
| 669 | name = "mimalloc" | 857 | name = "mimalloc" |
| 670 | version = "0.1.19" | 858 | version = "0.1.20" |
| 671 | source = "registry+https://github.com/rust-lang/crates.io-index" | 859 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 672 | checksum = "6c52de2069999f01bd26436564dbe7de3a87898feeb7a0d0ff9eb20a05bb7ca0" | 860 | checksum = "00759bcf69082fa629ae8823fcc72f7454a90c6476110297a1ae5fb3a559e474" |
| 673 | dependencies = [ | 861 | dependencies = [ |
| 674 | "libmimalloc-sys", | 862 | "libmimalloc-sys", |
| 675 | ] | 863 | ] |
| @@ -794,9 +982,9 @@ checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" | |||
| 794 | 982 | ||
| 795 | [[package]] | 983 | [[package]] |
| 796 | name = "once_cell" | 984 | name = "once_cell" |
| 797 | version = "1.4.0" | 985 | version = "1.4.1" |
| 798 | source = "registry+https://github.com/rust-lang/crates.io-index" | 986 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 799 | checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" | 987 | checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" |
| 800 | 988 | ||
| 801 | [[package]] | 989 | [[package]] |
| 802 | name = "oorandom" | 990 | name = "oorandom" |
| @@ -831,8 +1019,15 @@ dependencies = [ | |||
| 831 | ] | 1019 | ] |
| 832 | 1020 | ||
| 833 | [[package]] | 1021 | [[package]] |
| 1022 | name = "parser" | ||
| 1023 | version = "0.0.0" | ||
| 1024 | dependencies = [ | ||
| 1025 | "drop_bomb", | ||
| 1026 | ] | ||
| 1027 | |||
| 1028 | [[package]] | ||
| 834 | name = "paths" | 1029 | name = "paths" |
| 835 | version = "0.1.0" | 1030 | version = "0.0.0" |
| 836 | 1031 | ||
| 837 | [[package]] | 1032 | [[package]] |
| 838 | name = "percent-encoding" | 1033 | name = "percent-encoding" |
| @@ -842,9 +1037,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" | |||
| 842 | 1037 | ||
| 843 | [[package]] | 1038 | [[package]] |
| 844 | name = "perf-event" | 1039 | name = "perf-event" |
| 845 | version = "0.4.4" | 1040 | version = "0.4.5" |
| 846 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1041 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 847 | checksum = "76c42ba5d85a2f4472b99f475fb60cf336d9b4c85b1ea8bb300fef2e3c7c8f89" | 1042 | checksum = "273069d0b956939ba75e8b5663328b9b7f0dc2e262b3306c6be66c4d87e2240a" |
| 848 | dependencies = [ | 1043 | dependencies = [ |
| 849 | "libc", | 1044 | "libc", |
| 850 | "perf-event-open-sys", | 1045 | "perf-event-open-sys", |
| @@ -852,9 +1047,9 @@ dependencies = [ | |||
| 852 | 1047 | ||
| 853 | [[package]] | 1048 | [[package]] |
| 854 | name = "perf-event-open-sys" | 1049 | name = "perf-event-open-sys" |
| 855 | version = "0.3.1" | 1050 | version = "1.0.0" |
| 856 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1051 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 857 | checksum = "95db63e37862bc1b842135d2234ef9418f222cc660c6752f45e7cf9ddfb97f96" | 1052 | checksum = "66f37842e29d92d05872a3c0271ba6717842695ecb896cb2e147a825c804b207" |
| 858 | dependencies = [ | 1053 | dependencies = [ |
| 859 | "libc", | 1054 | "libc", |
| 860 | ] | 1055 | ] |
| @@ -871,9 +1066,9 @@ dependencies = [ | |||
| 871 | 1066 | ||
| 872 | [[package]] | 1067 | [[package]] |
| 873 | name = "pico-args" | 1068 | name = "pico-args" |
| 874 | version = "0.3.3" | 1069 | version = "0.3.4" |
| 875 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1070 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 876 | checksum = "1b1eee8b1f4966c8343d7ca0f5a8452cd35d5610a2e0efbe2a68cae44bef2046" | 1071 | checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1" |
| 877 | 1072 | ||
| 878 | [[package]] | 1073 | [[package]] |
| 879 | name = "plain" | 1074 | name = "plain" |
| @@ -891,362 +1086,97 @@ dependencies = [ | |||
| 891 | ] | 1086 | ] |
| 892 | 1087 | ||
| 893 | [[package]] | 1088 | [[package]] |
| 894 | name = "pulldown-cmark" | 1089 | name = "proc_macro_api" |
| 895 | version = "0.7.2" | 1090 | version = "0.0.0" |
| 896 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 897 | checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55" | ||
| 898 | dependencies = [ | ||
| 899 | "bitflags", | ||
| 900 | "memchr", | ||
| 901 | "unicase", | ||
| 902 | ] | ||
| 903 | |||
| 904 | [[package]] | ||
| 905 | name = "pulldown-cmark-to-cmark" | ||
| 906 | version = "5.0.0" | ||
| 907 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 908 | checksum = "32accf4473121d8c0b508ca5673363703762d6cc59cf25af1df48f653346f736" | ||
| 909 | dependencies = [ | ||
| 910 | "pulldown-cmark", | ||
| 911 | ] | ||
| 912 | |||
| 913 | [[package]] | ||
| 914 | name = "quote" | ||
| 915 | version = "1.0.7" | ||
| 916 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 917 | checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" | ||
| 918 | dependencies = [ | ||
| 919 | "proc-macro2", | ||
| 920 | ] | ||
| 921 | |||
| 922 | [[package]] | ||
| 923 | name = "ra_arena" | ||
| 924 | version = "0.1.0" | ||
| 925 | |||
| 926 | [[package]] | ||
| 927 | name = "ra_assists" | ||
| 928 | version = "0.1.0" | ||
| 929 | dependencies = [ | ||
| 930 | "either", | ||
| 931 | "itertools", | ||
| 932 | "ra_db", | ||
| 933 | "ra_fmt", | ||
| 934 | "ra_hir", | ||
| 935 | "ra_ide_db", | ||
| 936 | "ra_prof", | ||
| 937 | "ra_syntax", | ||
| 938 | "ra_text_edit", | ||
| 939 | "rustc-hash", | ||
| 940 | "stdx", | ||
| 941 | "test_utils", | ||
| 942 | ] | ||
| 943 | |||
| 944 | [[package]] | ||
| 945 | name = "ra_cfg" | ||
| 946 | version = "0.1.0" | ||
| 947 | dependencies = [ | ||
| 948 | "ra_mbe", | ||
| 949 | "ra_syntax", | ||
| 950 | "ra_tt", | ||
| 951 | "rustc-hash", | ||
| 952 | ] | ||
| 953 | |||
| 954 | [[package]] | ||
| 955 | name = "ra_db" | ||
| 956 | version = "0.1.0" | ||
| 957 | dependencies = [ | ||
| 958 | "ra_cfg", | ||
| 959 | "ra_prof", | ||
| 960 | "ra_syntax", | ||
| 961 | "ra_tt", | ||
| 962 | "rustc-hash", | ||
| 963 | "salsa", | ||
| 964 | "stdx", | ||
| 965 | "test_utils", | ||
| 966 | "vfs", | ||
| 967 | ] | ||
| 968 | |||
| 969 | [[package]] | ||
| 970 | name = "ra_fmt" | ||
| 971 | version = "0.1.0" | ||
| 972 | dependencies = [ | ||
| 973 | "itertools", | ||
| 974 | "ra_syntax", | ||
| 975 | ] | ||
| 976 | |||
| 977 | [[package]] | ||
| 978 | name = "ra_hir" | ||
| 979 | version = "0.1.0" | ||
| 980 | dependencies = [ | ||
| 981 | "arrayvec", | ||
| 982 | "either", | ||
| 983 | "itertools", | ||
| 984 | "log", | ||
| 985 | "ra_db", | ||
| 986 | "ra_hir_def", | ||
| 987 | "ra_hir_expand", | ||
| 988 | "ra_hir_ty", | ||
| 989 | "ra_prof", | ||
| 990 | "ra_syntax", | ||
| 991 | "ra_tt", | ||
| 992 | "rustc-hash", | ||
| 993 | "stdx", | ||
| 994 | "url", | ||
| 995 | ] | ||
| 996 | |||
| 997 | [[package]] | ||
| 998 | name = "ra_hir_def" | ||
| 999 | version = "0.1.0" | ||
| 1000 | dependencies = [ | ||
| 1001 | "anymap", | ||
| 1002 | "drop_bomb", | ||
| 1003 | "either", | ||
| 1004 | "expect", | ||
| 1005 | "fst", | ||
| 1006 | "indexmap", | ||
| 1007 | "itertools", | ||
| 1008 | "log", | ||
| 1009 | "once_cell", | ||
| 1010 | "ra_arena", | ||
| 1011 | "ra_cfg", | ||
| 1012 | "ra_db", | ||
| 1013 | "ra_hir_expand", | ||
| 1014 | "ra_mbe", | ||
| 1015 | "ra_prof", | ||
| 1016 | "ra_syntax", | ||
| 1017 | "ra_tt", | ||
| 1018 | "rustc-hash", | ||
| 1019 | "smallvec", | ||
| 1020 | "stdx", | ||
| 1021 | "test_utils", | ||
| 1022 | ] | ||
| 1023 | |||
| 1024 | [[package]] | ||
| 1025 | name = "ra_hir_expand" | ||
| 1026 | version = "0.1.0" | ||
| 1027 | dependencies = [ | ||
| 1028 | "either", | ||
| 1029 | "log", | ||
| 1030 | "ra_arena", | ||
| 1031 | "ra_db", | ||
| 1032 | "ra_mbe", | ||
| 1033 | "ra_parser", | ||
| 1034 | "ra_prof", | ||
| 1035 | "ra_syntax", | ||
| 1036 | "ra_tt", | ||
| 1037 | "rustc-hash", | ||
| 1038 | "test_utils", | ||
| 1039 | ] | ||
| 1040 | |||
| 1041 | [[package]] | ||
| 1042 | name = "ra_hir_ty" | ||
| 1043 | version = "0.1.0" | ||
| 1044 | dependencies = [ | ||
| 1045 | "arrayvec", | ||
| 1046 | "chalk-ir", | ||
| 1047 | "chalk-recursive", | ||
| 1048 | "chalk-solve", | ||
| 1049 | "ena", | ||
| 1050 | "expect", | ||
| 1051 | "itertools", | ||
| 1052 | "log", | ||
| 1053 | "ra_arena", | ||
| 1054 | "ra_db", | ||
| 1055 | "ra_hir_def", | ||
| 1056 | "ra_hir_expand", | ||
| 1057 | "ra_prof", | ||
| 1058 | "ra_syntax", | ||
| 1059 | "rustc-hash", | ||
| 1060 | "scoped-tls", | ||
| 1061 | "smallvec", | ||
| 1062 | "stdx", | ||
| 1063 | "test_utils", | ||
| 1064 | "tracing", | ||
| 1065 | "tracing-subscriber", | ||
| 1066 | "tracing-tree", | ||
| 1067 | ] | ||
| 1068 | |||
| 1069 | [[package]] | ||
| 1070 | name = "ra_ide" | ||
| 1071 | version = "0.1.0" | ||
| 1072 | dependencies = [ | ||
| 1073 | "either", | ||
| 1074 | "expect", | ||
| 1075 | "indexmap", | ||
| 1076 | "itertools", | ||
| 1077 | "log", | ||
| 1078 | "oorandom", | ||
| 1079 | "pulldown-cmark", | ||
| 1080 | "pulldown-cmark-to-cmark", | ||
| 1081 | "ra_assists", | ||
| 1082 | "ra_cfg", | ||
| 1083 | "ra_db", | ||
| 1084 | "ra_fmt", | ||
| 1085 | "ra_hir", | ||
| 1086 | "ra_ide_db", | ||
| 1087 | "ra_prof", | ||
| 1088 | "ra_ssr", | ||
| 1089 | "ra_syntax", | ||
| 1090 | "ra_text_edit", | ||
| 1091 | "rustc-hash", | ||
| 1092 | "stdx", | ||
| 1093 | "test_utils", | ||
| 1094 | ] | ||
| 1095 | |||
| 1096 | [[package]] | ||
| 1097 | name = "ra_ide_db" | ||
| 1098 | version = "0.1.0" | ||
| 1099 | dependencies = [ | ||
| 1100 | "either", | ||
| 1101 | "fst", | ||
| 1102 | "log", | ||
| 1103 | "once_cell", | ||
| 1104 | "ra_db", | ||
| 1105 | "ra_hir", | ||
| 1106 | "ra_prof", | ||
| 1107 | "ra_syntax", | ||
| 1108 | "ra_text_edit", | ||
| 1109 | "rayon", | ||
| 1110 | "rustc-hash", | ||
| 1111 | "stdx", | ||
| 1112 | "test_utils", | ||
| 1113 | ] | ||
| 1114 | |||
| 1115 | [[package]] | ||
| 1116 | name = "ra_mbe" | ||
| 1117 | version = "0.1.0" | ||
| 1118 | dependencies = [ | ||
| 1119 | "log", | ||
| 1120 | "ra_parser", | ||
| 1121 | "ra_syntax", | ||
| 1122 | "ra_tt", | ||
| 1123 | "rustc-hash", | ||
| 1124 | "smallvec", | ||
| 1125 | "test_utils", | ||
| 1126 | ] | ||
| 1127 | |||
| 1128 | [[package]] | ||
| 1129 | name = "ra_parser" | ||
| 1130 | version = "0.1.0" | ||
| 1131 | dependencies = [ | ||
| 1132 | "drop_bomb", | ||
| 1133 | ] | ||
| 1134 | |||
| 1135 | [[package]] | ||
| 1136 | name = "ra_proc_macro" | ||
| 1137 | version = "0.1.0" | ||
| 1138 | dependencies = [ | 1091 | dependencies = [ |
| 1139 | "crossbeam-channel", | 1092 | "crossbeam-channel", |
| 1140 | "jod-thread", | 1093 | "jod-thread", |
| 1141 | "log", | 1094 | "log", |
| 1142 | "ra_tt", | ||
| 1143 | "serde", | 1095 | "serde", |
| 1144 | "serde_json", | 1096 | "serde_json", |
| 1097 | "tt", | ||
| 1145 | ] | 1098 | ] |
| 1146 | 1099 | ||
| 1147 | [[package]] | 1100 | [[package]] |
| 1148 | name = "ra_proc_macro_srv" | 1101 | name = "proc_macro_srv" |
| 1149 | version = "0.1.0" | 1102 | version = "0.0.0" |
| 1150 | dependencies = [ | 1103 | dependencies = [ |
| 1151 | "cargo_metadata", | 1104 | "cargo_metadata", |
| 1152 | "difference", | 1105 | "difference", |
| 1153 | "goblin", | 1106 | "goblin", |
| 1154 | "libloading", | 1107 | "libloading", |
| 1108 | "mbe", | ||
| 1155 | "memmap", | 1109 | "memmap", |
| 1156 | "ra_mbe", | 1110 | "proc_macro_api", |
| 1157 | "ra_proc_macro", | 1111 | "proc_macro_test", |
| 1158 | "ra_toolchain", | ||
| 1159 | "ra_tt", | ||
| 1160 | "serde_derive", | 1112 | "serde_derive", |
| 1161 | "test_utils", | 1113 | "test_utils", |
| 1114 | "toolchain", | ||
| 1115 | "tt", | ||
| 1162 | ] | 1116 | ] |
| 1163 | 1117 | ||
| 1164 | [[package]] | 1118 | [[package]] |
| 1165 | name = "ra_prof" | 1119 | name = "proc_macro_test" |
| 1166 | version = "0.1.0" | 1120 | version = "0.0.0" |
| 1121 | |||
| 1122 | [[package]] | ||
| 1123 | name = "profile" | ||
| 1124 | version = "0.0.0" | ||
| 1167 | dependencies = [ | 1125 | dependencies = [ |
| 1126 | "arena", | ||
| 1168 | "backtrace", | 1127 | "backtrace", |
| 1169 | "cfg-if", | 1128 | "cfg-if", |
| 1170 | "libc", | 1129 | "libc", |
| 1171 | "once_cell", | 1130 | "once_cell", |
| 1172 | "perf-event", | 1131 | "perf-event", |
| 1173 | "ra_arena", | ||
| 1174 | ] | 1132 | ] |
| 1175 | 1133 | ||
| 1176 | [[package]] | 1134 | [[package]] |
| 1177 | name = "ra_project_model" | 1135 | name = "project_model" |
| 1178 | version = "0.1.0" | 1136 | version = "0.0.0" |
| 1179 | dependencies = [ | 1137 | dependencies = [ |
| 1180 | "anyhow", | 1138 | "anyhow", |
| 1139 | "arena", | ||
| 1140 | "base_db", | ||
| 1181 | "cargo_metadata", | 1141 | "cargo_metadata", |
| 1142 | "cfg", | ||
| 1182 | "log", | 1143 | "log", |
| 1183 | "paths", | 1144 | "paths", |
| 1184 | "ra_arena", | 1145 | "proc_macro_api", |
| 1185 | "ra_cfg", | ||
| 1186 | "ra_db", | ||
| 1187 | "ra_proc_macro", | ||
| 1188 | "ra_toolchain", | ||
| 1189 | "rustc-hash", | 1146 | "rustc-hash", |
| 1190 | "serde", | 1147 | "serde", |
| 1191 | "serde_json", | 1148 | "serde_json", |
| 1192 | "stdx", | 1149 | "stdx", |
| 1150 | "toolchain", | ||
| 1193 | ] | 1151 | ] |
| 1194 | 1152 | ||
| 1195 | [[package]] | 1153 | [[package]] |
| 1196 | name = "ra_ssr" | 1154 | name = "pulldown-cmark" |
| 1197 | version = "0.1.0" | 1155 | version = "0.7.2" |
| 1198 | dependencies = [ | 1156 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1199 | "expect", | 1157 | checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55" |
| 1200 | "ra_db", | ||
| 1201 | "ra_hir", | ||
| 1202 | "ra_ide_db", | ||
| 1203 | "ra_syntax", | ||
| 1204 | "ra_text_edit", | ||
| 1205 | "rustc-hash", | ||
| 1206 | "test_utils", | ||
| 1207 | ] | ||
| 1208 | |||
| 1209 | [[package]] | ||
| 1210 | name = "ra_syntax" | ||
| 1211 | version = "0.1.0" | ||
| 1212 | dependencies = [ | ||
| 1213 | "arrayvec", | ||
| 1214 | "expect", | ||
| 1215 | "itertools", | ||
| 1216 | "once_cell", | ||
| 1217 | "ra_parser", | ||
| 1218 | "ra_text_edit", | ||
| 1219 | "rayon", | ||
| 1220 | "rowan", | ||
| 1221 | "rustc-ap-rustc_lexer", | ||
| 1222 | "rustc-hash", | ||
| 1223 | "serde", | ||
| 1224 | "smol_str", | ||
| 1225 | "stdx", | ||
| 1226 | "test_utils", | ||
| 1227 | "walkdir", | ||
| 1228 | ] | ||
| 1229 | |||
| 1230 | [[package]] | ||
| 1231 | name = "ra_text_edit" | ||
| 1232 | version = "0.1.0" | ||
| 1233 | dependencies = [ | 1158 | dependencies = [ |
| 1234 | "text-size", | 1159 | "bitflags", |
| 1160 | "memchr", | ||
| 1161 | "unicase", | ||
| 1235 | ] | 1162 | ] |
| 1236 | 1163 | ||
| 1237 | [[package]] | 1164 | [[package]] |
| 1238 | name = "ra_toolchain" | 1165 | name = "pulldown-cmark-to-cmark" |
| 1239 | version = "0.1.0" | 1166 | version = "5.0.0" |
| 1167 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1168 | checksum = "32accf4473121d8c0b508ca5673363703762d6cc59cf25af1df48f653346f736" | ||
| 1240 | dependencies = [ | 1169 | dependencies = [ |
| 1241 | "home", | 1170 | "pulldown-cmark", |
| 1242 | ] | 1171 | ] |
| 1243 | 1172 | ||
| 1244 | [[package]] | 1173 | [[package]] |
| 1245 | name = "ra_tt" | 1174 | name = "quote" |
| 1246 | version = "0.1.0" | 1175 | version = "1.0.7" |
| 1176 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1177 | checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" | ||
| 1247 | dependencies = [ | 1178 | dependencies = [ |
| 1248 | "smol_str", | 1179 | "proc-macro2", |
| 1249 | "stdx", | ||
| 1250 | ] | 1180 | ] |
| 1251 | 1181 | ||
| 1252 | [[package]] | 1182 | [[package]] |
| @@ -1286,10 +1216,7 @@ version = "1.3.9" | |||
| 1286 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1216 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1287 | checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" | 1217 | checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" |
| 1288 | dependencies = [ | 1218 | dependencies = [ |
| 1289 | "aho-corasick", | ||
| 1290 | "memchr", | ||
| 1291 | "regex-syntax", | 1219 | "regex-syntax", |
| 1292 | "thread_local", | ||
| 1293 | ] | 1220 | ] |
| 1294 | 1221 | ||
| 1295 | [[package]] | 1222 | [[package]] |
| @@ -1322,45 +1249,45 @@ dependencies = [ | |||
| 1322 | 1249 | ||
| 1323 | [[package]] | 1250 | [[package]] |
| 1324 | name = "rust-analyzer" | 1251 | name = "rust-analyzer" |
| 1325 | version = "0.1.0" | 1252 | version = "0.0.0" |
| 1326 | dependencies = [ | 1253 | dependencies = [ |
| 1327 | "anyhow", | 1254 | "anyhow", |
| 1255 | "base_db", | ||
| 1256 | "cfg", | ||
| 1328 | "crossbeam-channel", | 1257 | "crossbeam-channel", |
| 1329 | "env_logger", | 1258 | "env_logger", |
| 1330 | "expect", | 1259 | "expect-test", |
| 1331 | "flycheck", | 1260 | "flycheck", |
| 1261 | "hir", | ||
| 1262 | "hir_def", | ||
| 1263 | "hir_ty", | ||
| 1264 | "ide", | ||
| 1265 | "ide_db", | ||
| 1332 | "itertools", | 1266 | "itertools", |
| 1333 | "jod-thread", | 1267 | "jod-thread", |
| 1334 | "log", | 1268 | "log", |
| 1335 | "lsp-server", | 1269 | "lsp-server", |
| 1336 | "lsp-types", | 1270 | "lsp-types", |
| 1271 | "mbe", | ||
| 1337 | "mimalloc", | 1272 | "mimalloc", |
| 1338 | "oorandom", | 1273 | "oorandom", |
| 1339 | "parking_lot", | 1274 | "parking_lot", |
| 1340 | "pico-args", | 1275 | "pico-args", |
| 1341 | "ra_cfg", | 1276 | "proc_macro_srv", |
| 1342 | "ra_db", | 1277 | "profile", |
| 1343 | "ra_hir", | 1278 | "project_model", |
| 1344 | "ra_hir_def", | ||
| 1345 | "ra_hir_ty", | ||
| 1346 | "ra_ide", | ||
| 1347 | "ra_ide_db", | ||
| 1348 | "ra_mbe", | ||
| 1349 | "ra_proc_macro_srv", | ||
| 1350 | "ra_prof", | ||
| 1351 | "ra_project_model", | ||
| 1352 | "ra_ssr", | ||
| 1353 | "ra_syntax", | ||
| 1354 | "ra_text_edit", | ||
| 1355 | "ra_toolchain", | ||
| 1356 | "ra_tt", | ||
| 1357 | "rayon", | 1279 | "rayon", |
| 1358 | "rustc-hash", | 1280 | "rustc-hash", |
| 1359 | "serde", | 1281 | "serde", |
| 1360 | "serde_json", | 1282 | "serde_json", |
| 1283 | "ssr", | ||
| 1361 | "stdx", | 1284 | "stdx", |
| 1285 | "syntax", | ||
| 1362 | "test_utils", | 1286 | "test_utils", |
| 1287 | "text_edit", | ||
| 1363 | "threadpool", | 1288 | "threadpool", |
| 1289 | "toolchain", | ||
| 1290 | "tt", | ||
| 1364 | "vfs", | 1291 | "vfs", |
| 1365 | "vfs-notify", | 1292 | "vfs-notify", |
| 1366 | "winapi 0.3.9", | 1293 | "winapi 0.3.9", |
| @@ -1368,9 +1295,9 @@ dependencies = [ | |||
| 1368 | 1295 | ||
| 1369 | [[package]] | 1296 | [[package]] |
| 1370 | name = "rustc-ap-rustc_lexer" | 1297 | name = "rustc-ap-rustc_lexer" |
| 1371 | version = "671.0.0" | 1298 | version = "673.0.0" |
| 1372 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1299 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1373 | checksum = "22e1221f3bfa2943c942cf8da319ab2346887f8757778c29c7f1822cd27b521f" | 1300 | checksum = "f6b71fa1285bdefe5fb61e59b63d6cc246abf337f4acafdd620d721bc488e671" |
| 1374 | dependencies = [ | 1301 | dependencies = [ |
| 1375 | "unicode-xid", | 1302 | "unicode-xid", |
| 1376 | ] | 1303 | ] |
| @@ -1395,9 +1322,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" | |||
| 1395 | 1322 | ||
| 1396 | [[package]] | 1323 | [[package]] |
| 1397 | name = "salsa" | 1324 | name = "salsa" |
| 1398 | version = "0.15.1" | 1325 | version = "0.15.2" |
| 1399 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1326 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1400 | checksum = "d4cdc109fcc9e9450c7ef47fb7474e99bffd51799da03ed0a6c7f0e2cb3848a6" | 1327 | checksum = "9ab29056d4fb4048a5f0d169c9b6e5526160c9ec37aded5a6879c2c9c445a8e4" |
| 1401 | dependencies = [ | 1328 | dependencies = [ |
| 1402 | "crossbeam-utils", | 1329 | "crossbeam-utils", |
| 1403 | "indexmap", | 1330 | "indexmap", |
| @@ -1412,9 +1339,9 @@ dependencies = [ | |||
| 1412 | 1339 | ||
| 1413 | [[package]] | 1340 | [[package]] |
| 1414 | name = "salsa-macros" | 1341 | name = "salsa-macros" |
| 1415 | version = "0.15.0" | 1342 | version = "0.15.2" |
| 1416 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1343 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1417 | checksum = "2c280ac85b15ac214b86ac4b407626a48e6a1c4f90769a582fec74aa57942b9f" | 1344 | checksum = "a1c3aec007c63c4ed4cd7a018529fb0b5575c4562575fc6a40d6cd2ae0b792ef" |
| 1418 | dependencies = [ | 1345 | dependencies = [ |
| 1419 | "heck", | 1346 | "heck", |
| 1420 | "proc-macro2", | 1347 | "proc-macro2", |
| @@ -1481,18 +1408,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" | |||
| 1481 | 1408 | ||
| 1482 | [[package]] | 1409 | [[package]] |
| 1483 | name = "serde" | 1410 | name = "serde" |
| 1484 | version = "1.0.114" | 1411 | version = "1.0.115" |
| 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1412 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1486 | checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" | 1413 | checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5" |
| 1487 | dependencies = [ | 1414 | dependencies = [ |
| 1488 | "serde_derive", | 1415 | "serde_derive", |
| 1489 | ] | 1416 | ] |
| 1490 | 1417 | ||
| 1491 | [[package]] | 1418 | [[package]] |
| 1492 | name = "serde_derive" | 1419 | name = "serde_derive" |
| 1493 | version = "1.0.114" | 1420 | version = "1.0.115" |
| 1494 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1421 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1495 | checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" | 1422 | checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48" |
| 1496 | dependencies = [ | 1423 | dependencies = [ |
| 1497 | "proc-macro2", | 1424 | "proc-macro2", |
| 1498 | "quote", | 1425 | "quote", |
| @@ -1538,9 +1465,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" | |||
| 1538 | 1465 | ||
| 1539 | [[package]] | 1466 | [[package]] |
| 1540 | name = "smallvec" | 1467 | name = "smallvec" |
| 1541 | version = "1.4.1" | 1468 | version = "1.4.2" |
| 1542 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1469 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1543 | checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" | 1470 | checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" |
| 1544 | 1471 | ||
| 1545 | [[package]] | 1472 | [[package]] |
| 1546 | name = "smol_str" | 1473 | name = "smol_str" |
| @@ -1552,14 +1479,29 @@ dependencies = [ | |||
| 1552 | ] | 1479 | ] |
| 1553 | 1480 | ||
| 1554 | [[package]] | 1481 | [[package]] |
| 1482 | name = "ssr" | ||
| 1483 | version = "0.0.0" | ||
| 1484 | dependencies = [ | ||
| 1485 | "base_db", | ||
| 1486 | "expect-test", | ||
| 1487 | "hir", | ||
| 1488 | "ide_db", | ||
| 1489 | "itertools", | ||
| 1490 | "rustc-hash", | ||
| 1491 | "syntax", | ||
| 1492 | "test_utils", | ||
| 1493 | "text_edit", | ||
| 1494 | ] | ||
| 1495 | |||
| 1496 | [[package]] | ||
| 1555 | name = "stdx" | 1497 | name = "stdx" |
| 1556 | version = "0.1.0" | 1498 | version = "0.0.0" |
| 1557 | 1499 | ||
| 1558 | [[package]] | 1500 | [[package]] |
| 1559 | name = "syn" | 1501 | name = "syn" |
| 1560 | version = "1.0.36" | 1502 | version = "1.0.38" |
| 1561 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1503 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1562 | checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" | 1504 | checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" |
| 1563 | dependencies = [ | 1505 | dependencies = [ |
| 1564 | "proc-macro2", | 1506 | "proc-macro2", |
| 1565 | "quote", | 1507 | "quote", |
| @@ -1579,6 +1521,27 @@ dependencies = [ | |||
| 1579 | ] | 1521 | ] |
| 1580 | 1522 | ||
| 1581 | [[package]] | 1523 | [[package]] |
| 1524 | name = "syntax" | ||
| 1525 | version = "0.0.0" | ||
| 1526 | dependencies = [ | ||
| 1527 | "arrayvec", | ||
| 1528 | "expect-test", | ||
| 1529 | "itertools", | ||
| 1530 | "once_cell", | ||
| 1531 | "parser", | ||
| 1532 | "rayon", | ||
| 1533 | "rowan", | ||
| 1534 | "rustc-ap-rustc_lexer", | ||
| 1535 | "rustc-hash", | ||
| 1536 | "serde", | ||
| 1537 | "smol_str", | ||
| 1538 | "stdx", | ||
| 1539 | "test_utils", | ||
| 1540 | "text_edit", | ||
| 1541 | "walkdir", | ||
| 1542 | ] | ||
| 1543 | |||
| 1544 | [[package]] | ||
| 1582 | name = "termcolor" | 1545 | name = "termcolor" |
| 1583 | version = "1.1.0" | 1546 | version = "1.1.0" |
| 1584 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1547 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1589,7 +1552,7 @@ dependencies = [ | |||
| 1589 | 1552 | ||
| 1590 | [[package]] | 1553 | [[package]] |
| 1591 | name = "test_utils" | 1554 | name = "test_utils" |
| 1592 | version = "0.1.0" | 1555 | version = "0.0.0" |
| 1593 | dependencies = [ | 1556 | dependencies = [ |
| 1594 | "difference", | 1557 | "difference", |
| 1595 | "rustc-hash", | 1558 | "rustc-hash", |
| @@ -1605,6 +1568,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 1605 | checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" | 1568 | checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" |
| 1606 | 1569 | ||
| 1607 | [[package]] | 1570 | [[package]] |
| 1571 | name = "text_edit" | ||
| 1572 | version = "0.0.0" | ||
| 1573 | dependencies = [ | ||
| 1574 | "text-size", | ||
| 1575 | ] | ||
| 1576 | |||
| 1577 | [[package]] | ||
| 1608 | name = "thin-dst" | 1578 | name = "thin-dst" |
| 1609 | version = "1.1.0" | 1579 | version = "1.1.0" |
| 1610 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1580 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1640,15 +1610,22 @@ dependencies = [ | |||
| 1640 | 1610 | ||
| 1641 | [[package]] | 1611 | [[package]] |
| 1642 | name = "tinyvec" | 1612 | name = "tinyvec" |
| 1643 | version = "0.3.3" | 1613 | version = "0.3.4" |
| 1644 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1614 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1645 | checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" | 1615 | checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" |
| 1616 | |||
| 1617 | [[package]] | ||
| 1618 | name = "toolchain" | ||
| 1619 | version = "0.0.0" | ||
| 1620 | dependencies = [ | ||
| 1621 | "home", | ||
| 1622 | ] | ||
| 1646 | 1623 | ||
| 1647 | [[package]] | 1624 | [[package]] |
| 1648 | name = "tracing" | 1625 | name = "tracing" |
| 1649 | version = "0.1.17" | 1626 | version = "0.1.19" |
| 1650 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1627 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1651 | checksum = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9" | 1628 | checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" |
| 1652 | dependencies = [ | 1629 | dependencies = [ |
| 1653 | "cfg-if", | 1630 | "cfg-if", |
| 1654 | "tracing-attributes", | 1631 | "tracing-attributes", |
| @@ -1657,9 +1634,9 @@ dependencies = [ | |||
| 1657 | 1634 | ||
| 1658 | [[package]] | 1635 | [[package]] |
| 1659 | name = "tracing-attributes" | 1636 | name = "tracing-attributes" |
| 1660 | version = "0.1.9" | 1637 | version = "0.1.11" |
| 1661 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1638 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1662 | checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" | 1639 | checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" |
| 1663 | dependencies = [ | 1640 | dependencies = [ |
| 1664 | "proc-macro2", | 1641 | "proc-macro2", |
| 1665 | "quote", | 1642 | "quote", |
| @@ -1668,9 +1645,9 @@ dependencies = [ | |||
| 1668 | 1645 | ||
| 1669 | [[package]] | 1646 | [[package]] |
| 1670 | name = "tracing-core" | 1647 | name = "tracing-core" |
| 1671 | version = "0.1.11" | 1648 | version = "0.1.14" |
| 1672 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1649 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1673 | checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f" | 1650 | checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545" |
| 1674 | dependencies = [ | 1651 | dependencies = [ |
| 1675 | "lazy_static", | 1652 | "lazy_static", |
| 1676 | ] | 1653 | ] |
| @@ -1698,9 +1675,9 @@ dependencies = [ | |||
| 1698 | 1675 | ||
| 1699 | [[package]] | 1676 | [[package]] |
| 1700 | name = "tracing-subscriber" | 1677 | name = "tracing-subscriber" |
| 1701 | version = "0.2.9" | 1678 | version = "0.2.11" |
| 1702 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1679 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1703 | checksum = "e4f5dd7095c2481b7b3cbed71c8de53085fb3542bc3c2b4c73cba43e8f11c7ba" | 1680 | checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40" |
| 1704 | dependencies = [ | 1681 | dependencies = [ |
| 1705 | "ansi_term", | 1682 | "ansi_term", |
| 1706 | "chrono", | 1683 | "chrono", |
| @@ -1711,6 +1688,7 @@ dependencies = [ | |||
| 1711 | "serde_json", | 1688 | "serde_json", |
| 1712 | "sharded-slab", | 1689 | "sharded-slab", |
| 1713 | "smallvec", | 1690 | "smallvec", |
| 1691 | "thread_local", | ||
| 1714 | "tracing-core", | 1692 | "tracing-core", |
| 1715 | "tracing-log", | 1693 | "tracing-log", |
| 1716 | "tracing-serde", | 1694 | "tracing-serde", |
| @@ -1718,9 +1696,9 @@ dependencies = [ | |||
| 1718 | 1696 | ||
| 1719 | [[package]] | 1697 | [[package]] |
| 1720 | name = "tracing-tree" | 1698 | name = "tracing-tree" |
| 1721 | version = "0.1.4" | 1699 | version = "0.1.5" |
| 1722 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1700 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1723 | checksum = "37ee7f0f53ed2093971a698db799ef56a2dfd89b32e3aeb5165f0e637a02be04" | 1701 | checksum = "e1a3dc4774db3a6b2d66a4f8d8de670e874ec3ed55615860c994927419b32c5f" |
| 1724 | dependencies = [ | 1702 | dependencies = [ |
| 1725 | "ansi_term", | 1703 | "ansi_term", |
| 1726 | "atty", | 1704 | "atty", |
| @@ -1731,10 +1709,18 @@ dependencies = [ | |||
| 1731 | ] | 1709 | ] |
| 1732 | 1710 | ||
| 1733 | [[package]] | 1711 | [[package]] |
| 1712 | name = "tt" | ||
| 1713 | version = "0.0.0" | ||
| 1714 | dependencies = [ | ||
| 1715 | "smol_str", | ||
| 1716 | "stdx", | ||
| 1717 | ] | ||
| 1718 | |||
| 1719 | [[package]] | ||
| 1734 | name = "ungrammar" | 1720 | name = "ungrammar" |
| 1735 | version = "0.1.0" | 1721 | version = "1.1.2" |
| 1736 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1722 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1737 | checksum = "0ee12e4891ab3acc2d95d5023022ace22020247bb8a8d1ece875a443f7dab37d" | 1723 | checksum = "bab6142ac77be714b1ea78faca6efaed5478c50724786b0fe80d8528d10692b3" |
| 1738 | 1724 | ||
| 1739 | [[package]] | 1725 | [[package]] |
| 1740 | name = "unicase" | 1726 | name = "unicase" |
| @@ -1795,7 +1781,7 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" | |||
| 1795 | 1781 | ||
| 1796 | [[package]] | 1782 | [[package]] |
| 1797 | name = "vfs" | 1783 | name = "vfs" |
| 1798 | version = "0.1.0" | 1784 | version = "0.0.0" |
| 1799 | dependencies = [ | 1785 | dependencies = [ |
| 1800 | "fst", | 1786 | "fst", |
| 1801 | "paths", | 1787 | "paths", |
| @@ -1804,7 +1790,7 @@ dependencies = [ | |||
| 1804 | 1790 | ||
| 1805 | [[package]] | 1791 | [[package]] |
| 1806 | name = "vfs-notify" | 1792 | name = "vfs-notify" |
| 1807 | version = "0.1.0" | 1793 | version = "0.0.0" |
| 1808 | dependencies = [ | 1794 | dependencies = [ |
| 1809 | "crossbeam-channel", | 1795 | "crossbeam-channel", |
| 1810 | "jod-thread", | 1796 | "jod-thread", |
| @@ -1871,6 +1857,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 1871 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | 1857 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
| 1872 | 1858 | ||
| 1873 | [[package]] | 1859 | [[package]] |
| 1860 | name = "write-json" | ||
| 1861 | version = "0.1.2" | ||
| 1862 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1863 | checksum = "06069a848f95fceae3e5e03c0ddc8cb78452b56654ee0c8e68f938cf790fb9e3" | ||
| 1864 | |||
| 1865 | [[package]] | ||
| 1874 | name = "ws2_32-sys" | 1866 | name = "ws2_32-sys" |
| 1875 | version = "0.2.1" | 1867 | version = "0.2.1" |
| 1876 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1868 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| @@ -1891,4 +1883,5 @@ dependencies = [ | |||
| 1891 | "quote", | 1883 | "quote", |
| 1892 | "ungrammar", | 1884 | "ungrammar", |
| 1893 | "walkdir", | 1885 | "walkdir", |
| 1886 | "write-json", | ||
| 1894 | ] | 1887 | ] |
diff --git a/Cargo.toml b/Cargo.toml index 612e6809f..218581d9d 100644 --- a/Cargo.toml +++ b/Cargo.toml | |||
| @@ -2,37 +2,34 @@ | |||
| 2 | members = [ "crates/*", "xtask/" ] | 2 | members = [ "crates/*", "xtask/" ] |
| 3 | 3 | ||
| 4 | [profile.dev] | 4 | [profile.dev] |
| 5 | # disabling debug info speeds up builds a bunch, | 5 | # Disabling debug info speeds up builds a bunch, |
| 6 | # and we don't rely on it for debugging that much. | 6 | # and we don't rely on it for debugging that much. |
| 7 | debug = 0 | 7 | debug = 0 |
| 8 | 8 | ||
| 9 | [profile.dev.package] | ||
| 10 | # These speed up local tests. | ||
| 11 | rowan.opt-level = 3 | ||
| 12 | rustc-hash.opt-level = 3 | ||
| 13 | smol_str.opt-level = 3 | ||
| 14 | text-size.opt-level = 3 | ||
| 15 | # This speeds up `cargo xtask dist`. | ||
| 16 | miniz_oxide.opt-level = 3 | ||
| 17 | |||
| 9 | [profile.release] | 18 | [profile.release] |
| 10 | incremental = true | 19 | incremental = true |
| 11 | debug = 0 # set this to 1 or 2 to get more useful backtraces in debugger | 20 | debug = 0 # Set this to 1 or 2 to get more useful backtraces in debugger. |
| 12 | |||
| 13 | # ideally, we would use `build-override` here, but some crates are also | ||
| 14 | # needed at run-time and we end up compiling them twice | ||
| 15 | [profile.release.package.proc-macro2] | ||
| 16 | opt-level = 0 | ||
| 17 | [profile.release.package.quote] | ||
| 18 | opt-level = 0 | ||
| 19 | [profile.release.package.syn] | ||
| 20 | opt-level = 0 | ||
| 21 | [profile.release.package.serde_derive] | ||
| 22 | opt-level = 0 | ||
| 23 | [profile.release.package.chalk-derive] | ||
| 24 | opt-level = 0 | ||
| 25 | [profile.release.package.salsa-macros] | ||
| 26 | opt-level = 0 | ||
| 27 | [profile.release.package.tracing-attributes] | ||
| 28 | opt-level = 0 | ||
| 29 | [profile.release.package.xtask] | ||
| 30 | opt-level = 0 | ||
| 31 | 21 | ||
| 32 | # Gzipping the artifacts is up to 10 times faster with optimizations (`cargo xtask dist`). | 22 | # Ideally, we would use `build-override` here, but some crates are also |
| 33 | # `miniz_oxide` is the direct dependency of `flate2` which does all the heavy lifting | 23 | # needed at run-time and we end up compiling them twice. |
| 34 | [profile.dev.package.miniz_oxide] | 24 | [profile.release.package] |
| 35 | opt-level = 3 | 25 | chalk-derive.opt-level = 0 |
| 26 | proc-macro2.opt-level = 0 | ||
| 27 | quote.opt-level = 0 | ||
| 28 | salsa-macros.opt-level = 0 | ||
| 29 | serde_derive.opt-level = 0 | ||
| 30 | syn.opt-level = 0 | ||
| 31 | tracing-attributes.opt-level = 0 | ||
| 32 | xtask.opt-level = 0 | ||
| 36 | 33 | ||
| 37 | [patch.'crates-io'] | 34 | [patch.'crates-io'] |
| 38 | # rowan = { path = "../rowan" } | 35 | # rowan = { path = "../rowan" } |
| @@ -39,7 +39,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 | |||
| 39 | 39 | ||
| 40 | * Website: https://rust-analyzer.github.io/ | 40 | * Website: https://rust-analyzer.github.io/ |
| 41 | * Metrics: https://rust-analyzer.github.io/metrics/ | 41 | * Metrics: https://rust-analyzer.github.io/metrics/ |
| 42 | * API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ | 42 | * API docs: https://rust-analyzer.github.io/rust-analyzer/ide/ |
| 43 | 43 | ||
| 44 | ## License | 44 | ## License |
| 45 | 45 | ||
| @@ -1,9 +1,8 @@ | |||
| 1 | status = [ | 1 | status = [ |
| 2 | "Rust (ubuntu-latest)", | 2 | "Rust (ubuntu-latest)", |
| 3 | "Rust (windows-latest)", | 3 | "Rust (windows-latest)", |
| 4 | "Rust (macos-latest)", | 4 | # "Rust (macos-latest)", |
| 5 | "TypeScript (ubuntu-latest)", | 5 | "TypeScript (ubuntu-latest)", |
| 6 | "TypeScript (windows-latest)", | 6 | "TypeScript (windows-latest)", |
| 7 | "TypeScript (macos-latest)", | ||
| 8 | ] | 7 | ] |
| 9 | delete_merged_branches = true | 8 | delete_merged_branches = true |
diff --git a/crates/arena/Cargo.toml b/crates/arena/Cargo.toml new file mode 100644 index 000000000..f2bb5cc45 --- /dev/null +++ b/crates/arena/Cargo.toml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | [package] | ||
| 2 | name = "arena" | ||
| 3 | version = "0.0.0" | ||
| 4 | license = "MIT OR Apache-2.0" | ||
| 5 | authors = ["rust-analyzer developers"] | ||
| 6 | edition = "2018" | ||
| 7 | |||
| 8 | [lib] | ||
| 9 | doctest = false | ||
diff --git a/crates/ra_arena/src/lib.rs b/crates/arena/src/lib.rs index 3169aa5b8..3169aa5b8 100644 --- a/crates/ra_arena/src/lib.rs +++ b/crates/arena/src/lib.rs | |||
diff --git a/crates/ra_arena/src/map.rs b/crates/arena/src/map.rs index 0f33907c0..0f33907c0 100644 --- a/crates/ra_arena/src/map.rs +++ b/crates/arena/src/map.rs | |||
diff --git a/crates/assists/Cargo.toml b/crates/assists/Cargo.toml new file mode 100644 index 000000000..a560a35c7 --- /dev/null +++ b/crates/assists/Cargo.toml | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | [package] | ||
| 2 | name = "assists" | ||
| 3 | version = "0.0.0" | ||
| 4 | license = "MIT OR Apache-2.0" | ||
| 5 | authors = ["rust-analyzer developers"] | ||
| 6 | edition = "2018" | ||
| 7 | |||
| 8 | [lib] | ||
| 9 | doctest = false | ||
| 10 | |||
| 11 | [dependencies] | ||
| 12 | rustc-hash = "1.1.0" | ||
| 13 | itertools = "0.9.0" | ||
| 14 | either = "1.5.3" | ||
| 15 | |||
| 16 | stdx = { path = "../stdx" } | ||
| 17 | syntax = { path = "../syntax" } | ||
| 18 | text_edit = { path = "../text_edit" } | ||
| 19 | profile = { path = "../profile" } | ||
| 20 | base_db = { path = "../base_db" } | ||
| 21 | ide_db = { path = "../ide_db" } | ||
| 22 | hir = { path = "../hir" } | ||
| 23 | test_utils = { path = "../test_utils" } | ||
diff --git a/crates/ra_assists/src/assist_config.rs b/crates/assists/src/assist_config.rs index cda2abfb9..cda2abfb9 100644 --- a/crates/ra_assists/src/assist_config.rs +++ b/crates/assists/src/assist_config.rs | |||
diff --git a/crates/assists/src/assist_context.rs b/crates/assists/src/assist_context.rs new file mode 100644 index 000000000..11c171fc2 --- /dev/null +++ b/crates/assists/src/assist_context.rs | |||
| @@ -0,0 +1,293 @@ | |||
| 1 | //! See `AssistContext` | ||
| 2 | |||
| 3 | use std::mem; | ||
| 4 | |||
| 5 | use algo::find_covering_element; | ||
| 6 | use base_db::{FileId, FileRange}; | ||
| 7 | use hir::Semantics; | ||
| 8 | use ide_db::{ | ||
| 9 | label::Label, | ||
| 10 | source_change::{SourceChange, SourceFileEdit}, | ||
| 11 | RootDatabase, | ||
| 12 | }; | ||
| 13 | use syntax::{ | ||
| 14 | algo::{self, find_node_at_offset, SyntaxRewriter}, | ||
| 15 | AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxToken, TextRange, TextSize, | ||
| 16 | TokenAtOffset, | ||
| 17 | }; | ||
| 18 | use text_edit::{TextEdit, TextEditBuilder}; | ||
| 19 | |||
| 20 | use crate::{ | ||
| 21 | assist_config::{AssistConfig, SnippetCap}, | ||
| 22 | Assist, AssistId, AssistKind, GroupLabel, ResolvedAssist, | ||
| 23 | }; | ||
| 24 | |||
| 25 | /// `AssistContext` allows to apply an assist or check if it could be applied. | ||
| 26 | /// | ||
| 27 | /// Assists use a somewhat over-engineered approach, given the current needs. | ||
| 28 | /// The assists workflow consists of two phases. In the first phase, a user asks | ||
| 29 | /// for the list of available assists. In the second phase, the user picks a | ||
| 30 | /// particular assist and it gets applied. | ||
| 31 | /// | ||
| 32 | /// There are two peculiarities here: | ||
| 33 | /// | ||
| 34 | /// * first, we ideally avoid computing more things then necessary to answer "is | ||
| 35 | /// assist applicable" in the first phase. | ||
| 36 | /// * second, when we are applying assist, we don't have a guarantee that there | ||
| 37 | /// weren't any changes between the point when user asked for assists and when | ||
| 38 | /// they applied a particular assist. So, when applying assist, we need to do | ||
| 39 | /// all the checks from scratch. | ||
| 40 | /// | ||
| 41 | /// To avoid repeating the same code twice for both "check" and "apply" | ||
| 42 | /// functions, we use an approach reminiscent of that of Django's function based | ||
| 43 | /// views dealing with forms. Each assist receives a runtime parameter, | ||
| 44 | /// `resolve`. It first check if an edit is applicable (potentially computing | ||
| 45 | /// info required to compute the actual edit). If it is applicable, and | ||
| 46 | /// `resolve` is `true`, it then computes the actual edit. | ||
| 47 | /// | ||
| 48 | /// So, to implement the original assists workflow, we can first apply each edit | ||
| 49 | /// with `resolve = false`, and then applying the selected edit again, with | ||
| 50 | /// `resolve = true` this time. | ||
| 51 | /// | ||
| 52 | /// Note, however, that we don't actually use such two-phase logic at the | ||
| 53 | /// moment, because the LSP API is pretty awkward in this place, and it's much | ||
| 54 | /// easier to just compute the edit eagerly :-) | ||
| 55 | pub(crate) struct AssistContext<'a> { | ||
| 56 | pub(crate) config: &'a AssistConfig, | ||
| 57 | pub(crate) sema: Semantics<'a, RootDatabase>, | ||
| 58 | pub(crate) frange: FileRange, | ||
| 59 | source_file: SourceFile, | ||
| 60 | } | ||
| 61 | |||
| 62 | impl<'a> AssistContext<'a> { | ||
| 63 | pub(crate) fn new( | ||
| 64 | sema: Semantics<'a, RootDatabase>, | ||
| 65 | config: &'a AssistConfig, | ||
| 66 | frange: FileRange, | ||
| 67 | ) -> AssistContext<'a> { | ||
| 68 | let source_file = sema.parse(frange.file_id); | ||
| 69 | AssistContext { config, sema, frange, source_file } | ||
| 70 | } | ||
| 71 | |||
| 72 | pub(crate) fn db(&self) -> &RootDatabase { | ||
| 73 | self.sema.db | ||
| 74 | } | ||
| 75 | |||
| 76 | pub(crate) fn source_file(&self) -> &SourceFile { | ||
| 77 | &self.source_file | ||
| 78 | } | ||
| 79 | |||
| 80 | // NB, this ignores active selection. | ||
| 81 | pub(crate) fn offset(&self) -> TextSize { | ||
| 82 | self.frange.range.start() | ||
| 83 | } | ||
| 84 | |||
| 85 | pub(crate) fn token_at_offset(&self) -> TokenAtOffset<SyntaxToken> { | ||
| 86 | self.source_file.syntax().token_at_offset(self.offset()) | ||
| 87 | } | ||
| 88 | pub(crate) fn find_token_at_offset(&self, kind: SyntaxKind) -> Option<SyntaxToken> { | ||
| 89 | self.token_at_offset().find(|it| it.kind() == kind) | ||
| 90 | } | ||
| 91 | pub(crate) fn find_node_at_offset<N: AstNode>(&self) -> Option<N> { | ||
| 92 | find_node_at_offset(self.source_file.syntax(), self.offset()) | ||
| 93 | } | ||
| 94 | pub(crate) fn find_node_at_offset_with_descend<N: AstNode>(&self) -> Option<N> { | ||
| 95 | self.sema.find_node_at_offset_with_descend(self.source_file.syntax(), self.offset()) | ||
| 96 | } | ||
| 97 | pub(crate) fn covering_element(&self) -> SyntaxElement { | ||
| 98 | find_covering_element(self.source_file.syntax(), self.frange.range) | ||
| 99 | } | ||
| 100 | // FIXME: remove | ||
| 101 | pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement { | ||
| 102 | find_covering_element(self.source_file.syntax(), range) | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | pub(crate) struct Assists { | ||
| 107 | resolve: bool, | ||
| 108 | file: FileId, | ||
| 109 | buf: Vec<(Assist, Option<SourceChange>)>, | ||
| 110 | allowed: Option<Vec<AssistKind>>, | ||
| 111 | } | ||
| 112 | |||
| 113 | impl Assists { | ||
| 114 | pub(crate) fn new_resolved(ctx: &AssistContext) -> Assists { | ||
| 115 | Assists { | ||
| 116 | resolve: true, | ||
| 117 | file: ctx.frange.file_id, | ||
| 118 | buf: Vec::new(), | ||
| 119 | allowed: ctx.config.allowed.clone(), | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | pub(crate) fn new_unresolved(ctx: &AssistContext) -> Assists { | ||
| 124 | Assists { | ||
| 125 | resolve: false, | ||
| 126 | file: ctx.frange.file_id, | ||
| 127 | buf: Vec::new(), | ||
| 128 | allowed: ctx.config.allowed.clone(), | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | pub(crate) fn finish_unresolved(self) -> Vec<Assist> { | ||
| 133 | assert!(!self.resolve); | ||
| 134 | self.finish() | ||
| 135 | .into_iter() | ||
| 136 | .map(|(label, edit)| { | ||
| 137 | assert!(edit.is_none()); | ||
| 138 | label | ||
| 139 | }) | ||
| 140 | .collect() | ||
| 141 | } | ||
| 142 | |||
| 143 | pub(crate) fn finish_resolved(self) -> Vec<ResolvedAssist> { | ||
| 144 | assert!(self.resolve); | ||
| 145 | self.finish() | ||
| 146 | .into_iter() | ||
| 147 | .map(|(label, edit)| ResolvedAssist { assist: label, source_change: edit.unwrap() }) | ||
| 148 | .collect() | ||
| 149 | } | ||
| 150 | |||
| 151 | pub(crate) fn add( | ||
| 152 | &mut self, | ||
| 153 | id: AssistId, | ||
| 154 | label: impl Into<String>, | ||
| 155 | target: TextRange, | ||
| 156 | f: impl FnOnce(&mut AssistBuilder), | ||
| 157 | ) -> Option<()> { | ||
| 158 | if !self.is_allowed(&id) { | ||
| 159 | return None; | ||
| 160 | } | ||
| 161 | let label = Label::new(label.into()); | ||
| 162 | let assist = Assist { id, label, group: None, target }; | ||
| 163 | self.add_impl(assist, f) | ||
| 164 | } | ||
| 165 | |||
| 166 | pub(crate) fn add_group( | ||
| 167 | &mut self, | ||
| 168 | group: &GroupLabel, | ||
| 169 | id: AssistId, | ||
| 170 | label: impl Into<String>, | ||
| 171 | target: TextRange, | ||
| 172 | f: impl FnOnce(&mut AssistBuilder), | ||
| 173 | ) -> Option<()> { | ||
| 174 | if !self.is_allowed(&id) { | ||
| 175 | return None; | ||
| 176 | } | ||
| 177 | let label = Label::new(label.into()); | ||
| 178 | let assist = Assist { id, label, group: Some(group.clone()), target }; | ||
| 179 | self.add_impl(assist, f) | ||
| 180 | } | ||
| 181 | |||
| 182 | fn add_impl(&mut self, assist: Assist, f: impl FnOnce(&mut AssistBuilder)) -> Option<()> { | ||
| 183 | let source_change = if self.resolve { | ||
| 184 | let mut builder = AssistBuilder::new(self.file); | ||
| 185 | f(&mut builder); | ||
| 186 | Some(builder.finish()) | ||
| 187 | } else { | ||
| 188 | None | ||
| 189 | }; | ||
| 190 | |||
| 191 | self.buf.push((assist, source_change)); | ||
| 192 | Some(()) | ||
| 193 | } | ||
| 194 | |||
| 195 | fn finish(mut self) -> Vec<(Assist, Option<SourceChange>)> { | ||
| 196 | self.buf.sort_by_key(|(label, _edit)| label.target.len()); | ||
| 197 | self.buf | ||
| 198 | } | ||
| 199 | |||
| 200 | fn is_allowed(&self, id: &AssistId) -> bool { | ||
| 201 | match &self.allowed { | ||
| 202 | Some(allowed) => allowed.iter().any(|kind| kind.contains(id.1)), | ||
| 203 | None => true, | ||
| 204 | } | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | pub(crate) struct AssistBuilder { | ||
| 209 | edit: TextEditBuilder, | ||
| 210 | file_id: FileId, | ||
| 211 | is_snippet: bool, | ||
| 212 | change: SourceChange, | ||
| 213 | } | ||
| 214 | |||
| 215 | impl AssistBuilder { | ||
| 216 | pub(crate) fn new(file_id: FileId) -> AssistBuilder { | ||
| 217 | AssistBuilder { | ||
| 218 | edit: TextEdit::builder(), | ||
| 219 | file_id, | ||
| 220 | is_snippet: false, | ||
| 221 | change: SourceChange::default(), | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | pub(crate) fn edit_file(&mut self, file_id: FileId) { | ||
| 226 | self.file_id = file_id; | ||
| 227 | } | ||
| 228 | |||
| 229 | fn commit(&mut self) { | ||
| 230 | let edit = mem::take(&mut self.edit).finish(); | ||
| 231 | if !edit.is_empty() { | ||
| 232 | let new_edit = SourceFileEdit { file_id: self.file_id, edit }; | ||
| 233 | assert!(!self.change.source_file_edits.iter().any(|it| it.file_id == new_edit.file_id)); | ||
| 234 | self.change.source_file_edits.push(new_edit); | ||
| 235 | } | ||
| 236 | } | ||
| 237 | |||
| 238 | /// Remove specified `range` of text. | ||
| 239 | pub(crate) fn delete(&mut self, range: TextRange) { | ||
| 240 | self.edit.delete(range) | ||
| 241 | } | ||
| 242 | /// Append specified `text` at the given `offset` | ||
| 243 | pub(crate) fn insert(&mut self, offset: TextSize, text: impl Into<String>) { | ||
| 244 | self.edit.insert(offset, text.into()) | ||
| 245 | } | ||
| 246 | /// Append specified `snippet` at the given `offset` | ||
| 247 | pub(crate) fn insert_snippet( | ||
| 248 | &mut self, | ||
| 249 | _cap: SnippetCap, | ||
| 250 | offset: TextSize, | ||
| 251 | snippet: impl Into<String>, | ||
| 252 | ) { | ||
| 253 | self.is_snippet = true; | ||
| 254 | self.insert(offset, snippet); | ||
| 255 | } | ||
| 256 | /// Replaces specified `range` of text with a given string. | ||
| 257 | pub(crate) fn replace(&mut self, range: TextRange, replace_with: impl Into<String>) { | ||
| 258 | self.edit.replace(range, replace_with.into()) | ||
| 259 | } | ||
| 260 | /// Replaces specified `range` of text with a given `snippet`. | ||
| 261 | pub(crate) fn replace_snippet( | ||
| 262 | &mut self, | ||
| 263 | _cap: SnippetCap, | ||
| 264 | range: TextRange, | ||
| 265 | snippet: impl Into<String>, | ||
| 266 | ) { | ||
| 267 | self.is_snippet = true; | ||
| 268 | self.replace(range, snippet); | ||
| 269 | } | ||
| 270 | pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) { | ||
| 271 | algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) | ||
| 272 | } | ||
| 273 | pub(crate) fn rewrite(&mut self, rewriter: SyntaxRewriter) { | ||
| 274 | let node = rewriter.rewrite_root().unwrap(); | ||
| 275 | let new = rewriter.rewrite(&node); | ||
| 276 | algo::diff(&node, &new).into_text_edit(&mut self.edit); | ||
| 277 | } | ||
| 278 | |||
| 279 | // FIXME: kill this API | ||
| 280 | /// Get access to the raw `TextEditBuilder`. | ||
| 281 | pub(crate) fn text_edit_builder(&mut self) -> &mut TextEditBuilder { | ||
| 282 | &mut self.edit | ||
| 283 | } | ||
| 284 | |||
| 285 | fn finish(mut self) -> SourceChange { | ||
| 286 | self.commit(); | ||
| 287 | let mut change = mem::take(&mut self.change); | ||
| 288 | if self.is_snippet { | ||
| 289 | change.is_snippet = true; | ||
| 290 | } | ||
| 291 | change | ||
| 292 | } | ||
| 293 | } | ||
diff --git a/crates/assists/src/ast_transform.rs b/crates/assists/src/ast_transform.rs new file mode 100644 index 000000000..5216862ba --- /dev/null +++ b/crates/assists/src/ast_transform.rs | |||
| @@ -0,0 +1,200 @@ | |||
| 1 | //! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined. | ||
| 2 | use rustc_hash::FxHashMap; | ||
| 3 | |||
| 4 | use hir::{HirDisplay, PathResolution, SemanticsScope}; | ||
| 5 | use syntax::{ | ||
| 6 | algo::SyntaxRewriter, | ||
| 7 | ast::{self, AstNode}, | ||
| 8 | }; | ||
| 9 | |||
| 10 | pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: N) -> N { | ||
| 11 | SyntaxRewriter::from_fn(|element| match element { | ||
| 12 | syntax::SyntaxElement::Node(n) => { | ||
| 13 | let replacement = transformer.get_substitution(&n)?; | ||
| 14 | Some(replacement.into()) | ||
| 15 | } | ||
| 16 | _ => None, | ||
| 17 | }) | ||
| 18 | .rewrite_ast(&node) | ||
| 19 | } | ||
| 20 | |||
| 21 | pub trait AstTransform<'a> { | ||
| 22 | fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode>; | ||
| 23 | |||
| 24 | fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a>; | ||
| 25 | fn or<T: AstTransform<'a> + 'a>(self, other: T) -> Box<dyn AstTransform<'a> + 'a> | ||
| 26 | where | ||
| 27 | Self: Sized + 'a, | ||
| 28 | { | ||
| 29 | self.chain_before(Box::new(other)) | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | struct NullTransformer; | ||
| 34 | |||
| 35 | impl<'a> AstTransform<'a> for NullTransformer { | ||
| 36 | fn get_substitution(&self, _node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> { | ||
| 37 | None | ||
| 38 | } | ||
| 39 | fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> { | ||
| 40 | other | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | pub struct SubstituteTypeParams<'a> { | ||
| 45 | source_scope: &'a SemanticsScope<'a>, | ||
| 46 | substs: FxHashMap<hir::TypeParam, ast::Type>, | ||
| 47 | previous: Box<dyn AstTransform<'a> + 'a>, | ||
| 48 | } | ||
| 49 | |||
| 50 | impl<'a> SubstituteTypeParams<'a> { | ||
| 51 | pub fn for_trait_impl( | ||
| 52 | source_scope: &'a SemanticsScope<'a>, | ||
| 53 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... | ||
| 54 | trait_: hir::Trait, | ||
| 55 | impl_def: ast::Impl, | ||
| 56 | ) -> SubstituteTypeParams<'a> { | ||
| 57 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); | ||
| 58 | let generic_def: hir::GenericDef = trait_.into(); | ||
| 59 | let substs_by_param: FxHashMap<_, _> = generic_def | ||
| 60 | .params(source_scope.db) | ||
| 61 | .into_iter() | ||
| 62 | // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky | ||
| 63 | .skip(1) | ||
| 64 | // The actual list of trait type parameters may be longer than the one | ||
| 65 | // used in the `impl` block due to trailing default type parameters. | ||
| 66 | // For that case we extend the `substs` with an empty iterator so we | ||
| 67 | // can still hit those trailing values and check if they actually have | ||
| 68 | // a default type. If they do, go for that type from `hir` to `ast` so | ||
| 69 | // the resulting change can be applied correctly. | ||
| 70 | .zip(substs.into_iter().map(Some).chain(std::iter::repeat(None))) | ||
| 71 | .filter_map(|(k, v)| match v { | ||
| 72 | Some(v) => Some((k, v)), | ||
| 73 | None => { | ||
| 74 | let default = k.default(source_scope.db)?; | ||
| 75 | Some(( | ||
| 76 | k, | ||
| 77 | ast::make::ty( | ||
| 78 | &default | ||
| 79 | .display_source_code(source_scope.db, source_scope.module()?.into()) | ||
| 80 | .ok()?, | ||
| 81 | ), | ||
| 82 | )) | ||
| 83 | } | ||
| 84 | }) | ||
| 85 | .collect(); | ||
| 86 | return SubstituteTypeParams { | ||
| 87 | source_scope, | ||
| 88 | substs: substs_by_param, | ||
| 89 | previous: Box::new(NullTransformer), | ||
| 90 | }; | ||
| 91 | |||
| 92 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the | ||
| 93 | // trait ref, and then go from the types in the substs back to the syntax). | ||
| 94 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { | ||
| 95 | let target_trait = impl_def.trait_()?; | ||
| 96 | let path_type = match target_trait { | ||
| 97 | ast::Type::PathType(path) => path, | ||
| 98 | _ => return None, | ||
| 99 | }; | ||
| 100 | let generic_arg_list = path_type.path()?.segment()?.generic_arg_list()?; | ||
| 101 | |||
| 102 | let mut result = Vec::new(); | ||
| 103 | for generic_arg in generic_arg_list.generic_args() { | ||
| 104 | match generic_arg { | ||
| 105 | ast::GenericArg::TypeArg(type_arg) => result.push(type_arg.ty()?), | ||
| 106 | ast::GenericArg::AssocTypeArg(_) | ||
| 107 | | ast::GenericArg::LifetimeArg(_) | ||
| 108 | | ast::GenericArg::ConstArg(_) => (), | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | Some(result) | ||
| 113 | } | ||
| 114 | } | ||
| 115 | fn get_substitution_inner(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> { | ||
| 116 | let type_ref = ast::Type::cast(node.clone())?; | ||
| 117 | let path = match &type_ref { | ||
| 118 | ast::Type::PathType(path_type) => path_type.path()?, | ||
| 119 | _ => return None, | ||
| 120 | }; | ||
| 121 | let resolution = self.source_scope.speculative_resolve(&path)?; | ||
| 122 | match resolution { | ||
| 123 | hir::PathResolution::TypeParam(tp) => Some(self.substs.get(&tp)?.syntax().clone()), | ||
| 124 | _ => None, | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> { | ||
| 130 | fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> { | ||
| 131 | self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node)) | ||
| 132 | } | ||
| 133 | fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> { | ||
| 134 | Box::new(SubstituteTypeParams { previous: other, ..self }) | ||
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 | pub struct QualifyPaths<'a> { | ||
| 139 | target_scope: &'a SemanticsScope<'a>, | ||
| 140 | source_scope: &'a SemanticsScope<'a>, | ||
| 141 | previous: Box<dyn AstTransform<'a> + 'a>, | ||
| 142 | } | ||
| 143 | |||
| 144 | impl<'a> QualifyPaths<'a> { | ||
| 145 | pub fn new(target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>) -> Self { | ||
| 146 | Self { target_scope, source_scope, previous: Box::new(NullTransformer) } | ||
| 147 | } | ||
| 148 | |||
| 149 | fn get_substitution_inner(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> { | ||
| 150 | // FIXME handle value ns? | ||
| 151 | let from = self.target_scope.module()?; | ||
| 152 | let p = ast::Path::cast(node.clone())?; | ||
| 153 | if p.segment().and_then(|s| s.param_list()).is_some() { | ||
| 154 | // don't try to qualify `Fn(Foo) -> Bar` paths, they are in prelude anyway | ||
| 155 | return None; | ||
| 156 | } | ||
| 157 | let resolution = self.source_scope.speculative_resolve(&p)?; | ||
| 158 | match resolution { | ||
| 159 | PathResolution::Def(def) => { | ||
| 160 | let found_path = from.find_use_path(self.source_scope.db.upcast(), def)?; | ||
| 161 | let mut path = path_to_ast(found_path); | ||
| 162 | |||
| 163 | let type_args = p | ||
| 164 | .segment() | ||
| 165 | .and_then(|s| s.generic_arg_list()) | ||
| 166 | .map(|arg_list| apply(self, arg_list)); | ||
| 167 | if let Some(type_args) = type_args { | ||
| 168 | let last_segment = path.segment().unwrap(); | ||
| 169 | path = path.with_segment(last_segment.with_type_args(type_args)) | ||
| 170 | } | ||
| 171 | |||
| 172 | Some(path.syntax().clone()) | ||
| 173 | } | ||
| 174 | PathResolution::Local(_) | ||
| 175 | | PathResolution::TypeParam(_) | ||
| 176 | | PathResolution::SelfType(_) => None, | ||
| 177 | PathResolution::Macro(_) => None, | ||
| 178 | PathResolution::AssocItem(_) => None, | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | impl<'a> AstTransform<'a> for QualifyPaths<'a> { | ||
| 184 | fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> { | ||
| 185 | self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node)) | ||
| 186 | } | ||
| 187 | fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> { | ||
| 188 | Box::new(QualifyPaths { previous: other, ..self }) | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | pub(crate) fn path_to_ast(path: hir::ModPath) -> ast::Path { | ||
| 193 | let parse = ast::SourceFile::parse(&path.to_string()); | ||
| 194 | parse | ||
| 195 | .tree() | ||
| 196 | .syntax() | ||
| 197 | .descendants() | ||
| 198 | .find_map(ast::Path::cast) | ||
| 199 | .unwrap_or_else(|| panic!("failed to parse path {:?}, `{}`", path, path)) | ||
| 200 | } | ||
diff --git a/crates/assists/src/handlers/add_custom_impl.rs b/crates/assists/src/handlers/add_custom_impl.rs new file mode 100644 index 000000000..8757fa33f --- /dev/null +++ b/crates/assists/src/handlers/add_custom_impl.rs | |||
| @@ -0,0 +1,208 @@ | |||
| 1 | use itertools::Itertools; | ||
| 2 | use syntax::{ | ||
| 3 | ast::{self, AstNode}, | ||
| 4 | Direction, SmolStr, | ||
| 5 | SyntaxKind::{IDENT, WHITESPACE}, | ||
| 6 | TextRange, TextSize, | ||
| 7 | }; | ||
| 8 | |||
| 9 | use crate::{ | ||
| 10 | assist_context::{AssistContext, Assists}, | ||
| 11 | AssistId, AssistKind, | ||
| 12 | }; | ||
| 13 | |||
| 14 | // Assist: add_custom_impl | ||
| 15 | // | ||
| 16 | // Adds impl block for derived trait. | ||
| 17 | // | ||
| 18 | // ``` | ||
| 19 | // #[derive(Deb<|>ug, Display)] | ||
| 20 | // struct S; | ||
| 21 | // ``` | ||
| 22 | // -> | ||
| 23 | // ``` | ||
| 24 | // #[derive(Display)] | ||
| 25 | // struct S; | ||
| 26 | // | ||
| 27 | // impl Debug for S { | ||
| 28 | // $0 | ||
| 29 | // } | ||
| 30 | // ``` | ||
| 31 | pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | ||
| 32 | let attr = ctx.find_node_at_offset::<ast::Attr>()?; | ||
| 33 | let input = attr.token_tree()?; | ||
| 34 | |||
| 35 | let attr_name = attr | ||
| 36 | .syntax() | ||
| 37 | .descendants_with_tokens() | ||
| 38 | .filter(|t| t.kind() == IDENT) | ||
| 39 | .find_map(|i| i.into_token()) | ||
| 40 | .filter(|t| *t.text() == "derive")? | ||
| 41 | .text() | ||
| 42 | .clone(); | ||
| 43 | |||
| 44 | let trait_token = | ||
| 45 | ctx.token_at_offset().find(|t| t.kind() == IDENT && *t.text() != attr_name)?; | ||
| 46 | |||
| 47 | let annotated = attr.syntax().siblings(Direction::Next).find_map(ast::Name::cast)?; | ||
| 48 | let annotated_name = annotated.syntax().text().to_string(); | ||
| 49 | let start_offset = annotated.syntax().parent()?.text_range().end(); | ||
| 50 | |||
| 51 | let label = | ||
| 52 | format!("Add custom impl `{}` for `{}`", trait_token.text().as_str(), annotated_name); | ||
| 53 | |||
| 54 | let target = attr.syntax().text_range(); | ||
| 55 | acc.add(AssistId("add_custom_impl", AssistKind::Refactor), label, target, |builder| { | ||
| 56 | let new_attr_input = input | ||
| 57 | .syntax() | ||
| 58 | .descendants_with_tokens() | ||
| 59 | .filter(|t| t.kind() == IDENT) | ||
| 60 | .filter_map(|t| t.into_token().map(|t| t.text().clone())) | ||
| 61 | .filter(|t| t != trait_token.text()) | ||
| 62 | .collect::<Vec<SmolStr>>(); | ||
| 63 | let has_more_derives = !new_attr_input.is_empty(); | ||
| 64 | |||
| 65 | if has_more_derives { | ||
| 66 | let new_attr_input = format!("({})", new_attr_input.iter().format(", ")); | ||
| 67 | builder.replace(input.syntax().text_range(), new_attr_input); | ||
| 68 | } else { | ||
| 69 | let attr_range = attr.syntax().text_range(); | ||
| 70 | builder.delete(attr_range); | ||
| 71 | |||
| 72 | let line_break_range = attr | ||
| 73 | .syntax() | ||
| 74 | .next_sibling_or_token() | ||
| 75 | .filter(|t| t.kind() == WHITESPACE) | ||
| 76 | .map(|t| t.text_range()) | ||
| 77 | .unwrap_or_else(|| TextRange::new(TextSize::from(0), TextSize::from(0))); | ||
| 78 | builder.delete(line_break_range); | ||
| 79 | } | ||
| 80 | |||
| 81 | match ctx.config.snippet_cap { | ||
| 82 | Some(cap) => { | ||
| 83 | builder.insert_snippet( | ||
| 84 | cap, | ||
| 85 | start_offset, | ||
| 86 | format!("\n\nimpl {} for {} {{\n $0\n}}", trait_token, annotated_name), | ||
| 87 | ); | ||
| 88 | } | ||
| 89 | None => { | ||
| 90 | builder.insert( | ||
| 91 | start_offset, | ||
| 92 | format!("\n\nimpl {} for {} {{\n\n}}", trait_token, annotated_name), | ||
| 93 | ); | ||
| 94 | } | ||
| 95 | } | ||
| 96 | }) | ||
| 97 | } | ||
| 98 | |||
| 99 | #[cfg(test)] | ||
| 100 | mod tests { | ||
| 101 | use crate::tests::{check_assist, check_assist_not_applicable}; | ||
| 102 | |||
| 103 | use super::*; | ||
| 104 | |||
| 105 | #[test] | ||
| 106 | fn add_custom_impl_for_unique_input() { | ||
| 107 | check_assist( | ||
| 108 | add_custom_impl, | ||
| 109 | " | ||
| 110 | #[derive(Debu<|>g)] | ||
| 111 | struct Foo { | ||
| 112 | bar: String, | ||
| 113 | } | ||
| 114 | ", | ||
| 115 | " | ||
| 116 | struct Foo { | ||
| 117 | bar: String, | ||
| 118 | } | ||
| 119 | |||
| 120 | impl Debug for Foo { | ||
| 121 | $0 | ||
| 122 | } | ||
| 123 | ", | ||
| 124 | ) | ||
| 125 | } | ||
| 126 | |||
| 127 | #[test] | ||
| 128 | fn add_custom_impl_for_with_visibility_modifier() { | ||
| 129 | check_assist( | ||
| 130 | add_custom_impl, | ||
| 131 | " | ||
| 132 | #[derive(Debug<|>)] | ||
| 133 | pub struct Foo { | ||
| 134 | bar: String, | ||
| 135 | } | ||
| 136 | ", | ||
| 137 | " | ||
| 138 | pub struct Foo { | ||
| 139 | bar: String, | ||
| 140 | } | ||
| 141 | |||
| 142 | impl Debug for Foo { | ||
| 143 | $0 | ||
| 144 | } | ||
| 145 | ", | ||
| 146 | ) | ||
| 147 | } | ||
| 148 | |||
| 149 | #[test] | ||
| 150 | fn add_custom_impl_when_multiple_inputs() { | ||
| 151 | check_assist( | ||
| 152 | add_custom_impl, | ||
| 153 | " | ||
| 154 | #[derive(Display, Debug<|>, Serialize)] | ||
| 155 | struct Foo {} | ||
| 156 | ", | ||
| 157 | " | ||
| 158 | #[derive(Display, Serialize)] | ||
| 159 | struct Foo {} | ||
| 160 | |||
| 161 | impl Debug for Foo { | ||
| 162 | $0 | ||
| 163 | } | ||
| 164 | ", | ||
| 165 | ) | ||
| 166 | } | ||
| 167 | |||
| 168 | #[test] | ||
| 169 | fn test_ignore_derive_macro_without_input() { | ||
| 170 | check_assist_not_applicable( | ||
| 171 | add_custom_impl, | ||
| 172 | " | ||
| 173 | #[derive(<|>)] | ||
| 174 | struct Foo {} | ||
| 175 | ", | ||
| 176 | ) | ||
| 177 | } | ||
| 178 | |||
| 179 | #[test] | ||
| 180 | fn test_ignore_if_cursor_on_param() { | ||
| 181 | check_assist_not_applicable( | ||
| 182 | add_custom_impl, | ||
| 183 | " | ||
| 184 | #[derive<|>(Debug)] | ||
| 185 | struct Foo {} | ||
| 186 | ", | ||
| 187 | ); | ||
| 188 | |||
| 189 | check_assist_not_applicable( | ||
| 190 | add_custom_impl, | ||
| 191 | " | ||
| 192 | #[derive(Debug)<|>] | ||
| 193 | struct Foo {} | ||
| 194 | ", | ||
| 195 | ) | ||
| 196 | } | ||
| 197 | |||
| 198 | #[test] | ||
| 199 | fn test_ignore_if_not_derive() { | ||
| 200 | check_assist_not_applicable( | ||
| 201 | add_custom_impl, | ||
| 202 | " | ||
| 203 | #[allow(non_camel_<|>case_types)] | ||
| 204 | struct Foo {} | ||
| 205 | ", | ||
| 206 | ) | ||
| 207 | } | ||
| 208 | } | ||
diff --git a/crates/assists/src/handlers/add_explicit_type.rs b/crates/assists/src/handlers/add_explicit_type.rs new file mode 100644 index 000000000..563cbf505 --- /dev/null +++ b/crates/assists/src/handlers/add_explicit_type.rs | |||
| @@ -0,0 +1,211 @@ | |||
| 1 | use hir::HirDisplay; | ||
| 2 | use syntax::{ | ||
| 3 | ast::{self, AstNode, LetStmt, NameOwner}, | ||
| 4 | TextRange, | ||
| 5 | }; | ||
| 6 | |||
| 7 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | ||
| 8 | |||
| 9 | // Assist: add_explicit_type | ||
| 10 | // | ||
| 11 | // Specify type for a let binding. | ||
| 12 | // | ||
| 13 | // ``` | ||
| 14 | // fn main() { | ||
| 15 | // let x<|> = 92; | ||
| 16 | // } | ||
| 17 | // ``` | ||
| 18 | // -> | ||
| 19 | // ``` | ||
| 20 | // fn main() { | ||
| 21 | // let x: i32 = 92; | ||
| 22 | // } | ||
| 23 | // ``` | ||
| 24 | pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | ||
| 25 | let let_stmt = ctx.find_node_at_offset::<LetStmt>()?; | ||
| 26 | let module = ctx.sema.scope(let_stmt.syntax()).module()?; | ||
| 27 | let expr = let_stmt.initializer()?; | ||
| 28 | // Must be a binding | ||
| 29 | let pat = match let_stmt.pat()? { | ||
| 30 | ast::Pat::IdentPat(bind_pat) => bind_pat, | ||
| 31 | _ => return None, | ||
| 32 | }; | ||
| 33 | let pat_range = pat.syntax().text_range(); | ||
| 34 | // The binding must have a name | ||
| 35 | let name = pat.name()?; | ||
| 36 | let name_range = name.syntax().text_range(); | ||
| 37 | let stmt_range = let_stmt.syntax().text_range(); | ||
| 38 | let eq_range = let_stmt.eq_token()?.text_range(); | ||
| 39 | // Assist should only be applicable if cursor is between 'let' and '=' | ||
| 40 | let let_range = TextRange::new(stmt_range.start(), eq_range.start()); | ||
| 41 | let cursor_in_range = let_range.contains_range(ctx.frange.range); | ||
| 42 | if !cursor_in_range { | ||
| 43 | return None; | ||
| 44 | } | ||
| 45 | // Assist not applicable if the type has already been specified | ||
| 46 | // and it has no placeholders | ||
| 47 | let ascribed_ty = let_stmt.ty(); | ||
| 48 | if let Some(ty) = &ascribed_ty { | ||
| 49 | if ty.syntax().descendants().find_map(ast::InferType::cast).is_none() { | ||
| 50 | return None; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | // Infer type | ||
| 54 | let ty = ctx.sema.type_of_expr(&expr)?; | ||
| 55 | |||
| 56 | if ty.contains_unknown() || ty.is_closure() { | ||
| 57 | return None; | ||
| 58 | } | ||
| 59 | |||
| 60 | let inferred_type = ty.display_source_code(ctx.db(), module.into()).ok()?; | ||
| 61 | acc.add( | ||
| 62 | AssistId("add_explicit_type", AssistKind::RefactorRewrite), | ||
| 63 | format!("Insert explicit type `{}`", inferred_type), | ||
| 64 | pat_range, | ||
| 65 | |builder| match ascribed_ty { | ||
| 66 | Some(ascribed_ty) => { | ||
| 67 | builder.replace(ascribed_ty.syntax().text_range(), inferred_type); | ||
| 68 | } | ||
| 69 | None => { | ||
| 70 | builder.insert(name_range.end(), format!(": {}", inferred_type)); | ||
| 71 | } | ||
| 72 | }, | ||
| 73 | ) | ||
| 74 | } | ||
| 75 | |||
| 76 | #[cfg(test)] | ||
| 77 | mod tests { | ||
| 78 | use super::*; | ||
| 79 | |||
| 80 | use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; | ||
| 81 | |||
| 82 | #[test] | ||
| 83 | fn add_explicit_type_target() { | ||
| 84 | check_assist_target(add_explicit_type, "fn f() { let a<|> = 1; }", "a"); | ||
| 85 | } | ||
| 86 | |||
| 87 | #[test] | ||
| 88 | fn add_explicit_type_works_for_simple_expr() { | ||
| 89 | check_assist(add_explicit_type, "fn f() { let a<|> = 1; }", "fn f() { let a: i32 = 1; }"); | ||
| 90 | } | ||
| 91 | |||
| 92 | #[test] | ||
| 93 | fn add_explicit_type_works_for_underscore() { | ||
| 94 | check_assist( | ||
| 95 | add_explicit_type, | ||
| 96 | "fn f() { let a<|>: _ = 1; }", | ||
| 97 | "fn f() { let a: i32 = 1; }", | ||
| 98 | ); | ||
| 99 | } | ||
| 100 | |||
| 101 | #[test] | ||
| 102 | fn add_explicit_type_works_for_nested_underscore() { | ||
| 103 | check_assist( | ||
| 104 | add_explicit_type, | ||
| 105 | r#" | ||
| 106 | enum Option<T> { | ||
| 107 | Some(T), | ||
| 108 | None | ||
| 109 | } | ||
| 110 | |||
| 111 | fn f() { | ||
| 112 | let a<|>: Option<_> = Option::Some(1); | ||
| 113 | }"#, | ||
| 114 | r#" | ||
| 115 | enum Option<T> { | ||
| 116 | Some(T), | ||
| 117 | None | ||
| 118 | } | ||
| 119 | |||
| 120 | fn f() { | ||
| 121 | let a: Option<i32> = Option::Some(1); | ||
| 122 | }"#, | ||
| 123 | ); | ||
| 124 | } | ||
| 125 | |||
| 126 | #[test] | ||
| 127 | fn add_explicit_type_works_for_macro_call() { | ||
| 128 | check_assist( | ||
| 129 | add_explicit_type, | ||
| 130 | r"macro_rules! v { () => {0u64} } fn f() { let a<|> = v!(); }", | ||
| 131 | r"macro_rules! v { () => {0u64} } fn f() { let a: u64 = v!(); }", | ||
| 132 | ); | ||
| 133 | } | ||
| 134 | |||
| 135 | #[test] | ||
| 136 | fn add_explicit_type_works_for_macro_call_recursive() { | ||
| 137 | check_assist( | ||
| 138 | add_explicit_type, | ||
| 139 | r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a<|> = v!(); }"#, | ||
| 140 | r#"macro_rules! u { () => {0u64} } macro_rules! v { () => {u!()} } fn f() { let a: u64 = v!(); }"#, | ||
| 141 | ); | ||
| 142 | } | ||
| 143 | |||
| 144 | #[test] | ||
| 145 | fn add_explicit_type_not_applicable_if_ty_not_inferred() { | ||
| 146 | check_assist_not_applicable(add_explicit_type, "fn f() { let a<|> = None; }"); | ||
| 147 | } | ||
| 148 | |||
| 149 | #[test] | ||
| 150 | fn add_explicit_type_not_applicable_if_ty_already_specified() { | ||
| 151 | check_assist_not_applicable(add_explicit_type, "fn f() { let a<|>: i32 = 1; }"); | ||
| 152 | } | ||
| 153 | |||
| 154 | #[test] | ||
| 155 | fn add_explicit_type_not_applicable_if_specified_ty_is_tuple() { | ||
| 156 | check_assist_not_applicable(add_explicit_type, "fn f() { let a<|>: (i32, i32) = (3, 4); }"); | ||
| 157 | } | ||
| 158 | |||
| 159 | #[test] | ||
| 160 | fn add_explicit_type_not_applicable_if_cursor_after_equals() { | ||
| 161 | check_assist_not_applicable( | ||
| 162 | add_explicit_type, | ||
| 163 | "fn f() {let a =<|> match 1 {2 => 3, 3 => 5};}", | ||
| 164 | ) | ||
| 165 | } | ||
| 166 | |||
| 167 | #[test] | ||
| 168 | fn add_explicit_type_not_applicable_if_cursor_before_let() { | ||
| 169 | check_assist_not_applicable( | ||
| 170 | add_explicit_type, | ||
| 171 | "fn f() <|>{let a = match 1 {2 => 3, 3 => 5};}", | ||
| 172 | ) | ||
| 173 | } | ||
| 174 | |||
| 175 | #[test] | ||
| 176 | fn closure_parameters_are_not_added() { | ||
| 177 | check_assist_not_applicable( | ||
| 178 | add_explicit_type, | ||
| 179 | r#" | ||
| 180 | fn main() { | ||
| 181 | let multiply_by_two<|> = |i| i * 3; | ||
| 182 | let six = multiply_by_two(2); | ||
| 183 | }"#, | ||
| 184 | ) | ||
| 185 | } | ||
| 186 | |||
| 187 | #[test] | ||
| 188 | fn default_generics_should_not_be_added() { | ||
| 189 | check_assist( | ||
| 190 | add_explicit_type, | ||
| 191 | r#" | ||
| 192 | struct Test<K, T = u8> { | ||
| 193 | k: K, | ||
| 194 | t: T, | ||
| 195 | } | ||
| 196 | |||
| 197 | fn main() { | ||
| 198 | let test<|> = Test { t: 23u8, k: 33 }; | ||
| 199 | }"#, | ||
| 200 | r#" | ||
| 201 | struct Test<K, T = u8> { | ||
| 202 | k: K, | ||
| 203 | t: T, | ||
| 204 | } | ||
| 205 | |||
| 206 | fn main() { | ||
| 207 | let test: Test<i32> = Test { t: 23u8, k: 33 }; | ||
| 208 | }"#, | ||
| 209 | ); | ||
| 210 | } | ||
| 211 | } | ||
diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs new file mode 100644 index 000000000..83a2ada9a --- /dev/null +++ b/crates/assists/src/handlers/add_missing_impl_members.rs | |||
| @@ -0,0 +1,766 @@ | |||
| 1 | use hir::HasSource; | ||
| 2 | use syntax::{ | ||
| 3 | ast::{ | ||
| 4 | self, | ||
| 5 | edit::{self, AstNodeEdit, IndentLevel}, | ||
| 6 | make, AstNode, NameOwner, | ||
| 7 | }, | ||
| 8 | SmolStr, | ||
| 9 | }; | ||
| 10 | |||
| 11 | use crate::{ | ||
| 12 | assist_context::{AssistContext, Assists}, | ||
| 13 | ast_transform::{self, AstTransform, QualifyPaths, SubstituteTypeParams}, | ||
| 14 | utils::{get_missing_assoc_items, render_snippet, resolve_target_trait, Cursor}, | ||
| 15 | AssistId, AssistKind, | ||
| 16 | }; | ||
| 17 | |||
| 18 | #[derive(PartialEq)] | ||
| 19 | enum AddMissingImplMembersMode { | ||
| 20 | DefaultMethodsOnly, | ||
| 21 | NoDefaultMethods, | ||
| 22 | } | ||
| 23 | |||
| 24 | // Assist: add_impl_missing_members | ||
| 25 | // | ||
| 26 | // Adds scaffold for required impl members. | ||
| 27 | // | ||
| 28 | // ``` | ||
| 29 | // trait Trait<T> { | ||
| 30 | // Type X; | ||
| 31 | // fn foo(&self) -> T; | ||
| 32 | // fn bar(&self) {} | ||
| 33 | // } | ||
| 34 | // | ||
| 35 | // impl Trait<u32> for () {<|> | ||
| 36 | // | ||
| 37 | // } | ||
| 38 | // ``` | ||
| 39 | // -> | ||
| 40 | // ``` | ||
| 41 | // trait Trait<T> { | ||
| 42 | // Type X; | ||
| 43 | // fn foo(&self) -> T; | ||
| 44 | // fn bar(&self) {} | ||
| 45 | // } | ||
| 46 | // | ||
| 47 | // impl Trait<u32> for () { | ||
| 48 | // fn foo(&self) -> u32 { | ||
| 49 | // ${0:todo!()} | ||
| 50 | // } | ||
| 51 | // } | ||
| 52 | // ``` | ||
| 53 | pub(crate) fn add_missing_impl_members(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | ||
| 54 | add_missing_impl_members_inner( | ||
| 55 | acc, | ||
| 56 | ctx, | ||
| 57 | AddMissingImplMembersMode::NoDefaultMethods, | ||
| 58 | "add_impl_missing_members", | ||
| 59 | "Implement missing members", | ||
| 60 | ) | ||
| 61 | } | ||
| 62 | |||
| 63 | // Assist: add_impl_default_members | ||
| 64 | // | ||
| 65 | // Adds scaffold for overriding default impl members. | ||
| 66 | // | ||
| 67 | // ``` | ||
| 68 | // trait Trait { | ||
| 69 | // Type X; | ||
| 70 | // fn foo(&self); | ||
| 71 | // fn bar(&self) {} | ||
| 72 | // } | ||
| 73 | // | ||
| 74 | // impl Trait for () { | ||
| 75 | // Type X = (); | ||
| 76 | // fn foo(&self) {}<|> | ||
| 77 | // | ||
| 78 | // } | ||
| 79 | // ``` | ||
| 80 | // -> | ||
| 81 | // ``` | ||
| 82 | // trait Trait { | ||
| 83 | // Type X; | ||
| 84 | // fn foo(&self); | ||
| 85 | // fn bar(&self) {} | ||
| 86 | // } | ||
| 87 | // | ||
| 88 | // impl Trait for () { | ||
| 89 | // Type X = (); | ||
| 90 | // fn foo(&self) {} | ||
| 91 | // | ||
| 92 | // $0fn bar(&self) {} | ||
| 93 | // } | ||
| 94 | // ``` | ||
| 95 | pub(crate) fn add_missing_default_members(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | ||
| 96 | add_missing_impl_members_inner( | ||
| 97 | acc, | ||
| 98 | ctx, | ||
| 99 | AddMissingImplMembersMode::DefaultMethodsOnly, | ||
| 100 | "add_impl_default_members", | ||
| 101 | "Implement default members", | ||
| 102 | ) | ||
| 103 | } | ||
| 104 | |||
| 105 | fn add_missing_impl_members_inner( | ||
| 106 | acc: &mut Assists, | ||
| 107 | ctx: &AssistContext, | ||
| 108 | mode: AddMissingImplMembersMode, | ||
| 109 | assist_id: &'static str, | ||
| 110 | label: &'static str, | ||
| 111 | ) -> Option<()> { | ||
| 112 | let _p = profile::span("add_missing_impl_members_inner"); | ||
| 113 | let impl_def = ctx.find_node_at_offset::<ast::Impl>()?; | ||
| 114 | let impl_item_list = impl_def.assoc_item_list()?; | ||
| 115 | |||
| 116 | let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; | ||
| 117 | |||
| 118 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { | ||
| 119 | match item { | ||
| 120 | ast::AssocItem::Fn(def) => def.name(), | ||
| 121 | ast::AssocItem::TypeAlias(def) => def.name(), | ||
| 122 | ast::AssocItem::Const(def) => def.name(), | ||
| 123 | ast::AssocItem::MacroCall(_) => None, | ||
| 124 | } | ||
| 125 | .map(|it| it.text().clone()) | ||
| 126 | }; | ||
| 127 | |||
| 128 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) | ||
| 129 | .iter() | ||
| 130 | .map(|i| match i { | ||
| 131 | hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), | ||
| 132 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value), | ||
| 133 | hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(ctx.db()).value), | ||
| 134 | }) | ||
| 135 | .filter(|t| def_name(&t).is_some()) | ||
| 136 | .filter(|t| match t { | ||
| 137 | ast::AssocItem::Fn(def) => match mode { | ||
| 138 | AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), | ||
| 139 | AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), | ||
| 140 | }, | ||
| 141 | _ => mode == AddMissingImplMembersMode::NoDefaultMethods, | ||
| 142 | }) | ||
| 143 | .collect::<Vec<_>>(); | ||
| 144 | |||
| 145 | if missing_items.is_empty() { | ||
| 146 | return None; | ||
| 147 | } | ||
| 148 | |||
| 149 | let target = impl_def.syntax().text_range(); | ||
| 150 | acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| { | ||
| 151 | let n_existing_items = impl_item_list.assoc_items().count(); | ||
| 152 | let source_scope = ctx.sema.scope_for_def(trait_); | ||
| 153 | let target_scope = ctx.sema.scope(impl_item_list.syntax()); | ||
| 154 | let ast_transform = QualifyPaths::new(&target_scope, &source_scope) | ||
| 155 | .or(SubstituteTypeParams::for_trait_impl(&source_scope, trait_, impl_def)); | ||
| 156 | let items = missing_items | ||
| 157 | .into_iter() | ||
| 158 | .map(|it| ast_transform::apply(&*ast_transform, it)) | ||
| 159 | .map(|it| match it { | ||
| 160 | ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), | ||
| 161 | ast::AssocItem::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()), | ||
| 162 | _ => it, | ||
| 163 | }) | ||
| 164 | .map(|it| edit::remove_attrs_and_docs(&it)); | ||
| 165 | let new_impl_item_list = impl_item_list.append_items(items); | ||
| 166 | let first_new_item = new_impl_item_list.assoc_items().nth(n_existing_items).unwrap(); | ||
| 167 | |||
| 168 | let original_range = impl_item_list.syntax().text_range(); | ||
| 169 | match ctx.config.snippet_cap { | ||
| 170 | None => builder.replace(original_range, new_impl_item_list.to_string()), | ||
| 171 | Some(cap) => { | ||
| 172 | let mut cursor = Cursor::Before(first_new_item.syntax()); | ||
| 173 | let placeholder; | ||
| 174 | if let ast::AssocItem::Fn(func) = &first_new_item { | ||
| 175 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { | ||
| 176 | if m.syntax().text() == "todo!()" { | ||
| 177 | placeholder = m; | ||
| 178 | cursor = Cursor::Replace(placeholder.syntax()); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | builder.replace_snippet( | ||
| 183 | cap, | ||
| 184 | original_range, | ||
| 185 | render_snippet(cap, new_impl_item_list.syntax(), cursor), | ||
| 186 | ) | ||
| 187 | } | ||
| 188 | }; | ||
| 189 | }) | ||
| 190 | } | ||
| 191 | |||
| 192 | fn add_body(fn_def: ast::Fn) -> ast::Fn { | ||
