1
1
mirror of https://github.com/oxalica/nil.git synced 2024-11-21 15:56:00 +03:00

Enforce merging of "use" stmts

This commit is contained in:
oxalica 2022-08-02 03:27:55 +08:00
parent bc9dc1546f
commit 675c3ab022
14 changed files with 42 additions and 52 deletions

View File

@ -2,7 +2,9 @@ use indexmap::IndexMap;
use lsp_types::Url;
use nil::{Change, FileId, FilePos};
use std::collections::HashMap;
use std::{fmt, mem, path::PathBuf, sync::Arc};
use std::path::PathBuf;
use std::sync::Arc;
use std::{fmt, mem};
use text_size::TextSize;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

1
rustfmt.toml Normal file
View File

@ -0,0 +1 @@
imports_granularity = "Module"

View File

@ -1,6 +1,7 @@
use rowan::{TextRange, TextSize};
use salsa::Durability;
use std::{fmt, sync::Arc};
use std::fmt;
use std::sync::Arc;
use syntax::Parse;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

View File

@ -9,10 +9,8 @@ use rowan::ast::AstNode;
use rowan::TextRange;
use smol_str::SmolStr;
use std::str;
use syntax::{
ast::{self, HasBindings, HasStringParts, LiteralKind},
Parse,
};
use syntax::ast::{self, HasBindings, HasStringParts, LiteralKind};
use syntax::Parse;
pub(super) fn lower(parse: InFile<Parse>) -> (Module, ModuleSourceMap) {
let diagnostics = parse

View File

@ -4,14 +4,14 @@ mod scope;
#[cfg(test)]
mod tests;
use crate::{
base::SourceDatabase,
{Diagnostic, FileId},
};
use crate::base::SourceDatabase;
use crate::{Diagnostic, FileId};
use la_arena::{Arena, ArenaMap, Idx};
use ordered_float::OrderedFloat;
use smol_str::SmolStr;
use std::{collections::HashMap, ops, sync::Arc};
use std::collections::HashMap;
use std::ops;
use std::sync::Arc;
pub use self::scope::{ModuleScopes, ResolveResult, ScopeData, ScopeId};
pub use syntax::ast::{BinaryOpKind as BinaryOp, UnaryOpKind as UnaryOp};

View File

@ -2,7 +2,9 @@ use super::{BindingKey, BindingValue, Bindings, DefDatabase, Expr, ExprId, Modul
use crate::{builtin, FileId};
use la_arena::{Arena, ArenaMap, Idx};
use smol_str::SmolStr;
use std::{collections::HashMap, iter, ops, sync::Arc};
use std::collections::HashMap;
use std::sync::Arc;
use std::{iter, ops};
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct ModuleScopes {
@ -208,10 +210,8 @@ impl ScopeData {
#[cfg(test)]
mod tests {
use super::ScopeKind;
use crate::{
def::{AstPtr, DefDatabase, ResolveResult, SourceDatabase},
tests::TestDB,
};
use crate::def::{AstPtr, DefDatabase, ResolveResult, SourceDatabase};
use crate::tests::TestDB;
use expect_test::{expect, Expect};
use rowan::ast::AstNode;
use syntax::{ast, match_ast};

View File

@ -1,8 +1,5 @@
use crate::{
builtin,
def::{AstPtr, DefDatabase},
FileId,
};
use crate::def::{AstPtr, DefDatabase};
use crate::{builtin, FileId};
use rowan::ast::AstNode;
use smol_str::SmolStr;
use syntax::{ast, match_ast, SyntaxKind, TextRange, TextSize, T};

View File

@ -1,9 +1,8 @@
use super::NavigationTarget;
use crate::{
def::{AstPtr, DefDatabase, ResolveResult},
FileId,
};
use rowan::{ast::AstNode, TextSize};
use crate::def::{AstPtr, DefDatabase, ResolveResult};
use crate::FileId;
use rowan::ast::AstNode;
use rowan::TextSize;
use syntax::{ast, match_ast, SyntaxKind, T};
pub(crate) fn goto_definition(

View File

@ -1,7 +1,9 @@
mod completion;
mod goto_definition;
use crate::{base::SourceDatabaseStorage, def::DefDatabaseStorage, Change, FileId, FilePos};
use crate::base::SourceDatabaseStorage;
use crate::def::DefDatabaseStorage;
use crate::{Change, FileId, FilePos};
use rowan::TextRange;
use salsa::{Cancelled, Database, Durability, ParallelDatabase};
use std::fmt;

View File

@ -1,7 +1,8 @@
use crate::base::{SourceDatabase, SourceDatabaseStorage};
use crate::def::DefDatabaseStorage;
use crate::{Change, FileId};
use rowan::{ast::AstNode, TextSize};
use rowan::ast::AstNode;
use rowan::TextSize;
use std::ops;
use syntax::{NixLanguage, SyntaxNode};

View File

@ -1,13 +1,7 @@
use super::{
NixLanguage,
SyntaxKind::{self, *},
SyntaxNode, SyntaxToken,
};
use crate::SyntaxElementChildren;
use rowan::ast::{
support::{child, children, token},
AstChildren, AstNode,
};
use crate::SyntaxKind::{self, *};
use crate::{NixLanguage, SyntaxElementChildren, SyntaxNode, SyntaxToken};
use rowan::ast::support::{child, children, token};
use rowan::ast::{AstChildren, AstNode};
use rowan::NodeOrToken;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]

View File

@ -1,10 +1,8 @@
use crate::SyntaxKind::{self, *};
use once_cell::sync::Lazy;
use regex_automata::{
dfa::{dense, Automaton},
nfa::thompson,
SyntaxConfig,
};
use regex_automata::dfa::{dense, Automaton};
use regex_automata::nfa::thompson;
use regex_automata::SyntaxConfig;
use rowan::{TextRange, TextSize};
use std::ptr;

View File

@ -10,8 +10,7 @@ mod tests;
use core::fmt;
pub use rowan;
pub use rowan::{TextRange, TextSize};
pub use rowan::{self, TextRange, TextSize};
pub use self::kind::SyntaxKind;
pub use self::parser::{parse_file, Parse};

View File

@ -1,10 +1,8 @@
use crate::{
ast::SourceFile,
lexer, Error,
SyntaxKind::{self, *},
SyntaxNode,
};
use rowan::{ast::AstNode, Checkpoint, GreenNode, GreenNodeBuilder, TextSize};
use crate::ast::SourceFile;
use crate::SyntaxKind::{self, *};
use crate::{lexer, Error, SyntaxNode};
use rowan::ast::AstNode;
use rowan::{Checkpoint, GreenNode, GreenNodeBuilder, TextSize};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Parse {