mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
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:
parent
2b2cd829b0
commit
1834bae5b8
166 changed files with 798 additions and 814 deletions
|
@ -2,7 +2,7 @@ pub mod visit;
|
|||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{SyntaxNode, TextRange, TextUnit, AstNode, Direction, SyntaxToken, SyntaxElement};
|
||||
use crate::{AstNode, Direction, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit};
|
||||
|
||||
pub use rowan::TokenAtOffset;
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@ mod expr_extensions;
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::{
|
||||
syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, SyntaxToken},
|
||||
syntax_node::{SyntaxNode, SyntaxNodeChildren, SyntaxToken, TreeArc},
|
||||
SmolStr,
|
||||
};
|
||||
|
||||
pub use self::{
|
||||
expr_extensions::{ArrayExprKind, BinOp, ElseBranch, LiteralKind, PrefixOp},
|
||||
extensions::{FieldKind, PathSegmentKind, SelfParamKind, StructKind},
|
||||
generated::*,
|
||||
traits::*,
|
||||
tokens::*,
|
||||
extensions::{PathSegmentKind, StructKind,FieldKind, SelfParamKind},
|
||||
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind,ArrayExprKind},
|
||||
traits::*,
|
||||
};
|
||||
|
||||
/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! Various extension methods to ast Expr Nodes, which are hard to code-generate.
|
||||
|
||||
use crate::{
|
||||
SyntaxToken, SyntaxElement, SmolStr,
|
||||
ast::{self, AstNode, AstChildren, children, child_opt},
|
||||
ast::{self, child_opt, children, AstChildren, AstNode},
|
||||
SmolStr, SyntaxElement,
|
||||
SyntaxKind::*,
|
||||
T
|
||||
SyntaxToken, T,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
use itertools::Itertools;
|
||||
|
||||
use crate::{
|
||||
SmolStr, SyntaxToken,
|
||||
ast::{self, AstNode, children, child_opt},
|
||||
ast::{self, child_opt, children, AstNode},
|
||||
SmolStr, SyntaxElement,
|
||||
SyntaxKind::*,
|
||||
SyntaxElement, T,
|
||||
SyntaxToken, T,
|
||||
};
|
||||
use ra_parser::SyntaxKind;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! There are many AstNodes, but only a few tokens, so we hand-write them here.
|
||||
|
||||
use crate::{
|
||||
SyntaxToken,
|
||||
SyntaxKind::{COMMENT, WHITESPACE},
|
||||
ast::AstToken,
|
||||
SyntaxKind::{COMMENT, WHITESPACE},
|
||||
SyntaxToken,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
@ -61,7 +61,7 @@ pub enum CommentPlacement {
|
|||
}
|
||||
|
||||
const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = {
|
||||
use {CommentShape::*, CommentPlacement::*};
|
||||
use {CommentPlacement::*, CommentShape::*};
|
||||
&[
|
||||
("///", CommentKind { shape: Line, doc: Some(Outer) }),
|
||||
("//!", CommentKind { shape: Line, doc: Some(Inner) }),
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
use itertools::Itertools;
|
||||
|
||||
use crate::{
|
||||
syntax_node::{SyntaxNodeChildren, SyntaxElementChildren},
|
||||
ast::{self, child_opt, children, AstNode, AstToken, AstChildren},
|
||||
ast::{self, child_opt, children, AstChildren, AstNode, AstToken},
|
||||
syntax_node::{SyntaxElementChildren, SyntaxNodeChildren},
|
||||
};
|
||||
|
||||
pub trait TypeAscriptionOwner: AstNode {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{SourceFile, validation, TextUnit, TextRange, AstNode};
|
||||
use crate::{validation, AstNode, SourceFile, TextRange, TextUnit};
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
use std::str::{self, FromStr};
|
||||
|
||||
|
|
|
@ -31,23 +31,26 @@ pub mod ast;
|
|||
#[doc(hidden)]
|
||||
pub mod fuzz;
|
||||
|
||||
use std::{sync::Arc, fmt::Write};
|
||||
use std::{fmt::Write, sync::Arc};
|
||||
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
|
||||
use crate::syntax_node::GreenNode;
|
||||
|
||||
pub use rowan::{SmolStr, TextRange, TextUnit};
|
||||
pub use ra_parser::SyntaxKind;
|
||||
pub use ra_parser::T;
|
||||
pub use crate::{
|
||||
ast::AstNode,
|
||||
syntax_error::{SyntaxError, SyntaxErrorKind, Location},
|
||||
parsing::{classify_literal, tokenize, Token},
|
||||
ptr::{AstPtr, SyntaxNodePtr},
|
||||
syntax_error::{Location, SyntaxError, SyntaxErrorKind},
|
||||
syntax_node::{
|
||||
Direction, InsertPosition, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder,
|
||||
TreeArc, WalkEvent,
|
||||
},
|
||||
syntax_text::SyntaxText,
|
||||
syntax_node::{Direction, SyntaxNode, WalkEvent, TreeArc, SyntaxTreeBuilder, SyntaxElement, SyntaxToken, InsertPosition},
|
||||
ptr::{SyntaxNodePtr, AstPtr},
|
||||
parsing::{tokenize, classify_literal, Token},
|
||||
};
|
||||
pub use ra_parser::SyntaxKind;
|
||||
pub use ra_parser::T;
|
||||
pub use rowan::{SmolStr, TextRange, TextUnit};
|
||||
|
||||
/// `Parse` is the result of the parsing: a syntax tree and a collection of
|
||||
/// errors.
|
||||
|
|
|
@ -6,12 +6,9 @@ mod text_token_source;
|
|||
mod text_tree_sink;
|
||||
mod reparsing;
|
||||
|
||||
use crate::{
|
||||
SyntaxError,
|
||||
syntax_node::GreenNode,
|
||||
};
|
||||
use crate::{syntax_node::GreenNode, SyntaxError};
|
||||
|
||||
pub use self::lexer::{tokenize, classify_literal, Token};
|
||||
pub use self::lexer::{classify_literal, tokenize, Token};
|
||||
|
||||
pub(crate) use self::reparsing::incremental_reparse;
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ mod strings;
|
|||
|
||||
use crate::{
|
||||
SyntaxKind::{self, *},
|
||||
TextUnit,
|
||||
T,
|
||||
TextUnit, T,
|
||||
};
|
||||
|
||||
use self::{
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
use crate::parsing::lexer::{
|
||||
ptr::Ptr,
|
||||
classes::*,
|
||||
};
|
||||
use crate::parsing::lexer::{classes::*, ptr::Ptr};
|
||||
|
||||
use crate::SyntaxKind::{self, *};
|
||||
|
||||
|
|
|
@ -6,19 +6,20 @@
|
|||
//! - otherwise, we search for the nearest `{}` block which contains the edit
|
||||
//! and try to parse only this block.
|
||||
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
use ra_parser::Reparser;
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
|
||||
use crate::{
|
||||
SyntaxKind::*, TextRange, TextUnit, SyntaxError,
|
||||
algo,
|
||||
syntax_node::{GreenNode, SyntaxNode, GreenToken, SyntaxElement},
|
||||
parsing::{
|
||||
lexer::{tokenize, Token},
|
||||
text_token_source::TextTokenSource,
|
||||
text_tree_sink::TextTreeSink,
|
||||
lexer::{tokenize, Token},
|
||||
},
|
||||
T,
|
||||
syntax_node::{GreenNode, GreenToken, SyntaxElement, SyntaxNode},
|
||||
SyntaxError,
|
||||
SyntaxKind::*,
|
||||
TextRange, TextUnit, T,
|
||||
};
|
||||
|
||||
pub(crate) fn incremental_reparse(
|
||||
|
@ -168,10 +169,10 @@ fn merge_errors(
|
|||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use test_utils::{extract_range, assert_eq_text};
|
||||
use test_utils::{assert_eq_text, extract_range};
|
||||
|
||||
use crate::{SourceFile, AstNode, Parse};
|
||||
use super::*;
|
||||
use crate::{AstNode, Parse, SourceFile};
|
||||
|
||||
fn do_check(before: &str, replace_with: &str, reparsed_len: u32) {
|
||||
let (range, before) = extract_range(before);
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
use ra_parser::TokenSource;
|
||||
use ra_parser::Token as PToken;
|
||||
use ra_parser::TokenSource;
|
||||
|
||||
use crate::{
|
||||
SyntaxKind::EOF, TextRange, TextUnit,
|
||||
parsing::lexer::Token,
|
||||
};
|
||||
use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextUnit};
|
||||
|
||||
pub(crate) struct TextTokenSource<'t> {
|
||||
text: &'t str,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::mem;
|
||||
|
||||
use ra_parser::{TreeSink, ParseError};
|
||||
use ra_parser::{ParseError, TreeSink};
|
||||
|
||||
use crate::{
|
||||
SmolStr, SyntaxError, TextUnit, TextRange, SyntaxTreeBuilder,
|
||||
SyntaxKind::{self, *},
|
||||
parsing::Token,
|
||||
syntax_node::GreenNode,
|
||||
SmolStr, SyntaxError,
|
||||
SyntaxKind::{self, *},
|
||||
SyntaxTreeBuilder, TextRange, TextUnit,
|
||||
};
|
||||
|
||||
/// Bridges the parser with our specific syntax tree representation.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
use std::{
|
||||
marker::PhantomData,
|
||||
iter::successors,
|
||||
};
|
||||
use crate::{
|
||||
AstNode, SyntaxKind, SyntaxNode, TextRange,
|
||||
};
|
||||
use crate::{AstNode, SyntaxKind, SyntaxNode, TextRange};
|
||||
use std::{iter::successors, marker::PhantomData};
|
||||
|
||||
/// A pointer to a syntax node inside a file. It can be used to remember a
|
||||
/// specific node across reparses of the same file.
|
||||
|
|
|
@ -2,10 +2,7 @@ use std::fmt;
|
|||
|
||||
use ra_parser::ParseError;
|
||||
|
||||
use crate::{
|
||||
TextRange, TextUnit,
|
||||
validation::EscapeError,
|
||||
};
|
||||
use crate::{validation::EscapeError, TextRange, TextUnit};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SyntaxError {
|
||||
|
|
|
@ -7,18 +7,18 @@
|
|||
//! modules just wraps its API.
|
||||
|
||||
use std::{
|
||||
ops::RangeInclusive,
|
||||
fmt::{self, Write},
|
||||
borrow::Borrow,
|
||||
fmt::{self, Write},
|
||||
iter::successors,
|
||||
ops::RangeInclusive,
|
||||
};
|
||||
|
||||
use ra_parser::ParseError;
|
||||
use rowan::{TransparentNewType, GreenNodeBuilder};
|
||||
use rowan::{GreenNodeBuilder, TransparentNewType};
|
||||
|
||||
use crate::{
|
||||
SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode, SyntaxNodePtr,
|
||||
syntax_error::{SyntaxError, SyntaxErrorKind},
|
||||
AstNode, SmolStr, SourceFile, SyntaxKind, SyntaxNodePtr, SyntaxText, TextRange, TextUnit,
|
||||
};
|
||||
|
||||
pub use rowan::WalkEvent;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
use std::{fmt, ops::{self, Bound}};
|
||||
use std::{
|
||||
fmt,
|
||||
ops::{self, Bound},
|
||||
};
|
||||
|
||||
use crate::{SmolStr, SyntaxNode, TextRange, TextUnit, SyntaxElement};
|
||||
use crate::{SmolStr, SyntaxElement, SyntaxNode, TextRange, TextUnit};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SyntaxText<'a> {
|
||||
|
|
|
@ -4,11 +4,10 @@ mod block;
|
|||
mod field_expr;
|
||||
|
||||
use crate::{
|
||||
SourceFile, SyntaxError, AstNode, SyntaxNode, TextUnit,
|
||||
SyntaxKind::{BYTE, BYTE_STRING, STRING, CHAR},
|
||||
ast,
|
||||
algo::visit::{visitor_ctx, VisitorCtx},
|
||||
T,
|
||||
ast, AstNode, SourceFile, SyntaxError,
|
||||
SyntaxKind::{BYTE, BYTE_STRING, CHAR, STRING},
|
||||
SyntaxNode, TextUnit, T,
|
||||
};
|
||||
|
||||
pub(crate) use unescape::EscapeError;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use crate::{SyntaxKind::*,
|
||||
ast::{self, AttrsOwner, AstNode},
|
||||
use crate::{
|
||||
ast::{self, AstNode, AttrsOwner},
|
||||
SyntaxError,
|
||||
SyntaxErrorKind::*,
|
||||
SyntaxKind::*,
|
||||
};
|
||||
|
||||
pub(crate) fn validate_block_node(node: &ast::Block, errors: &mut Vec<SyntaxError>) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::{ast::{self, FieldKind},
|
||||
SyntaxError,
|
||||
SyntaxErrorKind::*,
|
||||
use crate::{
|
||||
ast::{self, FieldKind},
|
||||
SyntaxError,
|
||||
SyntaxErrorKind::*,
|
||||
};
|
||||
|
||||
pub(crate) fn validate_field_expr_node(node: &ast::FieldExpr, errors: &mut Vec<SyntaxError>) {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//!
|
||||
//! Hopefully, we'll share this code in a proper way some day
|
||||
|
||||
use std::str::Chars;
|
||||
use std::ops::Range;
|
||||
use std::str::Chars;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||
pub enum EscapeError {
|
||||
|
|
|
@ -4,11 +4,11 @@ extern crate walkdir;
|
|||
|
||||
use std::{
|
||||
fmt::Write,
|
||||
path::{PathBuf, Component},
|
||||
path::{Component, PathBuf},
|
||||
};
|
||||
|
||||
use test_utils::{project_dir, dir_tests, read_text, collect_tests};
|
||||
use ra_syntax::{SourceFile, fuzz};
|
||||
use ra_syntax::{fuzz, SourceFile};
|
||||
use test_utils::{collect_tests, dir_tests, project_dir, read_text};
|
||||
|
||||
#[test]
|
||||
fn lexer_tests() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue