From 1834bae5b86c54ed9dece26e82436919d59e6cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 4 Jul 2019 23:05:17 +0300 Subject: 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 --- crates/ra_lsp_server/src/caps.rs | 7 ++++--- crates/ra_lsp_server/src/cargo_target_spec.rs | 2 +- crates/ra_lsp_server/src/conv.rs | 14 +++++++------- crates/ra_lsp_server/src/lib.rs | 5 ++++- crates/ra_lsp_server/src/main.rs | 4 ++-- crates/ra_lsp_server/src/main_loop.rs | 9 ++++----- crates/ra_lsp_server/src/main_loop/handlers.rs | 21 ++++++++++----------- crates/ra_lsp_server/src/project_model.rs | 2 +- crates/ra_lsp_server/src/req.rs | 11 +++++------ crates/ra_lsp_server/src/vfs_filter.rs | 4 ++-- crates/ra_lsp_server/src/world.rs | 10 ++++------ crates/ra_lsp_server/tests/heavy_tests/main.rs | 12 +++++------- crates/ra_lsp_server/tests/heavy_tests/support.rs | 9 +++------ 13 files changed, 52 insertions(+), 58 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index 9095bee89..3851aadf2 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -1,8 +1,9 @@ use lsp_types::{ - CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, - ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability, + CodeActionProviderCapability, CodeLensOptions, CompletionOptions, + DocumentOnTypeFormattingOptions, ExecuteCommandOptions, FoldingRangeProviderCapability, + GenericCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, - TextDocumentSyncOptions, ImplementationProviderCapability, GenericCapability, TypeDefinitionProviderCapability + TextDocumentSyncOptions, TypeDefinitionProviderCapability, }; pub fn server_capabilities() -> ServerCapabilities { diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index 082ac8609..050c5fd95 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs @@ -1,7 +1,7 @@ use crate::{ project_model::{self, TargetKind}, world::WorldSnapshot, - Result + Result, }; use ra_ide_api::{FileId, RunnableKind}; diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 257492589..c8128f55b 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -1,13 +1,13 @@ use lsp_types::{ - self, CreateFile, Documentation, DocumentChangeOperation, DocumentChanges, Location, LocationLink, - MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, - TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, - WorkspaceEdit, + self, CreateFile, DocumentChangeOperation, DocumentChanges, Documentation, Location, + LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, SymbolKind, + TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url, + VersionedTextDocumentIdentifier, WorkspaceEdit, }; use ra_ide_api::{ - CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit, - NavigationTarget, SourceChange, SourceFileEdit, RangeInfo, - LineCol, LineIndex, translate_offset_with_edit, InsertTextFormat + translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, + FileRange, FileSystemEdit, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo, + SourceChange, SourceFileEdit, }; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs index 14cfa401f..56a263aa5 100644 --- a/crates/ra_lsp_server/src/lib.rs +++ b/crates/ra_lsp_server/src/lib.rs @@ -10,4 +10,7 @@ pub mod init; mod world; pub type Result = std::result::Result>; -pub use crate::{caps::server_capabilities, main_loop::main_loop, main_loop::LspError, init::InitializationOptions}; +pub use crate::{ + caps::server_capabilities, init::InitializationOptions, main_loop::main_loop, + main_loop::LspError, +}; diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 4aadb5ea8..6aa6dd49f 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -1,8 +1,8 @@ -use serde::Deserialize; use flexi_logger::{Duplicate, Logger}; use gen_lsp_server::{run_server, stdio_transport}; +use serde::Deserialize; -use ra_lsp_server::{Result, InitializationOptions}; +use ra_lsp_server::{InitializationOptions, Result}; use ra_prof; fn main() -> Result<()> { diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index aeb8a2299..cb73e6586 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -2,7 +2,7 @@ mod handlers; mod subscriptions; pub(crate) mod pending_requests; -use std::{fmt, path::PathBuf, sync::Arc, time::Instant, error::Error}; +use std::{error::Error, fmt, path::PathBuf, sync::Arc, time::Instant}; use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender}; use gen_lsp_server::{ @@ -10,21 +10,20 @@ use gen_lsp_server::{ }; use lsp_types::NumberOrString; use ra_ide_api::{Canceled, FileId, LibraryData}; +use ra_prof::profile; use ra_vfs::VfsTask; use serde::{de::DeserializeOwned, Serialize}; use threadpool::ThreadPool; -use ra_prof::profile; use crate::{ main_loop::{ + pending_requests::{PendingRequest, PendingRequests}, subscriptions::Subscriptions, - pending_requests::{PendingRequests, PendingRequest}, }, project_model::workspace_loader, req, world::{WorldSnapshot, WorldState}, - Result, - InitializationOptions, + InitializationOptions, Result, }; const THREADPOOL_SIZE: usize = 8; diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 47222cd0a..bbbc93b1c 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -1,22 +1,21 @@ -use std::{io::Write as _, fmt::Write as _}; +use std::{fmt::Write as _, io::Write as _}; use gen_lsp_server::ErrorCode; use lsp_types::{ - CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, CodeAction, - DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, - FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, - MarkupKind, Position, PrepareRenameResponse, Range, - RenameParams,SymbolInformation, TextDocumentIdentifier, TextEdit, - WorkspaceEdit, + CodeAction, CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, + DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind, + FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, + PrepareRenameResponse, Range, RenameParams, SymbolInformation, TextDocumentIdentifier, + TextEdit, WorkspaceEdit, }; use ra_ide_api::{ - FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, Cancelable, - AssistId, + AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, + RunnableKind, Severity, }; -use ra_syntax::{AstNode, SyntaxKind, TextUnit, TextRange}; use ra_prof::profile; +use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; use rustc_hash::FxHashMap; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use serde_json::to_value; use url_serde::Ser; diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index 7d6440fad..1130d08de 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -5,7 +5,7 @@ use thread_worker::Worker; use crate::Result; pub use ra_project_model::{ - ProjectWorkspace, CargoWorkspace, Package, Target, TargetKind, Sysroot, + CargoWorkspace, Package, ProjectWorkspace, Sysroot, Target, TargetKind, }; pub fn workspace_loader() -> Worker> { diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 992c24eac..27f2deb34 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -4,12 +4,11 @@ use serde::{Deserialize, Serialize}; use url_serde; pub use lsp_types::{ - notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams, - CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams, - DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, - PublishDiagnosticsParams, ReferenceParams, SignatureHelp, TextDocumentEdit, - TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, - MessageType, ShowMessageParams, + notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, + CodeLensParams, CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, + DocumentSymbolParams, DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, + MessageType, PublishDiagnosticsParams, ReferenceParams, ShowMessageParams, SignatureHelp, + TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, }; pub enum AnalyzerStatus {} diff --git a/crates/ra_lsp_server/src/vfs_filter.rs b/crates/ra_lsp_server/src/vfs_filter.rs index dd20c1203..e16a57da5 100644 --- a/crates/ra_lsp_server/src/vfs_filter.rs +++ b/crates/ra_lsp_server/src/vfs_filter.rs @@ -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 diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 7822e1c1c..fdc577622 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -3,22 +3,20 @@ use std::{ sync::Arc, }; +use gen_lsp_server::ErrorCode; use lsp_types::Url; +use parking_lot::RwLock; use ra_ide_api::{ - Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, - SourceRootId + Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId, }; use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot}; use relative_path::RelativePathBuf; -use parking_lot::RwLock; -use gen_lsp_server::ErrorCode; use crate::{ main_loop::pending_requests::{CompletedRequest, LatestRequests}, project_model::ProjectWorkspace, vfs_filter::IncludeRustFiles, - Result, - LspError, + LspError, Result, }; /// `WorldState` is the primary mutable state of the language server diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 40d825893..d271b02fc 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -1,16 +1,14 @@ mod support; -use std::{ - collections::HashMap, - time::Instant, -}; +use std::{collections::HashMap, time::Instant}; use lsp_types::{ - CodeActionContext, DocumentFormattingParams, FormattingOptions, Position, Range, DidOpenTextDocumentParams, TextDocumentItem, TextDocumentPositionParams + CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, + Position, Range, TextDocumentItem, TextDocumentPositionParams, }; use ra_lsp_server::req::{ - CodeActionParams, CodeActionRequest, Formatting, Runnables, RunnablesParams, CompletionParams, Completion, - DidOpenTextDocument, OnEnter, + CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, + Formatting, OnEnter, Runnables, RunnablesParams, }; use serde_json::json; use tempfile::TempDir; diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 75912afdd..a5e352da1 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -11,20 +11,17 @@ use flexi_logger::Logger; use gen_lsp_server::{RawMessage, RawNotification, RawRequest}; use lsp_types::{ notification::DidOpenTextDocument, + notification::{Notification, ShowMessage}, request::{Request, Shutdown}, DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url, - notification::{Notification, ShowMessage}, }; use serde::Serialize; use serde_json::{to_string_pretty, Value}; use tempfile::TempDir; +use test_utils::{find_mismatch, parse_fixture}; use thread_worker::Worker; -use test_utils::{parse_fixture, find_mismatch}; -use ra_lsp_server::{ - main_loop, req, - InitializationOptions, -}; +use ra_lsp_server::{main_loop, req, InitializationOptions}; pub struct Project<'a> { fixture: &'a str, -- cgit v1.2.3