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 crossbeam_channel::{Sender, Receiver};
use crossbeam_channel::{Receiver, Sender};
use gen_lsp_server::{handle_shutdown, run_server, stdio_transport, RawMessage, RawResponse};
use lsp_types::{
ServerCapabilities, InitializeParams,
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>> {
let (receiver, sender, io_threads) = stdio_transport();

View file

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

View file

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

View file

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

View file

@ -1,13 +1,10 @@
use hir::{
HirDisplay, Ty,
db::HirDatabase,
};
use hir::{db::HirDatabase, HirDisplay, Ty};
use ra_syntax::{
ast::{AstNode, LetStmt, NameOwner, PatKind},
T,
ast::{LetStmt, PatKind, NameOwner, AstNode}
};
use crate::{AssistCtx, Assist, AssistId};
use crate::{Assist, AssistCtx, AssistId};
/// Add explicit type 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 {
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]
fn add_explicit_type_target() {

View file

@ -1,11 +1,11 @@
use join_to_string::join;
use hir::db::HirDatabase;
use join_to_string::join;
use ra_syntax::{
ast::{self, AstNode, NameOwner, TypeParamsOwner},
TextUnit,
};
use crate::{AssistCtx, Assist, AssistId};
use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
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 ra_syntax::{SmolStr, TreeArc};
use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner};
use hir::{db::HirDatabase, HasSource};
use ra_db::FilePosition;
use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner};
use ra_syntax::{SmolStr, TreeArc};
#[derive(PartialEq)]
enum AddMissingImplMembersMode {

View file

@ -1,13 +1,13 @@
use hir::db::HirDatabase;
use ra_text_edit::TextEditBuilder;
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_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)]
pub(crate) enum Assist {

View file

@ -1,10 +1,12 @@
use std::{iter, ops::RangeInclusive};
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 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> {
original_ast: TreeArc<N>,
@ -283,7 +285,7 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> {
mod tokens {
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);

View file

@ -1,14 +1,15 @@
use hir::{self, db::HirDatabase};
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::{
assist_ctx::{Assist, AssistCtx},
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>(
@ -577,7 +578,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
#[cfg(test)]
mod tests {
use super::*;
use crate::helpers::{ check_assist, check_assist_not_applicable };
use crate::helpers::{check_assist, check_assist_not_applicable};
#[test]
fn test_auto_import_add_use_no_anchor() {

View file

@ -1,12 +1,15 @@
use hir::db::HirDatabase;
use ra_syntax::{
T,
AstNode, SyntaxNode, TextUnit,
ast::{self, VisibilityOwner, NameOwner},
SyntaxKind::{VISIBILITY, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF, IDENT, WHITESPACE, COMMENT, ATTR},
ast::{self, NameOwner, VisibilityOwner},
AstNode,
SyntaxKind::{
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> {
if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() {

View file

@ -1,13 +1,10 @@
use std::fmt::Write;
use itertools::Itertools;
use std::fmt::Write;
use hir::{
AdtDef, FieldSource, HasSource,
db::HirDatabase,
};
use hir::{db::HirDatabase, AdtDef, FieldSource, HasSource};
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 single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> {

View file

@ -1,7 +1,7 @@
use hir::db::HirDatabase;
use ra_syntax::ast::{AstNode, BinExpr, BinOp};
use crate::{AssistCtx, Assist, AssistId};
use crate::{Assist, AssistCtx, AssistId};
/// Flip binary expression assist.
pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
@ -68,7 +68,7 @@ impl From<BinOp> for FlipAction {
mod tests {
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]
fn flip_binexpr_target_is_the_op() {

View file

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

View file

@ -1,11 +1,11 @@
use hir::db::HirDatabase;
use ra_syntax::{
ast::{self, AstNode, AstToken, PatKind, ExprKind},
ast::{self, AstNode, AstToken, ExprKind, PatKind},
TextRange,
};
use crate::{Assist, AssistCtx, AssistId};
use crate::assist_ctx::AssistBuilder;
use crate::{Assist, AssistCtx, AssistId};
pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
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 ra_syntax::{
ast::{self, AstNode},
SyntaxKind::{
BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, WHITESPACE,
},
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> {
if ctx.frange.range.is_empty() {
@ -121,7 +123,9 @@ fn anchor_stmt(expr: &ast::Expr) -> Option<(&SyntaxNode, bool)> {
mod tests {
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::*;

View file

@ -11,12 +11,12 @@ pub mod ast_editor;
use itertools::Itertools;
use ra_text_edit::TextEdit;
use ra_syntax::{TextRange, TextUnit};
use ra_db::FileRange;
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
/// directly.
@ -127,11 +127,11 @@ fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assis
#[cfg(test)]
mod helpers {
use hir::mock::MockDatabase;
use ra_syntax::TextRange;
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(
assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>,
@ -289,8 +289,8 @@ mod helpers {
#[cfg(test)]
mod tests {
use hir::mock::MockDatabase;
use ra_syntax::TextRange;
use ra_db::FileRange;
use ra_syntax::TextRange;
use test_utils::{extract_offset, extract_range};
#[test]

View file

@ -1,12 +1,11 @@
use hir::db::HirDatabase;
use ra_syntax::{
TextUnit,
SyntaxElement,
ast::{MatchArm, AstNode, AstToken, IfExpr},
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> {
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 {
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]
fn move_guard_to_arm_body_target() {

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
use std::path::PathBuf;
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
/// from `ProjectRoot` to `RootEntry` for VFS

View file

@ -1,10 +1,10 @@
use std::{
path::{PathBuf, Path},
path::{Path, PathBuf},
time::Instant,
};
use ra_db::{SourceDatabase, salsa::Database};
use ra_ide_api::{AnalysisHost, Analysis, LineCol, FilePosition};
use ra_db::{salsa::Database, SourceDatabase};
use ra_ide_api::{Analysis, AnalysisHost, FilePosition, LineCol};
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_hir::{Crate, ModuleDef, Ty, ImplItem, HasSource};
use ra_hir::{Crate, HasSource, ImplItem, ModuleDef, Ty};
use ra_syntax::AstNode;
use crate::Result;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,24 +3,32 @@ pub(crate) mod docs;
use std::sync::Arc;
use ra_db::{CrateId, SourceRootId, Edition, FileId};
use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc};
use ra_db::{CrateId, Edition, FileId, SourceRootId};
use ra_syntax::{
ast::{self, NameOwner, TypeAscriptionOwner},
TreeArc,
};
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},
diagnostics::DiagnosticSink,
expr::{validation::ExprValidator, Body, BodySourceMap},
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,
nameres::{CrateModuleId, ImportId, ModuleScope, Namespace},
resolve::Resolver,
diagnostics::{DiagnosticSink},
traits::{TraitItem, TraitData},
traits::{TraitData, TraitItem},
ty::{
primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness},
InferenceResult, TraitRef,
},
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

View file

@ -3,8 +3,8 @@ use std::sync::Arc;
use ra_syntax::ast;
use crate::{
HirDatabase, DefDatabase, AstDatabase, HasSource,
Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef,
AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource,
HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union,
};
#[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::{
HirFileId, DefDatabase, AstDatabase, Module, ModuleSource,
StructField, Struct, Enum, Union, EnumVariant, Function, Static, Trait, Const, TypeAlias,
FieldSource, MacroDef, ids::AstItemDef,
ids::AstItemDef, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function,
HirFileId, MacroDef, Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias,
Union,
};
pub struct Source<T> {

View file

@ -1,23 +1,25 @@
use std::sync::Arc;
use parking_lot::Mutex;
use ra_syntax::{SyntaxNode, TreeArc, SmolStr, ast};
use ra_db::{SourceDatabase, salsa};
use ra_db::{salsa, SourceDatabase};
use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc};
use crate::{
HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc,
Function, FnData, ExprScopes, TypeAlias,
Struct, Enum, StructField,
Const, ConstData, Static,
DefWithBody, Trait,
adt::{EnumData, StructData},
generics::{GenericDef, GenericParams},
ids,
nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap},
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, CallableDef, FnSig, TypeCtor, GenericPredicate, Substs},
adt::{StructData, EnumData},
impl_block::{ModuleImplBlocks, ImplSourceMap, ImplBlock},
generics::{GenericParams, GenericDef},
impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks},
lang_item::{LangItemTarget, LangItems},
nameres::{CrateDefMap, ImportSourceMap, Namespace, RawItems},
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.

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 crate::{HirFileId, HirDatabase, Name};
use crate::{HirDatabase, HirFileId, Name};
/// Diagnostic defines hir API for errors and warnings.
///

View file

@ -3,19 +3,25 @@ use std::sync::Arc;
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::{
SyntaxNodePtr, AstPtr, AstNode,
ast::{self, TryBlockBodyOwner, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner},
ast::{
self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner,
TryBlockBodyOwner, TypeAscriptionOwner,
},
AstNode, AstPtr, SyntaxNodePtr,
};
use crate::{
Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
HasSource,
name::AsName,
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;
@ -249,8 +255,8 @@ pub enum Expr {
Literal(Literal),
}
pub use ra_syntax::ast::PrefixOp as UnaryOp;
pub use ra_syntax::ast::BinOp as BinaryOp;
pub use ra_syntax::ast::PrefixOp as UnaryOp;
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Array {
ElementList(Vec<ExprId>),

View file

@ -1,12 +1,11 @@
use std::sync::Arc;
use ra_arena::{impl_arena_id, Arena, RawId};
use rustc_hash::FxHashMap;
use ra_arena::{Arena, RawId, impl_arena_id};
use crate::{
Name, DefWithBody,
expr::{PatId, ExprId, Pat, Expr, Body, Statement},
HirDatabase,
expr::{Body, Expr, ExprId, Pat, PatId, Statement},
DefWithBody, HirDatabase, Name,
};
#[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)]
mod tests {
use ra_db::SourceDatabase;
use ra_syntax::{algo::find_node_at_offset, AstNode, SyntaxNodePtr, ast};
use test_utils::{extract_offset, assert_eq_text};
use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNodePtr};
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]) {
let (off, code) = extract_offset(code);

View file

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

View file

@ -5,13 +5,14 @@
use std::sync::Arc;
use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner};
use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner};
use crate::{
HasSource,
Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef,
db::{HirDatabase, DefDatabase, AstDatabase},
path::Path, type_ref::TypeRef,
db::{AstDatabase, DefDatabase, HirDatabase},
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, ...).

View file

@ -3,14 +3,12 @@ use std::{
sync::Arc,
};
use ra_db::{FileId, salsa};
use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode};
use ra_prof::profile;
use mbe::MacroRules;
use ra_db::{salsa, FileId};
use ra_prof::profile;
use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc};
use crate::{
Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, InternDatabase,
};
use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source};
/// 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

View file

@ -1,21 +1,21 @@
use std::sync::Arc;
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::{
ast::{self, AstNode},
AstPtr, SourceFile, TreeArc,
ast::{self, AstNode}
};
use crate::{
Const, TypeAlias, Function, HirFileId, AstDatabase, HasSource, Source,
HirDatabase, DefDatabase, TraitRef,
type_ref::TypeRef,
code_model::{Module, ModuleSource},
generics::HasGenericParams,
ids::LocationCtx,
resolve::Resolver,
ty::Ty,
generics::HasGenericParams,
code_model::{Module, ModuleSource}
type_ref::TypeRef,
AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef,
TypeAlias,
};
#[derive(Debug, Default, PartialEq, Eq)]

View file

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

View file

@ -47,39 +47,33 @@ mod code_model;
mod marks;
use crate::{
db::{InternDatabase, AstDatabase, DefDatabase, HirDatabase},
name::{AsName, KnownName},
source_id::{FileAstId, AstId},
resolve::Resolver,
db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase},
ids::MacroFileKind,
name::{AsName, KnownName},
resolve::Resolver,
source_id::{AstId, FileAstId},
};
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,
either::Either,
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,
generics::{GenericParams, GenericParam, HasGenericParams},
source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax},
source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer},
source_id::{AstIdMap, ErasedFileAstId},
ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor},
};
pub use self::code_model::{
Crate, CrateDependency,
DefWithBody,
Module, ModuleDef, ModuleSource,
Struct, Union, Enum, EnumVariant,
Function, FnData,
StructField, FieldSource,
Static, Const, ConstData,
Trait, TypeAlias, MacroDef, Container,
BuiltinType,
src::{Source, HasSource},
docs::{Docs, Documentation, DocDef},
docs::{DocDef, Docs, Documentation},
src::{HasSource, Source},
BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
EnumVariant, FieldSource, FnData, Function, MacroDef, Module, ModuleDef, ModuleSource, Static,
Struct, StructField, Trait, TypeAlias, Union,
};

View file

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

View file

@ -55,28 +55,24 @@ mod tests;
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 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::{
ModuleDef, Name, Crate, Module, MacroDef, AsName, BuiltinType, AstDatabase,
DefDatabase, Path, PathKind, HirFileId, Trait,
ids::MacroDefId,
diagnostics::DiagnosticSink,
nameres::diagnostics::DefDiagnostic,
either::Either,
AstId,
diagnostics::DiagnosticSink, either::Either, ids::MacroDefId,
nameres::diagnostics::DefDiagnostic, AsName, AstDatabase, AstId, BuiltinType, Crate,
DefDatabase, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
};
pub(crate) use self::raw::{RawItems, ImportSourceMap};
pub(crate) use self::raw::{ImportSourceMap, RawItems};
pub use self::{
per_ns::{PerNs, Namespace},
per_ns::{Namespace, PerNs},
raw::ImportId,
};
@ -512,14 +508,14 @@ impl CrateDefMap {
}
mod diagnostics {
use ra_syntax::{ast, AstPtr};
use relative_path::RelativePathBuf;
use ra_syntax::{AstPtr, ast};
use crate::{
AstId, DefDatabase, AstDatabase,
diagnostics::{DiagnosticSink, UnresolvedModule},
nameres::CrateModuleId,
diagnostics::{DiagnosticSink, UnresolvedModule}
};
AstDatabase, AstId, DefDatabase,
};
#[derive(Debug, PartialEq, Eq)]
pub(super) enum DefDiagnostic {

View file

@ -1,22 +1,19 @@
use arrayvec::ArrayVec;
use rustc_hash::FxHashMap;
use relative_path::RelativePathBuf;
use test_utils::tested_by;
use ra_db::FileId;
use ra_syntax::ast;
use relative_path::RelativePathBuf;
use rustc_hash::FxHashMap;
use test_utils::tested_by;
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,
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 {
@ -666,9 +663,9 @@ fn resolve_submodule(
mod tests {
use ra_db::SourceDatabase;
use crate::{Crate, mock::MockDatabase, DefDatabase};
use ra_arena::{Arena};
use super::*;
use crate::{mock::MockDatabase, Crate, DefDatabase};
use ra_arena::Arena;
use rustc_hash::FxHashSet;
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::{Arena, impl_arena_id, RawId, map::ArenaMap};
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
use ra_syntax::{
AstNode, SourceFile, AstPtr, TreeArc,
ast::{self, NameOwner, AttrsOwner},
ast::{self, AttrsOwner, NameOwner},
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).
///

View file

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

View file

@ -1,8 +1,11 @@
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)]
pub struct Path {

View file

@ -4,16 +4,19 @@ use std::sync::Arc;
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
ModuleDef, Trait, MacroDef,
code_model::Crate,
db::HirDatabase,
name::{Name, KnownName},
nameres::{PerNs, CrateDefMap, CrateModuleId},
generics::GenericParams,
expr::{scope::{ExprScopes, ScopeId}, PatId},
impl_block::ImplBlock,
path::Path,
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)]

View file

@ -7,21 +7,25 @@
/// purely for "IDE needs".
use std::sync::Arc;
use rustc_hash::{FxHashSet, FxHashMap};
use ra_db::{FileId, FilePosition};
use ra_syntax::{
SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange,
ast::{self, AstNode, NameOwner},
algo::find_node_at_offset,
ast::{self, AstNode, NameOwner},
AstPtr,
SyntaxKind::*,
SyntaxNode, SyntaxNodePtr, TextRange, TextUnit,
};
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, Path, MacroDef,
expr::{BodySourceMap, scope::{ScopeId, ExprScopes}},
expr,
expr::{
scope::{ExprScopes, ScopeId},
BodySourceMap,
},
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.

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_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast};
use ra_arena::{impl_arena_id, Arena, RawId};
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.
///

View file

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

View file

@ -12,17 +12,20 @@ mod lower;
mod infer;
pub(crate) mod display;
use std::sync::Arc;
use std::ops::Deref;
use std::sync::Arc;
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};
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 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;
/// 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 crate::{HirDatabase, Name, Resolver, HasGenericParams};
use super::{traits::Solution, Ty, Canonical};
use super::{traits::Solution, Canonical, Ty};
use crate::{HasGenericParams, HirDatabase, Name, Resolver};
const AUTODEREF_RECURSION_LIMIT: usize = 10;

View file

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

View file

@ -1,8 +1,8 @@
//! Unification and canonicalization logic.
use crate::db::HirDatabase;
use crate::ty::{Ty, Canonical, TraitRef, InferTy};
use super::InferenceContext;
use crate::db::HirDatabase;
use crate::ty::{Canonical, InferTy, TraitRef, Ty};
impl<'a, D: HirDatabase> InferenceContext<'a, 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.
//!
//! This usually involves resolving names, collecting generic arguments etc.
use std::sync::Arc;
use std::iter;
use std::sync::Arc;
use super::{FnSig, GenericPredicate, Substs, TraitRef, Ty, TypeCtor};
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,
Trait,
generics::{WherePredicate, GenericDef},
generics::HasGenericParams,
generics::{GenericDef, WherePredicate},
nameres::Namespace,
path::{GenericArg, PathSegment},
resolve::{Resolution, Resolver},
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 {
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 rustc_hash::FxHashMap;
use super::{autoderef, Canonical, TraitRef};
use crate::{
HirDatabase, Module, Crate, Name, Function, Trait,
impl_block::{ImplId, ImplBlock, ImplItem},
ty::{Ty, TypeCtor},
generics::HasGenericParams,
impl_block::{ImplBlock, ImplId, ImplItem},
nameres::CrateModuleId,
resolve::Resolver,
traits::TraitItem,
generics::HasGenericParams,
ty::primitive::{UncertainIntTy, UncertainFloatTy}
ty::primitive::{UncertainFloatTy, UncertainIntTy},
ty::{Ty, TypeCtor},
Crate, Function, HirDatabase, Module, Name, Trait,
};
use super::{TraitRef, Canonical, autoderef};
/// This is used as a key for indexing impls.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

View file

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

View file

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

View file

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

View file

@ -3,20 +3,25 @@ use std::sync::Arc;
use log::debug;
use chalk_ir::{TypeId, ImplId, TypeKindId, Parameter, Identifier, cast::Cast, PlaceholderIndex, UniverseIndex, TypeName};
use chalk_rust_ir::{AssociatedTyDatum, TraitDatum, StructDatum, ImplDatum};
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_ir::{
cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName,
UniverseIndex,
};
use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
use ra_db::salsa::{InternId, InternKey};
use test_utils::tested_by;
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.
const UNKNOWN_TRAIT: chalk_ir::TraitId =

View file

@ -4,7 +4,12 @@ use std::sync::Arc;
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)]
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;

View file

@ -1,12 +1,12 @@
use test_utils::tested_by;
use ra_db::SourceDatabase;
use ra_syntax::{
AstNode, SyntaxNode, TextUnit,
ast::{self, ArgListOwner},
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.
pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {

View file

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

View file

@ -14,19 +14,19 @@ mod complete_postfix;
use ra_db::SourceDatabase;
use crate::{
db,
FilePosition,
completion::{
completion_item::{Completions, CompletionKind},
completion_context::CompletionContext,
},
};
#[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.
///

View file

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

View file

@ -1,11 +1,10 @@
use ra_syntax::{
algo::visit::{visitor_ctx, VisitorCtx},
ast,
AstNode,
ast, AstNode,
};
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
/// functions in a file have a `spam: &mut Spam` parameter, a completion with

View file

@ -1,11 +1,14 @@
use ra_syntax::{
algo::visit::{visitor, Visitor},
AstNode,
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) {
// 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 test_utils::tested_by;
use crate::completion::{Completions, CompletionContext};
use crate::completion::{CompletionContext, Completions};
pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
let path = match &ctx.path_prefix {
@ -78,7 +78,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
mod tests {
use test_utils::covers;
use crate::completion::{CompletionKind, do_completion, CompletionItem};
use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches;
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)]
mod tests {
use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches;
use crate::completion::{CompletionItem, CompletionKind, do_completion};
fn complete(code: &str) -> Vec<CompletionItem> {
do_completion(code, CompletionKind::Reference)

View file

@ -1,18 +1,11 @@
use crate::{
completion::{
completion_item::{
Completions,
Builder,
CompletionKind,
},
completion_context::CompletionContext,
completion_item::{Builder, CompletionKind, Completions},
},
CompletionItem
};
use ra_syntax::{
ast::AstNode,
TextRange
CompletionItem,
};
use ra_syntax::{ast::AstNode, TextRange};
use ra_text_edit::TextEditBuilder;
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)]
mod tests {
use crate::completion::{CompletionKind, check_completion};
use crate::completion::{check_completion, CompletionKind};
fn check_snippet_completion(test_name: &str, code: &str) {
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_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) {
if ctx.is_trivial_path {
@ -121,7 +121,7 @@ impl ImportResolver {
#[cfg(test)]
mod tests {
use crate::completion::{CompletionKind, check_completion};
use crate::completion::{check_completion, CompletionKind};
fn check_reference_completion(name: &str, code: &str) {
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 {
CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label)
@ -36,7 +39,7 @@ fn ${1:feature}() {
#[cfg(test)]
mod tests {
use crate::completion::{CompletionKind, check_completion};
use crate::completion::{check_completion, CompletionKind};
fn check_snippet_completion(name: &str, code: &str) {
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)]
mod tests {
use crate::completion::{do_completion, CompletionItem, CompletionKind};
use insta::assert_debug_snapshot_matches;
use crate::completion::{CompletionItem, CompletionKind, do_completion};
fn complete(code: &str) -> Vec<CompletionItem> {
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 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};

View file

@ -2,7 +2,7 @@ use std::fmt;
use hir::Documentation;
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.
/// It is basically a POD with various properties. To construct a
@ -285,8 +285,8 @@ impl Into<Vec<CompletionItem>> for Completions {
#[cfg(test)]
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::mock_analysis::{analysis_and_position, single_file_with_position};
let (analysis, position) = if code.contains("//-") {
analysis_and_position(code)
} else {

View file

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

View file

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

View file

@ -1,17 +1,20 @@
use std::cell::RefCell;
use itertools::Itertools;
use hir::{source_binder, diagnostics::{Diagnostic as _, DiagnosticSink}};
use ra_db::SourceDatabase;
use ra_syntax::{
T, Location, TextRange, SyntaxNode,
ast::{self, AstNode, NamedFieldList, NamedField},
use hir::{
diagnostics::{Diagnostic as _, DiagnosticSink},
source_binder,
};
use ra_assists::ast_editor::{AstEditor, AstBuilder};
use ra_text_edit::{TextEdit, TextEditBuilder};
use itertools::Itertools;
use ra_assists::ast_editor::{AstBuilder, AstEditor};
use ra_db::SourceDatabase;
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)]
pub enum Severity {
@ -170,9 +173,9 @@ fn check_struct_shorthand_initialization(
#[cfg(test)]
mod tests {
use test_utils::assert_eq_text;
use insta::assert_debug_snapshot_matches;
use ra_syntax::SourceFile;
use test_utils::assert_eq_text;
use crate::mock_analysis::single_file;

View file

@ -6,14 +6,17 @@ mod navigation_target;
mod structure;
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 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 navigation_target::{docs_from_symbol, description_from_symbol};
pub(crate) fn function_label(node: &ast::FnDef) -> String {
FunctionSignature::from(node).to_string()

View file

@ -1,11 +1,14 @@
use std::fmt::{self, Display};
use hir::{Docs, Documentation, HasSource};
use join_to_string::join;
use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
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
#[derive(Debug)]

View file

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

View file

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

View file

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

View file

@ -1,13 +1,13 @@
use ra_db::SourceDatabase;
use ra_syntax::{
Direction, SyntaxNode, TextRange, TextUnit, SyntaxElement,
algo::{find_covering_element, find_token_at_offset, TokenAtOffset},
SyntaxKind::*, SyntaxToken,
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
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)]
mod tests {
use ra_syntax::{SourceFile, AstNode};
use ra_syntax::{AstNode, SourceFile};
use test_utils::extract_offset;
use super::*;

View file

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

View file

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

View file

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

View file

@ -1,16 +1,22 @@
use hir::{HasSource, HirDisplay};
use ra_db::SourceDatabase;
use ra_syntax::{
AstNode, TreeArc,
algo::{
ancestors_at_offset, find_covering_element, find_node_at_offset,
visit::{visitor, Visitor},
},
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::{
db::RootDatabase,
RangeInfo, FilePosition, FileRange,
display::{rust_code_markup, rust_code_markup_with_doc, ShortLabel, docs_from_symbol, description_from_symbol},
name_ref_kind::{NameRefKind::*, classify_name_ref},
display::{
description_from_symbol, docs_from_symbol, rust_code_markup, rust_code_markup_with_doc,
ShortLabel,
},
name_ref_kind::{classify_name_ref, NameRefKind::*},
FilePosition, FileRange, RangeInfo,
};
/// 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)]
mod tests {
use crate::mock_analysis::{
analysis_and_position, single_file_with_position, single_file_with_range,
};
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 {
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 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(
db: &RootDatabase,

View file

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

View file

@ -46,33 +46,35 @@ mod test_utils;
use std::sync::Arc;
use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit};
use ra_text_edit::TextEdit;
use ra_db::{
SourceDatabase, CheckCanceled,
salsa::{self, ParallelDatabase},
CheckCanceled, SourceDatabase,
};
use ra_syntax::{SourceFile, TextRange, TextUnit, TreeArc};
use ra_text_edit::TextEdit;
use relative_path::RelativePathBuf;
use crate::{symbol_index::FileSymbol, db::LineIndexDatabase};
use crate::{db::LineIndexDatabase, symbol_index::FileSymbol};
pub use crate::{
assists::{Assist, AssistId},
change::{AnalysisChange, LibraryData},
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,
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 ra_db::{
Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId,
};
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 {
use super::*;
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]
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_syntax::{TextUnit, TextRange};
use crate::{LineIndex, LineCol, line_index::Utf16Char};
#[derive(Debug, Clone)]
enum Step {
@ -292,8 +292,8 @@ pub fn translate_offset_with_edit(
#[cfg(test)]
mod test {
use super::*;
use proptest::{prelude::*, proptest};
use crate::line_index;
use proptest::{prelude::*, proptest};
use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit};
use ra_text_edit::TextEdit;

View file

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

View file

@ -3,7 +3,10 @@ use std::sync::Arc;
use relative_path::RelativePathBuf;
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
/// from a set of in-memory files.

View file

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

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