Merge #5748
5748: Rename ra_ssr -> ssr
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
d2212a49f6
114 changed files with 288 additions and 313 deletions
176
Cargo.lock
generated
176
Cargo.lock
generated
|
|
@ -463,6 +463,24 @@ dependencies = [
|
|||
"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"
|
||||
|
|
@ -507,6 +525,34 @@ dependencies = [
|
|||
"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]]
|
||||
name = "home"
|
||||
version = "0.5.3"
|
||||
|
|
@ -516,6 +562,25 @@ dependencies = [
|
|||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[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]]
|
||||
name = "idna"
|
||||
version = "0.2.0"
|
||||
|
|
@ -1043,10 +1108,10 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"base_db",
|
||||
"either",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"itertools",
|
||||
"profile",
|
||||
"ra_hir",
|
||||
"ra_ide_db",
|
||||
"rustc-hash",
|
||||
"stdx",
|
||||
"syntax",
|
||||
|
|
@ -1054,52 +1119,6 @@ dependencies = [
|
|||
"text_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra_hir"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"base_db",
|
||||
"either",
|
||||
"hir_def",
|
||||
"hir_expand",
|
||||
"itertools",
|
||||
"log",
|
||||
"profile",
|
||||
"ra_hir_ty",
|
||||
"rustc-hash",
|
||||
"stdx",
|
||||
"syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra_hir_ty"
|
||||
version = "0.1.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]]
|
||||
name = "ra_ide"
|
||||
version = "0.1.0"
|
||||
|
|
@ -1108,55 +1127,22 @@ dependencies = [
|
|||
"cfg",
|
||||
"either",
|
||||
"expect",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"indexmap",
|
||||
"itertools",
|
||||
"log",
|
||||
"oorandom",
|
||||
"profile",
|
||||
"ra_assists",
|
||||
"ra_hir",
|
||||
"ra_ide_db",
|
||||
"ra_ssr",
|
||||
"rustc-hash",
|
||||
"ssr",
|
||||
"stdx",
|
||||
"syntax",
|
||||
"test_utils",
|
||||
"text_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra_ide_db"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base_db",
|
||||
"either",
|
||||
"fst",
|
||||
"log",
|
||||
"once_cell",
|
||||
"profile",
|
||||
"ra_hir",
|
||||
"rayon",
|
||||
"rustc-hash",
|
||||
"stdx",
|
||||
"syntax",
|
||||
"test_utils",
|
||||
"text_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra_ssr"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base_db",
|
||||
"expect",
|
||||
"ra_hir",
|
||||
"ra_ide_db",
|
||||
"rustc-hash",
|
||||
"syntax",
|
||||
"test_utils",
|
||||
"text_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.3.1"
|
||||
|
|
@ -1236,7 +1222,10 @@ dependencies = [
|
|||
"env_logger",
|
||||
"expect",
|
||||
"flycheck",
|
||||
"hir",
|
||||
"hir_def",
|
||||
"hir_ty",
|
||||
"ide_db",
|
||||
"itertools",
|
||||
"jod-thread",
|
||||
"log",
|
||||
|
|
@ -1250,15 +1239,12 @@ dependencies = [
|
|||
"proc_macro_srv",
|
||||
"profile",
|
||||
"project_model",
|
||||
"ra_hir",
|
||||
"ra_hir_ty",
|
||||
"ra_ide",
|
||||
"ra_ide_db",
|
||||
"ra_ssr",
|
||||
"rayon",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"ssr",
|
||||
"stdx",
|
||||
"syntax",
|
||||
"test_utils",
|
||||
|
|
@ -1456,6 +1442,20 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ssr"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base_db",
|
||||
"expect",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"rustc-hash",
|
||||
"syntax",
|
||||
"test_utils",
|
||||
"text_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stdx"
|
||||
version = "0.1.0"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "ra_hir"
|
||||
version = "0.1.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
name = "hir"
|
||||
version = "0.0.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
@ -13,7 +13,6 @@ log = "0.4.8"
|
|||
rustc-hash = "1.1.0"
|
||||
either = "1.5.3"
|
||||
arrayvec = "0.5.1"
|
||||
|
||||
itertools = "0.9.0"
|
||||
|
||||
stdx = { path = "../stdx" }
|
||||
|
|
@ -22,4 +21,4 @@ base_db = { path = "../base_db" }
|
|||
profile = { path = "../profile" }
|
||||
hir_expand = { path = "../hir_expand" }
|
||||
hir_def = { path = "../hir_def" }
|
||||
hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
|
||||
hir_ty = { path = "../hir_ty" }
|
||||
|
|
@ -9,11 +9,11 @@
|
|||
//! 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".
|
||||
//!
|
||||
//! `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.
|
||||
//! 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:
|
||||
//! https://www.tedinski.com/2018/02/06/system-boundaries.html.
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "ra_hir_ty"
|
||||
version = "0.1.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
name = "hir_ty"
|
||||
version = "0.0.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
@ -15,9 +15,12 @@ smallvec = "1.2.0"
|
|||
ena = "0.14.0"
|
||||
log = "0.4.8"
|
||||
rustc-hash = "1.1.0"
|
||||
scoped-tls = "1"
|
||||
chalk-solve = { version = "0.21.0" }
|
||||
chalk-ir = { version = "0.21.0" }
|
||||
chalk-recursive = { version = "0.21.0" }
|
||||
|
||||
stdx = { path = "../stdx" }
|
||||
|
||||
hir_def = { path = "../hir_def" }
|
||||
hir_expand = { path = "../hir_expand" }
|
||||
arena = { path = "../arena" }
|
||||
|
|
@ -26,15 +29,9 @@ profile = { path = "../profile" }
|
|||
syntax = { path = "../syntax" }
|
||||
test_utils = { path = "../test_utils" }
|
||||
|
||||
scoped-tls = "1"
|
||||
|
||||
chalk-solve = { version = "0.21.0" }
|
||||
chalk-ir = { version = "0.21.0" }
|
||||
chalk-recursive = { version = "0.21.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
expect = { path = "../expect" }
|
||||
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] }
|
||||
tracing-tree = { version = "0.1.4" }
|
||||
|
||||
expect = { path = "../expect" }
|
||||
|
|
@ -35,7 +35,7 @@ use crate::{
|
|||
|
||||
// These tests compare the inference results for all expressions in a file
|
||||
// against snapshots of the expected results using expect. Use
|
||||
// `env UPDATE_EXPECT=1 cargo test -p ra_hir_ty` to update the snapshots.
|
||||
// `env UPDATE_EXPECT=1 cargo test -p hir_ty` to update the snapshots.
|
||||
|
||||
fn setup_tracing() -> tracing::subscriber::DefaultGuard {
|
||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "ra_ide_db"
|
||||
version = "0.1.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
name = "ide_db"
|
||||
version = "0.0.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
@ -20,13 +20,11 @@ once_cell = "1.3.1"
|
|||
either = "1.5.3"
|
||||
|
||||
stdx = { path = "../stdx" }
|
||||
|
||||
syntax = { path = "../syntax" }
|
||||
text_edit = { path = "../text_edit" }
|
||||
base_db = { path = "../base_db" }
|
||||
profile = { path = "../profile" }
|
||||
test_utils = { path = "../test_utils" }
|
||||
|
||||
# ra_ide should depend only on the top-level `hir` package. if you need
|
||||
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
||||
hir = { path = "../ra_hir", package = "ra_hir" }
|
||||
hir = { path = "../hir" }
|
||||
|
|
@ -19,6 +19,6 @@ syntax = { path = "../syntax" }
|
|||
text_edit = { path = "../text_edit" }
|
||||
profile = { path = "../profile" }
|
||||
base_db = { path = "../base_db" }
|
||||
ra_ide_db = { path = "../ra_ide_db" }
|
||||
hir = { path = "../ra_hir", package = "ra_hir" }
|
||||
ide_db = { path = "../ide_db" }
|
||||
hir = { path = "../hir" }
|
||||
test_utils = { path = "../test_utils" }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::mem;
|
|||
use algo::find_covering_element;
|
||||
use base_db::{FileId, FileRange};
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
source_change::{SourceChange, SourceFileEdit},
|
||||
RootDatabase,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ra_ide_db::defs::{classify_name_ref, Definition, NameRefClass};
|
||||
use ide_db::defs::{classify_name_ref, Definition, NameRefClass};
|
||||
use syntax::{ast, AstNode, SyntaxKind, T};
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use hir::{
|
|||
AsAssocItem, AssocItemContainer, ModPath, Module, ModuleDef, PathResolution, Semantics, Trait,
|
||||
Type,
|
||||
};
|
||||
use ra_ide_db::{imports_locator, RootDatabase};
|
||||
use ide_db::{imports_locator, RootDatabase};
|
||||
use rustc_hash::FxHashSet;
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope};
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
defs::{classify_name_ref, Definition, NameRefClass},
|
||||
RootDatabase,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use base_db::FileId;
|
||||
use hir::{EnumVariant, Module, ModuleDef, Name};
|
||||
use ra_ide_db::{defs::Definition, search::Reference, RootDatabase};
|
||||
use ide_db::{defs::Definition, search::Reference, RootDatabase};
|
||||
use rustc_hash::FxHashSet;
|
||||
use syntax::{
|
||||
algo::find_node_at_offset,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::iter;
|
||||
|
||||
use hir::{Adt, HasSource, ModuleDef, Semantics};
|
||||
use ide_db::RootDatabase;
|
||||
use itertools::Itertools;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::ast::{self, AstNode, NameOwner};
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ra_ide_db::defs::Definition;
|
||||
use ide_db::defs::Definition;
|
||||
use syntax::{
|
||||
ast::{self, AstNode, AstToken},
|
||||
TextRange,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use itertools::Itertools;
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode};
|
||||
|
||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub mod ast_transform;
|
|||
|
||||
use base_db::FileRange;
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::{source_change::SourceChange, RootDatabase};
|
||||
use ide_db::{source_change::SourceChange, RootDatabase};
|
||||
use syntax::TextRange;
|
||||
|
||||
pub(crate) use crate::assist_context::{AssistContext, Assists};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod generated;
|
|||
|
||||
use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt};
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::TextRange;
|
||||
use test_utils::{assert_eq_text, extract_offset, extract_range};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ pub(crate) mod insert_use;
|
|||
use std::{iter, ops};
|
||||
|
||||
use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type};
|
||||
use ide_db::RootDatabase;
|
||||
use itertools::Itertools;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use rustc_hash::FxHashSet;
|
||||
use syntax::{
|
||||
ast::{self, make, NameOwner},
|
||||
|
|
|
|||
|
|
@ -24,16 +24,16 @@ stdx = { path = "../stdx" }
|
|||
syntax = { path = "../syntax" }
|
||||
text_edit = { path = "../text_edit" }
|
||||
base_db = { path = "../base_db" }
|
||||
ra_ide_db = { path = "../ra_ide_db" }
|
||||
ide_db = { path = "../ide_db" }
|
||||
cfg = { path = "../cfg" }
|
||||
profile = { path = "../profile" }
|
||||
test_utils = { path = "../test_utils" }
|
||||
ra_assists = { path = "../ra_assists" }
|
||||
ra_ssr = { path = "../ra_ssr" }
|
||||
ssr = { path = "../ssr" }
|
||||
|
||||
# ra_ide should depend only on the top-level `hir` package. if you need
|
||||
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
||||
hir = { path = "../ra_hir", package = "ra_hir" }
|
||||
hir = { path = "../hir" }
|
||||
|
||||
[dev-dependencies]
|
||||
expect = { path = "../expect" }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use indexmap::IndexMap;
|
||||
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{ast, match_ast, AstNode, TextRange};
|
||||
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! FIXME: write short doc here
|
||||
use either::Either;
|
||||
use hir::{Docs, HirDisplay, Semantics, Type};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use stdx::format_to;
|
||||
use syntax::{
|
||||
ast::{self, ArgListOwner},
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ mod complete_postfix;
|
|||
mod complete_macro_in_item_position;
|
||||
mod complete_trait_impl;
|
||||
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
|
||||
use crate::{
|
||||
completion::{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use base_db::SourceDatabase;
|
||||
use hir::{Semantics, SemanticsScope, Type};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
algo::{find_covering_element, find_node_at_offset},
|
||||
ast, match_ast, AstNode, NodeOrToken,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use std::cell::RefCell;
|
|||
|
||||
use base_db::SourceDatabase;
|
||||
use hir::{diagnostics::DiagnosticSinkBuilder, Semantics};
|
||||
use ide_db::RootDatabase;
|
||||
use itertools::Itertools;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
SyntaxNode, TextRange, T,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use hir::{
|
|||
diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule},
|
||||
HasSource, HirDisplay, Semantics, VariantDef,
|
||||
};
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
source_change::{FileSystemEdit, SourceFileEdit},
|
||||
RootDatabase,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use base_db::{FileId, SourceDatabase};
|
||||
use either::Either;
|
||||
use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource};
|
||||
use ra_ide_db::{defs::Definition, RootDatabase};
|
||||
use ide_db::{defs::Definition, RootDatabase};
|
||||
use syntax::{
|
||||
ast::{self, DocCommentsOwner, NameOwner},
|
||||
match_ast, AstNode, SmolStr,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use hir::Semantics;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
algo::{find_node_at_offset, SyntaxRewriter},
|
||||
ast, AstNode, NodeOrToken, SyntaxKind,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::iter::successors;
|
||||
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
algo::{self, find_covering_element, skip_trivia_token},
|
||||
ast::{self, AstNode, AstToken},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use hir::Semantics;
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
defs::{classify_name, classify_name_ref},
|
||||
symbol_index, RootDatabase,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use hir::{Crate, ImplDef, Semantics};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{algo::find_node_at_offset, ast, AstNode};
|
||||
|
||||
use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
|
||||
|
||||
use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ use hir::{
|
|||
Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay,
|
||||
Module, ModuleDef, ModuleSource, Semantics,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
defs::{classify_name, classify_name_ref, Definition},
|
||||
RootDatabase,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use stdx::format_to;
|
||||
use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
|
||||
use test_utils::mark;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use hir::{Adt, Callable, HirDisplay, Semantics, Type};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use stdx::to_lower_snake_case;
|
||||
use syntax::{
|
||||
ast::{self, ArgListOwner, AstNode},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//! Strings, suitable for displaying to the human.
|
||||
//!
|
||||
//! What powers this API are the `RootDatabase` struct, which defines a `salsa`
|
||||
//! database, and the `ra_hir` crate, where majority of the analysis happens.
|
||||
//! database, and the `hir` crate, where majority of the analysis happens.
|
||||
//! However, IDE specific bits of the analysis (most notably completion) happen
|
||||
//! in this crate.
|
||||
|
||||
|
|
@ -39,7 +39,6 @@ mod matching_brace;
|
|||
mod parent_module;
|
||||
mod references;
|
||||
mod runnables;
|
||||
mod ssr;
|
||||
mod status;
|
||||
mod syntax_highlighting;
|
||||
mod syntax_tree;
|
||||
|
|
@ -52,7 +51,7 @@ use base_db::{
|
|||
CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath,
|
||||
};
|
||||
use cfg::CfgOptions;
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
symbol_index::{self, FileSymbol},
|
||||
LineIndexDatabase,
|
||||
};
|
||||
|
|
@ -86,8 +85,7 @@ pub use base_db::{
|
|||
SourceRootId,
|
||||
};
|
||||
pub use hir::{Documentation, Semantics};
|
||||
pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist};
|
||||
pub use ra_ide_db::{
|
||||
pub use ide_db::{
|
||||
change::AnalysisChange,
|
||||
line_index::{LineCol, LineIndex},
|
||||
search::SearchScope,
|
||||
|
|
@ -95,7 +93,8 @@ pub use ra_ide_db::{
|
|||
symbol_index::Query,
|
||||
RootDatabase,
|
||||
};
|
||||
pub use ra_ssr::SsrError;
|
||||
pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist};
|
||||
pub use ssr::SsrError;
|
||||
pub use text_edit::{Indel, TextEdit};
|
||||
|
||||
pub type Cancelable<T> = Result<T, Canceled>;
|
||||
|
|
@ -515,20 +514,23 @@ impl Analysis {
|
|||
&self,
|
||||
query: &str,
|
||||
parse_only: bool,
|
||||
position: FilePosition,
|
||||
resolve_context: FilePosition,
|
||||
selections: Vec<FileRange>,
|
||||
) -> Cancelable<Result<SourceChange, SsrError>> {
|
||||
self.with_db(|db| {
|
||||
let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?;
|
||||
let rule: ssr::SsrRule = query.parse()?;
|
||||
let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections);
|
||||
match_finder.add_rule(rule)?;
|
||||
let edits = if parse_only { Vec::new() } else { match_finder.edits() };
|
||||
Ok(SourceChange::from(edits))
|
||||
})
|
||||
}
|
||||
|
||||
/// Performs an operation on that may be Canceled.
|
||||
fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>(
|
||||
&self,
|
||||
f: F,
|
||||
) -> Cancelable<T> {
|
||||
fn with_db<F, T>(&self, f: F) -> Cancelable<T>
|
||||
where
|
||||
F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe,
|
||||
{
|
||||
self.db.catch_canceled(f)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use base_db::{CrateId, FileId, FilePosition};
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
algo::find_node_at_offset,
|
||||
ast::{self, AstNode},
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
mod rename;
|
||||
|
||||
use hir::Semantics;
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
defs::{classify_name, classify_name_ref, Definition},
|
||||
search::SearchScope,
|
||||
RootDatabase,
|
||||
|
|
@ -27,7 +27,7 @@ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeI
|
|||
|
||||
pub(crate) use self::rename::rename;
|
||||
|
||||
pub use ra_ide_db::search::{Reference, ReferenceAccess, ReferenceKind};
|
||||
pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReferenceSearchResult {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use base_db::SourceDatabaseExt;
|
||||
use hir::{Module, ModuleDef, ModuleSource, Semantics};
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
|
||||
RootDatabase,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use std::fmt;
|
|||
|
||||
use cfg::CfgExpr;
|
||||
use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics};
|
||||
use ide_db::RootDatabase;
|
||||
use itertools::Itertools;
|
||||
use ra_ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner},
|
||||
match_ast, SyntaxNode,
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
use base_db::{FilePosition, FileRange};
|
||||
use ra_ide_db::RootDatabase;
|
||||
|
||||
use crate::SourceFileEdit;
|
||||
use ra_ssr::{MatchFinder, SsrError, SsrRule};
|
||||
|
||||
// Feature: Structural Search and Replace
|
||||
//
|
||||
// Search and replace with named wildcards that will match any expression, type, path, pattern or item.
|
||||
// The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`.
|
||||
// A `$<name>` placeholder in the search pattern will match any AST node and `$<name>` will reference it in the replacement.
|
||||
// Within a macro call, a placeholder will match up until whatever token follows the placeholder.
|
||||
//
|
||||
// All paths in both the search pattern and the replacement template must resolve in the context
|
||||
// in which this command is invoked. Paths in the search pattern will then match the code if they
|
||||
// resolve to the same item, even if they're written differently. For example if we invoke the
|
||||
// command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers
|
||||
// to `foo::Bar` will match.
|
||||
//
|
||||
// Paths in the replacement template will be rendered appropriately for the context in which the
|
||||
// replacement occurs. For example if our replacement template is `foo::Bar` and we match some
|
||||
// code in the `foo` module, we'll insert just `Bar`.
|
||||
//
|
||||
// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will
|
||||
// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`.
|
||||
//
|
||||
// The scope of the search / replace will be restricted to the current selection if any, otherwise
|
||||
// it will apply to the whole workspace.
|
||||
//
|
||||
// Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`.
|
||||
//
|
||||
// Supported constraints:
|
||||
//
|
||||
// |===
|
||||
// | Constraint | Restricts placeholder
|
||||
//
|
||||
// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`)
|
||||
// | not(a) | Negates the constraint `a`
|
||||
// |===
|
||||
//
|
||||
// Available via the command `rust-analyzer.ssr`.
|
||||
//
|
||||
// ```rust
|
||||
// // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)]
|
||||
//
|
||||
// // BEFORE
|
||||
// String::from(foo(y + 5, z))
|
||||
//
|
||||
// // AFTER
|
||||
// String::from((y + 5).foo(z))
|
||||
// ```
|
||||
//
|
||||
// |===
|
||||
// | Editor | Action Name
|
||||
//
|
||||
// | VS Code | **Rust Analyzer: Structural Search Replace**
|
||||
// |===
|
||||
pub fn parse_search_replace(
|
||||
rule: &str,
|
||||
parse_only: bool,
|
||||
db: &RootDatabase,
|
||||
resolve_context: FilePosition,
|
||||
selections: Vec<FileRange>,
|
||||
) -> Result<Vec<SourceFileEdit>, SsrError> {
|
||||
let rule: SsrRule = rule.parse()?;
|
||||
let mut match_finder = MatchFinder::in_context(db, resolve_context, selections);
|
||||
match_finder.add_rule(rule)?;
|
||||
if parse_only {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
Ok(match_finder.edits())
|
||||
}
|
||||
|
|
@ -5,11 +5,11 @@ use base_db::{
|
|||
FileTextQuery, SourceRootId,
|
||||
};
|
||||
use hir::MacroFile;
|
||||
use profile::{memory_usage, Bytes};
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
symbol_index::{LibrarySymbolsQuery, SymbolIndex},
|
||||
RootDatabase,
|
||||
};
|
||||
use profile::{memory_usage, Bytes};
|
||||
use rustc_hash::FxHashMap;
|
||||
use syntax::{ast, Parse, SyntaxNode};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ mod injection;
|
|||
mod tests;
|
||||
|
||||
use hir::{Name, Semantics, VariantDef};
|
||||
use ra_ide_db::{
|
||||
use ide_db::{
|
||||
defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
|
||||
RootDatabase,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use base_db::{FileId, SourceDatabase};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
algo, AstNode, NodeOrToken, SourceFile,
|
||||
SyntaxKind::{RAW_STRING, STRING},
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
mod on_enter;
|
||||
|
||||
use base_db::{FilePosition, SourceDatabase};
|
||||
use ra_ide_db::{source_change::SourceFileEdit, RootDatabase};
|
||||
use ide_db::{source_change::SourceFileEdit, RootDatabase};
|
||||
use syntax::{
|
||||
algo::find_node_at_offset,
|
||||
ast::{self, edit::IndentLevel, AstToken},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//! comments, but should handle indent some time in the future as well.
|
||||
|
||||
use base_db::{FilePosition, SourceDatabase};
|
||||
use ra_ide_db::RootDatabase;
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
ast::{self, AstToken},
|
||||
AstNode, SmolStr, SourceFile,
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ toolchain = { path = "../toolchain" }
|
|||
|
||||
# This should only be used in CLI
|
||||
base_db = { path = "../base_db" }
|
||||
ra_ide_db = { path = "../ra_ide_db" }
|
||||
ra_ssr = { path = "../ra_ssr" }
|
||||
hir = { path = "../ra_hir", package = "ra_hir" }
|
||||
ide_db = { path = "../ide_db" }
|
||||
ssr = { path = "../ssr" }
|
||||
hir = { path = "../hir" }
|
||||
hir_def = { path = "../hir_def" }
|
||||
hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
|
||||
hir_ty = { path = "../hir_ty" }
|
||||
proc_macro_srv = { path = "../proc_macro_srv" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ use std::{env, fmt::Write, path::PathBuf};
|
|||
|
||||
use anyhow::{bail, Result};
|
||||
use pico_args::Arguments;
|
||||
use ra_ssr::{SsrPattern, SsrRule};
|
||||
use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity};
|
||||
use ssr::{SsrPattern, SsrRule};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
pub(crate) struct Args {
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ use anyhow::Result;
|
|||
use ra_ide::Analysis;
|
||||
use syntax::{AstNode, SourceFile};
|
||||
|
||||
pub use analysis_bench::{BenchCmd, BenchWhat, Position};
|
||||
pub use analysis_stats::AnalysisStatsCmd;
|
||||
pub use diagnostics::diagnostics;
|
||||
pub use load_cargo::load_cargo;
|
||||
pub use ssr::{apply_ssr_rules, search_for_patterns};
|
||||
pub use self::{
|
||||
analysis_bench::{BenchCmd, BenchWhat, Position},
|
||||
analysis_stats::AnalysisStatsCmd,
|
||||
diagnostics::diagnostics,
|
||||
load_cargo::load_cargo,
|
||||
ssr::{apply_ssr_rules, search_for_patterns},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Verbosity {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Applies structured search replace rules from the command line.
|
||||
|
||||
use crate::cli::{load_cargo::load_cargo, Result};
|
||||
use ra_ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||
use ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||
|
||||
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||
use base_db::SourceDatabaseExt;
|
||||
|
|
@ -27,7 +27,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
|||
/// for much else.
|
||||
pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
|
||||
use base_db::SourceDatabaseExt;
|
||||
use ra_ide_db::symbol_index::SymbolsDatabase;
|
||||
use ide_db::symbol_index::SymbolsDatabase;
|
||||
let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
|
||||
let db = host.raw_database();
|
||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
||||
|
|
|
|||
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