Rename ra_ide_db -> ide_db

This commit is contained in:
Aleksey Kladov 2020-08-13 16:39:16 +02:00
parent ae71a631fd
commit bb5c189b7d
59 changed files with 93 additions and 99 deletions

46
Cargo.lock generated
View file

@ -562,6 +562,25 @@ dependencies = [
"winapi 0.3.9", "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]] [[package]]
name = "idna" name = "idna"
version = "0.2.0" version = "0.2.0"
@ -1090,9 +1109,9 @@ dependencies = [
"base_db", "base_db",
"either", "either",
"hir", "hir",
"ide_db",
"itertools", "itertools",
"profile", "profile",
"ra_ide_db",
"rustc-hash", "rustc-hash",
"stdx", "stdx",
"syntax", "syntax",
@ -1109,13 +1128,13 @@ dependencies = [
"either", "either",
"expect", "expect",
"hir", "hir",
"ide_db",
"indexmap", "indexmap",
"itertools", "itertools",
"log", "log",
"oorandom", "oorandom",
"profile", "profile",
"ra_assists", "ra_assists",
"ra_ide_db",
"ra_ssr", "ra_ssr",
"rustc-hash", "rustc-hash",
"stdx", "stdx",
@ -1124,25 +1143,6 @@ dependencies = [
"text_edit", "text_edit",
] ]
[[package]]
name = "ra_ide_db"
version = "0.1.0"
dependencies = [
"base_db",
"either",
"fst",
"hir",
"log",
"once_cell",
"profile",
"rayon",
"rustc-hash",
"stdx",
"syntax",
"test_utils",
"text_edit",
]
[[package]] [[package]]
name = "ra_ssr" name = "ra_ssr"
version = "0.1.0" version = "0.1.0"
@ -1150,7 +1150,7 @@ dependencies = [
"base_db", "base_db",
"expect", "expect",
"hir", "hir",
"ra_ide_db", "ide_db",
"rustc-hash", "rustc-hash",
"syntax", "syntax",
"test_utils", "test_utils",
@ -1239,6 +1239,7 @@ dependencies = [
"hir", "hir",
"hir_def", "hir_def",
"hir_ty", "hir_ty",
"ide_db",
"itertools", "itertools",
"jod-thread", "jod-thread",
"log", "log",
@ -1253,7 +1254,6 @@ dependencies = [
"profile", "profile",
"project_model", "project_model",
"ra_ide", "ra_ide",
"ra_ide_db",
"ra_ssr", "ra_ssr",
"rayon", "rayon",
"rustc-hash", "rustc-hash",

View file

@ -1,9 +1,9 @@
[package] [package]
edition = "2018" name = "ide_db"
name = "ra_ide_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
@ -20,13 +20,11 @@ once_cell = "1.3.1"
either = "1.5.3" either = "1.5.3"
stdx = { path = "../stdx" } stdx = { path = "../stdx" }
syntax = { path = "../syntax" } syntax = { path = "../syntax" }
text_edit = { path = "../text_edit" } text_edit = { path = "../text_edit" }
base_db = { path = "../base_db" } base_db = { path = "../base_db" }
profile = { path = "../profile" } profile = { path = "../profile" }
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }
# ra_ide should depend only on the top-level `hir` package. if you need # 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`. # something from some `hir_xxx` subpackage, reexport the API via `hir`.
hir = { path = "../hir" } hir = { path = "../hir" }

View file

@ -19,6 +19,6 @@ syntax = { path = "../syntax" }
text_edit = { path = "../text_edit" } text_edit = { path = "../text_edit" }
profile = { path = "../profile" } profile = { path = "../profile" }
base_db = { path = "../base_db" } base_db = { path = "../base_db" }
ra_ide_db = { path = "../ra_ide_db" } ide_db = { path = "../ide_db" }
hir = { path = "../hir" } hir = { path = "../hir" }
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }

View file

@ -5,7 +5,7 @@ use std::mem;
use algo::find_covering_element; use algo::find_covering_element;
use base_db::{FileId, FileRange}; use base_db::{FileId, FileRange};
use hir::Semantics; use hir::Semantics;
use ra_ide_db::{ use ide_db::{
source_change::{SourceChange, SourceFileEdit}, source_change::{SourceChange, SourceFileEdit},
RootDatabase, RootDatabase,
}; };

View file

@ -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 syntax::{ast, AstNode, SyntaxKind, T};
use test_utils::mark; use test_utils::mark;

View file

@ -5,7 +5,7 @@ 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 rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use syntax::{ use syntax::{
ast::{self, AstNode}, ast::{self, AstNode},

View file

@ -1,5 +1,5 @@
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,
}; };

View file

@ -1,6 +1,6 @@
use base_db::FileId; use base_db::FileId;
use hir::{EnumVariant, Module, ModuleDef, Name}; 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 rustc_hash::FxHashSet;
use syntax::{ use syntax::{
algo::find_node_at_offset, algo::find_node_at_offset,

View file

@ -1,8 +1,8 @@
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 syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
use test_utils::mark; use test_utils::mark;

View file

@ -1,4 +1,4 @@
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::ast::{self, AstNode, NameOwner}; use syntax::ast::{self, AstNode, NameOwner};
use test_utils::mark; use test_utils::mark;

View file

@ -1,4 +1,4 @@
use ra_ide_db::defs::Definition; use ide_db::defs::Definition;
use syntax::{ use syntax::{
ast::{self, AstNode, AstToken}, ast::{self, AstNode, AstToken},
TextRange, TextRange,

View file

@ -2,7 +2,7 @@ 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 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};

View file

@ -19,7 +19,7 @@ pub mod ast_transform;
use base_db::FileRange; use base_db::FileRange;
use hir::Semantics; use hir::Semantics;
use ra_ide_db::{source_change::SourceChange, RootDatabase}; use ide_db::{source_change::SourceChange, RootDatabase};
use syntax::TextRange; use syntax::TextRange;
pub(crate) use crate::assist_context::{AssistContext, Assists}; pub(crate) use crate::assist_context::{AssistContext, Assists};

View file

@ -2,7 +2,7 @@ mod generated;
use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt};
use hir::Semantics; use hir::Semantics;
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::TextRange; use syntax::TextRange;
use test_utils::{assert_eq_text, extract_offset, extract_range}; use test_utils::{assert_eq_text, extract_offset, extract_range};

View file

@ -4,8 +4,8 @@ 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 ide_db::RootDatabase;
use itertools::Itertools; use itertools::Itertools;
use ra_ide_db::RootDatabase;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use syntax::{ use syntax::{
ast::{self, make, NameOwner}, ast::{self, make, NameOwner},

View file

@ -24,7 +24,7 @@ stdx = { path = "../stdx" }
syntax = { path = "../syntax" } syntax = { path = "../syntax" }
text_edit = { path = "../text_edit" } text_edit = { path = "../text_edit" }
base_db = { path = "../base_db" } base_db = { path = "../base_db" }
ra_ide_db = { path = "../ra_ide_db" } ide_db = { path = "../ide_db" }
cfg = { path = "../cfg" } cfg = { path = "../cfg" }
profile = { path = "../profile" } profile = { path = "../profile" }
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }

View file

@ -3,7 +3,7 @@
use indexmap::IndexMap; use indexmap::IndexMap;
use hir::Semantics; use hir::Semantics;
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ast, match_ast, AstNode, TextRange}; use syntax::{ast, match_ast, AstNode, TextRange};
use crate::{ use crate::{

View file

@ -1,7 +1,7 @@
//! FIXME: write short doc here //! FIXME: write short doc here
use either::Either; use either::Either;
use hir::{Docs, HirDisplay, Semantics, Type}; use hir::{Docs, HirDisplay, Semantics, Type};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use stdx::format_to; use stdx::format_to;
use syntax::{ use syntax::{
ast::{self, ArgListOwner}, ast::{self, ArgListOwner},

View file

@ -19,7 +19,7 @@ mod complete_postfix;
mod complete_macro_in_item_position; mod complete_macro_in_item_position;
mod complete_trait_impl; mod complete_trait_impl;
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use crate::{ use crate::{
completion::{ completion::{

View file

@ -2,7 +2,7 @@
use base_db::SourceDatabase; use base_db::SourceDatabase;
use hir::{Semantics, SemanticsScope, Type}; use hir::{Semantics, SemanticsScope, Type};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ use syntax::{
algo::{find_covering_element, find_node_at_offset}, algo::{find_covering_element, find_node_at_offset},
ast, match_ast, AstNode, NodeOrToken, ast, match_ast, AstNode, NodeOrToken,

View file

@ -8,8 +8,8 @@ use std::cell::RefCell;
use base_db::SourceDatabase; use base_db::SourceDatabase;
use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; use hir::{diagnostics::DiagnosticSinkBuilder, Semantics};
use ide_db::RootDatabase;
use itertools::Itertools; use itertools::Itertools;
use ra_ide_db::RootDatabase;
use syntax::{ use syntax::{
ast::{self, AstNode}, ast::{self, AstNode},
SyntaxNode, TextRange, T, SyntaxNode, TextRange, T,

View file

@ -8,7 +8,7 @@ use hir::{
diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule},
HasSource, HirDisplay, Semantics, VariantDef, HasSource, HirDisplay, Semantics, VariantDef,
}; };
use ra_ide_db::{ use ide_db::{
source_change::{FileSystemEdit, SourceFileEdit}, source_change::{FileSystemEdit, SourceFileEdit},
RootDatabase, RootDatabase,
}; };

View file

@ -3,7 +3,7 @@
use base_db::{FileId, SourceDatabase}; use base_db::{FileId, SourceDatabase};
use either::Either; use either::Either;
use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource};
use ra_ide_db::{defs::Definition, RootDatabase}; use ide_db::{defs::Definition, RootDatabase};
use syntax::{ use syntax::{
ast::{self, DocCommentsOwner, NameOwner}, ast::{self, DocCommentsOwner, NameOwner},
match_ast, AstNode, SmolStr, match_ast, AstNode, SmolStr,

View file

@ -1,5 +1,5 @@
use hir::Semantics; use hir::Semantics;
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ use syntax::{
algo::{find_node_at_offset, SyntaxRewriter}, algo::{find_node_at_offset, SyntaxRewriter},
ast, AstNode, NodeOrToken, SyntaxKind, ast, AstNode, NodeOrToken, SyntaxKind,

View file

@ -1,7 +1,7 @@
use std::iter::successors; use std::iter::successors;
use hir::Semantics; use hir::Semantics;
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ use syntax::{
algo::{self, find_covering_element, skip_trivia_token}, algo::{self, find_covering_element, skip_trivia_token},
ast::{self, AstNode, AstToken}, ast::{self, AstNode, AstToken},

View file

@ -1,5 +1,5 @@
use hir::Semantics; use hir::Semantics;
use ra_ide_db::{ use ide_db::{
defs::{classify_name, classify_name_ref}, defs::{classify_name, classify_name_ref},
symbol_index, RootDatabase, symbol_index, RootDatabase,
}; };

View file

@ -1,5 +1,5 @@
use hir::{Crate, ImplDef, Semantics}; use hir::{Crate, ImplDef, Semantics};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{algo::find_node_at_offset, ast, AstNode}; use syntax::{algo::find_node_at_offset, ast, AstNode};
use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};

View file

@ -1,4 +1,4 @@
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};

View file

@ -3,11 +3,11 @@ use hir::{
Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay,
Module, ModuleDef, ModuleSource, Semantics, Module, ModuleDef, ModuleSource, Semantics,
}; };
use itertools::Itertools; use ide_db::{
use ra_ide_db::{
defs::{classify_name, classify_name_ref, Definition}, defs::{classify_name, classify_name_ref, Definition},
RootDatabase, RootDatabase,
}; };
use itertools::Itertools;
use stdx::format_to; use stdx::format_to;
use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
use test_utils::mark; use test_utils::mark;

View file

@ -1,5 +1,5 @@
use hir::{Adt, Callable, HirDisplay, Semantics, Type}; use hir::{Adt, Callable, HirDisplay, Semantics, Type};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use stdx::to_lower_snake_case; use stdx::to_lower_snake_case;
use syntax::{ use syntax::{
ast::{self, ArgListOwner, AstNode}, ast::{self, ArgListOwner, AstNode},

View file

@ -52,7 +52,7 @@ use base_db::{
CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath,
}; };
use cfg::CfgOptions; use cfg::CfgOptions;
use ra_ide_db::{ use ide_db::{
symbol_index::{self, FileSymbol}, symbol_index::{self, FileSymbol},
LineIndexDatabase, LineIndexDatabase,
}; };
@ -86,8 +86,7 @@ pub use base_db::{
SourceRootId, SourceRootId,
}; };
pub use hir::{Documentation, Semantics}; pub use hir::{Documentation, Semantics};
pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use ide_db::{
pub use ra_ide_db::{
change::AnalysisChange, change::AnalysisChange,
line_index::{LineCol, LineIndex}, line_index::{LineCol, LineIndex},
search::SearchScope, search::SearchScope,
@ -95,6 +94,7 @@ pub use ra_ide_db::{
symbol_index::Query, symbol_index::Query,
RootDatabase, RootDatabase,
}; };
pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist};
pub use ra_ssr::SsrError; pub use ra_ssr::SsrError;
pub use text_edit::{Indel, TextEdit}; pub use text_edit::{Indel, TextEdit};

View file

@ -1,6 +1,6 @@
use base_db::{CrateId, FileId, FilePosition}; use base_db::{CrateId, FileId, FilePosition};
use hir::Semantics; use hir::Semantics;
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ use syntax::{
algo::find_node_at_offset, algo::find_node_at_offset,
ast::{self, AstNode}, ast::{self, AstNode},

View file

@ -12,7 +12,7 @@
mod rename; mod rename;
use hir::Semantics; use hir::Semantics;
use ra_ide_db::{ use ide_db::{
defs::{classify_name, classify_name_ref, Definition}, defs::{classify_name, classify_name_ref, Definition},
search::SearchScope, search::SearchScope,
RootDatabase, RootDatabase,
@ -27,7 +27,7 @@ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeI
pub(crate) use self::rename::rename; 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)] #[derive(Debug, Clone)]
pub struct ReferenceSearchResult { pub struct ReferenceSearchResult {

View file

@ -2,7 +2,7 @@
use base_db::SourceDatabaseExt; use base_db::SourceDatabaseExt;
use hir::{Module, ModuleDef, ModuleSource, Semantics}; use hir::{Module, ModuleDef, ModuleSource, Semantics};
use ra_ide_db::{ use ide_db::{
defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
RootDatabase, RootDatabase,
}; };

View file

@ -2,8 +2,8 @@ use std::fmt;
use cfg::CfgExpr; use cfg::CfgExpr;
use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics};
use ide_db::RootDatabase;
use itertools::Itertools; use itertools::Itertools;
use ra_ide_db::RootDatabase;
use syntax::{ use syntax::{
ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner},
match_ast, SyntaxNode, match_ast, SyntaxNode,

View file

@ -1,5 +1,5 @@
use base_db::{FilePosition, FileRange}; use base_db::{FilePosition, FileRange};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use crate::SourceFileEdit; use crate::SourceFileEdit;
use ra_ssr::{MatchFinder, SsrError, SsrRule}; use ra_ssr::{MatchFinder, SsrError, SsrRule};

View file

@ -5,11 +5,11 @@ use base_db::{
FileTextQuery, SourceRootId, FileTextQuery, SourceRootId,
}; };
use hir::MacroFile; use hir::MacroFile;
use profile::{memory_usage, Bytes}; use ide_db::{
use ra_ide_db::{
symbol_index::{LibrarySymbolsQuery, SymbolIndex}, symbol_index::{LibrarySymbolsQuery, SymbolIndex},
RootDatabase, RootDatabase,
}; };
use profile::{memory_usage, Bytes};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use syntax::{ast, Parse, SyntaxNode}; use syntax::{ast, Parse, SyntaxNode};

View file

@ -5,7 +5,7 @@ mod injection;
mod tests; mod tests;
use hir::{Name, Semantics, VariantDef}; use hir::{Name, Semantics, VariantDef};
use ra_ide_db::{ use ide_db::{
defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
RootDatabase, RootDatabase,
}; };

View file

@ -1,5 +1,5 @@
use base_db::{FileId, SourceDatabase}; use base_db::{FileId, SourceDatabase};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ use syntax::{
algo, AstNode, NodeOrToken, SourceFile, algo, AstNode, NodeOrToken, SourceFile,
SyntaxKind::{RAW_STRING, STRING}, SyntaxKind::{RAW_STRING, STRING},

View file

@ -16,7 +16,7 @@
mod on_enter; mod on_enter;
use base_db::{FilePosition, SourceDatabase}; use base_db::{FilePosition, SourceDatabase};
use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; use ide_db::{source_change::SourceFileEdit, RootDatabase};
use syntax::{ use syntax::{
algo::find_node_at_offset, algo::find_node_at_offset,
ast::{self, edit::IndentLevel, AstToken}, ast::{self, edit::IndentLevel, AstToken},

View file

@ -2,7 +2,7 @@
//! comments, but should handle indent some time in the future as well. //! comments, but should handle indent some time in the future as well.
use base_db::{FilePosition, SourceDatabase}; use base_db::{FilePosition, SourceDatabase};
use ra_ide_db::RootDatabase; use ide_db::RootDatabase;
use syntax::{ use syntax::{
ast::{self, AstToken}, ast::{self, AstToken},
AstNode, SmolStr, SourceFile, AstNode, SmolStr, SourceFile,

View file

@ -14,7 +14,7 @@ doctest = false
text_edit = { path = "../text_edit" } text_edit = { path = "../text_edit" }
syntax = { path = "../syntax" } syntax = { path = "../syntax" }
base_db = { path = "../base_db" } base_db = { path = "../base_db" }
ra_ide_db = { path = "../ra_ide_db" } ide_db = { path = "../ide_db" }
hir = { path = "../hir" } hir = { path = "../hir" }
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }

View file

@ -20,7 +20,7 @@ pub use crate::matching::Match;
use crate::matching::MatchFailureReason; use crate::matching::MatchFailureReason;
use base_db::{FileId, FilePosition, FileRange}; use base_db::{FileId, FilePosition, FileRange};
use hir::Semantics; use hir::Semantics;
use ra_ide_db::source_change::SourceFileEdit; use ide_db::source_change::SourceFileEdit;
use resolving::ResolvedRule; use resolving::ResolvedRule;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, SyntaxNode, TextRange}; use syntax::{ast, AstNode, SyntaxNode, TextRange};
@ -49,7 +49,7 @@ pub struct SsrMatches {
/// Searches a crate for pattern matches and possibly replaces them with something else. /// Searches a crate for pattern matches and possibly replaces them with something else.
pub struct MatchFinder<'db> { pub struct MatchFinder<'db> {
/// Our source of information about the user's code. /// Our source of information about the user's code.
sema: Semantics<'db, ra_ide_db::RootDatabase>, sema: Semantics<'db, ide_db::RootDatabase>,
rules: Vec<ResolvedRule>, rules: Vec<ResolvedRule>,
resolution_scope: resolving::ResolutionScope<'db>, resolution_scope: resolving::ResolutionScope<'db>,
restrict_ranges: Vec<FileRange>, restrict_ranges: Vec<FileRange>,
@ -59,7 +59,7 @@ impl<'db> MatchFinder<'db> {
/// Constructs a new instance where names will be looked up as if they appeared at /// Constructs a new instance where names will be looked up as if they appeared at
/// `lookup_context`. /// `lookup_context`.
pub fn in_context( pub fn in_context(
db: &'db ra_ide_db::RootDatabase, db: &'db ide_db::RootDatabase,
lookup_context: FilePosition, lookup_context: FilePosition,
mut restrict_ranges: Vec<FileRange>, mut restrict_ranges: Vec<FileRange>,
) -> MatchFinder<'db> { ) -> MatchFinder<'db> {
@ -70,9 +70,9 @@ impl<'db> MatchFinder<'db> {
} }
/// Constructs an instance using the start of the first file in `db` as the lookup context. /// Constructs an instance using the start of the first file in `db` as the lookup context.
pub fn at_first_file(db: &'db ra_ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> { pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> {
use base_db::SourceDatabaseExt; use base_db::SourceDatabaseExt;
use ra_ide_db::symbol_index::SymbolsDatabase; use ide_db::symbol_index::SymbolsDatabase;
if let Some(first_file_id) = db if let Some(first_file_id) = db
.local_roots() .local_roots()
.iter() .iter()

View file

@ -92,7 +92,7 @@ pub(crate) fn get_match(
rule: &ResolvedRule, rule: &ResolvedRule,
code: &SyntaxNode, code: &SyntaxNode,
restrict_range: &Option<FileRange>, restrict_range: &Option<FileRange>,
sema: &Semantics<ra_ide_db::RootDatabase>, sema: &Semantics<ide_db::RootDatabase>,
) -> Result<Match, MatchFailed> { ) -> Result<Match, MatchFailed> {
record_match_fails_reasons_scope(debug_active, || { record_match_fails_reasons_scope(debug_active, || {
Matcher::try_match(rule, code, restrict_range, sema) Matcher::try_match(rule, code, restrict_range, sema)
@ -101,7 +101,7 @@ pub(crate) fn get_match(
/// Checks if our search pattern matches a particular node of the AST. /// Checks if our search pattern matches a particular node of the AST.
struct Matcher<'db, 'sema> { struct Matcher<'db, 'sema> {
sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, sema: &'sema Semantics<'db, ide_db::RootDatabase>,
/// If any placeholders come from anywhere outside of this range, then the match will be /// If any placeholders come from anywhere outside of this range, then the match will be
/// rejected. /// rejected.
restrict_range: Option<FileRange>, restrict_range: Option<FileRange>,
@ -123,7 +123,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
rule: &ResolvedRule, rule: &ResolvedRule,
code: &SyntaxNode, code: &SyntaxNode,
restrict_range: &Option<FileRange>, restrict_range: &Option<FileRange>,
sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, sema: &'sema Semantics<'db, ide_db::RootDatabase>,
) -> Result<Match, MatchFailed> { ) -> Result<Match, MatchFailed> {
let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule }; let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule };
// First pass at matching, where we check that node types and idents match. // First pass at matching, where we check that node types and idents match.
@ -606,7 +606,7 @@ impl Match {
fn render_template_paths( fn render_template_paths(
&mut self, &mut self,
template: &ResolvedPattern, template: &ResolvedPattern,
sema: &Semantics<ra_ide_db::RootDatabase>, sema: &Semantics<ide_db::RootDatabase>,
) -> Result<(), MatchFailed> { ) -> Result<(), MatchFailed> {
let module = sema let module = sema
.scope(&self.matched_node) .scope(&self.matched_node)

View file

@ -13,7 +13,7 @@ use syntax::SyntaxNode;
pub(crate) fn nest_and_remove_collisions( pub(crate) fn nest_and_remove_collisions(
mut matches: Vec<Match>, mut matches: Vec<Match>,
sema: &hir::Semantics<ra_ide_db::RootDatabase>, sema: &hir::Semantics<ide_db::RootDatabase>,
) -> SsrMatches { ) -> SsrMatches {
// We sort the matches by depth then by rule index. Sorting by depth means that by the time we // We sort the matches by depth then by rule index. Sorting by depth means that by the time we
// see a match, any parent matches or conflicting matches will have already been seen. Sorting // see a match, any parent matches or conflicting matches will have already been seen. Sorting
@ -36,7 +36,7 @@ impl MatchCollector {
/// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If /// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If
/// it is entirely within the a placeholder of an existing match, then it is added as a child /// it is entirely within the a placeholder of an existing match, then it is added as a child
/// match of the existing match. /// match of the existing match.
fn add_match(&mut self, m: Match, sema: &hir::Semantics<ra_ide_db::RootDatabase>) { fn add_match(&mut self, m: Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
let matched_node = m.matched_node.clone(); let matched_node = m.matched_node.clone();
if let Some(existing) = self.matches_by_node.get_mut(&matched_node) { if let Some(existing) = self.matches_by_node.get_mut(&matched_node) {
try_add_sub_match(m, existing, sema); try_add_sub_match(m, existing, sema);
@ -53,11 +53,7 @@ impl MatchCollector {
} }
/// Attempts to add `m` as a sub-match of `existing`. /// Attempts to add `m` as a sub-match of `existing`.
fn try_add_sub_match( fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
m: Match,
existing: &mut Match,
sema: &hir::Semantics<ra_ide_db::RootDatabase>,
) {
for p in existing.placeholder_values.values_mut() { for p in existing.placeholder_values.values_mut() {
// Note, no need to check if p.range.file is equal to m.range.file, since we // Note, no need to check if p.range.file is equal to m.range.file, since we
// already know we're within `existing`. // already know we're within `existing`.

View file

@ -187,7 +187,7 @@ impl Resolver<'_, '_> {
impl<'db> ResolutionScope<'db> { impl<'db> ResolutionScope<'db> {
pub(crate) fn new( pub(crate) fn new(
sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, sema: &hir::Semantics<'db, ide_db::RootDatabase>,
resolve_context: FilePosition, resolve_context: FilePosition,
) -> ResolutionScope<'db> { ) -> ResolutionScope<'db> {
use syntax::ast::AstNode; use syntax::ast::AstNode;

View file

@ -6,7 +6,7 @@ use crate::{
Match, MatchFinder, Match, MatchFinder,
}; };
use base_db::{FileId, FileRange}; use base_db::{FileId, FileRange};
use ra_ide_db::{ use ide_db::{
defs::Definition, defs::Definition,
search::{Reference, SearchScope}, search::{Reference, SearchScope},
}; };
@ -146,7 +146,7 @@ impl<'db> MatchFinder<'db> {
if self.restrict_ranges.is_empty() { if self.restrict_ranges.is_empty() {
// Unrestricted search. // Unrestricted search.
use base_db::SourceDatabaseExt; use base_db::SourceDatabaseExt;
use ra_ide_db::symbol_index::SymbolsDatabase; use ide_db::symbol_index::SymbolsDatabase;
for &root in self.sema.db.local_roots().iter() { for &root in self.sema.db.local_roots().iter() {
let sr = self.sema.db.source_root(root); let sr = self.sema.db.source_root(root);
for file_id in sr.iter() { for file_id in sr.iter() {

View file

@ -61,13 +61,13 @@ fn parser_undefined_placeholder_in_replacement() {
/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be /// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be
/// the start of the file. If there's a second cursor marker, then we'll return a single range. /// the start of the file. If there's a second cursor marker, then we'll return a single range.
pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec<FileRange>) { pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Vec<FileRange>) {
use base_db::fixture::WithFixture; use base_db::fixture::WithFixture;
use ra_ide_db::symbol_index::SymbolsDatabase; use ide_db::symbol_index::SymbolsDatabase;
let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) { let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) {
ra_ide_db::RootDatabase::with_range_or_offset(code) ide_db::RootDatabase::with_range_or_offset(code)
} else { } else {
let (db, file_id) = ra_ide_db::RootDatabase::with_single_file(code); let (db, file_id) = ide_db::RootDatabase::with_single_file(code);
(db, file_id, RangeOrOffset::Offset(0.into())) (db, file_id, RangeOrOffset::Offset(0.into()))
}; };
let selections; let selections;

View file

@ -47,7 +47,7 @@ toolchain = { path = "../toolchain" }
# This should only be used in CLI # This should only be used in CLI
base_db = { path = "../base_db" } base_db = { path = "../base_db" }
ra_ide_db = { path = "../ra_ide_db" } ide_db = { path = "../ide_db" }
ra_ssr = { path = "../ra_ssr" } ra_ssr = { path = "../ra_ssr" }
hir = { path = "../hir" } hir = { path = "../hir" }
hir_def = { path = "../hir_def" } hir_def = { path = "../hir_def" }

View file

@ -27,7 +27,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
/// for much else. /// for much else.
pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> { pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
use base_db::SourceDatabaseExt; 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 (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
let db = host.raw_database(); let db = host.raw_database();
let mut match_finder = MatchFinder::at_first_file(db)?; let mut match_finder = MatchFinder::at_first_file(db)?;