mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Merge branch 'master' into add-disable-diagnostics
This commit is contained in:
commit
c26c911ec1
1140 changed files with 2355 additions and 2386 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1,5 +1,5 @@
|
||||||
* text=auto eol=lf
|
* text=auto eol=lf
|
||||||
crates/ra_syntax/test_data/** -text eof=LF
|
crates/syntax/test_data/** -text eof=LF
|
||||||
# Older git versions try to fix line endings on images, this prevents it.
|
# Older git versions try to fix line endings on images, this prevents it.
|
||||||
*.png binary
|
*.png binary
|
||||||
*.jpg binary
|
*.jpg binary
|
||||||
|
|
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
|
@ -25,7 +25,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest] #, macos-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
@ -115,7 +115,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
|
743
Cargo.lock
generated
743
Cargo.lock
generated
|
@ -15,15 +15,6 @@ version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
|
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "0.7.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ansi_term"
|
name = "ansi_term"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
|
@ -45,12 +36,33 @@ version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344"
|
checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arena"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "assists"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"base_db",
|
||||||
|
"either",
|
||||||
|
"hir",
|
||||||
|
"ide_db",
|
||||||
|
"itertools",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"text_edit",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
@ -88,6 +100,21 @@ version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base_db"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"salsa",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"tt",
|
||||||
|
"vfs",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
|
@ -117,6 +144,16 @@ version = "1.0.58"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
|
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"mbe",
|
||||||
|
"rustc-hash",
|
||||||
|
"syntax",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
|
@ -285,9 +322,9 @@ checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.5.3"
|
version = "1.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ena"
|
name = "ena"
|
||||||
|
@ -309,7 +346,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "expect"
|
name = "expect"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"difference",
|
"difference",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -348,14 +385,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flycheck"
|
name = "flycheck"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"jod-thread",
|
"jod-thread",
|
||||||
"log",
|
"log",
|
||||||
"ra_toolchain",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"toolchain",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -443,6 +480,96 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hir"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
"base_db",
|
||||||
|
"either",
|
||||||
|
"hir_def",
|
||||||
|
"hir_expand",
|
||||||
|
"hir_ty",
|
||||||
|
"itertools",
|
||||||
|
"log",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hir_def"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"anymap",
|
||||||
|
"arena",
|
||||||
|
"base_db",
|
||||||
|
"cfg",
|
||||||
|
"drop_bomb",
|
||||||
|
"either",
|
||||||
|
"expect",
|
||||||
|
"fst",
|
||||||
|
"hir_expand",
|
||||||
|
"indexmap",
|
||||||
|
"itertools",
|
||||||
|
"log",
|
||||||
|
"mbe",
|
||||||
|
"once_cell",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"smallvec",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hir_expand"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"arena",
|
||||||
|
"base_db",
|
||||||
|
"either",
|
||||||
|
"log",
|
||||||
|
"mbe",
|
||||||
|
"parser",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hir_ty"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"arena",
|
||||||
|
"arrayvec",
|
||||||
|
"base_db",
|
||||||
|
"chalk-ir",
|
||||||
|
"chalk-recursive",
|
||||||
|
"chalk-solve",
|
||||||
|
"ena",
|
||||||
|
"expect",
|
||||||
|
"hir_def",
|
||||||
|
"hir_expand",
|
||||||
|
"itertools",
|
||||||
|
"log",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"scoped-tls",
|
||||||
|
"smallvec",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"tracing-tree",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "home"
|
name = "home"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
|
@ -452,6 +579,49 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ide"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"assists",
|
||||||
|
"base_db",
|
||||||
|
"cfg",
|
||||||
|
"either",
|
||||||
|
"expect",
|
||||||
|
"hir",
|
||||||
|
"ide_db",
|
||||||
|
"indexmap",
|
||||||
|
"itertools",
|
||||||
|
"log",
|
||||||
|
"oorandom",
|
||||||
|
"profile",
|
||||||
|
"rustc-hash",
|
||||||
|
"ssr",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"text_edit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ide_db"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"base_db",
|
||||||
|
"either",
|
||||||
|
"fst",
|
||||||
|
"hir",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"profile",
|
||||||
|
"rayon",
|
||||||
|
"rustc-hash",
|
||||||
|
"stdx",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"text_edit",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -547,9 +717,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazycell"
|
name = "lazycell"
|
||||||
version = "1.2.1"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
|
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
|
@ -641,10 +811,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "mbe"
|
||||||
version = "2.3.3"
|
version = "0.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
dependencies = [
|
||||||
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
"log",
|
||||||
|
"parser",
|
||||||
|
"rustc-hash",
|
||||||
|
"smallvec",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memmap"
|
name = "memmap"
|
||||||
|
@ -830,9 +1007,16 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parser"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"drop_bomb",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paths"
|
name = "paths"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
|
@ -890,6 +1074,66 @@ dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc_macro_api"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-channel",
|
||||||
|
"jod-thread",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc_macro_srv"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"cargo_metadata",
|
||||||
|
"difference",
|
||||||
|
"goblin",
|
||||||
|
"libloading",
|
||||||
|
"mbe",
|
||||||
|
"memmap",
|
||||||
|
"proc_macro_api",
|
||||||
|
"serde_derive",
|
||||||
|
"test_utils",
|
||||||
|
"toolchain",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "profile"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"arena",
|
||||||
|
"backtrace",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"once_cell",
|
||||||
|
"perf-event",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "project_model"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"arena",
|
||||||
|
"base_db",
|
||||||
|
"cargo_metadata",
|
||||||
|
"cfg",
|
||||||
|
"log",
|
||||||
|
"paths",
|
||||||
|
"proc_macro_api",
|
||||||
|
"rustc-hash",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"stdx",
|
||||||
|
"toolchain",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
@ -899,332 +1143,6 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_arena"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_assists"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
"itertools",
|
|
||||||
"ra_db",
|
|
||||||
"ra_fmt",
|
|
||||||
"ra_hir",
|
|
||||||
"ra_ide_db",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_text_edit",
|
|
||||||
"rustc-hash",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_cfg"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"ra_mbe",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_tt",
|
|
||||||
"rustc-hash",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_db"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"ra_cfg",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_tt",
|
|
||||||
"rustc-hash",
|
|
||||||
"salsa",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
"vfs",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_fmt"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"itertools",
|
|
||||||
"ra_syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_hir"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"arrayvec",
|
|
||||||
"either",
|
|
||||||
"itertools",
|
|
||||||
"log",
|
|
||||||
"ra_db",
|
|
||||||
"ra_hir_def",
|
|
||||||
"ra_hir_expand",
|
|
||||||
"ra_hir_ty",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"rustc-hash",
|
|
||||||
"stdx",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_hir_def"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anymap",
|
|
||||||
"drop_bomb",
|
|
||||||
"either",
|
|
||||||
"expect",
|
|
||||||
"fst",
|
|
||||||
"indexmap",
|
|
||||||
"itertools",
|
|
||||||
"log",
|
|
||||||
"once_cell",
|
|
||||||
"ra_arena",
|
|
||||||
"ra_cfg",
|
|
||||||
"ra_db",
|
|
||||||
"ra_hir_expand",
|
|
||||||
"ra_mbe",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_tt",
|
|
||||||
"rustc-hash",
|
|
||||||
"smallvec",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_hir_expand"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
"log",
|
|
||||||
"ra_arena",
|
|
||||||
"ra_db",
|
|
||||||
"ra_mbe",
|
|
||||||
"ra_parser",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_tt",
|
|
||||||
"rustc-hash",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_hir_ty"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"arrayvec",
|
|
||||||
"chalk-ir",
|
|
||||||
"chalk-recursive",
|
|
||||||
"chalk-solve",
|
|
||||||
"ena",
|
|
||||||
"expect",
|
|
||||||
"itertools",
|
|
||||||
"log",
|
|
||||||
"ra_arena",
|
|
||||||
"ra_db",
|
|
||||||
"ra_hir_def",
|
|
||||||
"ra_hir_expand",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"rustc-hash",
|
|
||||||
"scoped-tls",
|
|
||||||
"smallvec",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
"tracing",
|
|
||||||
"tracing-subscriber",
|
|
||||||
"tracing-tree",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_ide"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
"expect",
|
|
||||||
"indexmap",
|
|
||||||
"itertools",
|
|
||||||
"log",
|
|
||||||
"oorandom",
|
|
||||||
"ra_assists",
|
|
||||||
"ra_cfg",
|
|
||||||
"ra_db",
|
|
||||||
"ra_fmt",
|
|
||||||
"ra_hir",
|
|
||||||
"ra_ide_db",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_ssr",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_text_edit",
|
|
||||||
"rustc-hash",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_ide_db"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
"fst",
|
|
||||||
"log",
|
|
||||||
"once_cell",
|
|
||||||
"ra_db",
|
|
||||||
"ra_hir",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_text_edit",
|
|
||||||
"rayon",
|
|
||||||
"rustc-hash",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_mbe"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
"ra_parser",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_tt",
|
|
||||||
"rustc-hash",
|
|
||||||
"smallvec",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_parser"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"drop_bomb",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_proc_macro"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-channel",
|
|
||||||
"jod-thread",
|
|
||||||
"log",
|
|
||||||
"ra_tt",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_proc_macro_srv"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"cargo_metadata",
|
|
||||||
"difference",
|
|
||||||
"goblin",
|
|
||||||
"libloading",
|
|
||||||
"memmap",
|
|
||||||
"ra_mbe",
|
|
||||||
"ra_proc_macro",
|
|
||||||
"ra_toolchain",
|
|
||||||
"ra_tt",
|
|
||||||
"serde_derive",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_prof"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"backtrace",
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"perf-event",
|
|
||||||
"ra_arena",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_project_model"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"cargo_metadata",
|
|
||||||
"log",
|
|
||||||
"paths",
|
|
||||||
"ra_arena",
|
|
||||||
"ra_cfg",
|
|
||||||
"ra_db",
|
|
||||||
"ra_proc_macro",
|
|
||||||
"ra_toolchain",
|
|
||||||
"rustc-hash",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"stdx",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_ssr"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"expect",
|
|
||||||
"ra_db",
|
|
||||||
"ra_hir",
|
|
||||||
"ra_ide_db",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_text_edit",
|
|
||||||
"rustc-hash",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_syntax"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"arrayvec",
|
|
||||||
"expect",
|
|
||||||
"itertools",
|
|
||||||
"once_cell",
|
|
||||||
"ra_parser",
|
|
||||||
"ra_text_edit",
|
|
||||||
"rayon",
|
|
||||||
"rowan",
|
|
||||||
"rustc-ap-rustc_lexer",
|
|
||||||
"rustc-hash",
|
|
||||||
"serde",
|
|
||||||
"smol_str",
|
|
||||||
"stdx",
|
|
||||||
"test_utils",
|
|
||||||
"walkdir",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_text_edit"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"text-size",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_toolchain"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"home",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ra_tt"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"smol_str",
|
|
||||||
"stdx",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
|
@ -1262,10 +1180,7 @@ version = "1.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
|
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
"thread_local",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1298,45 +1213,45 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-analyzer"
|
name = "rust-analyzer"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"base_db",
|
||||||
|
"cfg",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"expect",
|
"expect",
|
||||||
"flycheck",
|
"flycheck",
|
||||||
|
"hir",
|
||||||
|
"hir_def",
|
||||||
|
"hir_ty",
|
||||||
|
"ide",
|
||||||
|
"ide_db",
|
||||||
"itertools",
|
"itertools",
|
||||||
"jod-thread",
|
"jod-thread",
|
||||||
"log",
|
"log",
|
||||||
"lsp-server",
|
"lsp-server",
|
||||||
"lsp-types",
|
"lsp-types",
|
||||||
|
"mbe",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"oorandom",
|
"oorandom",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pico-args",
|
"pico-args",
|
||||||
"ra_cfg",
|
"proc_macro_srv",
|
||||||
"ra_db",
|
"profile",
|
||||||
"ra_hir",
|
"project_model",
|
||||||
"ra_hir_def",
|
|
||||||
"ra_hir_ty",
|
|
||||||
"ra_ide",
|
|
||||||
"ra_ide_db",
|
|
||||||
"ra_mbe",
|
|
||||||
"ra_proc_macro_srv",
|
|
||||||
"ra_prof",
|
|
||||||
"ra_project_model",
|
|
||||||
"ra_ssr",
|
|
||||||
"ra_syntax",
|
|
||||||
"ra_text_edit",
|
|
||||||
"ra_toolchain",
|
|
||||||
"ra_tt",
|
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"ssr",
|
||||||
"stdx",
|
"stdx",
|
||||||
|
"syntax",
|
||||||
"test_utils",
|
"test_utils",
|
||||||
|
"text_edit",
|
||||||
"threadpool",
|
"threadpool",
|
||||||
|
"toolchain",
|
||||||
|
"tt",
|
||||||
"vfs",
|
"vfs",
|
||||||
"vfs-notify",
|
"vfs-notify",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
|
@ -1457,18 +1372,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.114"
|
version = "1.0.115"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
|
checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.114"
|
version = "1.0.115"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e"
|
checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1514,9 +1429,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.4.1"
|
version = "1.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
|
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smol_str"
|
name = "smol_str"
|
||||||
|
@ -1527,9 +1442,23 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ssr"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"base_db",
|
||||||
|
"expect",
|
||||||
|
"hir",
|
||||||
|
"ide_db",
|
||||||
|
"rustc-hash",
|
||||||
|
"syntax",
|
||||||
|
"test_utils",
|
||||||
|
"text_edit",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stdx"
|
name = "stdx"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
|
@ -1554,6 +1483,27 @@ dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syntax"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
"expect",
|
||||||
|
"itertools",
|
||||||
|
"once_cell",
|
||||||
|
"parser",
|
||||||
|
"rayon",
|
||||||
|
"rowan",
|
||||||
|
"rustc-ap-rustc_lexer",
|
||||||
|
"rustc-hash",
|
||||||
|
"serde",
|
||||||
|
"smol_str",
|
||||||
|
"stdx",
|
||||||
|
"test_utils",
|
||||||
|
"text_edit",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termcolor"
|
name = "termcolor"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -1565,7 +1515,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "test_utils"
|
name = "test_utils"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"difference",
|
"difference",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
@ -1580,6 +1530,13 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a"
|
checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "text_edit"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"text-size",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thin-dst"
|
name = "thin-dst"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -1620,11 +1577,18 @@ version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
|
checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toolchain"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"home",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing"
|
name = "tracing"
|
||||||
version = "0.1.18"
|
version = "0.1.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178"
|
checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"tracing-attributes",
|
"tracing-attributes",
|
||||||
|
@ -1633,9 +1597,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-attributes"
|
name = "tracing-attributes"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b"
|
checksum = "1fe233f4227389ab7df5b32649239da7ebe0b281824b4e84b342d04d3fd8c25e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1644,9 +1608,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.13"
|
version = "0.1.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d593f98af59ebc017c0648f0117525db358745a8894a8d684e185ba3f45954f9"
|
checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
@ -1674,9 +1638,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-subscriber"
|
name = "tracing-subscriber"
|
||||||
version = "0.2.10"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc"
|
checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -1687,6 +1651,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sharded-slab",
|
"sharded-slab",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
"thread_local",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
"tracing-serde",
|
"tracing-serde",
|
||||||
|
@ -1706,6 +1671,14 @@ dependencies = [
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tt"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"smol_str",
|
||||||
|
"stdx",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ungrammar"
|
name = "ungrammar"
|
||||||
version = "1.1.1"
|
version = "1.1.1"
|
||||||
|
@ -1756,7 +1729,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vfs"
|
name = "vfs"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fst",
|
"fst",
|
||||||
"paths",
|
"paths",
|
||||||
|
@ -1765,7 +1738,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vfs-notify"
|
name = "vfs-notify"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"jod-thread",
|
"jod-thread",
|
||||||
|
|
|
@ -39,7 +39,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0
|
||||||
|
|
||||||
* Website: https://rust-analyzer.github.io/
|
* Website: https://rust-analyzer.github.io/
|
||||||
* Metrics: https://rust-analyzer.github.io/metrics/
|
* Metrics: https://rust-analyzer.github.io/metrics/
|
||||||
* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/
|
* API docs: https://rust-analyzer.github.io/rust-analyzer/ide/
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
status = [
|
status = [
|
||||||
"Rust (ubuntu-latest)",
|
"Rust (ubuntu-latest)",
|
||||||
"Rust (windows-latest)",
|
"Rust (windows-latest)",
|
||||||
"Rust (macos-latest)",
|
# "Rust (macos-latest)",
|
||||||
"TypeScript (ubuntu-latest)",
|
"TypeScript (ubuntu-latest)",
|
||||||
"TypeScript (windows-latest)",
|
"TypeScript (windows-latest)",
|
||||||
"TypeScript (macos-latest)",
|
|
||||||
]
|
]
|
||||||
delete_merged_branches = true
|
delete_merged_branches = true
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
edition = "2018"
|
name = "arena"
|
||||||
name = "ra_arena"
|
version = "0.0.0"
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["rust-analyzer developers"]
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
23
crates/assists/Cargo.toml
Normal file
23
crates/assists/Cargo.toml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[package]
|
||||||
|
name = "assists"
|
||||||
|
version = "0.0.0"
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
doctest = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rustc-hash = "1.1.0"
|
||||||
|
itertools = "0.9.0"
|
||||||
|
either = "1.5.3"
|
||||||
|
|
||||||
|
stdx = { path = "../stdx" }
|
||||||
|
syntax = { path = "../syntax" }
|
||||||
|
text_edit = { path = "../text_edit" }
|
||||||
|
profile = { path = "../profile" }
|
||||||
|
base_db = { path = "../base_db" }
|
||||||
|
ide_db = { path = "../ide_db" }
|
||||||
|
hir = { path = "../hir" }
|
||||||
|
test_utils = { path = "../test_utils" }
|
|
@ -3,19 +3,18 @@
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use algo::find_covering_element;
|
use algo::find_covering_element;
|
||||||
|
use base_db::{FileId, FileRange};
|
||||||
use hir::Semantics;
|
use hir::Semantics;
|
||||||
use ra_db::{FileId, FileRange};
|
use ide_db::{
|
||||||
use ra_fmt::{leading_indent, reindent};
|
|
||||||
use ra_ide_db::{
|
|
||||||
source_change::{SourceChange, SourceFileEdit},
|
source_change::{SourceChange, SourceFileEdit},
|
||||||
RootDatabase,
|
RootDatabase,
|
||||||
};
|
};
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
algo::{self, find_node_at_offset, SyntaxRewriter},
|
algo::{self, find_node_at_offset, SyntaxRewriter},
|
||||||
AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize,
|
AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxToken, TextRange, TextSize,
|
||||||
TokenAtOffset,
|
TokenAtOffset,
|
||||||
};
|
};
|
||||||
use ra_text_edit::TextEditBuilder;
|
use text_edit::{TextEdit, TextEditBuilder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assist_config::{AssistConfig, SnippetCap},
|
assist_config::{AssistConfig, SnippetCap},
|
||||||
|
@ -214,7 +213,7 @@ pub(crate) struct AssistBuilder {
|
||||||
impl AssistBuilder {
|
impl AssistBuilder {
|
||||||
pub(crate) fn new(file_id: FileId) -> AssistBuilder {
|
pub(crate) fn new(file_id: FileId) -> AssistBuilder {
|
||||||
AssistBuilder {
|
AssistBuilder {
|
||||||
edit: TextEditBuilder::default(),
|
edit: TextEdit::builder(),
|
||||||
file_id,
|
file_id,
|
||||||
is_snippet: false,
|
is_snippet: false,
|
||||||
change: SourceChange::default(),
|
change: SourceChange::default(),
|
||||||
|
@ -269,20 +268,6 @@ impl AssistBuilder {
|
||||||
pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) {
|
pub(crate) fn replace_ast<N: AstNode>(&mut self, old: N, new: N) {
|
||||||
algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit)
|
algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit)
|
||||||
}
|
}
|
||||||
/// Replaces specified `node` of text with a given string, reindenting the
|
|
||||||
/// string to maintain `node`'s existing indent.
|
|
||||||
// FIXME: remove in favor of ra_syntax::edit::IndentLevel::increase_indent
|
|
||||||
pub(crate) fn replace_node_and_indent(
|
|
||||||
&mut self,
|
|
||||||
node: &SyntaxNode,
|
|
||||||
replace_with: impl Into<String>,
|
|
||||||
) {
|
|
||||||
let mut replace_with = replace_with.into();
|
|
||||||
if let Some(indent) = leading_indent(node) {
|
|
||||||
replace_with = reindent(&replace_with, &indent)
|
|
||||||
}
|
|
||||||
self.replace(node.text_range(), replace_with)
|
|
||||||
}
|
|
||||||
pub(crate) fn rewrite(&mut self, rewriter: SyntaxRewriter) {
|
pub(crate) fn rewrite(&mut self, rewriter: SyntaxRewriter) {
|
||||||
let node = rewriter.rewrite_root().unwrap();
|
let node = rewriter.rewrite_root().unwrap();
|
||||||
let new = rewriter.rewrite(&node);
|
let new = rewriter.rewrite(&node);
|
|
@ -2,13 +2,13 @@
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use hir::{HirDisplay, PathResolution, SemanticsScope};
|
use hir::{HirDisplay, PathResolution, SemanticsScope};
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
algo::SyntaxRewriter,
|
algo::SyntaxRewriter,
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait AstTransform<'a> {
|
pub trait AstTransform<'a> {
|
||||||
fn get_substitution(&self, node: &ra_syntax::SyntaxNode) -> Option<ra_syntax::SyntaxNode>;
|
fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode>;
|
||||||
|
|
||||||
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a>;
|
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a>;
|
||||||
fn or<T: AstTransform<'a> + 'a>(self, other: T) -> Box<dyn AstTransform<'a> + 'a>
|
fn or<T: AstTransform<'a> + 'a>(self, other: T) -> Box<dyn AstTransform<'a> + 'a>
|
||||||
|
@ -22,7 +22,7 @@ pub trait AstTransform<'a> {
|
||||||
struct NullTransformer;
|
struct NullTransformer;
|
||||||
|
|
||||||
impl<'a> AstTransform<'a> for NullTransformer {
|
impl<'a> AstTransform<'a> for NullTransformer {
|
||||||
fn get_substitution(&self, _node: &ra_syntax::SyntaxNode) -> Option<ra_syntax::SyntaxNode> {
|
fn get_substitution(&self, _node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> {
|
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> {
|
||||||
|
@ -101,10 +101,7 @@ impl<'a> SubstituteTypeParams<'a> {
|
||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn get_substitution_inner(
|
fn get_substitution_inner(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> {
|
||||||
&self,
|
|
||||||
node: &ra_syntax::SyntaxNode,
|
|
||||||
) -> Option<ra_syntax::SyntaxNode> {
|
|
||||||
let type_ref = ast::Type::cast(node.clone())?;
|
let type_ref = ast::Type::cast(node.clone())?;
|
||||||
let path = match &type_ref {
|
let path = match &type_ref {
|
||||||
ast::Type::PathType(path_type) => path_type.path()?,
|
ast::Type::PathType(path_type) => path_type.path()?,
|
||||||
|
@ -122,7 +119,7 @@ impl<'a> SubstituteTypeParams<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> {
|
impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> {
|
||||||
fn get_substitution(&self, node: &ra_syntax::SyntaxNode) -> Option<ra_syntax::SyntaxNode> {
|
fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> {
|
||||||
self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node))
|
self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node))
|
||||||
}
|
}
|
||||||
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> {
|
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> {
|
||||||
|
@ -141,10 +138,7 @@ impl<'a> QualifyPaths<'a> {
|
||||||
Self { target_scope, source_scope, previous: Box::new(NullTransformer) }
|
Self { target_scope, source_scope, previous: Box::new(NullTransformer) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_substitution_inner(
|
fn get_substitution_inner(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> {
|
||||||
&self,
|
|
||||||
node: &ra_syntax::SyntaxNode,
|
|
||||||
) -> Option<ra_syntax::SyntaxNode> {
|
|
||||||
// FIXME handle value ns?
|
// FIXME handle value ns?
|
||||||
let from = self.target_scope.module()?;
|
let from = self.target_scope.module()?;
|
||||||
let p = ast::Path::cast(node.clone())?;
|
let p = ast::Path::cast(node.clone())?;
|
||||||
|
@ -183,7 +177,7 @@ impl<'a> QualifyPaths<'a> {
|
||||||
|
|
||||||
pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: N) -> N {
|
pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: N) -> N {
|
||||||
SyntaxRewriter::from_fn(|element| match element {
|
SyntaxRewriter::from_fn(|element| match element {
|
||||||
ra_syntax::SyntaxElement::Node(n) => {
|
syntax::SyntaxElement::Node(n) => {
|
||||||
let replacement = transformer.get_substitution(&n)?;
|
let replacement = transformer.get_substitution(&n)?;
|
||||||
Some(replacement.into())
|
Some(replacement.into())
|
||||||
}
|
}
|
||||||
|
@ -193,7 +187,7 @@ pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: N) -> N {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AstTransform<'a> for QualifyPaths<'a> {
|
impl<'a> AstTransform<'a> for QualifyPaths<'a> {
|
||||||
fn get_substitution(&self, node: &ra_syntax::SyntaxNode) -> Option<ra_syntax::SyntaxNode> {
|
fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option<syntax::SyntaxNode> {
|
||||||
self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node))
|
self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node))
|
||||||
}
|
}
|
||||||
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> {
|
fn chain_before(self, other: Box<dyn AstTransform<'a> + 'a>) -> Box<dyn AstTransform<'a> + 'a> {
|
|
@ -1,5 +1,5 @@
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
Direction, SmolStr,
|
Direction, SmolStr,
|
||||||
SyntaxKind::{IDENT, WHITESPACE},
|
SyntaxKind::{IDENT, WHITESPACE},
|
|
@ -1,5 +1,5 @@
|
||||||
use hir::HirDisplay;
|
use hir::HirDisplay;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode, LetStmt, NameOwner},
|
ast::{self, AstNode, LetStmt, NameOwner},
|
||||||
TextRange,
|
TextRange,
|
||||||
};
|
};
|
|
@ -1,5 +1,5 @@
|
||||||
use hir::HasSource;
|
use hir::HasSource;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
edit::{self, AstNodeEdit, IndentLevel},
|
edit::{self, AstNodeEdit, IndentLevel},
|
||||||
|
@ -110,7 +110,7 @@ fn add_missing_impl_members_inner(
|
||||||
assist_id: &'static str,
|
assist_id: &'static str,
|
||||||
label: &'static str,
|
label: &'static str,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let _p = ra_prof::profile("add_missing_impl_members_inner");
|
let _p = profile::span("add_missing_impl_members_inner");
|
||||||
let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
|
let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
|
||||||
let impl_item_list = impl_def.assoc_item_list()?;
|
let impl_item_list = impl_def.assoc_item_list()?;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ra_ide_db::defs::{classify_name_ref, Definition, NameRefClass};
|
use ide_db::defs::{classify_name_ref, Definition, NameRefClass};
|
||||||
use ra_syntax::{ast, AstNode, SyntaxKind, T};
|
use syntax::{ast, AstNode, SyntaxKind, T};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::ast::{self, AstNode};
|
use syntax::ast::{self, AstNode};
|
||||||
|
|
||||||
use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists};
|
use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -5,13 +5,12 @@ use hir::{
|
||||||
AsAssocItem, AssocItemContainer, ModPath, Module, ModuleDef, PathResolution, Semantics, Trait,
|
AsAssocItem, AssocItemContainer, ModPath, Module, ModuleDef, PathResolution, Semantics, Trait,
|
||||||
Type,
|
Type,
|
||||||
};
|
};
|
||||||
use ra_ide_db::{imports_locator, RootDatabase};
|
use ide_db::{imports_locator, RootDatabase};
|
||||||
use ra_prof::profile;
|
use rustc_hash::FxHashSet;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashSet;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
utils::insert_use_statement, AssistContext, AssistId, AssistKind, Assists, GroupLabel,
|
utils::insert_use_statement, AssistContext, AssistId, AssistKind, Assists, GroupLabel,
|
||||||
|
@ -130,7 +129,7 @@ impl AutoImportAssets {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_for_imports(&self, ctx: &AssistContext) -> BTreeSet<ModPath> {
|
fn search_for_imports(&self, ctx: &AssistContext) -> BTreeSet<ModPath> {
|
||||||
let _p = profile("auto_import::search_for_imports");
|
let _p = profile::span("auto_import::search_for_imports");
|
||||||
let db = ctx.db();
|
let db = ctx.db();
|
||||||
let current_crate = self.module_with_name_to_import.krate();
|
let current_crate = self.module_with_name_to_import.krate();
|
||||||
imports_locator::find_imports(&ctx.sema, current_crate, &self.get_search_query())
|
imports_locator::find_imports(&ctx.sema, current_crate, &self.get_search_query())
|
|
@ -1,10 +1,12 @@
|
||||||
use ra_syntax::{
|
use std::iter;
|
||||||
ast::{self, BlockExpr, Expr, LoopBodyOwner},
|
|
||||||
|
use syntax::{
|
||||||
|
ast::{self, make, BlockExpr, Expr, LoopBodyOwner},
|
||||||
AstNode, SyntaxNode,
|
AstNode, SyntaxNode,
|
||||||
};
|
};
|
||||||
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
use test_utils::mark;
|
|
||||||
|
|
||||||
// Assist: change_return_type_to_result
|
// Assist: change_return_type_to_result
|
||||||
//
|
//
|
||||||
|
@ -44,7 +46,13 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex
|
||||||
tail_return_expr_collector.collect_tail_exprs(block_expr);
|
tail_return_expr_collector.collect_tail_exprs(block_expr);
|
||||||
|
|
||||||
for ret_expr_arg in tail_return_expr_collector.exprs_to_wrap {
|
for ret_expr_arg in tail_return_expr_collector.exprs_to_wrap {
|
||||||
builder.replace_node_and_indent(&ret_expr_arg, format!("Ok({})", ret_expr_arg));
|
let ok_wrapped = make::expr_call(
|
||||||
|
make::expr_path(make::path_unqualified(make::path_segment(make::name_ref(
|
||||||
|
"Ok",
|
||||||
|
)))),
|
||||||
|
make::arg_list(iter::once(ret_expr_arg.clone())),
|
||||||
|
);
|
||||||
|
builder.replace_ast(ret_expr_arg, ok_wrapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
match ctx.config.snippet_cap {
|
match ctx.config.snippet_cap {
|
||||||
|
@ -60,7 +68,7 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TailReturnCollector {
|
struct TailReturnCollector {
|
||||||
exprs_to_wrap: Vec<SyntaxNode>,
|
exprs_to_wrap: Vec<ast::Expr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TailReturnCollector {
|
impl TailReturnCollector {
|
||||||
|
@ -86,7 +94,8 @@ impl TailReturnCollector {
|
||||||
if let Some(last_exprs) = get_tail_expr_from_block(&expr) {
|
if let Some(last_exprs) = get_tail_expr_from_block(&expr) {
|
||||||
for last_expr in last_exprs {
|
for last_expr in last_exprs {
|
||||||
let last_expr = match last_expr {
|
let last_expr = match last_expr {
|
||||||
NodeType::Node(expr) | NodeType::Leaf(expr) => expr,
|
NodeType::Node(expr) => expr,
|
||||||
|
NodeType::Leaf(expr) => expr.syntax().clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(last_expr) = Expr::cast(last_expr.clone()) {
|
if let Some(last_expr) = Expr::cast(last_expr.clone()) {
|
||||||
|
@ -113,12 +122,12 @@ impl TailReturnCollector {
|
||||||
}
|
}
|
||||||
Expr::ReturnExpr(ret_expr) => {
|
Expr::ReturnExpr(ret_expr) => {
|
||||||
if let Some(ret_expr_arg) = &ret_expr.expr() {
|
if let Some(ret_expr_arg) = &ret_expr.expr() {
|
||||||
self.exprs_to_wrap.push(ret_expr_arg.syntax().clone());
|
self.exprs_to_wrap.push(ret_expr_arg.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::BreakExpr(break_expr) if collect_break => {
|
Expr::BreakExpr(break_expr) if collect_break => {
|
||||||
if let Some(break_expr_arg) = &break_expr.expr() {
|
if let Some(break_expr_arg) = &break_expr.expr() {
|
||||||
self.exprs_to_wrap.push(break_expr_arg.syntax().clone());
|
self.exprs_to_wrap.push(break_expr_arg.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::IfExpr(if_expr) => {
|
Expr::IfExpr(if_expr) => {
|
||||||
|
@ -166,14 +175,11 @@ impl TailReturnCollector {
|
||||||
NodeType::Leaf(expr) => {
|
NodeType::Leaf(expr) => {
|
||||||
self.exprs_to_wrap.push(expr.clone());
|
self.exprs_to_wrap.push(expr.clone());
|
||||||
}
|
}
|
||||||
NodeType::Node(expr) => match &Expr::cast(expr.clone()) {
|
NodeType::Node(expr) => {
|
||||||
Some(last_expr) => {
|
if let Some(last_expr) = Expr::cast(expr.clone()) {
|
||||||
self.fetch_tail_exprs(last_expr);
|
self.fetch_tail_exprs(&last_expr);
|
||||||
}
|
}
|
||||||
None => {
|
}
|
||||||
self.exprs_to_wrap.push(expr.clone());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +188,7 @@ impl TailReturnCollector {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum NodeType {
|
enum NodeType {
|
||||||
Leaf(SyntaxNode),
|
Leaf(ast::Expr),
|
||||||
Node(SyntaxNode),
|
Node(SyntaxNode),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,25 +239,26 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> {
|
||||||
|
|
||||||
Some(arms)
|
Some(arms)
|
||||||
}
|
}
|
||||||
Expr::BreakExpr(expr) => expr.expr().map(|e| vec![NodeType::Leaf(e.syntax().clone())]),
|
Expr::BreakExpr(expr) => expr.expr().map(|e| vec![NodeType::Leaf(e)]),
|
||||||
Expr::ReturnExpr(ret_expr) => Some(vec![NodeType::Node(ret_expr.syntax().clone())]),
|
Expr::ReturnExpr(ret_expr) => Some(vec![NodeType::Node(ret_expr.syntax().clone())]),
|
||||||
Expr::CallExpr(call_expr) => Some(vec![NodeType::Leaf(call_expr.syntax().clone())]),
|
|
||||||
Expr::Literal(lit_expr) => Some(vec![NodeType::Leaf(lit_expr.syntax().clone())]),
|
Expr::CallExpr(_)
|
||||||
Expr::TupleExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::Literal(_)
|
||||||
Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::TupleExpr(_)
|
||||||
Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::ArrayExpr(_)
|
||||||
Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::ParenExpr(_)
|
||||||
Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::PathExpr(_)
|
||||||
Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::RecordExpr(_)
|
||||||
Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::IndexExpr(_)
|
||||||
Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::MethodCallExpr(_)
|
||||||
Expr::CastExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::AwaitExpr(_)
|
||||||
Expr::RefExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::CastExpr(_)
|
||||||
Expr::PrefixExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::RefExpr(_)
|
||||||
Expr::RangeExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::PrefixExpr(_)
|
||||||
Expr::BinExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::RangeExpr(_)
|
||||||
Expr::MacroCall(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::BinExpr(_)
|
||||||
Expr::BoxExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]),
|
| Expr::MacroCall(_)
|
||||||
|
| Expr::BoxExpr(_) => Some(vec![NodeType::Leaf(expr.clone())]),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, NameOwner, VisibilityOwner},
|
ast::{self, NameOwner, VisibilityOwner},
|
||||||
AstNode,
|
AstNode,
|
||||||
SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY},
|
SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY},
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{iter::once, ops::RangeInclusive};
|
use std::{iter::once, ops::RangeInclusive};
|
||||||
|
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
algo::replace_children,
|
algo::replace_children,
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
|
@ -1,9 +1,9 @@
|
||||||
use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope};
|
use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope};
|
||||||
use ra_ide_db::{
|
use ide_db::{
|
||||||
defs::{classify_name_ref, Definition, NameRefClass},
|
defs::{classify_name_ref, Definition, NameRefClass},
|
||||||
RootDatabase,
|
RootDatabase,
|
||||||
};
|
};
|
||||||
use ra_syntax::{algo, ast, match_ast, AstNode, SyntaxNode, SyntaxToken, T};
|
use syntax::{algo, ast, match_ast, AstNode, SyntaxNode, SyntaxToken, T};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assist_context::{AssistBuilder, AssistContext, Assists},
|
assist_context::{AssistBuilder, AssistContext, Assists},
|
|
@ -1,13 +1,12 @@
|
||||||
|
use base_db::FileId;
|
||||||
use hir::{EnumVariant, Module, ModuleDef, Name};
|
use hir::{EnumVariant, Module, ModuleDef, Name};
|
||||||
use ra_db::FileId;
|
use ide_db::{defs::Definition, search::Reference, RootDatabase};
|
||||||
use ra_fmt::leading_indent;
|
|
||||||
use ra_ide_db::{defs::Definition, search::Reference, RootDatabase};
|
|
||||||
use ra_syntax::{
|
|
||||||
algo::find_node_at_offset,
|
|
||||||
ast::{self, ArgListOwner, AstNode, NameOwner, VisibilityOwner},
|
|
||||||
SourceFile, SyntaxNode, TextRange, TextSize,
|
|
||||||
};
|
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
use syntax::{
|
||||||
|
algo::find_node_at_offset,
|
||||||
|
ast::{self, edit::IndentLevel, ArgListOwner, AstNode, NameOwner, VisibilityOwner},
|
||||||
|
SourceFile, TextRange, TextSize,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assist_context::AssistBuilder, utils::insert_use_statement, AssistContext, AssistId,
|
assist_context::AssistBuilder, utils::insert_use_statement, AssistContext, AssistId,
|
||||||
|
@ -72,7 +71,7 @@ pub(crate) fn extract_struct_from_enum_variant(
|
||||||
}
|
}
|
||||||
extract_struct_def(
|
extract_struct_def(
|
||||||
builder,
|
builder,
|
||||||
enum_ast.syntax(),
|
&enum_ast,
|
||||||
&variant_name,
|
&variant_name,
|
||||||
&field_list.to_string(),
|
&field_list.to_string(),
|
||||||
start_offset,
|
start_offset,
|
||||||
|
@ -112,9 +111,10 @@ fn insert_import(
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this should use strongly-typed `make`, rather than string manipulation.
|
||||||
fn extract_struct_def(
|
fn extract_struct_def(
|
||||||
builder: &mut AssistBuilder,
|
builder: &mut AssistBuilder,
|
||||||
enum_ast: &SyntaxNode,
|
enum_: &ast::Enum,
|
||||||
variant_name: &str,
|
variant_name: &str,
|
||||||
variant_list: &str,
|
variant_list: &str,
|
||||||
start_offset: TextSize,
|
start_offset: TextSize,
|
||||||
|
@ -126,11 +126,7 @@ fn extract_struct_def(
|
||||||
} else {
|
} else {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
};
|
};
|
||||||
let indent = if let Some(indent) = leading_indent(enum_ast) {
|
let indent = IndentLevel::from_node(enum_.syntax());
|
||||||
indent.to_string()
|
|
||||||
} else {
|
|
||||||
"".to_string()
|
|
||||||
};
|
|
||||||
let struct_def = format!(
|
let struct_def = format!(
|
||||||
r#"{}struct {}{};
|
r#"{}struct {}{};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use ra_syntax::{
|
use stdx::format_to;
|
||||||
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
SyntaxKind::{
|
SyntaxKind::{
|
||||||
BLOCK_EXPR, BREAK_EXPR, CLOSURE_EXPR, COMMENT, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR,
|
BLOCK_EXPR, BREAK_EXPR, CLOSURE_EXPR, COMMENT, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR,
|
||||||
},
|
},
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
};
|
};
|
||||||
use stdx::format_to;
|
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
|
@ -1,9 +1,9 @@
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use hir::{Adt, HasSource, ModuleDef, Semantics};
|
use hir::{Adt, HasSource, ModuleDef, Semantics};
|
||||||
|
use ide_db::RootDatabase;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ra_ide_db::RootDatabase;
|
use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
|
||||||
use ra_syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
|
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
|
@ -1,6 +1,6 @@
|
||||||
|
use base_db::FileId;
|
||||||
use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution};
|
use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution};
|
||||||
use ra_db::FileId;
|
use syntax::{ast, AstNode, TextRange, TextSize};
|
||||||
use ra_syntax::{ast, AstNode, TextRange, TextSize};
|
|
||||||
|
|
||||||
use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
|
use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
|
||||||
use ast::VisibilityOwner;
|
use ast::VisibilityOwner;
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::ast::{AstNode, BinExpr, BinOp};
|
use syntax::ast::{AstNode, BinExpr, BinOp};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{algo::non_trivia_sibling, Direction, T};
|
use syntax::{algo::non_trivia_sibling, Direction, T};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
algo::non_trivia_sibling,
|
algo::non_trivia_sibling,
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
Direction, T,
|
Direction, T,
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode, AttrsOwner},
|
ast::{self, AstNode, AttrsOwner},
|
||||||
SyntaxKind::{COMMENT, WHITESPACE},
|
SyntaxKind::{COMMENT, WHITESPACE},
|
||||||
TextSize,
|
TextSize,
|
|
@ -1,5 +1,5 @@
|
||||||
use ra_ide_db::RootDatabase;
|
use ide_db::RootDatabase;
|
||||||
use ra_syntax::ast::{self, AstNode, NameOwner};
|
use syntax::ast::{self, AstNode, NameOwner};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{utils::FamousDefs, AssistContext, AssistId, AssistKind, Assists};
|
use crate::{utils::FamousDefs, AssistContext, AssistId, AssistKind, Assists};
|
|
@ -1,6 +1,7 @@
|
||||||
|
use base_db::FileId;
|
||||||
use hir::HirDisplay;
|
use hir::HirDisplay;
|
||||||
use ra_db::FileId;
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
edit::{AstNodeEdit, IndentLevel},
|
edit::{AstNodeEdit, IndentLevel},
|
||||||
|
@ -8,7 +9,6 @@ use ra_syntax::{
|
||||||
},
|
},
|
||||||
SyntaxKind, SyntaxNode, TextSize,
|
SyntaxKind, SyntaxNode, TextSize,
|
||||||
};
|
};
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assist_config::SnippetCap,
|
assist_config::SnippetCap,
|
|
@ -1,6 +1,6 @@
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
|
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
|
use syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use hir::Adt;
|
use hir::Adt;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ra_syntax::{
|
use stdx::format_to;
|
||||||
|
use syntax::{
|
||||||
ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner},
|
ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner},
|
||||||
T,
|
T,
|
||||||
};
|
};
|
||||||
use stdx::format_to;
|
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ra_ide_db::defs::Definition;
|
use ide_db::defs::Definition;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode, AstToken},
|
ast::{self, AstNode, AstToken},
|
||||||
TextRange,
|
TextRange,
|
||||||
};
|
};
|
|
@ -1,8 +1,8 @@
|
||||||
use ra_syntax::{
|
use rustc_hash::FxHashSet;
|
||||||
|
use syntax::{
|
||||||
ast::{self, GenericParamsOwner, NameOwner},
|
ast::{self, GenericParamsOwner, NameOwner},
|
||||||
AstNode, SyntaxKind, TextRange, TextSize,
|
AstNode, SyntaxKind, TextRange, TextSize,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashSet;
|
|
||||||
|
|
||||||
use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind, Assists};
|
use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
T,
|
T,
|
||||||
};
|
};
|
|
@ -1,6 +1,6 @@
|
||||||
use std::iter::successors;
|
use std::iter::successors;
|
||||||
|
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
algo::{neighbor, skip_trivia_token, SyntaxRewriter},
|
algo::{neighbor, skip_trivia_token, SyntaxRewriter},
|
||||||
ast::{self, edit::AstNodeEdit, make},
|
ast::{self, edit::AstNodeEdit, make},
|
||||||
AstNode, Direction, InsertPosition, SyntaxElement, T,
|
AstNode, Direction, InsertPosition, SyntaxElement, T,
|
||||||
|
@ -164,6 +164,33 @@ use std::fmt::{Display, Debug};
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn merge_self1() {
|
||||||
|
check_assist(
|
||||||
|
merge_imports,
|
||||||
|
r"
|
||||||
|
use std::fmt<|>;
|
||||||
|
use std::fmt::Display;
|
||||||
|
",
|
||||||
|
r"
|
||||||
|
use std::fmt::{self, Display};
|
||||||
|
",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn merge_self2() {
|
||||||
|
check_assist(
|
||||||
|
merge_imports,
|
||||||
|
r"
|
||||||
|
use std::{fmt, <|>fmt::Display};
|
||||||
|
",
|
||||||
|
r"
|
||||||
|
use std::{fmt::{Display, self}};
|
||||||
|
",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_merge_nested() {
|
fn test_merge_nested() {
|
||||||
check_assist(
|
check_assist(
|
|
@ -1,6 +1,6 @@
|
||||||
use std::iter::successors;
|
use std::iter::successors;
|
||||||
|
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
algo::neighbor,
|
algo::neighbor,
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
Direction,
|
Direction,
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, edit::AstNodeEdit, make, AstNode, NameOwner, TypeBoundsOwner},
|
ast::{self, edit::AstNodeEdit, make, AstNode, NameOwner, TypeBoundsOwner},
|
||||||
match_ast,
|
match_ast,
|
||||||
SyntaxKind::*,
|
SyntaxKind::*,
|
|
@ -1,5 +1,5 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{AstNode, IfExpr, MatchArm},
|
ast::{edit::AstNodeEdit, make, AstNode, IfExpr, MatchArm},
|
||||||
SyntaxKind::WHITESPACE,
|
SyntaxKind::WHITESPACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
//
|
//
|
||||||
// fn handle(action: Action) {
|
// fn handle(action: Action) {
|
||||||
// match action {
|
// match action {
|
||||||
// Action::Move { distance } => if distance > 10 { foo() },
|
// Action::Move { distance } => if distance > 10 {
|
||||||
|
// foo()
|
||||||
|
// },
|
||||||
// _ => (),
|
// _ => (),
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -35,9 +37,13 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) ->
|
||||||
let guard = match_arm.guard()?;
|
let guard = match_arm.guard()?;
|
||||||
let space_before_guard = guard.syntax().prev_sibling_or_token();
|
let space_before_guard = guard.syntax().prev_sibling_or_token();
|
||||||
|
|
||||||
let guard_conditions = guard.expr()?;
|
let guard_condition = guard.expr()?;
|
||||||
let arm_expr = match_arm.expr()?;
|
let arm_expr = match_arm.expr()?;
|
||||||
let buf = format!("if {} {{ {} }}", guard_conditions.syntax().text(), arm_expr.syntax().text());
|
let if_expr = make::expr_if(
|
||||||
|
make::condition(guard_condition, None),
|
||||||
|
make::block_expr(None, Some(arm_expr.clone())),
|
||||||
|
)
|
||||||
|
.indent(arm_expr.indent_level());
|
||||||
|
|
||||||
let target = guard.syntax().text_range();
|
let target = guard.syntax().text_range();
|
||||||
acc.add(
|
acc.add(
|
||||||
|
@ -53,7 +59,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) ->
|
||||||
};
|
};
|
||||||
|
|
||||||
edit.delete(guard.syntax().text_range());
|
edit.delete(guard.syntax().text_range());
|
||||||
edit.replace_node_and_indent(arm_expr.syntax(), buf);
|
edit.replace_ast(arm_expr, if_expr);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -134,16 +140,14 @@ mod tests {
|
||||||
check_assist_target(
|
check_assist_target(
|
||||||
move_guard_to_arm_body,
|
move_guard_to_arm_body,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x <|>if x > 10 => false,
|
||||||
match t {
|
_ => true
|
||||||
'\r' <|>if chars.clone().next() == Some('\n') => false,
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
r#"if x > 10"#,
|
||||||
"#,
|
|
||||||
r#"if chars.clone().next() == Some('\n')"#,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,25 +156,23 @@ mod tests {
|
||||||
check_assist(
|
check_assist(
|
||||||
move_guard_to_arm_body,
|
move_guard_to_arm_body,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x <|>if x > 10 => false,
|
||||||
match t {
|
_ => true
|
||||||
'\r' <|>if chars.clone().next() == Some('\n') => false,
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x => if x > 10 {
|
||||||
match t {
|
false
|
||||||
'\r' => if chars.clone().next() == Some('\n') { false },
|
},
|
||||||
_ => true
|
_ => true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,21 +181,23 @@ mod tests {
|
||||||
check_assist(
|
check_assist(
|
||||||
move_guard_to_arm_body,
|
move_guard_to_arm_body,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
match x {
|
match 92 {
|
||||||
<|>y @ 4 | y @ 5 if y > 5 => true,
|
<|>x @ 4 | x @ 5 if x > 5 => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
match x {
|
match 92 {
|
||||||
y @ 4 | y @ 5 => if y > 5 { true },
|
x @ 4 | x @ 5 => if x > 5 {
|
||||||
_ => false
|
true
|
||||||
}
|
},
|
||||||
}
|
_ => false
|
||||||
"#,
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,25 +206,21 @@ mod tests {
|
||||||
check_assist(
|
check_assist(
|
||||||
move_arm_cond_to_match_guard,
|
move_arm_cond_to_match_guard,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x => if x > 10 { <|>false },
|
||||||
match t {
|
_ => true
|
||||||
'\r' => if chars.clone().next() == Some('\n') { <|>false },
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x if x > 10 => false,
|
||||||
match t {
|
_ => true
|
||||||
'\r' if chars.clone().next() == Some('\n') => false,
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,15 +229,13 @@ mod tests {
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
move_arm_cond_to_match_guard,
|
move_arm_cond_to_match_guard,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x => if let 62 = x { <|>false },
|
||||||
match t {
|
_ => true
|
||||||
'\r' => if let Some(_) = chars.clone().next() { <|>false },
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,25 +244,21 @@ mod tests {
|
||||||
check_assist(
|
check_assist(
|
||||||
move_arm_cond_to_match_guard,
|
move_arm_cond_to_match_guard,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x => if x > 10 { <|> },
|
||||||
match t {
|
_ => true
|
||||||
'\r' => if chars.clone().next().is_some() { <|> },
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x if x > 10 => { },
|
||||||
match t {
|
_ => true
|
||||||
'\r' if chars.clone().next().is_some() => { },
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,31 +267,27 @@ mod tests {
|
||||||
check_assist(
|
check_assist(
|
||||||
move_arm_cond_to_match_guard,
|
move_arm_cond_to_match_guard,
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let mut t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x => if x > 10 {
|
||||||
match t {
|
92;<|>
|
||||||
'\r' => if chars.clone().next().is_some() {
|
false
|
||||||
t = 'e';<|>
|
},
|
||||||
false
|
_ => true
|
||||||
},
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn main() {
|
||||||
let mut t = 'a';
|
match 92 {
|
||||||
let chars = "abcd";
|
x if x > 10 => {
|
||||||
match t {
|
92;
|
||||||
'\r' if chars.clone().next().is_some() => {
|
false
|
||||||
t = 'e';
|
},
|
||||||
false
|
_ => true
|
||||||
},
|
}
|
||||||
_ => true
|
}
|
||||||
}
|
"#,
|
||||||
}
|
|
||||||
"#,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, HasQuotes, HasStringValue},
|
ast::{self, HasQuotes, HasStringValue},
|
||||||
AstToken,
|
AstToken,
|
||||||
SyntaxKind::{RAW_STRING, STRING},
|
SyntaxKind::{RAW_STRING, STRING},
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
TextRange, TextSize, T,
|
TextRange, TextSize, T,
|
||||||
};
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
use ra_syntax::{SyntaxKind, TextRange, T};
|
use syntax::{SyntaxKind, TextRange, T};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -2,8 +2,8 @@ use itertools::Itertools;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct};
|
use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct};
|
||||||
use ra_ide_db::RootDatabase;
|
use ide_db::RootDatabase;
|
||||||
use ra_syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode};
|
use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use ra_fmt::unwrap_trivial_block;
|
use syntax::{
|
||||||
use ra_syntax::{
|
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
edit::{AstNodeEdit, IndentLevel},
|
edit::{AstNodeEdit, IndentLevel},
|
||||||
|
@ -8,7 +7,10 @@ use ra_syntax::{
|
||||||
AstNode,
|
AstNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{utils::TryEnum, AssistContext, AssistId, AssistKind, Assists};
|
use crate::{
|
||||||
|
utils::{unwrap_trivial_block, TryEnum},
|
||||||
|
AssistContext, AssistId, AssistKind, Assists,
|
||||||
|
};
|
||||||
|
|
||||||
// Assist: replace_if_let_with_match
|
// Assist: replace_if_let_with_match
|
||||||
//
|
//
|
|
@ -1,6 +1,6 @@
|
||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
|
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
edit::{AstNodeEdit, IndentLevel},
|
edit::{AstNodeEdit, IndentLevel},
|
|
@ -1,5 +1,5 @@
|
||||||
use hir;
|
use hir;
|
||||||
use ra_syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SmolStr, SyntaxNode};
|
use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SmolStr, SyntaxNode};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
utils::{find_insert_use_container, insert_use_statement},
|
utils::{find_insert_use_container, insert_use_statement},
|
|
@ -1,6 +1,6 @@
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
edit::{AstNodeEdit, IndentLevel},
|
edit::{AstNodeEdit, IndentLevel},
|
|
@ -1,6 +1,6 @@
|
||||||
use std::iter::successors;
|
use std::iter::successors;
|
||||||
|
|
||||||
use ra_syntax::{ast, AstNode, T};
|
use syntax::{ast, AstNode, T};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use ra_fmt::unwrap_trivial_block;
|
use syntax::{
|
||||||
use ra_syntax::{
|
|
||||||
ast::{
|
ast::{
|
||||||
self,
|
self,
|
||||||
edit::{AstNodeEdit, IndentLevel},
|
edit::{AstNodeEdit, IndentLevel},
|
||||||
|
@ -7,7 +6,7 @@ use ra_syntax::{
|
||||||
AstNode, TextRange, T,
|
AstNode, TextRange, T,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
use crate::{utils::unwrap_trivial_block, AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
||||||
// Assist: unwrap_block
|
// Assist: unwrap_block
|
||||||
//
|
//
|
|
@ -1,4 +1,4 @@
|
||||||
//! `ra_assists` crate provides a bunch of code assists, also known as code
|
//! `assists` crate provides a bunch of code assists, also known as code
|
||||||
//! actions (in LSP) or intentions (in IntelliJ).
|
//! actions (in LSP) or intentions (in IntelliJ).
|
||||||
//!
|
//!
|
||||||
//! An assist is a micro-refactoring, which is automatically activated in
|
//! An assist is a micro-refactoring, which is automatically activated in
|
||||||
|
@ -17,10 +17,10 @@ mod tests;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod ast_transform;
|
pub mod ast_transform;
|
||||||
|
|
||||||
|
use base_db::FileRange;
|
||||||
use hir::Semantics;
|
use hir::Semantics;
|
||||||
use ra_db::FileRange;
|
use ide_db::{source_change::SourceChange, RootDatabase};
|
||||||
use ra_ide_db::{source_change::SourceChange, RootDatabase};
|
use syntax::TextRange;
|
||||||
use ra_syntax::TextRange;
|
|
||||||
|
|
||||||
pub(crate) use crate::assist_context::{AssistContext, Assists};
|
pub(crate) use crate::assist_context::{AssistContext, Assists};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
mod generated;
|
mod generated;
|
||||||
|
|
||||||
|
use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt};
|
||||||
use hir::Semantics;
|
use hir::Semantics;
|
||||||
use ra_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt};
|
use ide_db::RootDatabase;
|
||||||
use ra_ide_db::RootDatabase;
|
use syntax::TextRange;
|
||||||
use ra_syntax::TextRange;
|
|
||||||
use test_utils::{assert_eq_text, extract_offset, extract_range};
|
use test_utils::{assert_eq_text, extract_offset, extract_range};
|
||||||
|
|
||||||
use crate::{handlers::Handler, Assist, AssistConfig, AssistContext, AssistKind, Assists};
|
use crate::{handlers::Handler, Assist, AssistConfig, AssistContext, AssistKind, Assists};
|
|
@ -690,7 +690,9 @@ enum Action { Move { distance: u32 }, Stop }
|
||||||
|
|
||||||
fn handle(action: Action) {
|
fn handle(action: Action) {
|
||||||
match action {
|
match action {
|
||||||
Action::Move { distance } => if distance > 10 { foo() },
|
Action::Move { distance } => if distance > 10 {
|
||||||
|
foo()
|
||||||
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,19 +4,57 @@ pub(crate) mod insert_use;
|
||||||
use std::{iter, ops};
|
use std::{iter, ops};
|
||||||
|
|
||||||
use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type};
|
use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type};
|
||||||
use ra_ide_db::RootDatabase;
|
use ide_db::RootDatabase;
|
||||||
use ra_syntax::{
|
use itertools::Itertools;
|
||||||
|
use rustc_hash::FxHashSet;
|
||||||
|
use syntax::{
|
||||||
ast::{self, make, NameOwner},
|
ast::{self, make, NameOwner},
|
||||||
AstNode,
|
AstNode,
|
||||||
SyntaxKind::*,
|
SyntaxKind::*,
|
||||||
SyntaxNode, TextSize, T,
|
SyntaxNode, TextSize, T,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashSet;
|
|
||||||
|
|
||||||
use crate::assist_config::SnippetCap;
|
use crate::assist_config::SnippetCap;
|
||||||
|
|
||||||
pub(crate) use insert_use::{find_insert_use_container, insert_use_statement};
|
pub(crate) use insert_use::{find_insert_use_container, insert_use_statement};
|
||||||
|
|
||||||
|
pub(crate) fn unwrap_trivial_block(block: ast::BlockExpr) -> ast::Expr {
|
||||||
|
extract_trivial_expression(&block)
|
||||||
|
.filter(|expr| !expr.syntax().text().contains_char('\n'))
|
||||||
|
.unwrap_or_else(|| block.into())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extract_trivial_expression(block: &ast::BlockExpr) -> Option<ast::Expr> {
|
||||||
|
let has_anything_else = |thing: &SyntaxNode| -> bool {
|
||||||
|
let mut non_trivial_children =
|
||||||
|
block.syntax().children_with_tokens().filter(|it| match it.kind() {
|
||||||
|
WHITESPACE | T!['{'] | T!['}'] => false,
|
||||||
|
_ => it.as_node() != Some(thing),
|
||||||
|
});
|
||||||
|
non_trivial_children.next().is_some()
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(expr) = block.expr() {
|
||||||
|
if has_anything_else(expr.syntax()) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
return Some(expr);
|
||||||
|
}
|
||||||
|
// Unwrap `{ continue; }`
|
||||||
|
let (stmt,) = block.statements().next_tuple()?;
|
||||||
|
if let ast::Stmt::ExprStmt(expr_stmt) = stmt {
|
||||||
|
if has_anything_else(expr_stmt.syntax()) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let expr = expr_stmt.expr()?;
|
||||||
|
match expr.syntax().kind() {
|
||||||
|
CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub(crate) enum Cursor<'a> {
|
pub(crate) enum Cursor<'a> {
|
||||||
Replace(&'a SyntaxNode),
|
Replace(&'a SyntaxNode),
|
|
@ -2,17 +2,19 @@
|
||||||
// FIXME: rewrite according to the plan, outlined in
|
// FIXME: rewrite according to the plan, outlined in
|
||||||
// https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553
|
// https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553
|
||||||
|
|
||||||
|
use std::iter::successors;
|
||||||
|
|
||||||
|
use either::Either;
|
||||||
use hir::{self, ModPath};
|
use hir::{self, ModPath};
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, NameOwner, VisibilityOwner},
|
ast::{self, NameOwner, VisibilityOwner},
|
||||||
AstNode, Direction, SmolStr,
|
AstNode, AstToken, Direction, SmolStr,
|
||||||
SyntaxKind::{PATH, PATH_SEGMENT},
|
SyntaxKind::{PATH, PATH_SEGMENT},
|
||||||
SyntaxNode, T,
|
SyntaxNode, SyntaxToken, T,
|
||||||
};
|
};
|
||||||
use ra_text_edit::TextEditBuilder;
|
use text_edit::TextEditBuilder;
|
||||||
|
|
||||||
use crate::assist_context::AssistContext;
|
use crate::assist_context::AssistContext;
|
||||||
use either::Either;
|
|
||||||
|
|
||||||
/// Determines the containing syntax node in which to insert a `use` statement affecting `position`.
|
/// Determines the containing syntax node in which to insert a `use` statement affecting `position`.
|
||||||
pub(crate) fn find_insert_use_container(
|
pub(crate) fn find_insert_use_container(
|
||||||
|
@ -442,7 +444,7 @@ fn make_assist_add_new_use(
|
||||||
edit: &mut TextEditBuilder,
|
edit: &mut TextEditBuilder,
|
||||||
) {
|
) {
|
||||||
if let Some(anchor) = anchor {
|
if let Some(anchor) = anchor {
|
||||||
let indent = ra_fmt::leading_indent(anchor);
|
let indent = leading_indent(anchor);
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
if after {
|
if after {
|
||||||
buf.push_str("\n");
|
buf.push_str("\n");
|
||||||
|
@ -524,3 +526,22 @@ fn make_assist_add_nested_import(
|
||||||
edit.insert(end, "}".to_string());
|
edit.insert(end, "}".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If the node is on the beginning of the line, calculate indent.
|
||||||
|
fn leading_indent(node: &SyntaxNode) -> Option<SmolStr> {
|
||||||
|
for token in prev_tokens(node.first_token()?) {
|
||||||
|
if let Some(ws) = ast::Whitespace::cast(token.clone()) {
|
||||||
|
let ws_text = ws.text();
|
||||||
|
if let Some(pos) = ws_text.rfind('\n') {
|
||||||
|
return Some(ws_text[pos + 1..].into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if token.text().contains('\n') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return None;
|
||||||
|
fn prev_tokens(token: SyntaxToken) -> impl Iterator<Item = SyntaxToken> {
|
||||||
|
successors(token.prev_token(), |token| token.prev_token())
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
edition = "2018"
|
name = "base_db"
|
||||||
name = "ra_db"
|
version = "0.0.0"
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["rust-analyzer developers"]
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -12,10 +12,10 @@ doctest = false
|
||||||
salsa = "0.15.2"
|
salsa = "0.15.2"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
|
|
||||||
ra_syntax = { path = "../ra_syntax" }
|
syntax = { path = "../syntax" }
|
||||||
ra_cfg = { path = "../ra_cfg" }
|
cfg = { path = "../cfg" }
|
||||||
ra_prof = { path = "../ra_prof" }
|
profile = { path = "../profile" }
|
||||||
ra_tt = { path = "../ra_tt" }
|
tt = { path = "../tt" }
|
||||||
test_utils = { path = "../test_utils" }
|
test_utils = { path = "../test_utils" }
|
||||||
vfs = { path = "../vfs" }
|
vfs = { path = "../vfs" }
|
||||||
stdx = { path = "../stdx" }
|
stdx = { path = "../stdx" }
|
|
@ -59,7 +59,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
use std::{str::FromStr, sync::Arc};
|
use std::{str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use ra_cfg::CfgOptions;
|
use cfg::CfgOptions;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use test_utils::{extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER};
|
use test_utils::{extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER};
|
||||||
use vfs::{file_set::FileSet, VfsPath};
|
use vfs::{file_set::FileSet, VfsPath};
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc};
|
use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use ra_cfg::CfgOptions;
|
use cfg::CfgOptions;
|
||||||
use ra_syntax::SmolStr;
|
|
||||||
use ra_tt::TokenExpander;
|
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
use syntax::SmolStr;
|
||||||
|
use tt::TokenExpander;
|
||||||
use vfs::file_set::FileSet;
|
use vfs::file_set::FileSet;
|
||||||
|
|
||||||
pub use vfs::FileId;
|
pub use vfs::FileId;
|
||||||
|
@ -156,7 +156,7 @@ impl CrateGraph {
|
||||||
display_name: Option<String>,
|
display_name: Option<String>,
|
||||||
cfg_options: CfgOptions,
|
cfg_options: CfgOptions,
|
||||||
env: Env,
|
env: Env,
|
||||||
proc_macro: Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)>,
|
proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>,
|
||||||
) -> CrateId {
|
) -> CrateId {
|
||||||
let proc_macro =
|
let proc_macro =
|
||||||
proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect();
|
proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect();
|
|
@ -1,13 +1,12 @@
|
||||||
//! ra_db defines basic database traits. The concrete DB is defined by ra_ide.
|
//! base_db defines basic database traits. The concrete DB is defined by ide.
|
||||||
mod cancellation;
|
mod cancellation;
|
||||||
mod input;
|
mod input;
|
||||||
pub mod fixture;
|
pub mod fixture;
|
||||||
|
|
||||||
use std::{panic, sync::Arc};
|
use std::{panic, sync::Arc};
|
||||||
|
|
||||||
use ra_prof::profile;
|
|
||||||
use ra_syntax::{ast, Parse, SourceFile, TextRange, TextSize};
|
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
use syntax::{ast, Parse, SourceFile, TextRange, TextSize};
|
||||||
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
cancellation::Canceled,
|
cancellation::Canceled,
|
||||||
|
@ -113,7 +112,7 @@ pub trait SourceDatabase: CheckCanceled + FileLoader + std::fmt::Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
|
fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
|
||||||
let _p = profile("parse_query").detail(|| format!("{:?}", file_id));
|
let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id));
|
||||||
let text = db.file_text(file_id);
|
let text = db.file_text(file_id);
|
||||||
SourceFile::parse(&*text)
|
SourceFile::parse(&*text)
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
edition = "2018"
|
name = "cfg"
|
||||||
name = "ra_cfg"
|
version = "0.0.0"
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["rust-analyzer developers"]
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -11,8 +11,8 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
|
|
||||||
ra_syntax = { path = "../ra_syntax" }
|
tt = { path = "../tt" }
|
||||||
tt = { path = "../ra_tt", package = "ra_tt" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
mbe = { path = "../ra_mbe", package = "ra_mbe" }
|
mbe = { path = "../mbe" }
|
||||||
|
syntax = { path = "../syntax" }
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use std::slice::Iter as SliceIter;
|
use std::slice::Iter as SliceIter;
|
||||||
|
|
||||||
use ra_syntax::SmolStr;
|
use tt::SmolStr;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum CfgExpr {
|
pub enum CfgExpr {
|
||||||
|
@ -86,17 +86,15 @@ fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use mbe::{ast_to_token_tree, TokenMap};
|
use mbe::ast_to_token_tree;
|
||||||
use ra_syntax::ast::{self, AstNode};
|
use syntax::ast::{self, AstNode};
|
||||||
|
|
||||||
fn get_token_tree_generated(input: &str) -> (tt::Subtree, TokenMap) {
|
|
||||||
let source_file = ast::SourceFile::parse(input).ok().unwrap();
|
|
||||||
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
|
|
||||||
ast_to_token_tree(&tt).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn assert_parse_result(input: &str, expected: CfgExpr) {
|
fn assert_parse_result(input: &str, expected: CfgExpr) {
|
||||||
let (tt, _) = get_token_tree_generated(input);
|
let (tt, _) = {
|
||||||
|
let source_file = ast::SourceFile::parse(input).ok().unwrap();
|
||||||
|
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
|
||||||
|
ast_to_token_tree(&tt).unwrap()
|
||||||
|
};
|
||||||
let cfg = CfgExpr::parse(&tt);
|
let cfg = CfgExpr::parse(&tt);
|
||||||
assert_eq!(cfg, expected);
|
assert_eq!(cfg, expected);
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator
|
//! cfg defines conditional compiling options, `cfg` attibute parser and evaluator
|
||||||
|
|
||||||
mod cfg_expr;
|
mod cfg_expr;
|
||||||
|
|
||||||
use ra_syntax::SmolStr;
|
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
use tt::SmolStr;
|
||||||
|
|
||||||
pub use cfg_expr::CfgExpr;
|
pub use cfg_expr::CfgExpr;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "expect"
|
name = "expect"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
authors = ["rust-analyzer developers"]
|
authors = ["rust-analyzer developers"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT OR Apache-2.0"
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -11,4 +11,5 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
difference = "2"
|
difference = "2"
|
||||||
|
|
||||||
stdx = { path = "../stdx" }
|
stdx = { path = "../stdx" }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
edition = "2018"
|
|
||||||
name = "flycheck"
|
name = "flycheck"
|
||||||
version = "0.1.0"
|
version = "0.0.0"
|
||||||
authors = ["rust-analyzer developers"]
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -14,4 +14,5 @@ log = "0.4.8"
|
||||||
cargo_metadata = "0.11.1"
|
cargo_metadata = "0.11.1"
|
||||||
serde_json = "1.0.48"
|
serde_json = "1.0.48"
|
||||||
jod-thread = "0.1.1"
|
jod-thread = "0.1.1"
|
||||||
ra_toolchain = { path = "../ra_toolchain" }
|
|
||||||
|
toolchain = { path = "../toolchain" }
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl FlycheckActor {
|
||||||
extra_args,
|
extra_args,
|
||||||
features,
|
features,
|
||||||
} => {
|
} => {
|
||||||
let mut cmd = Command::new(ra_toolchain::cargo());
|
let mut cmd = Command::new(toolchain::cargo());
|
||||||
cmd.arg(command);
|
cmd.arg(command);
|
||||||
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
|
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
|
||||||
.arg(self.workspace_root.join("Cargo.toml"));
|
.arg(self.workspace_root.join("Cargo.toml"));
|
||||||
|
|
24
crates/hir/Cargo.toml
Normal file
24
crates/hir/Cargo.toml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
[package]
|
||||||
|
name = "hir"
|
||||||
|
version = "0.0.0"
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
doctest = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
log = "0.4.8"
|
||||||
|
rustc-hash = "1.1.0"
|
||||||
|
either = "1.5.3"
|
||||||
|
arrayvec = "0.5.1"
|
||||||
|
itertools = "0.9.0"
|
||||||
|
|
||||||
|
stdx = { path = "../stdx" }
|
||||||
|
syntax = { path = "../syntax" }
|
||||||
|
base_db = { path = "../base_db" }
|
||||||
|
profile = { path = "../profile" }
|
||||||
|
hir_expand = { path = "../hir_expand" }
|
||||||
|
hir_def = { path = "../hir_def" }
|
||||||
|
hir_ty = { path = "../hir_ty" }
|
|
@ -2,6 +2,7 @@
|
||||||
use std::{iter, sync::Arc};
|
use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
|
use base_db::{CrateId, Edition, FileId};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
adt::ReprKind,
|
adt::ReprKind,
|
||||||
|
@ -30,14 +31,12 @@ use hir_ty::{
|
||||||
method_resolution, ApplicationTy, CallableDefId, Canonical, FnSig, GenericPredicate,
|
method_resolution, ApplicationTy, CallableDefId, Canonical, FnSig, GenericPredicate,
|
||||||
InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor,
|
InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor,
|
||||||
};
|
};
|
||||||
use ra_db::{CrateId, Edition, FileId};
|
use rustc_hash::FxHashSet;
|
||||||
use ra_prof::profile;
|
use stdx::impl_from;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AttrsOwner, NameOwner},
|
ast::{self, AttrsOwner, NameOwner},
|
||||||
AstNode,
|
AstNode,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashSet;
|
|
||||||
use stdx::impl_from;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::{DefDatabase, HirDatabase},
|
db::{DefDatabase, HirDatabase},
|
||||||
|
@ -304,7 +303,7 @@ impl Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
|
pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
|
||||||
let _p = profile("Module::diagnostics");
|
let _p = profile::span("Module::diagnostics");
|
||||||
let crate_def_map = db.crate_def_map(self.id.krate);
|
let crate_def_map = db.crate_def_map(self.id.krate);
|
||||||
crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
|
crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
|
||||||
for decl in self.declarations(db) {
|
for decl in self.declarations(db) {
|
||||||
|
@ -816,7 +815,7 @@ pub struct MacroDef {
|
||||||
impl MacroDef {
|
impl MacroDef {
|
||||||
/// FIXME: right now, this just returns the root module of the crate that
|
/// FIXME: right now, this just returns the root module of the crate that
|
||||||
/// defines this macro. The reasons for this is that macros are expanded
|
/// defines this macro. The reasons for this is that macros are expanded
|
||||||
/// early, in `ra_hir_expand`, where modules simply do not exist yet.
|
/// early, in `hir_expand`, where modules simply do not exist yet.
|
||||||
pub fn module(self, db: &dyn HirDatabase) -> Option<Module> {
|
pub fn module(self, db: &dyn HirDatabase) -> Option<Module> {
|
||||||
let krate = self.id.krate?;
|
let krate = self.id.krate?;
|
||||||
let module_id = db.crate_def_map(krate).root;
|
let module_id = db.crate_def_map(krate).root;
|
||||||
|
@ -884,6 +883,13 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AssocItem {
|
impl AssocItem {
|
||||||
|
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||||
|
match self {
|
||||||
|
AssocItem::Function(it) => Some(it.name(db)),
|
||||||
|
AssocItem::Const(it) => it.name(db),
|
||||||
|
AssocItem::TypeAlias(it) => Some(it.name(db)),
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
||||||
match self {
|
match self {
|
||||||
AssocItem::Function(f) => f.module(db),
|
AssocItem::Function(f) => f.module(db),
|
|
@ -29,7 +29,7 @@ macro_rules! from_id {
|
||||||
}
|
}
|
||||||
|
|
||||||
from_id![
|
from_id![
|
||||||
(ra_db::CrateId, crate::Crate),
|
(base_db::CrateId, crate::Crate),
|
||||||
(hir_def::ModuleId, crate::Module),
|
(hir_def::ModuleId, crate::Module),
|
||||||
(hir_def::StructId, crate::Struct),
|
(hir_def::StructId, crate::Struct),
|
||||||
(hir_def::UnionId, crate::Union),
|
(hir_def::UnionId, crate::Union),
|
|
@ -6,7 +6,7 @@ use hir_def::{
|
||||||
src::{HasChildSource, HasSource as _},
|
src::{HasChildSource, HasSource as _},
|
||||||
Lookup, VariantId,
|
Lookup, VariantId,
|
||||||
};
|
};
|
||||||
use ra_syntax::ast;
|
use syntax::ast;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef,
|
db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef,
|
|
@ -9,11 +9,11 @@
|
||||||
//! It is written in "OO" style. Each type is self contained (as in, it knows it's
|
//! It is written in "OO" style. Each type is self contained (as in, it knows it's
|
||||||
//! parents and full context). It should be "clean code".
|
//! parents and full context). It should be "clean code".
|
||||||
//!
|
//!
|
||||||
//! `ra_hir_*` crates are the implementation of the compiler logic.
|
//! `hir_*` crates are the implementation of the compiler logic.
|
||||||
//! They are written in "ECS" style, with relatively little abstractions.
|
//! They are written in "ECS" style, with relatively little abstractions.
|
||||||
//! Many types are not self-contained, and explicitly use local indexes, arenas, etc.
|
//! Many types are not self-contained, and explicitly use local indexes, arenas, etc.
|
||||||
//!
|
//!
|
||||||
//! `ra_hir` is what insulates the "we don't know how to actually write an incremental compiler"
|
//! `hir` is what insulates the "we don't know how to actually write an incremental compiler"
|
||||||
//! from the ide with completions, hovers, etc. It is a (soft, internal) boundary:
|
//! from the ide with completions, hovers, etc. It is a (soft, internal) boundary:
|
||||||
//! https://www.tedinski.com/2018/02/06/system-boundaries.html.
|
//! https://www.tedinski.com/2018/02/06/system-boundaries.html.
|
||||||
|
|
||||||
|
@ -52,8 +52,12 @@ pub use hir_def::{
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
};
|
};
|
||||||
pub use hir_expand::{
|
pub use hir_expand::{
|
||||||
hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc,
|
name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, /* FIXME */ MacroDefId,
|
||||||
MacroDefId, /* FIXME */
|
|
||||||
MacroFile, Origin,
|
MacroFile, Origin,
|
||||||
};
|
};
|
||||||
pub use hir_ty::display::HirDisplay;
|
pub use hir_ty::display::HirDisplay;
|
||||||
|
|
||||||
|
// These are negative re-exports: pub using these names is forbidden, they
|
||||||
|
// should remain private to hir internals.
|
||||||
|
#[allow(unused)]
|
||||||
|
use hir_expand::hygiene::Hygiene;
|
|
@ -4,6 +4,7 @@ mod source_to_def;
|
||||||
|
|
||||||
use std::{cell::RefCell, fmt, iter::successors};
|
use std::{cell::RefCell, fmt, iter::successors};
|
||||||
|
|
||||||
|
use base_db::{FileId, FileRange};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
resolver::{self, HasResolver, Resolver},
|
resolver::{self, HasResolver, Resolver},
|
||||||
AsMacroCall, FunctionId, TraitId, VariantId,
|
AsMacroCall, FunctionId, TraitId, VariantId,
|
||||||
|
@ -11,13 +12,11 @@ use hir_def::{
|
||||||
use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo};
|
use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo};
|
||||||
use hir_ty::associated_type_shorthand_candidates;
|
use hir_ty::associated_type_shorthand_candidates;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ra_db::{FileId, FileRange};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
use ra_prof::profile;
|
use syntax::{
|
||||||
use ra_syntax::{
|
|
||||||
algo::{find_node_at_offset, skip_trivia_token},
|
algo::{find_node_at_offset, skip_trivia_token},
|
||||||
ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize,
|
ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize,
|
||||||
};
|
};
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
|
@ -334,7 +333,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken {
|
fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken {
|
||||||
let _p = profile("descend_into_macros");
|
let _p = profile::span("descend_into_macros");
|
||||||
let parent = token.parent();
|
let parent = token.parent();
|
||||||
let parent = self.find_file(parent);
|
let parent = self.find_file(parent);
|
||||||
let sa = self.analyze2(parent.as_ref(), None);
|
let sa = self.analyze2(parent.as_ref(), None);
|
||||||
|
@ -503,18 +502,19 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db> {
|
fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db> {
|
||||||
let node = self.find_file(node.clone());
|
let node = self.find_file(node.clone());
|
||||||
let resolver = self.analyze2(node.as_ref(), None).resolver;
|
let resolver = self.analyze2(node.as_ref(), None).resolver;
|
||||||
SemanticsScope { db: self.db, resolver }
|
SemanticsScope { db: self.db, file_id: node.file_id, resolver }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db> {
|
fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db> {
|
||||||
let node = self.find_file(node.clone());
|
let node = self.find_file(node.clone());
|
||||||
let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver;
|
let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver;
|
||||||
SemanticsScope { db: self.db, resolver }
|
SemanticsScope { db: self.db, file_id: node.file_id, resolver }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> {
|
fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> {
|
||||||
|
let file_id = self.db.lookup_intern_trait(def.id).id.file_id;
|
||||||
let resolver = def.id.resolver(self.db.upcast());
|
let resolver = def.id.resolver(self.db.upcast());
|
||||||
SemanticsScope { db: self.db, resolver }
|
SemanticsScope { db: self.db, file_id, resolver }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn analyze(&self, node: &SyntaxNode) -> SourceAnalyzer {
|
fn analyze(&self, node: &SyntaxNode) -> SourceAnalyzer {
|
||||||
|
@ -523,7 +523,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option<TextSize>) -> SourceAnalyzer {
|
fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option<TextSize>) -> SourceAnalyzer {
|
||||||
let _p = profile("Semantics::analyze2");
|
let _p = profile::span("Semantics::analyze2");
|
||||||
|
|
||||||
let container = match self.with_ctx(|ctx| ctx.find_container(src)) {
|
let container = match self.with_ctx(|ctx| ctx.find_container(src)) {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
|
@ -710,6 +710,7 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SemanticsScope<'a> {
|
pub struct SemanticsScope<'a> {
|
||||||
pub db: &'a dyn HirDatabase,
|
pub db: &'a dyn HirDatabase,
|
||||||
|
file_id: HirFileId,
|
||||||
resolver: Resolver,
|
resolver: Resolver,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,6 +754,14 @@ impl<'a> SemanticsScope<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resolve a path as-if it was written at the given scope. This is
|
||||||
|
/// necessary a heuristic, as it doesn't take hygiene into account.
|
||||||
|
pub fn resolve_hypothetical(&self, path: &ast::Path) -> Option<PathResolution> {
|
||||||
|
let hygiene = Hygiene::new(self.db.upcast(), self.file_id);
|
||||||
|
let path = Path::from_src(path.clone(), &hygiene)?;
|
||||||
|
self.resolve_hir_path(&path)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn resolve_hir_path(&self, path: &Path) -> Option<PathResolution> {
|
pub fn resolve_hir_path(&self, path: &Path) -> Option<PathResolution> {
|
||||||
resolve_hir_path(self.db, &self.resolver, path)
|
resolve_hir_path(self.db, &self.resolver, path)
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
//! Maps *syntax* of various definitions to their semantic ids.
|
//! Maps *syntax* of various definitions to their semantic ids.
|
||||||
|
|
||||||
|
use base_db::FileId;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
child_by_source::ChildBySource,
|
child_by_source::ChildBySource,
|
||||||
dyn_map::DynMap,
|
dyn_map::DynMap,
|
||||||
|
@ -9,14 +10,12 @@ use hir_def::{
|
||||||
ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId,
|
ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId,
|
||||||
};
|
};
|
||||||
use hir_expand::{name::AsName, AstId, MacroDefKind};
|
use hir_expand::{name::AsName, AstId, MacroDefKind};
|
||||||
use ra_db::FileId;
|
use rustc_hash::FxHashMap;
|
||||||
use ra_prof::profile;
|
use stdx::impl_from;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, NameOwner},
|
ast::{self, NameOwner},
|
||||||
match_ast, AstNode, SyntaxNode,
|
match_ast, AstNode, SyntaxNode,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use stdx::impl_from;
|
|
||||||
|
|
||||||
use crate::{db::HirDatabase, InFile, MacroDefId};
|
use crate::{db::HirDatabase, InFile, MacroDefId};
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ pub(super) struct SourceToDefCtx<'a, 'b> {
|
||||||
|
|
||||||
impl SourceToDefCtx<'_, '_> {
|
impl SourceToDefCtx<'_, '_> {
|
||||||
pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> {
|
pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> {
|
||||||
let _p = profile("SourceBinder::to_module_def");
|
let _p = profile::span("SourceBinder::to_module_def");
|
||||||
let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| {
|
let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| {
|
||||||
let crate_def_map = self.db.crate_def_map(crate_id);
|
let crate_def_map = self.db.crate_def_map(crate_id);
|
||||||
let local_id = crate_def_map.modules_for_file(file).next()?;
|
let local_id = crate_def_map.modules_for_file(file).next()?;
|
||||||
|
@ -39,7 +38,7 @@ impl SourceToDefCtx<'_, '_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> {
|
pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> {
|
||||||
let _p = profile("module_to_def");
|
let _p = profile::span("module_to_def");
|
||||||
let parent_declaration = src
|
let parent_declaration = src
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|it| it.syntax())
|
.map(|it| it.syntax())
|
|
@ -21,7 +21,7 @@ use hir_ty::{
|
||||||
diagnostics::{record_literal_missing_fields, record_pattern_missing_fields},
|
diagnostics::{record_literal_missing_fields, record_pattern_missing_fields},
|
||||||
InferenceResult, Substs, Ty,
|
InferenceResult, Substs, Ty,
|
||||||
};
|
};
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
SyntaxNode, TextRange, TextSize,
|
SyntaxNode, TextRange, TextSize,
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ use crate::{
|
||||||
MacroDef, ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias,
|
MacroDef, ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias,
|
||||||
TypeParam,
|
TypeParam,
|
||||||
};
|
};
|
||||||
use ra_db::CrateId;
|
use base_db::CrateId;
|
||||||
|
|
||||||
/// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of
|
/// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of
|
||||||
/// original source files. It should not be used inside the HIR itself.
|
/// original source files. It should not be used inside the HIR itself.
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
edition = "2018"
|
name = "hir_def"
|
||||||
name = "ra_hir_def"
|
version = "0.0.0"
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["rust-analyzer developers"]
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
authors = ["rust-analyzer developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
@ -21,16 +21,15 @@ indexmap = "1.4.0"
|
||||||
smallvec = "1.4.0"
|
smallvec = "1.4.0"
|
||||||
|
|
||||||
stdx = { path = "../stdx" }
|
stdx = { path = "../stdx" }
|
||||||
|
arena = { path = "../arena" }
|
||||||
ra_arena = { path = "../ra_arena" }
|
base_db = { path = "../base_db" }
|
||||||
ra_db = { path = "../ra_db" }
|
syntax = { path = "../syntax" }
|
||||||
ra_syntax = { path = "../ra_syntax" }
|
profile = { path = "../profile" }
|
||||||
ra_prof = { path = "../ra_prof" }
|
hir_expand = { path = "../hir_expand" }
|
||||||
hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
|
|
||||||
test_utils = { path = "../test_utils" }
|
test_utils = { path = "../test_utils" }
|
||||||
mbe = { path = "../ra_mbe", package = "ra_mbe" }
|
mbe = { path = "../mbe" }
|
||||||
ra_cfg = { path = "../ra_cfg" }
|
cfg = { path = "../cfg" }
|
||||||
tt = { path = "../ra_tt", package = "ra_tt" }
|
tt = { path = "../tt" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
expect = { path = "../expect" }
|
expect = { path = "../expect" }
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use arena::{map::ArenaMap, Arena};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
name::{AsName, Name},
|
name::{AsName, Name},
|
||||||
InFile,
|
InFile,
|
||||||
};
|
};
|
||||||
use ra_arena::{map::ArenaMap, Arena};
|
use syntax::ast::{self, NameOwner, VisibilityOwner};
|
||||||
use ra_syntax::ast::{self, NameOwner, VisibilityOwner};
|
|
||||||
use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree};
|
use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -23,7 +23,7 @@ use crate::{
|
||||||
EnumId, HasModule, LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StructId, UnionId,
|
EnumId, HasModule, LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StructId, UnionId,
|
||||||
VariantId,
|
VariantId,
|
||||||
};
|
};
|
||||||
use ra_cfg::CfgOptions;
|
use cfg::CfgOptions;
|
||||||
|
|
||||||
/// Note that we use `StructData` for unions as well!
|
/// Note that we use `StructData` for unions as well!
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
use std::{ops, sync::Arc};
|
use std::{ops, sync::Arc};
|
||||||
|
|
||||||
|
use cfg::{CfgExpr, CfgOptions};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{hygiene::Hygiene, AstId, InFile};
|
use hir_expand::{hygiene::Hygiene, AstId, InFile};
|
||||||
use mbe::ast_to_token_tree;
|
use mbe::ast_to_token_tree;
|
||||||
use ra_cfg::{CfgExpr, CfgOptions};
|
use syntax::{
|
||||||
use ra_syntax::{
|
|
||||||
ast::{self, AstNode, AttrsOwner},
|
ast::{self, AstNode, AttrsOwner},
|
||||||
SmolStr,
|
SmolStr,
|
||||||
};
|
};
|
|
@ -5,15 +5,14 @@ pub mod scope;
|
||||||
|
|
||||||
use std::{mem, ops::Index, sync::Arc};
|
use std::{mem, ops::Index, sync::Arc};
|
||||||
|
|
||||||
|
use arena::{map::ArenaMap, Arena};
|
||||||
|
use base_db::CrateId;
|
||||||
|
use cfg::CfgOptions;
|
||||||
use drop_bomb::DropBomb;
|
use drop_bomb::DropBomb;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId};
|
use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId};
|
||||||
use ra_arena::{map::ArenaMap, Arena};
|
|
||||||
use ra_cfg::CfgOptions;
|
|
||||||
use ra_db::CrateId;
|
|
||||||
use ra_prof::profile;
|
|
||||||
use ra_syntax::{ast, AstNode, AstPtr};
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
use syntax::{ast, AstNode, AstPtr};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
pub(crate) use lower::LowerCtx;
|
pub(crate) use lower::LowerCtx;
|
||||||
|
@ -228,7 +227,7 @@ impl Body {
|
||||||
db: &dyn DefDatabase,
|
db: &dyn DefDatabase,
|
||||||
def: DefWithBodyId,
|
def: DefWithBodyId,
|
||||||
) -> (Arc<Body>, Arc<BodySourceMap>) {
|
) -> (Arc<Body>, Arc<BodySourceMap>) {
|
||||||
let _p = profile("body_with_source_map_query");
|
let _p = profile::span("body_with_source_map_query");
|
||||||
let mut params = None;
|
let mut params = None;
|
||||||
|
|
||||||
let (file_id, module, body) = match def {
|
let (file_id, module, body) = match def {
|
||||||
|
@ -321,7 +320,7 @@ impl BodySourceMap {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ra_db::{fixture::WithFixture, SourceDatabase};
|
use base_db::{fixture::WithFixture, SourceDatabase};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::ModuleDefId;
|
use crate::ModuleDefId;
|
|
@ -3,21 +3,21 @@
|
||||||
|
|
||||||
use std::{any::type_name, sync::Arc};
|
use std::{any::type_name, sync::Arc};
|
||||||
|
|
||||||
|
use arena::Arena;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
hygiene::Hygiene,
|
hygiene::Hygiene,
|
||||||
name::{name, AsName, Name},
|
name::{name, AsName, Name},
|
||||||
HirFileId, MacroDefId, MacroDefKind,
|
HirFileId, MacroDefId, MacroDefKind,
|
||||||
};
|
};
|
||||||
use ra_arena::Arena;
|
use rustc_hash::FxHashMap;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{
|
ast::{
|
||||||
self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner,
|
self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner,
|
||||||
SlicePatComponents,
|
SlicePatComponents,
|
||||||
},
|
},
|
||||||
AstNode, AstPtr,
|
AstNode, AstPtr,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
|
@ -1,8 +1,8 @@
|
||||||
//! Name resolution for expressions.
|
//! Name resolution for expressions.
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use arena::{Arena, Idx};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use ra_arena::{Arena, Idx};
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -169,9 +169,9 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use base_db::{fixture::WithFixture, FileId, SourceDatabase};
|
||||||
use hir_expand::{name::AsName, InFile};
|
use hir_expand::{name::AsName, InFile};
|
||||||
use ra_db::{fixture::WithFixture, FileId, SourceDatabase};
|
use syntax::{algo::find_node_at_offset, ast, AstNode};
|
||||||
use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
|
|
||||||
use test_utils::{assert_eq_text, extract_offset, mark};
|
use test_utils::{assert_eq_text, extract_offset, mark};
|
||||||
|
|
||||||
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
|
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
|
|
@ -3,8 +3,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use hir_expand::{name::Name, InFile};
|
use hir_expand::{name::Name, InFile};
|
||||||
use ra_prof::profile;
|
use syntax::ast;
|
||||||
use ra_syntax::ast;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
attr::Attrs,
|
attr::Attrs,
|
||||||
|
@ -133,7 +132,7 @@ pub struct ImplData {
|
||||||
|
|
||||||
impl ImplData {
|
impl ImplData {
|
||||||
pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData> {
|
pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData> {
|
||||||
let _p = profile("impl_data_query");
|
let _p = profile::span("impl_data_query");
|
||||||
let impl_loc = id.lookup(db);
|
let impl_loc = id.lookup(db);
|
||||||
|
|
||||||
let item_tree = db.item_tree(impl_loc.id.file_id);
|
let item_tree = db.item_tree(impl_loc.id.file_id);
|
|
@ -1,10 +1,9 @@
|
||||||
//! Defines database & queries for name resolution.
|
//! Defines database & queries for name resolution.
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use base_db::{salsa, CrateId, SourceDatabase, Upcast};
|
||||||
use hir_expand::{db::AstDatabase, HirFileId};
|
use hir_expand::{db::AstDatabase, HirFileId};
|
||||||
use ra_db::{salsa, CrateId, SourceDatabase, Upcast};
|
use syntax::SmolStr;
|
||||||
use ra_prof::profile;
|
|
||||||
use ra_syntax::SmolStr;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
adt::{EnumData, StructData},
|
adt::{EnumData, StructData},
|
||||||
|
@ -116,6 +115,6 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
|
fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
|
||||||
let _p = profile("crate_def_map:wait");
|
let _p = profile::span("crate_def_map:wait");
|
||||||
db.crate_def_map_query(krate)
|
db.crate_def_map_query(krate)
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
use hir_expand::diagnostics::Diagnostic;
|
use hir_expand::diagnostics::Diagnostic;
|
||||||
use ra_syntax::{ast, AstPtr, SyntaxNodePtr};
|
use syntax::{ast, AstPtr, SyntaxNodePtr};
|
||||||
|
|
||||||
use hir_expand::{HirFileId, InFile};
|
use hir_expand::{HirFileId, InFile};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use ra_syntax::ast;
|
use syntax::ast;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
|
@ -12,9 +12,9 @@
|
||||||
//!
|
//!
|
||||||
//! See also a neighboring `body` module.
|
//! See also a neighboring `body` module.
|
||||||
|
|
||||||
|
use arena::{Idx, RawId};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use ra_arena::{Idx, RawId};
|
use syntax::ast::RangeOp;
|
||||||
use ra_syntax::ast::RangeOp;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
builtin_type::{BuiltinFloat, BuiltinInt},
|
builtin_type::{BuiltinFloat, BuiltinInt},
|
||||||
|
@ -197,7 +197,7 @@ pub enum ArithOp {
|
||||||
BitAnd,
|
BitAnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use ra_syntax::ast::PrefixOp as UnaryOp;
|
pub use syntax::ast::PrefixOp as UnaryOp;
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub enum Array {
|
pub enum Array {
|
||||||
ElementList(Vec<ExprId>),
|
ElementList(Vec<ExprId>),
|
|
@ -1,7 +1,6 @@
|
||||||
//! An algorithm to find a path to refer to a certain item.
|
//! An algorithm to find a path to refer to a certain item.
|
||||||
|
|
||||||
use hir_expand::name::{known, AsName, Name};
|
use hir_expand::name::{known, AsName, Name};
|
||||||
use ra_prof::profile;
|
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ use crate::{
|
||||||
/// Find a path that can be used to refer to a certain item. This can depend on
|
/// Find a path that can be used to refer to a certain item. This can depend on
|
||||||
/// *from where* you're referring to the item, hence the `from` parameter.
|
/// *from where* you're referring to the item, hence the `from` parameter.
|
||||||
pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> {
|
pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> {
|
||||||
let _p = profile("find_path");
|
let _p = profile::span("find_path");
|
||||||
find_path_inner(db, item, from, MAX_PATH_LEN)
|
find_path_inner(db, item, from, MAX_PATH_LEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +214,7 @@ fn find_local_import_locations(
|
||||||
item: ItemInNs,
|
item: ItemInNs,
|
||||||
from: ModuleId,
|
from: ModuleId,
|
||||||
) -> Vec<(ModuleId, Name)> {
|
) -> Vec<(ModuleId, Name)> {
|
||||||
let _p = profile("find_local_import_locations");
|
let _p = profile::span("find_local_import_locations");
|
||||||
|
|
||||||
// `from` can import anything below `from` with visibility of at least `from`, and anything
|
// `from` can import anything below `from` with visibility of at least `from`, and anything
|
||||||
// above `from` with any visibility. That means we do not need to descend into private siblings
|
// above `from` with any visibility. That means we do not need to descend into private siblings
|
||||||
|
@ -293,9 +292,9 @@ fn find_local_import_locations(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use base_db::fixture::WithFixture;
|
||||||
use hir_expand::hygiene::Hygiene;
|
use hir_expand::hygiene::Hygiene;
|
||||||
use ra_db::fixture::WithFixture;
|
use syntax::ast::AstNode;
|
||||||
use ra_syntax::ast::AstNode;
|
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::test_db::TestDB;
|
use crate::test_db::TestDB;
|
||||||
|
@ -308,12 +307,9 @@ mod tests {
|
||||||
fn check_found_path(ra_fixture: &str, path: &str) {
|
fn check_found_path(ra_fixture: &str, path: &str) {
|
||||||
let (db, pos) = TestDB::with_position(ra_fixture);
|
let (db, pos) = TestDB::with_position(ra_fixture);
|
||||||
let module = db.module_for_file(pos.file_id);
|
let module = db.module_for_file(pos.file_id);
|
||||||
let parsed_path_file = ra_syntax::SourceFile::parse(&format!("use {};", path));
|
let parsed_path_file = syntax::SourceFile::parse(&format!("use {};", path));
|
||||||
let ast_path = parsed_path_file
|
let ast_path =
|
||||||
.syntax_node()
|
parsed_path_file.syntax_node().descendants().find_map(syntax::ast::Path::cast).unwrap();
|
||||||
.descendants()
|
|
||||||
.find_map(ra_syntax::ast::Path::cast)
|
|
||||||
.unwrap();
|
|
||||||
let mod_path = ModPath::from_src(ast_path, &Hygiene::new_unhygienic()).unwrap();
|
let mod_path = ModPath::from_src(ast_path, &Hygiene::new_unhygienic()).unwrap();
|
||||||
|
|
||||||
let crate_def_map = db.crate_def_map(module.krate);
|
let crate_def_map = db.crate_def_map(module.krate);
|
||||||
|
@ -442,12 +438,12 @@ mod tests {
|
||||||
// already in scope.
|
// already in scope.
|
||||||
check_found_path(
|
check_found_path(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:ra_syntax
|
//- /main.rs crate:main deps:syntax
|
||||||
|
|
||||||
use ra_syntax::ast;
|
use syntax::ast;
|
||||||
<|>
|
<|>
|
||||||
|
|
||||||
//- /lib.rs crate:ra_syntax
|
//- /lib.rs crate:syntax
|
||||||
pub mod ast {
|
pub mod ast {
|
||||||
pub enum ModuleItem {
|
pub enum ModuleItem {
|
||||||
A, B, C,
|
A, B, C,
|
||||||
|
@ -459,18 +455,18 @@ mod tests {
|
||||||
|
|
||||||
check_found_path(
|
check_found_path(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:ra_syntax
|
//- /main.rs crate:main deps:syntax
|
||||||
|
|
||||||
<|>
|
<|>
|
||||||
|
|
||||||
//- /lib.rs crate:ra_syntax
|
//- /lib.rs crate:syntax
|
||||||
pub mod ast {
|
pub mod ast {
|
||||||
pub enum ModuleItem {
|
pub enum ModuleItem {
|
||||||
A, B, C,
|
A, B, C,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
"ra_syntax::ast::ModuleItem",
|
"syntax::ast::ModuleItem",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,14 @@
|
||||||
//! in rustc.
|
//! in rustc.
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use arena::{map::ArenaMap, Arena};
|
||||||
|
use base_db::FileId;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
name::{name, AsName, Name},
|
name::{name, AsName, Name},
|
||||||
InFile,
|
InFile,
|
||||||
};
|
};
|
||||||
use ra_arena::{map::ArenaMap, Arena};
|
use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner};
|
||||||
use ra_db::FileId;
|
|
||||||
use ra_prof::profile;
|
|
||||||
use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
body::LowerCtx,
|
body::LowerCtx,
|
||||||
|
@ -73,7 +72,7 @@ impl GenericParams {
|
||||||
db: &dyn DefDatabase,
|
db: &dyn DefDatabase,
|
||||||
def: GenericDefId,
|
def: GenericDefId,
|
||||||
) -> Arc<GenericParams> {
|
) -> Arc<GenericParams> {
|
||||||
let _p = profile("generic_params_query");
|
let _p = profile::span("generic_params_query");
|
||||||
|
|
||||||
let generics = match def {
|
let generics = match def {
|
||||||
GenericDefId::FunctionId(id) => {
|
GenericDefId::FunctionId(id) => {
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
use std::{cmp::Ordering, fmt, hash::BuildHasherDefault, sync::Arc};
|
use std::{cmp::Ordering, fmt, hash::BuildHasherDefault, sync::Arc};
|
||||||
|
|
||||||
|
use base_db::CrateId;
|
||||||
use fst::{self, Streamer};
|
use fst::{self, Streamer};
|
||||||
use indexmap::{map::Entry, IndexMap};
|
use indexmap::{map::Entry, IndexMap};
|
||||||
use ra_db::CrateId;
|
|
||||||
use ra_syntax::SmolStr;
|
|
||||||
use rustc_hash::{FxHashMap, FxHasher};
|
use rustc_hash::{FxHashMap, FxHasher};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use syntax::SmolStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
|
@ -56,7 +56,7 @@ pub struct ImportMap {
|
||||||
|
|
||||||
impl ImportMap {
|
impl ImportMap {
|
||||||
pub fn import_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<Self> {
|
pub fn import_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<Self> {
|
||||||
let _p = ra_prof::profile("import_map_query");
|
let _p = profile::span("import_map_query");
|
||||||
let def_map = db.crate_def_map(krate);
|
let def_map = db.crate_def_map(krate);
|
||||||
let mut import_map = Self::default();
|
let mut import_map = Self::default();
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ pub fn search_dependencies<'a>(
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
query: Query,
|
query: Query,
|
||||||
) -> Vec<ItemInNs> {
|
) -> Vec<ItemInNs> {
|
||||||
let _p = ra_prof::profile("search_dependencies").detail(|| format!("{:?}", query));
|
let _p = profile::span("search_dependencies").detail(|| format!("{:?}", query));
|
||||||
|
|
||||||
let graph = db.crate_graph();
|
let graph = db.crate_graph();
|
||||||
let import_maps: Vec<_> =
|
let import_maps: Vec<_> =
|
||||||
|
@ -327,8 +327,8 @@ pub fn search_dependencies<'a>(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use base_db::{fixture::WithFixture, SourceDatabase, Upcast};
|
||||||
use expect::{expect, Expect};
|
use expect::{expect, Expect};
|
||||||
use ra_db::{fixture::WithFixture, SourceDatabase, Upcast};
|
|
||||||
|
|
||||||
use crate::{test_db::TestDB, AssocContainerId, Lookup};
|
use crate::{test_db::TestDB, AssocContainerId, Lookup};
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
|
||||||
|
use base_db::CrateId;
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use ra_db::CrateId;
|
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
|
@ -13,6 +13,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use arena::{Arena, Idx, RawId};
|
||||||
use ast::{AstNode, AttrsOwner, NameOwner, StructKind};
|
use ast::{AstNode, AttrsOwner, NameOwner, StructKind};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
|
@ -21,10 +22,9 @@ use hir_expand::{
|
||||||
name::{name, AsName, Name},
|
name::{name, AsName, Name},
|
||||||
HirFileId, InFile,
|
HirFileId, InFile,
|
||||||
};
|
};
|
||||||
use ra_arena::{Arena, Idx, RawId};
|
|
||||||
use ra_syntax::{ast, match_ast};
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use syntax::{ast, match_ast};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -77,7 +77,7 @@ pub struct ItemTree {
|
||||||
|
|
||||||
impl ItemTree {
|
impl ItemTree {
|
||||||
pub fn item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc<ItemTree> {
|
pub fn item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc<ItemTree> {
|
||||||
let _p = ra_prof::profile("item_tree_query").detail(|| format!("{:?}", file_id));
|
let _p = profile::span("item_tree_query").detail(|| format!("{:?}", file_id));
|
||||||
let syntax = if let Some(node) = db.parse_or_expand(file_id) {
|
let syntax = if let Some(node) = db.parse_or_expand(file_id) {
|
||||||
node
|
node
|
||||||
} else {
|
} else {
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
use std::{collections::hash_map::Entry, mem, sync::Arc};
|
use std::{collections::hash_map::Entry, mem, sync::Arc};
|
||||||
|
|
||||||
|
use arena::map::ArenaMap;
|
||||||
use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId};
|
use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId};
|
||||||
use ra_arena::map::ArenaMap;
|
use smallvec::SmallVec;
|
||||||
use ra_syntax::{
|
use syntax::{
|
||||||
ast::{self, ModuleItemOwner},
|
ast::{self, ModuleItemOwner},
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
};
|
};
|
||||||
use smallvec::SmallVec;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
attr::Attrs,
|
attr::Attrs,
|
|
@ -1,10 +1,10 @@
|
||||||
|
use base_db::fixture::WithFixture;
|
||||||
use expect::{expect, Expect};
|
use expect::{expect, Expect};
|
||||||
use hir_expand::{db::AstDatabase, HirFileId, InFile};
|
use hir_expand::{db::AstDatabase, HirFileId, InFile};
|
||||||
use ra_db::fixture::WithFixture;
|
|
||||||
use ra_syntax::{ast, AstNode};
|
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
|
use syntax::{ast, AstNode};
|
||||||
|
|
||||||
use crate::{db::DefDatabase, test_db::TestDB};
|
use crate::{db::DefDatabase, test_db::TestDB};
|
||||||
|
|
||||||
|
@ -228,31 +228,31 @@ fn smoke() {
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
|
||||||
Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) }
|
Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<syntax::ast::generated::nodes::Use>(0) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }]
|
||||||
Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) }
|
Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<syntax::ast::generated::nodes::Use>(0) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }]
|
||||||
ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) }
|
ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<syntax::ast::generated::nodes::ExternCrate>(1) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }]
|
||||||
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(2) }
|
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<syntax::ast::generated::nodes::Trait>(2) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }]
|
||||||
> TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAlias>(8) }
|
> TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<syntax::ast::generated::nodes::TypeAlias>(8) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }]
|
||||||
> Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Const>(9) }
|
> Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<syntax::ast::generated::nodes::Const>(9) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(10) }
|
> Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(10) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(11) }
|
> Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(11) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
|
||||||
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(3), kind: Unit }
|
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<syntax::ast::generated::nodes::Struct>(3), kind: Unit }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
|
||||||
Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(4), kind: Tuple }
|
Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<syntax::ast::generated::nodes::Struct>(4), kind: Tuple }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }]
|
||||||
Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(5), kind: Record }
|
Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<syntax::ast::generated::nodes::Struct>(5), kind: Record }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }]
|
||||||
Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Enum>(6) }
|
Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<syntax::ast::generated::nodes::Enum>(6) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }]
|
||||||
Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Union>(7) }
|
Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<syntax::ast::generated::nodes::Union>(7) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -274,13 +274,13 @@ fn simple_inner_items() {
|
||||||
inner attrs: Attrs { entries: None }
|
inner attrs: Attrs { entries: None }
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
|
Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<syntax::ast::generated::nodes::Impl>(0) }
|
||||||
> Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
> Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(1) }
|
||||||
|
|
||||||
inner items:
|
inner items:
|
||||||
|
|
||||||
for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2):
|
for AST FileAstId::<syntax::ast::generated::nodes::Item>(2):
|
||||||
Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(2) }
|
||||||
|
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
@ -303,9 +303,9 @@ fn extern_attrs() {
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
||||||
Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(1) }
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }]
|
||||||
Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(2) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -327,11 +327,11 @@ fn trait_attrs() {
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }]
|
||||||
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(0) }
|
Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<syntax::ast::generated::nodes::Trait>(0) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(1) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(2) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -353,11 +353,11 @@ fn impl_attrs() {
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }]
|
||||||
Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
|
Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<syntax::ast::generated::nodes::Impl>(0) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
> Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(1) }
|
||||||
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }]
|
||||||
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) }
|
> Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(2) }
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -408,13 +408,13 @@ fn inner_item_attrs() {
|
||||||
inner attrs: Attrs { entries: None }
|
inner attrs: Attrs { entries: None }
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(0) }
|
Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(0) }
|
||||||
|
|
||||||
inner items:
|
inner items:
|
||||||
|
|
||||||
for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1):
|
for AST FileAstId::<syntax::ast::generated::nodes::Item>(1):
|
||||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }]
|
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }]
|
||||||
Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) }
|
Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<syntax::ast::generated::nodes::Fn>(1) }
|
||||||
|
|
||||||
"##]],
|
"##]],
|
||||||
);
|
);
|
||||||
|
@ -432,8 +432,8 @@ fn assoc_item_macros() {
|
||||||
inner attrs: Attrs { entries: None }
|
inner attrs: Attrs { entries: None }
|
||||||
|
|
||||||
top-level items:
|
top-level items:
|
||||||
Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) }
|
Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<syntax::ast::generated::nodes::Impl>(0) }
|
||||||
> MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) }
|
> MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<syntax::ast::generated::nodes::MacroCall>(1) }
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use hir_expand::{InFile, MacroDefId};
|
use hir_expand::{InFile, MacroDefId};
|
||||||
use ra_syntax::{ast, AstNode, AstPtr};
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
use syntax::{ast, AstNode, AstPtr};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dyn_map::{DynMap, Policy},
|
dyn_map::{DynMap, Policy},
|
|
@ -4,9 +4,8 @@
|
||||||
//! features, such as Fn family of traits.
|
//! features, such as Fn family of traits.
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ra_prof::profile;
|
|
||||||
use ra_syntax::SmolStr;
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
use syntax::SmolStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId,
|
db::DefDatabase, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId,
|
||||||
|
@ -79,7 +78,7 @@ impl LangItems {
|
||||||
|
|
||||||
/// Salsa query. This will look for lang items in a specific crate.
|
/// Salsa query. This will look for lang items in a specific crate.
|
||||||
pub(crate) fn crate_lang_items_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<LangItems> {
|
pub(crate) fn crate_lang_items_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<LangItems> {
|
||||||
let _p = profile("crate_lang_items_query");
|
let _p = profile::span("crate_lang_items_query");
|
||||||
|
|
||||||
let mut lang_items = LangItems::default();
|
let mut lang_items = LangItems::default();
|
||||||
|
|
||||||
|
@ -98,7 +97,7 @@ impl LangItems {
|
||||||
db: &dyn DefDatabase,
|
db: &dyn DefDatabase,
|
||||||
module: ModuleId,
|
module: ModuleId,
|
||||||
) -> Option<Arc<LangItems>> {
|
) -> Option<Arc<LangItems>> {
|
||||||
let _p = profile("module_lang_items_query");
|
let _p = profile::span("module_lang_items_query");
|
||||||
let mut lang_items = LangItems::default();
|
let mut lang_items = LangItems::default();
|
||||||
lang_items.collect_lang_items(db, module);
|
lang_items.collect_lang_items(db, module);
|
||||||
if lang_items.items.is_empty() {
|
if lang_items.items.is_empty() {
|
||||||
|
@ -115,7 +114,7 @@ impl LangItems {
|
||||||
start_crate: CrateId,
|
start_crate: CrateId,
|
||||||
item: SmolStr,
|
item: SmolStr,
|
||||||
) -> Option<LangItemTarget> {
|
) -> Option<LangItemTarget> {
|
||||||
let _p = profile("lang_item_query");
|
let _p = profile::span("lang_item_query");
|
||||||
let lang_items = db.crate_lang_items(start_crate);
|
let lang_items = db.crate_lang_items(start_crate);
|
||||||
let start_crate_target = lang_items.items.get(&item);
|
let start_crate_target = lang_items.items.get(&item);
|
||||||
if let Some(target) = start_crate_target {
|
if let Some(target) = start_crate_target {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue