allow rustfmt to reorder imports

This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
This commit is contained in:
Aleksey Kladov 2019-07-04 23:05:17 +03:00
parent 2b2cd829b0
commit 1834bae5b8
166 changed files with 798 additions and 814 deletions

View file

@ -1,11 +1,11 @@
use std::error::Error; use std::error::Error;
use crossbeam_channel::{Sender, Receiver}; use crossbeam_channel::{Receiver, Sender};
use gen_lsp_server::{handle_shutdown, run_server, stdio_transport, RawMessage, RawResponse};
use lsp_types::{ use lsp_types::{
ServerCapabilities, InitializeParams,
request::{GotoDefinition, GotoDefinitionResponse}, request::{GotoDefinition, GotoDefinitionResponse},
InitializeParams, ServerCapabilities,
}; };
use gen_lsp_server::{run_server, stdio_transport, handle_shutdown, RawMessage, RawResponse};
fn main() -> Result<(), Box<dyn Error + Sync + Send>> { fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
let (receiver, sender, io_threads) = stdio_transport(); let (receiver, sender, io_threads) = stdio_transport();

View file

@ -44,14 +44,14 @@
use std::error::Error; use std::error::Error;
use crossbeam_channel::{Sender, Receiver}; use crossbeam_channel::{Receiver, Sender};
use lsp_types::{ use gen_lsp_server::{
ServerCapabilities, InitializeParams, handle_shutdown, run_server, stdio_transport, RawMessage, RawRequest, RawResponse,
request::{GotoDefinition, GotoDefinitionResponse},
}; };
use log::info; use log::info;
use gen_lsp_server::{ use lsp_types::{
run_server, stdio_transport, handle_shutdown, RawMessage, RawResponse, RawRequest, request::{GotoDefinition, GotoDefinitionResponse},
InitializeParams, ServerCapabilities,
}; };
fn main() -> Result<(), Box<dyn Error + Sync + Send>> { fn main() -> Result<(), Box<dyn Error + Sync + Send>> {

View file

@ -2,9 +2,9 @@
use std::{ use std::{
fmt, fmt,
iter::FromIterator,
marker::PhantomData, marker::PhantomData,
ops::{Index, IndexMut}, ops::{Index, IndexMut},
iter::FromIterator,
}; };
pub mod map; pub mod map;

View file

@ -1,11 +1,11 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{
ast::{self, AstNode, AttrsOwner}, ast::{self, AstNode, AttrsOwner},
SyntaxKind::{WHITESPACE, COMMENT}, SyntaxKind::{COMMENT, WHITESPACE},
TextUnit, TextUnit,
}; };
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let nominal = ctx.node_at_offset::<ast::NominalDef>()?; let nominal = ctx.node_at_offset::<ast::NominalDef>()?;

View file

@ -1,13 +1,10 @@
use hir::{ use hir::{db::HirDatabase, HirDisplay, Ty};
HirDisplay, Ty,
db::HirDatabase,
};
use ra_syntax::{ use ra_syntax::{
ast::{AstNode, LetStmt, NameOwner, PatKind},
T, T,
ast::{LetStmt, PatKind, NameOwner, AstNode}
}; };
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
/// Add explicit type assist. /// Add explicit type assist.
pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
@ -56,7 +53,7 @@ fn is_unknown(ty: &Ty) -> bool {
mod tests { mod tests {
use super::*; use super::*;
use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
#[test] #[test]
fn add_explicit_type_target() { fn add_explicit_type_target() {

View file

@ -1,11 +1,11 @@
use join_to_string::join;
use hir::db::HirDatabase; use hir::db::HirDatabase;
use join_to_string::join;
use ra_syntax::{ use ra_syntax::{
ast::{self, AstNode, NameOwner, TypeParamsOwner}, ast::{self, AstNode, NameOwner, TypeParamsOwner},
TextUnit, TextUnit,
}; };
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let nominal = ctx.node_at_offset::<ast::NominalDef>()?; let nominal = ctx.node_at_offset::<ast::NominalDef>()?;

View file

@ -1,9 +1,12 @@
use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}}; use crate::{
ast_editor::{AstBuilder, AstEditor},
Assist, AssistCtx, AssistId,
};
use hir::{HasSource, db::HirDatabase}; use hir::{db::HirDatabase, HasSource};
use ra_syntax::{SmolStr, TreeArc};
use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner};
use ra_db::FilePosition; use ra_db::FilePosition;
use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner};
use ra_syntax::{SmolStr, TreeArc};
#[derive(PartialEq)] #[derive(PartialEq)]
enum AddMissingImplMembersMode { enum AddMissingImplMembersMode {

View file

@ -1,13 +1,13 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_text_edit::TextEditBuilder;
use ra_db::FileRange; use ra_db::FileRange;
use ra_syntax::{
SourceFile, TextRange, AstNode, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken,
algo::{find_token_at_offset, find_node_at_offset, find_covering_element, TokenAtOffset},
};
use ra_fmt::{leading_indent, reindent}; use ra_fmt::{leading_indent, reindent};
use ra_syntax::{
algo::{find_covering_element, find_node_at_offset, find_token_at_offset, TokenAtOffset},
AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit,
};
use ra_text_edit::TextEditBuilder;
use crate::{AssistLabel, AssistAction, AssistId}; use crate::{AssistAction, AssistId, AssistLabel};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub(crate) enum Assist { pub(crate) enum Assist {

View file

@ -1,10 +1,12 @@
use std::{iter, ops::RangeInclusive}; use std::{iter, ops::RangeInclusive};
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use ra_text_edit::TextEditBuilder;
use ra_syntax::{AstNode, TreeArc, ast, SyntaxKind::*, SyntaxElement, SourceFile, InsertPosition, Direction, T};
use ra_fmt::leading_indent;
use hir::Name; use hir::Name;
use ra_fmt::leading_indent;
use ra_syntax::{
ast, AstNode, Direction, InsertPosition, SourceFile, SyntaxElement, SyntaxKind::*, TreeArc, T,
};
use ra_text_edit::TextEditBuilder;
pub struct AstEditor<N: AstNode> { pub struct AstEditor<N: AstNode> {
original_ast: TreeArc<N>, original_ast: TreeArc<N>,
@ -283,7 +285,7 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> {
mod tokens { mod tokens {
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*, T}; use ra_syntax::{AstNode, SourceFile, SyntaxKind::*, SyntaxToken, TreeArc, T};
static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;").tree); static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;").tree);

View file

@ -1,14 +1,15 @@
use hir::{self, db::HirDatabase};
use ra_text_edit::TextEditBuilder; use ra_text_edit::TextEditBuilder;
use hir::{ self, db::HirDatabase};
use ra_syntax::{
T,
ast::{ self, NameOwner }, AstNode, SyntaxNode, Direction, TextRange, SmolStr,
SyntaxKind::{ PATH, PATH_SEGMENT }
};
use crate::{ use crate::{
assist_ctx::{Assist, AssistCtx},
AssistId, AssistId,
assist_ctx::{AssistCtx, Assist}, };
use ra_syntax::{
ast::{self, NameOwner},
AstNode, Direction, SmolStr,
SyntaxKind::{PATH, PATH_SEGMENT},
SyntaxNode, TextRange, T,
}; };
fn collect_path_segments_raw<'a>( fn collect_path_segments_raw<'a>(
@ -577,7 +578,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::helpers::{ check_assist, check_assist_not_applicable }; use crate::helpers::{check_assist, check_assist_not_applicable};
#[test] #[test]
fn test_auto_import_add_use_no_anchor() { fn test_auto_import_add_use_no_anchor() {

View file

@ -1,12 +1,15 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{
T, ast::{self, NameOwner, VisibilityOwner},
AstNode, SyntaxNode, TextUnit, AstNode,
ast::{self, VisibilityOwner, NameOwner}, SyntaxKind::{
SyntaxKind::{VISIBILITY, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF, IDENT, WHITESPACE, COMMENT, ATTR}, ATTR, COMMENT, ENUM_DEF, FN_DEF, IDENT, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
WHITESPACE,
},
SyntaxNode, TextUnit, T,
}; };
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() { if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() {

View file

@ -1,13 +1,10 @@
use std::fmt::Write;
use itertools::Itertools; use itertools::Itertools;
use std::fmt::Write;
use hir::{ use hir::{db::HirDatabase, AdtDef, FieldSource, HasSource};
AdtDef, FieldSource, HasSource,
db::HirDatabase,
};
use ra_syntax::ast::{self, AstNode}; use ra_syntax::ast::{self, AstNode};
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
fn is_trivial_arm(arm: &ast::MatchArm) -> bool { fn is_trivial_arm(arm: &ast::MatchArm) -> bool {
fn single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> { fn single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> {

View file

@ -1,7 +1,7 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::ast::{AstNode, BinExpr, BinOp}; use ra_syntax::ast::{AstNode, BinExpr, BinOp};
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
/// Flip binary expression assist. /// Flip binary expression assist.
pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
@ -68,7 +68,7 @@ impl From<BinOp> for FlipAction {
mod tests { mod tests {
use super::*; use super::*;
use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
#[test] #[test]
fn flip_binexpr_target_is_the_op() { fn flip_binexpr_target_is_the_op() {

View file

@ -1,11 +1,7 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{algo::non_trivia_sibling, Direction, T};
T,
Direction,
algo::non_trivia_sibling,
};
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?; let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?;

View file

@ -1,11 +1,11 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{
ast::{self, AstNode, AstToken, PatKind, ExprKind}, ast::{self, AstNode, AstToken, ExprKind, PatKind},
TextRange, TextRange,
}; };
use crate::{Assist, AssistCtx, AssistId};
use crate::assist_ctx::AssistBuilder; use crate::assist_ctx::AssistBuilder;
use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?;

View file

@ -1,12 +1,14 @@
use test_utils::tested_by;
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{
ast::{self, AstNode}, ast::{self, AstNode},
SyntaxKind::{
BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, WHITESPACE,
},
SyntaxNode, TextUnit, SyntaxNode, TextUnit,
SyntaxKind::{WHITESPACE, MATCH_ARM, LAMBDA_EXPR, PATH_EXPR, BREAK_EXPR, LOOP_EXPR, RETURN_EXPR, COMMENT},
}; };
use test_utils::tested_by;
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
if ctx.frange.range.is_empty() { if ctx.frange.range.is_empty() {
@ -121,7 +123,9 @@ fn anchor_stmt(expr: &ast::Expr) -> Option<(&SyntaxNode, bool)> {
mod tests { mod tests {
use test_utils::covers; use test_utils::covers;
use crate::helpers::{check_assist_range_not_applicable, check_assist_range, check_assist_range_target}; use crate::helpers::{
check_assist_range, check_assist_range_not_applicable, check_assist_range_target,
};
use super::*; use super::*;

View file

@ -11,12 +11,12 @@ pub mod ast_editor;
use itertools::Itertools; use itertools::Itertools;
use ra_text_edit::TextEdit;
use ra_syntax::{TextRange, TextUnit};
use ra_db::FileRange;
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_db::FileRange;
use ra_syntax::{TextRange, TextUnit};
use ra_text_edit::TextEdit;
pub(crate) use crate::assist_ctx::{AssistCtx, Assist}; pub(crate) use crate::assist_ctx::{Assist, AssistCtx};
/// Unique identifier of the assist, should not be shown to the user /// Unique identifier of the assist, should not be shown to the user
/// directly. /// directly.
@ -127,11 +127,11 @@ fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assis
#[cfg(test)] #[cfg(test)]
mod helpers { mod helpers {
use hir::mock::MockDatabase; use hir::mock::MockDatabase;
use ra_syntax::TextRange;
use ra_db::FileRange; use ra_db::FileRange;
use test_utils::{extract_offset, extract_range, assert_eq_text, add_cursor}; use ra_syntax::TextRange;
use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range};
use crate::{AssistCtx, Assist}; use crate::{Assist, AssistCtx};
pub(crate) fn check_assist( pub(crate) fn check_assist(
assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>, assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>,
@ -289,8 +289,8 @@ mod helpers {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use hir::mock::MockDatabase; use hir::mock::MockDatabase;
use ra_syntax::TextRange;
use ra_db::FileRange; use ra_db::FileRange;
use ra_syntax::TextRange;
use test_utils::{extract_offset, extract_range}; use test_utils::{extract_offset, extract_range};
#[test] #[test]

View file

@ -1,12 +1,11 @@
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{
TextUnit,
SyntaxElement,
ast::{MatchArm, AstNode, AstToken, IfExpr},
ast, ast,
ast::{AstNode, AstToken, IfExpr, MatchArm},
SyntaxElement, TextUnit,
}; };
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let match_arm = ctx.node_at_offset::<MatchArm>()?; let match_arm = ctx.node_at_offset::<MatchArm>()?;
@ -84,7 +83,7 @@ pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx<impl HirDatabase>)
mod tests { mod tests {
use super::*; use super::*;
use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
#[test] #[test]
fn move_guard_to_arm_body_target() { fn move_guard_to_arm_body_target() {

View file

@ -1,10 +1,9 @@
use crate::{Assist, AssistCtx, AssistId};
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{
ast::{self, AstNode}, ast::{self, AstNode},
TextUnit, TextUnit, T,
T
}; };
use crate::{AssistCtx, Assist, AssistId};
pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; let macro_call = ctx.node_at_offset::<ast::MacroCall>()?;

View file

@ -1,8 +1,8 @@
use ra_syntax::{AstNode, ast};
use ra_fmt::extract_trivial_expression;
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_fmt::extract_trivial_expression;
use ra_syntax::{ast, AstNode};
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let if_expr: &ast::IfExpr = ctx.node_at_offset()?; let if_expr: &ast::IfExpr = ctx.node_at_offset()?;

View file

@ -1,13 +1,9 @@
use std::iter::successors; use std::iter::successors;
use hir::db::HirDatabase; use hir::db::HirDatabase;
use ra_syntax::{ use ra_syntax::{ast, AstNode, TextUnit, T};
T,
TextUnit, AstNode,
ast,
};
use crate::{AssistCtx, Assist, AssistId}; use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?; let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?;

View file

@ -1,14 +1,12 @@
mod vfs_filter; mod vfs_filter;
use std::{path::Path, collections::HashSet, error::Error}; use std::{collections::HashSet, error::Error, path::Path};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use ra_db::{ use ra_db::{CrateGraph, FileId, SourceRootId};
CrateGraph, FileId, SourceRootId, use ra_ide_api::{AnalysisChange, AnalysisHost};
}; use ra_project_model::{ProjectRoot, ProjectWorkspace};
use ra_ide_api::{AnalysisHost, AnalysisChange};
use ra_project_model::{ProjectWorkspace, ProjectRoot};
use ra_vfs::{Vfs, VfsChange}; use ra_vfs::{Vfs, VfsChange};
use vfs_filter::IncludeRustFiles; use vfs_filter::IncludeRustFiles;
@ -106,8 +104,8 @@ pub fn load(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use ra_hir::Crate;
use super::*; use super::*;
use ra_hir::Crate;
#[test] #[test]
fn test_loading_rust_analyzer() { fn test_loading_rust_analyzer() {

View file

@ -1,6 +1,6 @@
use std::path::PathBuf;
use ra_project_model::ProjectRoot; use ra_project_model::ProjectRoot;
use ra_vfs::{RootEntry, Filter, RelativePath}; use ra_vfs::{Filter, RelativePath, RootEntry};
use std::path::PathBuf;
/// `IncludeRustFiles` is used to convert /// `IncludeRustFiles` is used to convert
/// from `ProjectRoot` to `RootEntry` for VFS /// from `ProjectRoot` to `RootEntry` for VFS

View file

@ -1,10 +1,10 @@
use std::{ use std::{
path::{PathBuf, Path}, path::{Path, PathBuf},
time::Instant, time::Instant,
}; };
use ra_db::{SourceDatabase, salsa::Database}; use ra_db::{salsa::Database, SourceDatabase};
use ra_ide_api::{AnalysisHost, Analysis, LineCol, FilePosition}; use ra_ide_api::{Analysis, AnalysisHost, FilePosition, LineCol};
use crate::Result; use crate::Result;

View file

@ -1,7 +1,7 @@
use std::{collections::HashSet, time::Instant, fmt::Write, path::Path}; use std::{collections::HashSet, fmt::Write, path::Path, time::Instant};
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use ra_hir::{Crate, ModuleDef, Ty, ImplItem, HasSource}; use ra_hir::{Crate, HasSource, ImplItem, ModuleDef, Ty};
use ra_syntax::AstNode; use ra_syntax::AstNode;
use crate::Result; use crate::Result;

View file

@ -1,13 +1,13 @@
mod analysis_stats; mod analysis_stats;
mod analysis_bench; mod analysis_bench;
use std::{io::Read, error::Error}; use std::{error::Error, io::Read};
use clap::{App, Arg, SubCommand}; use clap::{App, Arg, SubCommand};
use ra_ide_api::{file_structure, Analysis};
use ra_syntax::{SourceFile, TreeArc, AstNode};
use flexi_logger::Logger; use flexi_logger::Logger;
use ra_ide_api::{file_structure, Analysis};
use ra_prof::profile; use ra_prof::profile;
use ra_syntax::{AstNode, SourceFile, TreeArc};
type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;

View file

@ -197,7 +197,7 @@ impl CrateGraph {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{CrateGraph, FileId, SmolStr, Edition::Edition2018}; use super::{CrateGraph, Edition::Edition2018, FileId, SmolStr};
#[test] #[test]
fn it_should_panic_because_of_cycle_dependencies() { fn it_should_panic_because_of_cycle_dependencies() {

View file

@ -4,17 +4,15 @@ mod input;
use std::{panic, sync::Arc}; use std::{panic, sync::Arc};
use ra_syntax::{TextUnit, TextRange, SourceFile, Parse};
use relative_path::RelativePathBuf;
use ra_prof::profile; use ra_prof::profile;
use ra_syntax::{Parse, SourceFile, TextRange, TextUnit};
use relative_path::RelativePathBuf;
pub use ::salsa as salsa;
pub use crate::{ pub use crate::{
cancellation::Canceled, cancellation::Canceled,
input::{ input::{CrateGraph, CrateId, Dependency, Edition, FileId, SourceRoot, SourceRootId},
FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, Dependency, Edition,
},
}; };
pub use ::salsa;
pub trait CheckCanceled { pub trait CheckCanceled {
/// Aborts current query if there are pending changes. /// Aborts current query if there are pending changes.

View file

@ -1,11 +1,13 @@
//! This crate provides some utilities for indenting rust code. //! This crate provides some utilities for indenting rust code.
//! //!
use std::iter::successors;
use itertools::Itertools; use itertools::Itertools;
use ra_syntax::{ use ra_syntax::{
SyntaxNode, SyntaxKind::*, SyntaxToken, SyntaxKind, T,
ast::{self, AstNode, AstToken}, ast::{self, AstNode, AstToken},
SyntaxKind,
SyntaxKind::*,
SyntaxNode, SyntaxToken, T,
}; };
use std::iter::successors;
pub fn reindent(text: &str, indent: &str) -> String { pub fn reindent(text: &str, indent: &str) -> String {
let indent = format!("\n{}", indent); let indent = format!("\n{}", indent);

View file

@ -3,16 +3,15 @@
use std::sync::Arc; use std::sync::Arc;
use ra_arena::{RawId, Arena, impl_arena_id}; use ra_arena::{impl_arena_id, Arena, RawId};
use ra_syntax::{ use ra_syntax::{
ast::{self, NameOwner, StructKind, TypeAscriptionOwner},
TreeArc, TreeArc,
ast::{self, NameOwner, StructKind, TypeAscriptionOwner}
}; };
use crate::{ use crate::{
Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase, type_ref::TypeRef, AsName, AstDatabase, Crate, DefDatabase, Enum, EnumVariant, FieldSource,
HirDatabase, StructField, FieldSource, Source, HasSource, HasSource, HirDatabase, Name, Source, Struct, StructField, Union,
type_ref::TypeRef, DefDatabase,
}; };
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View file

@ -3,24 +3,32 @@ pub(crate) mod docs;
use std::sync::Arc; use std::sync::Arc;
use ra_db::{CrateId, SourceRootId, Edition, FileId}; use ra_db::{CrateId, Edition, FileId, SourceRootId};
use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc}; use ra_syntax::{
ast::{self, NameOwner, TypeAscriptionOwner},
TreeArc,
};
use crate::{ use crate::{
Name, AsName, AstId, Ty, Either, KnownName, HasSource,
HirDatabase, DefDatabase, AstDatabase,
type_ref::TypeRef,
nameres::{ModuleScope, Namespace, ImportId, CrateModuleId},
expr::{Body, BodySourceMap, validation::ExprValidator},
ty::{TraitRef, InferenceResult, primitive::{IntTy, FloatTy, Signedness, IntBitness, FloatBitness}},
adt::{EnumVariantId, StructFieldId, VariantDef}, adt::{EnumVariantId, StructFieldId, VariantDef},
diagnostics::DiagnosticSink,
expr::{validation::ExprValidator, Body, BodySourceMap},
generics::HasGenericParams, generics::HasGenericParams,
ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeAliasId, MacroDefId}, ids::{
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
TypeAliasId,
},
impl_block::ImplBlock, impl_block::ImplBlock,
nameres::{CrateModuleId, ImportId, ModuleScope, Namespace},
resolve::Resolver, resolve::Resolver,
diagnostics::{DiagnosticSink}, traits::{TraitData, TraitItem},
traits::{TraitItem, TraitData}, ty::{
primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness},
InferenceResult, TraitRef,
},
type_ref::Mutability, type_ref::Mutability,
type_ref::TypeRef,
AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, KnownName, Name, Ty,
}; };
/// hir::Crate describes a single crate. It's the main interface with which /// hir::Crate describes a single crate. It's the main interface with which

View file

@ -3,8 +3,8 @@ use std::sync::Arc;
use ra_syntax::ast; use ra_syntax::ast;
use crate::{ use crate::{
HirDatabase, DefDatabase, AstDatabase, HasSource, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource,
Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef, HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union,
}; };
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View file

@ -1,9 +1,9 @@
use ra_syntax::{TreeArc, ast}; use ra_syntax::{ast, TreeArc};
use crate::{ use crate::{
HirFileId, DefDatabase, AstDatabase, Module, ModuleSource, ids::AstItemDef, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function,
StructField, Struct, Enum, Union, EnumVariant, Function, Static, Trait, Const, TypeAlias, HirFileId, MacroDef, Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias,
FieldSource, MacroDef, ids::AstItemDef, Union,
}; };
pub struct Source<T> { pub struct Source<T> {

View file

@ -1,23 +1,25 @@
use std::sync::Arc; use std::sync::Arc;
use parking_lot::Mutex; use parking_lot::Mutex;
use ra_syntax::{SyntaxNode, TreeArc, SmolStr, ast}; use ra_db::{salsa, SourceDatabase};
use ra_db::{SourceDatabase, salsa}; use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc};
use crate::{ use crate::{
HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc, adt::{EnumData, StructData},
Function, FnData, ExprScopes, TypeAlias, generics::{GenericDef, GenericParams},
Struct, Enum, StructField,
Const, ConstData, Static,
DefWithBody, Trait,
ids, ids,
nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap}, impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks},
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, CallableDef, FnSig, TypeCtor, GenericPredicate, Substs}, lang_item::{LangItemTarget, LangItems},
adt::{StructData, EnumData}, nameres::{CrateDefMap, ImportSourceMap, Namespace, RawItems},
impl_block::{ModuleImplBlocks, ImplSourceMap, ImplBlock},
generics::{GenericParams, GenericDef},
traits::TraitData, traits::TraitData,
lang_item::{LangItems, LangItemTarget}, type_alias::TypeAliasData, ty::{
method_resolution::CrateImplBlocks, CallableDef, FnSig, GenericPredicate, InferenceResult,
Substs, Ty, TypableDef, TypeCtor,
},
type_alias::TypeAliasData,
AstIdMap, Const, ConstData, Crate, DefWithBody, Enum, ErasedFileAstId, ExprScopes, FnData,
Function, HirFileId, MacroCallLoc, MacroDefId, Module, Static, Struct, StructField, Trait,
TypeAlias,
}; };
/// We store all interned things in the single QueryGroup. /// We store all interned things in the single QueryGroup.

View file

@ -1,9 +1,9 @@
use std::{fmt, any::Any}; use std::{any::Any, fmt};
use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode}; use ra_syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange, TreeArc};
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use crate::{HirFileId, HirDatabase, Name}; use crate::{HirDatabase, HirFileId, Name};
/// Diagnostic defines hir API for errors and warnings. /// Diagnostic defines hir API for errors and warnings.
/// ///

View file

@ -3,19 +3,25 @@ use std::sync::Arc;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
use ra_syntax::{ use ra_syntax::{
SyntaxNodePtr, AstPtr, AstNode, ast::{
ast::{self, TryBlockBodyOwner, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner}, self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner,
TryBlockBodyOwner, TypeAscriptionOwner,
},
AstNode, AstPtr, SyntaxNodePtr,
}; };
use crate::{ use crate::{
Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
HasSource,
name::AsName, name::AsName,
type_ref::{Mutability, TypeRef}, type_ref::{Mutability, TypeRef},
DefWithBody, Either, HasSource, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Name,
Path, Resolver,
};
use crate::{
path::GenericArgs,
ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
}; };
use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
pub use self::scope::ExprScopes; pub use self::scope::ExprScopes;
@ -249,8 +255,8 @@ pub enum Expr {
Literal(Literal), Literal(Literal),
} }
pub use ra_syntax::ast::PrefixOp as UnaryOp;
pub use ra_syntax::ast::BinOp as BinaryOp; pub use ra_syntax::ast::BinOp as BinaryOp;
pub use ra_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>),

View file

@ -1,12 +1,11 @@
use std::sync::Arc; use std::sync::Arc;
use ra_arena::{impl_arena_id, Arena, RawId};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use ra_arena::{Arena, RawId, impl_arena_id};
use crate::{ use crate::{
Name, DefWithBody, expr::{Body, Expr, ExprId, Pat, PatId, Statement},
expr::{PatId, ExprId, Pat, Expr, Body, Statement}, DefWithBody, HirDatabase, Name,
HirDatabase,
}; };
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
@ -173,10 +172,10 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use ra_syntax::{algo::find_node_at_offset, AstNode, SyntaxNodePtr, ast}; use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNodePtr};
use test_utils::{extract_offset, assert_eq_text}; use test_utils::{assert_eq_text, extract_offset};
use crate::{source_binder::SourceAnalyzer, mock::MockDatabase}; use crate::{mock::MockDatabase, source_binder::SourceAnalyzer};
fn do_check(code: &str, expected: &[&str]) { fn do_check(code: &str, expected: &[&str]) {
let (off, code) = extract_offset(code); let (off, code) = extract_offset(code);

View file

@ -1,17 +1,16 @@
use std::sync::Arc;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use std::sync::Arc;
use ra_syntax::ast::{AstNode, StructLit}; use ra_syntax::ast::{AstNode, StructLit};
use super::{Expr, ExprId, StructLitField};
use crate::{ use crate::{
expr::AstPtr,
HirDatabase, Function, Name, HasSource,
diagnostics::{DiagnosticSink, MissingFields},
adt::AdtDef, adt::AdtDef,
Path, diagnostics::{DiagnosticSink, MissingFields},
expr::AstPtr,
ty::InferenceResult, ty::InferenceResult,
Function, HasSource, HirDatabase, Name, Path,
}; };
use super::{Expr, StructLitField, ExprId};
pub(crate) struct ExprValidator<'a, 'b: 'a> { pub(crate) struct ExprValidator<'a, 'b: 'a> {
func: Function, func: Function,

View file

@ -5,13 +5,14 @@
use std::sync::Arc; use std::sync::Arc;
use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner}; use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner};
use crate::{ use crate::{
HasSource, db::{AstDatabase, DefDatabase, HirDatabase},
Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef, path::Path,
db::{HirDatabase, DefDatabase, AstDatabase}, type_ref::TypeRef,
path::Path, type_ref::TypeRef, AdtDef, AsName, Container, Enum, Function, HasSource, ImplBlock, Name, Struct, Trait,
TypeAlias, Union,
}; };
/// Data about a generic parameter (to a function, struct, impl, ...). /// Data about a generic parameter (to a function, struct, impl, ...).

View file

@ -3,14 +3,12 @@ use std::{
sync::Arc, sync::Arc,
}; };
use ra_db::{FileId, salsa};
use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode};
use ra_prof::profile;
use mbe::MacroRules; use mbe::MacroRules;
use ra_db::{salsa, FileId};
use ra_prof::profile;
use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc};
use crate::{ use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source};
Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, InternDatabase,
};
/// hir makes heavy use of ids: integer (u32) handlers to various things. You /// hir makes heavy use of ids: integer (u32) handlers to various things. You
/// can think of id as a pointer (but without a lifetime) or a file descriptor /// can think of id as a pointer (but without a lifetime) or a file descriptor

View file

@ -1,21 +1,21 @@
use std::sync::Arc;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use std::sync::Arc;
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
use ra_syntax::{ use ra_syntax::{
ast::{self, AstNode},
AstPtr, SourceFile, TreeArc, AstPtr, SourceFile, TreeArc,
ast::{self, AstNode}
}; };
use crate::{ use crate::{
Const, TypeAlias, Function, HirFileId, AstDatabase, HasSource, Source, code_model::{Module, ModuleSource},
HirDatabase, DefDatabase, TraitRef, generics::HasGenericParams,
type_ref::TypeRef,
ids::LocationCtx, ids::LocationCtx,
resolve::Resolver, resolve::Resolver,
ty::Ty, ty::Ty,
generics::HasGenericParams, type_ref::TypeRef,
code_model::{Module, ModuleSource} AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef,
TypeAlias,
}; };
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, Default, PartialEq, Eq)]

View file

@ -1,11 +1,11 @@
use std::sync::Arc;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use std::sync::Arc;
use ra_syntax::{SmolStr, TreeArc, ast::AttrsOwner}; use ra_syntax::{ast::AttrsOwner, SmolStr, TreeArc};
use crate::{ use crate::{
Crate, DefDatabase, Enum, Function, HirDatabase, ImplBlock, Module, AstDatabase, Crate, DefDatabase, Enum, Function, HasSource, HirDatabase, ImplBlock, Module,
Static, Struct, Trait, ModuleDef, AstDatabase, HasSource ModuleDef, Static, Struct, Trait,
}; };
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

View file

@ -47,39 +47,33 @@ mod code_model;
mod marks; mod marks;
use crate::{ use crate::{
db::{InternDatabase, AstDatabase, DefDatabase, HirDatabase}, db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase},
name::{AsName, KnownName},
source_id::{FileAstId, AstId},
resolve::Resolver,
ids::MacroFileKind, ids::MacroFileKind,
name::{AsName, KnownName},
resolve::Resolver,
source_id::{AstId, FileAstId},
}; };
pub use self::{ pub use self::{
either::Either,
path::{Path, PathKind},
name::Name,
source_id::{AstIdMap, ErasedFileAstId},
ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc, MacroFile},
nameres::{PerNs, Namespace, ImportId},
ty::{Ty, ApplicationTy, TypeCtor, TraitRef, Substs, display::HirDisplay, CallableDef},
impl_block::{ImplBlock, ImplItem},
adt::AdtDef, adt::AdtDef,
either::Either,
expr::ExprScopes, expr::ExprScopes,
generics::{GenericParam, GenericParams, HasGenericParams},
ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile},
impl_block::{ImplBlock, ImplItem},
name::Name,
nameres::{ImportId, Namespace, PerNs},
path::{Path, PathKind},
resolve::Resolution, resolve::Resolution,
generics::{GenericParams, GenericParam, HasGenericParams}, source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer},
source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax}, source_id::{AstIdMap, ErasedFileAstId},
ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor},
}; };
pub use self::code_model::{ pub use self::code_model::{
Crate, CrateDependency, docs::{DocDef, Docs, Documentation},
DefWithBody, src::{HasSource, Source},
Module, ModuleDef, ModuleSource, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
Struct, Union, Enum, EnumVariant, EnumVariant, FieldSource, FnData, Function, MacroDef, Module, ModuleDef, ModuleSource, Static,
Function, FnData, Struct, StructField, Trait, TypeAlias, Union,
StructField, FieldSource,
Static, Const, ConstData,
Trait, TypeAlias, MacroDef, Container,
BuiltinType,
src::{Source, HasSource},
docs::{Docs, Documentation, DocDef},
}; };

View file

@ -1,13 +1,12 @@
use std::{sync::Arc, panic}; use std::{panic, sync::Arc};
use parking_lot::Mutex; use parking_lot::Mutex;
use ra_db::{ use ra_db::{
FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, SourceDatabase, salsa, salsa, CrateGraph, Edition, FileId, FilePosition, SourceDatabase, SourceRoot, SourceRootId,
Edition,
}; };
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER};
use crate::{db, diagnostics::DiagnosticSink}; use crate::{db, diagnostics::DiagnosticSink};

View file

@ -55,28 +55,24 @@ mod tests;
use std::sync::Arc; use std::sync::Arc;
use rustc_hash::{FxHashMap, FxHashSet};
use ra_arena::{Arena, RawId, impl_arena_id};
use ra_db::{FileId, Edition};
use test_utils::tested_by;
use ra_syntax::ast;
use ra_prof::profile;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use ra_arena::{impl_arena_id, Arena, RawId};
use ra_db::{Edition, FileId};
use ra_prof::profile;
use ra_syntax::ast;
use rustc_hash::{FxHashMap, FxHashSet};
use test_utils::tested_by;
use crate::{ use crate::{
ModuleDef, Name, Crate, Module, MacroDef, AsName, BuiltinType, AstDatabase, diagnostics::DiagnosticSink, either::Either, ids::MacroDefId,
DefDatabase, Path, PathKind, HirFileId, Trait, nameres::diagnostics::DefDiagnostic, AsName, AstDatabase, AstId, BuiltinType, Crate,
ids::MacroDefId, DefDatabase, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
diagnostics::DiagnosticSink,
nameres::diagnostics::DefDiagnostic,
either::Either,
AstId,
}; };
pub(crate) use self::raw::{RawItems, ImportSourceMap}; pub(crate) use self::raw::{ImportSourceMap, RawItems};
pub use self::{ pub use self::{
per_ns::{PerNs, Namespace}, per_ns::{Namespace, PerNs},
raw::ImportId, raw::ImportId,
}; };
@ -512,14 +508,14 @@ impl CrateDefMap {
} }
mod diagnostics { mod diagnostics {
use ra_syntax::{ast, AstPtr};
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use ra_syntax::{AstPtr, ast};
use crate::{ use crate::{
AstId, DefDatabase, AstDatabase, diagnostics::{DiagnosticSink, UnresolvedModule},
nameres::CrateModuleId, nameres::CrateModuleId,
diagnostics::{DiagnosticSink, UnresolvedModule} AstDatabase, AstId, DefDatabase,
}; };
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub(super) enum DefDiagnostic { pub(super) enum DefDiagnostic {

View file

@ -1,22 +1,19 @@
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use rustc_hash::FxHashMap;
use relative_path::RelativePathBuf;
use test_utils::tested_by;
use ra_db::FileId; use ra_db::FileId;
use ra_syntax::ast; use ra_syntax::ast;
use relative_path::RelativePathBuf;
use rustc_hash::FxHashMap;
use test_utils::tested_by;
use crate::{ use crate::{
Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef,
DefDatabase, HirFileId, Name, Path,
KnownName, AstId,
nameres::{
Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode,
CrateDefMap, CrateModuleId, ModuleData, ItemOrMacro,
diagnostics::DefDiagnostic,
raw,
},
ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId, MacroFileKind},
either::Either, either::Either,
ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind},
nameres::{
diagnostics::DefDiagnostic, raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData,
ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode,
},
AstId, Const, DefDatabase, Enum, Function, HirFileId, KnownName, MacroDef, Module, Name, Path,
Static, Struct, Trait, TypeAlias, Union,
}; };
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
@ -666,9 +663,9 @@ fn resolve_submodule(
mod tests { mod tests {
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use crate::{Crate, mock::MockDatabase, DefDatabase};
use ra_arena::{Arena};
use super::*; use super::*;
use crate::{mock::MockDatabase, Crate, DefDatabase};
use ra_arena::Arena;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
fn do_collect_defs( fn do_collect_defs(

View file

@ -1,13 +1,16 @@
use std::{sync::Arc, ops::Index}; use std::{ops::Index, sync::Arc};
use test_utils::tested_by; use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
use ra_arena::{Arena, impl_arena_id, RawId, map::ArenaMap};
use ra_syntax::{ use ra_syntax::{
AstNode, SourceFile, AstPtr, TreeArc, ast::{self, AttrsOwner, NameOwner},
ast::{self, NameOwner, AttrsOwner}, AstNode, AstPtr, SourceFile, TreeArc,
}; };
use test_utils::tested_by;
use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either, AstDatabase}; use crate::{
AsName, AstDatabase, AstIdMap, DefDatabase, Either, FileAstId, HirFileId, ModuleSource, Name,
Path,
};
/// `RawItems` is a set of top-level items in a file (except for impls). /// `RawItems` is a set of top-level items in a file (except for impls).
/// ///

View file

@ -5,14 +5,14 @@ mod primitives;
use std::sync::Arc; use std::sync::Arc;
use insta::assert_snapshot_matches;
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use test_utils::covers; use test_utils::covers;
use insta::assert_snapshot_matches;
use crate::{ use crate::{
Crate, Either, mock::{CrateGraphFixture, MockDatabase},
mock::{MockDatabase, CrateGraphFixture},
nameres::Resolution, nameres::Resolution,
Crate, Either,
}; };
use super::*; use super::*;

View file

@ -1,8 +1,11 @@
use std::sync::Arc; use std::sync::Arc;
use ra_syntax::{ast::{self, NameOwner}, AstNode}; use ra_syntax::{
ast::{self, NameOwner},
AstNode,
};
use crate::{Name, AsName, type_ref::TypeRef}; use crate::{type_ref::TypeRef, AsName, Name};
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Path { pub struct Path {

View file

@ -4,16 +4,19 @@ use std::sync::Arc;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use crate::{ use crate::{
ModuleDef, Trait, MacroDef,
code_model::Crate, code_model::Crate,
db::HirDatabase, db::HirDatabase,
name::{Name, KnownName},
nameres::{PerNs, CrateDefMap, CrateModuleId},
generics::GenericParams,
expr::{scope::{ExprScopes, ScopeId}, PatId},
impl_block::ImplBlock,
path::Path,
either::Either, either::Either,
expr::{
scope::{ExprScopes, ScopeId},
PatId,
},
generics::GenericParams,
impl_block::ImplBlock,
name::{KnownName, Name},
nameres::{CrateDefMap, CrateModuleId, PerNs},
path::Path,
MacroDef, ModuleDef, Trait,
}; };
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]

View file

@ -7,21 +7,25 @@
/// purely for "IDE needs". /// purely for "IDE needs".
use std::sync::Arc; use std::sync::Arc;
use rustc_hash::{FxHashSet, FxHashMap};
use ra_db::{FileId, FilePosition}; use ra_db::{FileId, FilePosition};
use ra_syntax::{ use ra_syntax::{
SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange,
ast::{self, AstNode, NameOwner},
algo::find_node_at_offset, algo::find_node_at_offset,
ast::{self, AstNode, NameOwner},
AstPtr,
SyntaxKind::*, SyntaxKind::*,
SyntaxNode, SyntaxNodePtr, TextRange, TextUnit,
}; };
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{ use crate::{
HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, expr,
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, Path, MacroDef, expr::{
expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, scope::{ExprScopes, ScopeId},
BodySourceMap,
},
ids::LocationCtx, ids::LocationCtx,
expr, AstId, AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId,
MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty,
}; };
/// Locates the module by `FileId`. Picks topmost module in the file. /// Locates the module by `FileId`. Picks topmost module in the file.

View file

@ -1,9 +1,13 @@
use std::{marker::PhantomData, sync::Arc, hash::{Hash, Hasher}}; use std::{
hash::{Hash, Hasher},
marker::PhantomData,
sync::Arc,
};
use ra_arena::{Arena, RawId, impl_arena_id}; use ra_arena::{impl_arena_id, Arena, RawId};
use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast}; use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr, TreeArc};
use crate::{HirFileId, AstDatabase}; use crate::{AstDatabase, HirFileId};
/// `AstId` points to an AST node in any file. /// `AstId` points to an AST node in any file.
/// ///

View file

@ -1,13 +1,13 @@
//! HIR for trait definitions. //! HIR for trait definitions.
use std::sync::Arc;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use std::sync::Arc;
use ra_syntax::ast::{self, NameOwner}; use ra_syntax::ast::{self, NameOwner};
use crate::{ use crate::{
Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource, ids::LocationCtx, name::AsName, AstDatabase, Const, DefDatabase, Function, HasSource, Module,
ids::LocationCtx, name::AsName, Name, Trait, TypeAlias,
}; };
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -12,17 +12,20 @@ mod lower;
mod infer; mod infer;
pub(crate) mod display; pub(crate) mod display;
use std::sync::Arc;
use std::ops::Deref; use std::ops::Deref;
use std::sync::Arc;
use std::{fmt, mem}; use std::{fmt, mem};
use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait, GenericParams, TypeAlias}; use crate::{db::HirDatabase, type_ref::Mutability, AdtDef, GenericParams, Name, Trait, TypeAlias};
use display::{HirDisplay, HirFormatter}; use display::{HirDisplay, HirFormatter};
pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults};
pub(crate) use infer::{infer_query, InferenceResult, InferTy};
pub use lower::CallableDef;
pub(crate) use autoderef::autoderef; pub(crate) use autoderef::autoderef;
pub(crate) use infer::{infer_query, InferTy, InferenceResult};
pub use lower::CallableDef;
pub(crate) use lower::{
callable_item_sig, generic_defaults, generic_predicates, type_for_def, type_for_field,
TypableDef,
};
pub(crate) use traits::ProjectionPredicate; pub(crate) use traits::ProjectionPredicate;
/// A type constructor or type name: this might be something like the primitive /// A type constructor or type name: this might be something like the primitive

View file

@ -7,8 +7,8 @@ use std::iter::successors;
use log::{info, warn}; use log::{info, warn};
use crate::{HirDatabase, Name, Resolver, HasGenericParams}; use super::{traits::Solution, Canonical, Ty};
use super::{traits::Solution, Ty, Canonical}; use crate::{HasGenericParams, HirDatabase, Name, Resolver};
const AUTODEREF_RECURSION_LIMIT: usize = 10; const AUTODEREF_RECURSION_LIMIT: usize = 10;

View file

@ -15,38 +15,37 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::iter::repeat; use std::iter::repeat;
use std::mem;
use std::ops::Index; use std::ops::Index;
use std::sync::Arc; use std::sync::Arc;
use std::mem;
use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use ra_arena::map::ArenaMap; use ra_arena::map::ArenaMap;
use ra_prof::profile; use ra_prof::profile;
use test_utils::tested_by; use test_utils::tested_by;
use super::{
autoderef, method_resolution, op, primitive,
traits::{Guidance, Obligation, Solution},
ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypableDef, TypeCtor,
};
use crate::{ use crate::{
Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase, adt::VariantDef,
DefWithBody, ImplItem, diagnostics::DiagnosticSink,
type_ref::{TypeRef, Mutability},
expr::{ expr::{
Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, FieldPat, Literal, Pat,
FieldPat, Array, self, PatId, Statement, UnaryOp,
}, },
generics::{GenericParams, HasGenericParams}, generics::{GenericParams, HasGenericParams},
path::{GenericArgs, GenericArg},
ModuleDef,
adt::VariantDef,
resolve::{Resolver, Resolution},
nameres::Namespace, nameres::Namespace,
path::{GenericArg, GenericArgs},
resolve::{Resolution, Resolver},
ty::infer::diagnostics::InferenceDiagnostic, ty::infer::diagnostics::InferenceDiagnostic,
diagnostics::DiagnosticSink, type_ref::{Mutability, TypeRef},
}; AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path,
use super::{ StructField,
Ty, TypableDef, Substs, primitive, op, ApplicationTy, TypeCtor, CallableDef, TraitRef,
traits::{Solution, Obligation, Guidance},
method_resolution, autoderef,
}; };
mod unify; mod unify;
@ -1415,10 +1414,10 @@ impl Expectation {
mod diagnostics { mod diagnostics {
use crate::{ use crate::{
expr::ExprId,
diagnostics::{DiagnosticSink, NoSuchField}, diagnostics::{DiagnosticSink, NoSuchField},
HirDatabase, Function, HasSource, expr::ExprId,
}; Function, HasSource, HirDatabase,
};
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub(super) enum InferenceDiagnostic { pub(super) enum InferenceDiagnostic {

View file

@ -1,8 +1,8 @@
//! Unification and canonicalization logic. //! Unification and canonicalization logic.
use crate::db::HirDatabase;
use crate::ty::{Ty, Canonical, TraitRef, InferTy};
use super::InferenceContext; use super::InferenceContext;
use crate::db::HirDatabase;
use crate::ty::{Canonical, InferTy, TraitRef, Ty};
impl<'a, D: HirDatabase> InferenceContext<'a, D> { impl<'a, D: HirDatabase> InferenceContext<'a, D> {
pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D>

View file

@ -5,23 +5,22 @@
//! - Building the type for an item: This happens through the `type_for_def` query. //! - Building the type for an item: This happens through the `type_for_def` query.
//! //!
//! This usually involves resolving names, collecting generic arguments etc. //! This usually involves resolving names, collecting generic arguments etc.
use std::sync::Arc;
use std::iter; use std::iter;
use std::sync::Arc;
use super::{FnSig, GenericPredicate, Substs, TraitRef, Ty, TypeCtor};
use crate::{ use crate::{
Function, Struct, Union, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static,
HirDatabase, BuiltinType,
type_ref::TypeRef,
nameres::Namespace,
resolve::{Resolver, Resolution},
path::{PathSegment, GenericArg},
generics::{HasGenericParams},
adt::VariantDef, adt::VariantDef,
Trait, generics::HasGenericParams,
generics::{WherePredicate, GenericDef}, generics::{GenericDef, WherePredicate},
nameres::Namespace,
path::{GenericArg, PathSegment},
resolve::{Resolution, Resolver},
ty::AdtDef, ty::AdtDef,
type_ref::TypeRef,
BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct,
StructField, Trait, TypeAlias, Union,
}; };
use super::{Ty, FnSig, Substs, TypeCtor, TraitRef, GenericPredicate};
impl Ty { impl Ty {
pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self {

View file

@ -7,17 +7,17 @@ use std::sync::Arc;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use super::{autoderef, Canonical, TraitRef};
use crate::{ use crate::{
HirDatabase, Module, Crate, Name, Function, Trait, generics::HasGenericParams,
impl_block::{ImplId, ImplBlock, ImplItem}, impl_block::{ImplBlock, ImplId, ImplItem},
ty::{Ty, TypeCtor},
nameres::CrateModuleId, nameres::CrateModuleId,
resolve::Resolver, resolve::Resolver,
traits::TraitItem, traits::TraitItem,
generics::HasGenericParams, ty::primitive::{UncertainFloatTy, UncertainIntTy},
ty::primitive::{UncertainIntTy, UncertainFloatTy} ty::{Ty, TypeCtor},
Crate, Function, HirDatabase, Module, Name, Trait,
}; };
use super::{TraitRef, Canonical, autoderef};
/// This is used as a key for indexing impls. /// This is used as a key for indexing impls.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

View file

@ -1,5 +1,5 @@
use crate::{ ty::ApplicationTy, expr::BinaryOp}; use super::{InferTy, Ty, TypeCtor};
use super::{Ty, TypeCtor, InferTy}; use crate::{expr::BinaryOp, ty::ApplicationTy};
pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
match op { match op {

View file

@ -1,17 +1,18 @@
use std::sync::Arc;
use std::fmt::Write; use std::fmt::Write;
use std::sync::Arc;
use insta::assert_snapshot_matches; use insta::assert_snapshot_matches;
use ra_db::{SourceDatabase, salsa::Database, FilePosition}; use ra_db::{salsa::Database, FilePosition, SourceDatabase};
use ra_syntax::{algo, ast::{self, AstNode}, SyntaxKind::*}; use ra_syntax::{
algo,
ast::{self, AstNode},
SyntaxKind::*,
};
use test_utils::covers; use test_utils::covers;
use crate::{ use crate::{
mock::MockDatabase, expr::BodySourceMap, mock::MockDatabase, ty::display::HirDisplay, ty::InferenceResult,
ty::display::HirDisplay,
ty::InferenceResult,
expr::BodySourceMap,
SourceAnalyzer, SourceAnalyzer,
}; };

View file

@ -1,16 +1,16 @@
//! Trait solving using Chalk. //! Trait solving using Chalk.
use std::sync::Arc; use std::sync::Arc;
use parking_lot::Mutex;
use rustc_hash::FxHashSet;
use log::debug;
use chalk_ir::cast::Cast; use chalk_ir::cast::Cast;
use log::debug;
use parking_lot::Mutex;
use ra_prof::profile; use ra_prof::profile;
use rustc_hash::FxHashSet;
use crate::{Crate, Trait, db::HirDatabase, ImplBlock}; use super::{Canonical, ProjectionTy, TraitRef, Ty};
use super::{TraitRef, Ty, Canonical, ProjectionTy}; use crate::{db::HirDatabase, Crate, ImplBlock, Trait};
use self::chalk::{ToChalk, from_chalk}; use self::chalk::{from_chalk, ToChalk};
pub(crate) mod chalk; pub(crate) mod chalk;

View file

@ -3,20 +3,25 @@ use std::sync::Arc;
use log::debug; use log::debug;
use chalk_ir::{TypeId, ImplId, TypeKindId, Parameter, Identifier, cast::Cast, PlaceholderIndex, UniverseIndex, TypeName}; use chalk_ir::{
use chalk_rust_ir::{AssociatedTyDatum, TraitDatum, StructDatum, ImplDatum}; cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName,
UniverseIndex,
use test_utils::tested_by;
use ra_db::salsa::{InternId, InternKey};
use crate::{
Trait, HasGenericParams, ImplBlock, Crate,
db::HirDatabase,
ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef, ProjectionTy},
ty::display::HirDisplay,
generics::GenericDef, TypeAlias, ImplItem,
}; };
use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
use ra_db::salsa::{InternId, InternKey};
use test_utils::tested_by;
use super::ChalkContext; use super::ChalkContext;
use crate::{
db::HirDatabase,
generics::GenericDef,
ty::display::HirDisplay,
ty::{
ApplicationTy, CallableDef, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
},
Crate, HasGenericParams, ImplBlock, ImplItem, Trait, TypeAlias,
};
/// This represents a trait whose name we could not resolve. /// This represents a trait whose name we could not resolve.
const UNKNOWN_TRAIT: chalk_ir::TraitId = const UNKNOWN_TRAIT: chalk_ir::TraitId =

View file

@ -4,7 +4,12 @@ use std::sync::Arc;
use ra_syntax::ast::NameOwner; use ra_syntax::ast::NameOwner;
use crate::{TypeAlias, db::{DefDatabase, AstDatabase}, type_ref::TypeRef, name::{Name, AsName}, HasSource}; use crate::{
db::{AstDatabase, DefDatabase},
name::{AsName, Name},
type_ref::TypeRef,
HasSource, TypeAlias,
};
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct TypeAliasData { pub struct TypeAliasData {

View file

@ -1,6 +1,6 @@
use ra_db::{FileRange, FilePosition}; use ra_db::{FilePosition, FileRange};
use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
pub use ra_assists::AssistId; pub use ra_assists::AssistId;

View file

@ -1,12 +1,12 @@
use test_utils::tested_by;
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use ra_syntax::{ use ra_syntax::{
AstNode, SyntaxNode, TextUnit,
ast::{self, ArgListOwner},
algo::find_node_at_offset, algo::find_node_at_offset,
ast::{self, ArgListOwner},
AstNode, SyntaxNode, TextUnit,
}; };
use test_utils::tested_by;
use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase}; use crate::{db::RootDatabase, CallInfo, FilePosition, FunctionSignature};
/// Computes parameter information for the given call expression. /// Computes parameter information for the given call expression.
pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {

View file

@ -1,22 +1,19 @@
use std::{ use std::{fmt, sync::Arc, time};
fmt, time,
sync::Arc,
};
use rustc_hash::FxHashMap;
use ra_db::{ use ra_db::{
SourceRootId, FileId, CrateGraph, SourceDatabase, SourceRoot,
salsa::{Database, SweepStrategy}, salsa::{Database, SweepStrategy},
CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId,
}; };
use ra_prof::{memory_usage, profile, Bytes};
use ra_syntax::SourceFile; use ra_syntax::SourceFile;
use ra_prof::{profile, Bytes, memory_usage};
use relative_path::RelativePathBuf;
use rayon::prelude::*; use rayon::prelude::*;
use relative_path::RelativePathBuf;
use rustc_hash::FxHashMap;
use crate::{ use crate::{
db::RootDatabase, db::RootDatabase,
symbol_index::{SymbolIndex, SymbolsDatabase},
status::syntax_tree_stats, status::syntax_tree_stats,
symbol_index::{SymbolIndex, SymbolsDatabase},
}; };
#[derive(Default)] #[derive(Default)]

View file

@ -14,19 +14,19 @@ mod complete_postfix;
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use crate::{
db,
FilePosition,
completion::{
completion_item::{Completions, CompletionKind},
completion_context::CompletionContext,
},
};
#[cfg(test)] #[cfg(test)]
use crate::completion::completion_item::{do_completion, check_completion}; use crate::completion::completion_item::{check_completion, do_completion};
use crate::{
completion::{
completion_context::CompletionContext,
completion_item::{CompletionKind, Completions},
},
db, FilePosition,
};
pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, InsertTextFormat}; pub use crate::completion::completion_item::{
CompletionItem, CompletionItemKind, InsertTextFormat,
};
/// Main entry point for completion. We run completion as a two-phase process. /// Main entry point for completion. We run completion as a two-phase process.
/// ///

View file

@ -1,4 +1,4 @@
use hir::{Ty, AdtDef, TypeCtor}; use hir::{AdtDef, Ty, TypeCtor};
use crate::completion::{CompletionContext, Completions}; use crate::completion::{CompletionContext, Completions};
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
@ -49,7 +49,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{do_completion, CompletionKind, CompletionItem}; use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches; use insta::assert_debug_snapshot_matches;
fn do_ref_completion(code: &str) -> Vec<CompletionItem> { fn do_ref_completion(code: &str) -> Vec<CompletionItem> {

View file

@ -1,11 +1,10 @@
use ra_syntax::{ use ra_syntax::{
algo::visit::{visitor_ctx, VisitorCtx}, algo::visit::{visitor_ctx, VisitorCtx},
ast, ast, AstNode,
AstNode,
}; };
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use crate::completion::{CompletionContext, Completions, CompletionKind, CompletionItem}; use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions};
/// Complete repeated parameters, both name and type. For example, if all /// Complete repeated parameters, both name and type. For example, if all
/// functions in a file have a `spam: &mut Spam` parameter, a completion with /// functions in a file have a `spam: &mut Spam` parameter, a completion with

View file

@ -1,11 +1,14 @@
use ra_syntax::{ use ra_syntax::{
algo::visit::{visitor, Visitor}, algo::visit::{visitor, Visitor},
AstNode,
ast::{self, LoopBodyOwner}, ast::{self, LoopBodyOwner},
SyntaxKind::*, SyntaxToken, AstNode,
SyntaxKind::*,
SyntaxToken,
}; };
use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; use crate::completion::{
CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
};
pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
// complete keyword "crate" in use stmt // complete keyword "crate" in use stmt

View file

@ -1,8 +1,8 @@
use hir::{Resolution, Either}; use hir::{Either, Resolution};
use ra_syntax::AstNode; use ra_syntax::AstNode;
use test_utils::tested_by; use test_utils::tested_by;
use crate::completion::{Completions, CompletionContext}; use crate::completion::{CompletionContext, Completions};
pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
let path = match &ctx.path_prefix { let path = match &ctx.path_prefix {
@ -78,7 +78,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
mod tests { mod tests {
use test_utils::covers; use test_utils::covers;
use crate::completion::{CompletionKind, do_completion, CompletionItem}; use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches; use insta::assert_debug_snapshot_matches;
fn do_reference_completion(code: &str) -> Vec<CompletionItem> { fn do_reference_completion(code: &str) -> Vec<CompletionItem> {

View file

@ -27,8 +27,8 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches; use insta::assert_debug_snapshot_matches;
use crate::completion::{CompletionItem, CompletionKind, do_completion};
fn complete(code: &str) -> Vec<CompletionItem> { fn complete(code: &str) -> Vec<CompletionItem> {
do_completion(code, CompletionKind::Reference) do_completion(code, CompletionKind::Reference)

View file

@ -1,18 +1,11 @@
use crate::{ use crate::{
completion::{ completion::{
completion_item::{
Completions,
Builder,
CompletionKind,
},
completion_context::CompletionContext, completion_context::CompletionContext,
completion_item::{Builder, CompletionKind, Completions},
}, },
CompletionItem CompletionItem,
};
use ra_syntax::{
ast::AstNode,
TextRange
}; };
use ra_syntax::{ast::AstNode, TextRange};
use ra_text_edit::TextEditBuilder; use ra_text_edit::TextEditBuilder;
fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder {
@ -58,7 +51,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{CompletionKind, check_completion}; use crate::completion::{check_completion, CompletionKind};
fn check_snippet_completion(test_name: &str, code: &str) { fn check_snippet_completion(test_name: &str, code: &str) {
check_completion(test_name, code, CompletionKind::Postfix); check_completion(test_name, code, CompletionKind::Postfix);

View file

@ -1,9 +1,9 @@
use rustc_hash::FxHashMap;
use ra_text_edit::TextEditBuilder;
use ra_syntax::{SmolStr, ast, AstNode};
use ra_assists::auto_import; use ra_assists::auto_import;
use ra_syntax::{ast, AstNode, SmolStr};
use ra_text_edit::TextEditBuilder;
use rustc_hash::FxHashMap;
use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext}; use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions};
pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
if ctx.is_trivial_path { if ctx.is_trivial_path {
@ -121,7 +121,7 @@ impl ImportResolver {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{CompletionKind, check_completion}; use crate::completion::{check_completion, CompletionKind};
fn check_reference_completion(name: &str, code: &str) { fn check_reference_completion(name: &str, code: &str) {
check_completion(name, code, CompletionKind::Reference); check_completion(name, code, CompletionKind::Reference);

View file

@ -1,4 +1,7 @@
use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; use crate::completion::{
completion_item::Builder, CompletionContext, CompletionItem, CompletionItemKind,
CompletionKind, Completions,
};
fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder {
CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label) CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label)
@ -36,7 +39,7 @@ fn ${1:feature}() {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{CompletionKind, check_completion}; use crate::completion::{check_completion, CompletionKind};
fn check_snippet_completion(name: &str, code: &str) { fn check_snippet_completion(name: &str, code: &str) {
check_completion(name, code, CompletionKind::Snippet); check_completion(name, code, CompletionKind::Snippet);

View file

@ -27,8 +27,8 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches; use insta::assert_debug_snapshot_matches;
use crate::completion::{CompletionItem, CompletionKind, do_completion};
fn complete(code: &str) -> Vec<CompletionItem> { fn complete(code: &str) -> Vec<CompletionItem> {
do_completion(code, CompletionKind::Reference) do_completion(code, CompletionKind::Reference)

View file

@ -1,11 +1,11 @@
use ra_text_edit::AtomTextEdit;
use ra_syntax::{
AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, Parse,
ast,
algo::{find_token_at_offset, find_covering_element, find_node_at_offset},
SyntaxKind::*,
};
use hir::source_binder; use hir::source_binder;
use ra_syntax::{
algo::{find_covering_element, find_node_at_offset, find_token_at_offset},
ast, AstNode, Parse, SourceFile,
SyntaxKind::*,
SyntaxNode, SyntaxToken, TextRange, TextUnit,
};
use ra_text_edit::AtomTextEdit;
use crate::{db, FilePosition}; use crate::{db, FilePosition};

View file

@ -2,7 +2,7 @@ use std::fmt;
use hir::Documentation; use hir::Documentation;
use ra_syntax::TextRange; use ra_syntax::TextRange;
use ra_text_edit::{TextEditBuilder, TextEdit}; use ra_text_edit::{TextEdit, TextEditBuilder};
/// `CompletionItem` describes a single completion variant in the editor pop-up. /// `CompletionItem` describes a single completion variant in the editor pop-up.
/// It is basically a POD with various properties. To construct a /// It is basically a POD with various properties. To construct a
@ -285,8 +285,8 @@ impl Into<Vec<CompletionItem>> for Completions {
#[cfg(test)] #[cfg(test)]
pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
use crate::mock_analysis::{single_file_with_position, analysis_and_position};
use crate::completion::completions; use crate::completion::completions;
use crate::mock_analysis::{analysis_and_position, single_file_with_position};
let (analysis, position) = if code.contains("//-") { let (analysis, position) = if code.contains("//-") {
analysis_and_position(code) analysis_and_position(code)
} else { } else {

View file

@ -1,16 +1,14 @@
//! This modules takes care of rendering various defenitions as completion items. //! This modules takes care of rendering various defenitions as completion items.
use hir::{Docs, HasSource, HirDisplay, PerNs, Resolution};
use join_to_string::join; use join_to_string::join;
use test_utils::tested_by;
use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource};
use ra_syntax::ast::NameOwner; use ra_syntax::ast::NameOwner;
use test_utils::tested_by;
use crate::completion::{ use crate::completion::{
Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
}; };
use crate::display::{ use crate::display::{const_label, function_label, type_label};
function_label, const_label, type_label,
};
impl Completions { impl Completions {
pub(crate) fn add_field( pub(crate) fn add_field(
@ -178,7 +176,7 @@ impl Completions {
mod tests { mod tests {
use test_utils::covers; use test_utils::covers;
use crate::completion::{CompletionKind, check_completion}; use crate::completion::{check_completion, CompletionKind};
fn check_reference_completion(code: &str, expected_completions: &str) { fn check_reference_completion(code: &str, expected_completions: &str) {
check_completion(code, expected_completions, CompletionKind::Reference); check_completion(code, expected_completions, CompletionKind::Reference);

View file

@ -1,14 +1,14 @@
use std::{ use std::{sync::Arc, time};
sync::Arc,
time,
};
use ra_db::{ use ra_db::{
CheckCanceled, FileId, Canceled, SourceDatabase,
salsa::{self, Database}, salsa::{self, Database},
Canceled, CheckCanceled, FileId, SourceDatabase,
}; };
use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; use crate::{
symbol_index::{self, SymbolsDatabase},
LineIndex,
};
#[salsa::database( #[salsa::database(
ra_db::SourceDatabaseStorage, ra_db::SourceDatabaseStorage,

View file

@ -1,17 +1,20 @@
use std::cell::RefCell; use std::cell::RefCell;
use itertools::Itertools; use hir::{
use hir::{source_binder, diagnostics::{Diagnostic as _, DiagnosticSink}}; diagnostics::{Diagnostic as _, DiagnosticSink},
use ra_db::SourceDatabase; source_binder,
use ra_syntax::{
T, Location, TextRange, SyntaxNode,
ast::{self, AstNode, NamedFieldList, NamedField},
}; };
use ra_assists::ast_editor::{AstEditor, AstBuilder}; use itertools::Itertools;
use ra_text_edit::{TextEdit, TextEditBuilder}; use ra_assists::ast_editor::{AstBuilder, AstEditor};
use ra_db::SourceDatabase;
use ra_prof::profile; use ra_prof::profile;
use ra_syntax::{
ast::{self, AstNode, NamedField, NamedFieldList},
Location, SyntaxNode, TextRange, T,
};
use ra_text_edit::{TextEdit, TextEditBuilder};
use crate::{Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit, db::RootDatabase}; use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit};
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum Severity { pub enum Severity {
@ -170,9 +173,9 @@ fn check_struct_shorthand_initialization(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use test_utils::assert_eq_text;
use insta::assert_debug_snapshot_matches; use insta::assert_debug_snapshot_matches;
use ra_syntax::SourceFile; use ra_syntax::SourceFile;
use test_utils::assert_eq_text;
use crate::mock_analysis::single_file; use crate::mock_analysis::single_file;

View file

@ -6,14 +6,17 @@ mod navigation_target;
mod structure; mod structure;
mod short_label; mod short_label;
use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}}; use ra_syntax::{
ast::{self, AstNode, TypeParamsOwner},
SyntaxKind::{ATTR, COMMENT},
};
pub use navigation_target::NavigationTarget;
pub use structure::{StructureNode, file_structure};
pub use function_signature::FunctionSignature; pub use function_signature::FunctionSignature;
pub use navigation_target::NavigationTarget;
pub use structure::{file_structure, StructureNode};
pub(crate) use navigation_target::{description_from_symbol, docs_from_symbol};
pub(crate) use short_label::ShortLabel; pub(crate) use short_label::ShortLabel;
pub(crate) use navigation_target::{docs_from_symbol, description_from_symbol};
pub(crate) fn function_label(node: &ast::FnDef) -> String { pub(crate) fn function_label(node: &ast::FnDef) -> String {
FunctionSignature::from(node).to_string() FunctionSignature::from(node).to_string()

View file

@ -1,11 +1,14 @@
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use hir::{Docs, Documentation, HasSource};
use join_to_string::join; use join_to_string::join;
use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
use std::convert::From; use std::convert::From;
use hir::{Docs, Documentation, HasSource};
use crate::{db, display::{where_predicates, generic_parameters}}; use crate::{
db,
display::{generic_parameters, where_predicates},
};
/// Contains information about a function signature /// Contains information about a function signature
#[derive(Debug)] #[derive(Debug)]

View file

@ -1,14 +1,15 @@
use hir::{FieldSource, HasSource, ImplItem, ModuleSource};
use ra_db::{FileId, SourceDatabase}; use ra_db::{FileId, SourceDatabase};
use ra_syntax::{ use ra_syntax::{
SyntaxNode, AstNode, SmolStr, TextRange, AstPtr, TreeArc,
SyntaxKind::{self, NAME},
ast::{self, DocCommentsOwner},
algo::visit::{visitor, Visitor}, algo::visit::{visitor, Visitor},
ast::{self, DocCommentsOwner},
AstNode, AstPtr, SmolStr,
SyntaxKind::{self, NAME},
SyntaxNode, TextRange, TreeArc,
}; };
use hir::{ModuleSource, FieldSource, ImplItem, HasSource};
use crate::{FileSymbol, db::RootDatabase};
use super::short_label::ShortLabel; use super::short_label::ShortLabel;
use crate::{db::RootDatabase, FileSymbol};
/// `NavigationTarget` represents and element in the editor's UI which you can /// `NavigationTarget` represents and element in the editor's UI which you can
/// click on to navigate to a particular piece of code. /// click on to navigate to a particular piece of code.

View file

@ -1,6 +1,4 @@
use ra_syntax::{ use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner};
ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner, AstNode},
};
pub(crate) trait ShortLabel { pub(crate) trait ShortLabel {
fn short_label(&self) -> Option<String>; fn short_label(&self) -> Option<String>;

View file

@ -2,7 +2,7 @@ use crate::TextRange;
use ra_syntax::{ use ra_syntax::{
algo::visit::{visitor, Visitor}, algo::visit::{visitor, Visitor},
ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner},
AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent,
}; };

View file

@ -1,13 +1,13 @@
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use ra_syntax::{ use ra_syntax::{
Direction, SyntaxNode, TextRange, TextUnit, SyntaxElement,
algo::{find_covering_element, find_token_at_offset, TokenAtOffset}, algo::{find_covering_element, find_token_at_offset, TokenAtOffset},
SyntaxKind::*, SyntaxToken,
ast::{self, AstNode, AstToken}, ast::{self, AstNode, AstToken},
T Direction, SyntaxElement,
SyntaxKind::*,
SyntaxNode, SyntaxToken, TextRange, TextUnit, T,
}; };
use crate::{FileRange, db::RootDatabase}; use crate::{db::RootDatabase, FileRange};
// FIXME: restore macro support // FIXME: restore macro support
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
@ -205,7 +205,7 @@ fn adj_comments(comment: ast::Comment, dir: Direction) -> ast::Comment {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use ra_syntax::{SourceFile, AstNode}; use ra_syntax::{AstNode, SourceFile};
use test_utils::extract_offset; use test_utils::extract_offset;
use super::*; use super::*;

View file

@ -1,9 +1,10 @@
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use ra_syntax::{ use ra_syntax::{
SourceFile, SyntaxNode, TextRange, Direction, SyntaxElement,
SyntaxKind::{self, *},
ast::{self, AstNode, AstToken, VisibilityOwner}, ast::{self, AstNode, AstToken, VisibilityOwner},
Direction, SourceFile, SyntaxElement,
SyntaxKind::{self, *},
SyntaxNode, TextRange,
}; };
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]

View file

@ -1,19 +1,18 @@
use ra_db::{FileId, SourceDatabase}; use ra_db::{FileId, SourceDatabase};
use ra_syntax::{ use ra_syntax::{
AstNode, ast::{self, DocCommentsOwner},
algo::{ algo::{
find_node_at_offset, find_node_at_offset,
visit::{visitor, Visitor}, visit::{visitor, Visitor},
}, },
SyntaxNode, ast::{self, DocCommentsOwner},
AstNode, SyntaxNode,
}; };
use crate::{ use crate::{
FilePosition, NavigationTarget,
db::RootDatabase, db::RootDatabase,
RangeInfo,
name_ref_kind::{NameRefKind::*, classify_name_ref},
display::ShortLabel, display::ShortLabel,
name_ref_kind::{classify_name_ref, NameRefKind::*},
FilePosition, NavigationTarget, RangeInfo,
}; };
pub(crate) fn goto_definition( pub(crate) fn goto_definition(

View file

@ -1,10 +1,7 @@
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use ra_syntax::{ use ra_syntax::{algo::find_token_at_offset, ast, AstNode};
AstNode, ast,
algo::find_token_at_offset
};
use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo};
pub(crate) fn goto_type_definition( pub(crate) fn goto_type_definition(
db: &RootDatabase, db: &RootDatabase,

View file

@ -1,16 +1,22 @@
use hir::{HasSource, HirDisplay};
use ra_db::SourceDatabase; use ra_db::SourceDatabase;
use ra_syntax::{ use ra_syntax::{
AstNode, TreeArc, algo::{
ancestors_at_offset, find_covering_element, find_node_at_offset,
visit::{visitor, Visitor},
},
ast::{self, DocCommentsOwner}, ast::{self, DocCommentsOwner},
algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}}, AstNode, TreeArc,
}; };
use hir::{HirDisplay, HasSource};
use crate::{ use crate::{
db::RootDatabase, db::RootDatabase,
RangeInfo, FilePosition, FileRange, display::{
display::{rust_code_markup, rust_code_markup_with_doc, ShortLabel, docs_from_symbol, description_from_symbol}, description_from_symbol, docs_from_symbol, rust_code_markup, rust_code_markup_with_doc,
name_ref_kind::{NameRefKind::*, classify_name_ref}, ShortLabel,
},
name_ref_kind::{classify_name_ref, NameRefKind::*},
FilePosition, FileRange, RangeInfo,
}; };
/// Contains the results when hovering over an item /// Contains the results when hovering over an item
@ -256,8 +262,10 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::mock_analysis::{
analysis_and_position, single_file_with_position, single_file_with_range,
};
use ra_syntax::TextRange; use ra_syntax::TextRange;
use crate::mock_analysis::{single_file_with_position, single_file_with_range, analysis_and_position};
fn trim_markup(s: &str) -> &str { fn trim_markup(s: &str) -> &str {
s.trim_start_matches("```rust\n").trim_end_matches("\n```") s.trim_start_matches("```rust\n").trim_end_matches("\n```")

View file

@ -1,11 +1,8 @@
use ra_db::SourceDatabase;
use ra_syntax::{
AstNode, ast,
algo::find_node_at_offset,
};
use hir::{db::HirDatabase, source_binder}; use hir::{db::HirDatabase, source_binder};
use ra_db::SourceDatabase;
use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo};
pub(crate) fn goto_implementation( pub(crate) fn goto_implementation(
db: &RootDatabase, db: &RootDatabase,

View file

@ -1,14 +1,11 @@
use itertools::Itertools; use itertools::Itertools;
use ra_fmt::{compute_ws, extract_trivial_expression};
use ra_syntax::{ use ra_syntax::{
T,
SourceFile, TextRange, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken,
SyntaxKind::{self, WHITESPACE},
algo::{find_covering_element, non_trivia_sibling}, algo::{find_covering_element, non_trivia_sibling},
ast::{self, AstNode, AstToken}, ast::{self, AstNode, AstToken},
Direction, Direction, SourceFile, SyntaxElement,
}; SyntaxKind::{self, WHITESPACE},
use ra_fmt::{ SyntaxNode, SyntaxToken, TextRange, TextUnit, T,
compute_ws, extract_trivial_expression
}; };
use ra_text_edit::{TextEdit, TextEditBuilder}; use ra_text_edit::{TextEdit, TextEditBuilder};

View file

@ -46,33 +46,35 @@ mod test_utils;
use std::sync::Arc; use std::sync::Arc;
use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit};
use ra_text_edit::TextEdit;
use ra_db::{ use ra_db::{
SourceDatabase, CheckCanceled,
salsa::{self, ParallelDatabase}, salsa::{self, ParallelDatabase},
CheckCanceled, SourceDatabase,
}; };
use ra_syntax::{SourceFile, TextRange, TextUnit, TreeArc};
use ra_text_edit::TextEdit;
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use crate::{symbol_index::FileSymbol, db::LineIndexDatabase}; use crate::{db::LineIndexDatabase, symbol_index::FileSymbol};
pub use crate::{ pub use crate::{
assists::{Assist, AssistId},
change::{AnalysisChange, LibraryData}, change::{AnalysisChange, LibraryData},
completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, completion::{CompletionItem, CompletionItemKind, InsertTextFormat},
runnables::{Runnable, RunnableKind},
references::ReferenceSearchResult,
assists::{Assist, AssistId},
hover::{HoverResult},
line_index::{LineIndex, LineCol},
line_index_utils::translate_offset_with_edit,
folding_ranges::{Fold, FoldKind},
syntax_highlighting::HighlightedRange,
diagnostics::Severity, diagnostics::Severity,
display::{FunctionSignature, NavigationTarget, StructureNode, file_structure}, display::{file_structure, FunctionSignature, NavigationTarget, StructureNode},
folding_ranges::{Fold, FoldKind},
hover::HoverResult,
line_index::{LineCol, LineIndex},
line_index_utils::translate_offset_with_edit,
references::ReferenceSearchResult,
runnables::{Runnable, RunnableKind},
syntax_highlighting::HighlightedRange,
}; };
pub use ra_db::{Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId, Edition};
pub use hir::Documentation; pub use hir::Documentation;
pub use ra_db::{
Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId,
};
pub type Cancelable<T> = Result<T, Canceled>; pub type Cancelable<T> = Result<T, Canceled>;

View file

@ -145,7 +145,7 @@ pub fn to_line_col(text: &str, offset: TextUnit) -> LineCol {
mod test_line_index { mod test_line_index {
use super::*; use super::*;
use proptest::{prelude::*, proptest}; use proptest::{prelude::*, proptest};
use ra_text_edit::test_utils::{arb_text, arb_offset}; use ra_text_edit::test_utils::{arb_offset, arb_text};
#[test] #[test]
fn test_line_index() { fn test_line_index() {

View file

@ -1,6 +1,6 @@
use crate::{line_index::Utf16Char, LineCol, LineIndex};
use ra_syntax::{TextRange, TextUnit};
use ra_text_edit::{AtomTextEdit, TextEdit}; use ra_text_edit::{AtomTextEdit, TextEdit};
use ra_syntax::{TextUnit, TextRange};
use crate::{LineIndex, LineCol, line_index::Utf16Char};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
enum Step { enum Step {
@ -292,8 +292,8 @@ pub fn translate_offset_with_edit(
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use proptest::{prelude::*, proptest};
use crate::line_index; use crate::line_index;
use proptest::{prelude::*, proptest};
use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit}; use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit};
use ra_text_edit::TextEdit; use ra_text_edit::TextEdit;

View file

@ -1,10 +1,4 @@
use ra_syntax::{ use ra_syntax::{algo::find_token_at_offset, ast::AstNode, SourceFile, SyntaxKind, TextUnit, T};
SourceFile, TextUnit,
algo::find_token_at_offset,
SyntaxKind::{self},
ast::AstNode,
T
};
pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
const BRACES: &[SyntaxKind] = const BRACES: &[SyntaxKind] =

View file

@ -3,7 +3,10 @@ use std::sync::Arc;
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER};
use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, SourceRootId, Edition::Edition2018}; use crate::{
Analysis, AnalysisChange, AnalysisHost, CrateGraph, Edition::Edition2018, FileId, FilePosition,
FileRange, SourceRootId,
};
/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
/// from a set of in-memory files. /// from a set of in-memory files.

View file

@ -1,5 +1,5 @@
use ra_syntax::{AstNode, AstPtr, ast};
use hir::Either; use hir::Either;
use ra_syntax::{ast, AstNode, AstPtr};
use test_utils::tested_by; use test_utils::tested_by;
use crate::db::RootDatabase; use crate::db::RootDatabase;

Some files were not shown because too many files have changed in this diff Show more