From 6be50f7d5de3737464853a589673375fc0cafa97 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 31 Oct 2018 23:41:43 +0300 Subject: Reformat all --- crates/ra_analysis/src/descriptors/function/imp.rs | 12 +++------ crates/ra_analysis/src/descriptors/function/mod.rs | 29 +++++++++++----------- .../ra_analysis/src/descriptors/function/scope.rs | 7 ++---- 3 files changed, 20 insertions(+), 28 deletions(-) (limited to 'crates/ra_analysis/src/descriptors/function') diff --git a/crates/ra_analysis/src/descriptors/function/imp.rs b/crates/ra_analysis/src/descriptors/function/imp.rs index 0a006f733..11fffeefc 100644 --- a/crates/ra_analysis/src/descriptors/function/imp.rs +++ b/crates/ra_analysis/src/descriptors/function/imp.rs @@ -1,14 +1,10 @@ use std::sync::Arc; -use ra_syntax::{ - ast::{AstNode, FnDef, FnDefNode}, -}; +use ra_syntax::ast::{AstNode, FnDef, FnDefNode}; -use crate::{ - descriptors::{ - DescriptorDatabase, - function::{FnId, FnScopes}, - }, +use crate::descriptors::{ + function::{FnId, FnScopes}, + DescriptorDatabase, }; /// Resolve `FnId` to the corresponding `SyntaxNode` diff --git a/crates/ra_analysis/src/descriptors/function/mod.rs b/crates/ra_analysis/src/descriptors/function/mod.rs index ae40f3e8f..d5db28a64 100644 --- a/crates/ra_analysis/src/descriptors/function/mod.rs +++ b/crates/ra_analysis/src/descriptors/function/mod.rs @@ -1,20 +1,16 @@ pub(super) mod imp; mod scope; -use std::cmp::{min, max}; +use std::cmp::{max, min}; use ra_syntax::{ ast::{self, AstNode, DocCommentsOwner, NameOwner}, - TextRange, TextUnit + TextRange, TextUnit, }; -use crate::{ - FileId, - syntax_ptr::SyntaxPtr -}; - -pub(crate) use self::scope::{FnScopes, resolve_local_name}; +use crate::{syntax_ptr::SyntaxPtr, FileId}; +pub(crate) use self::scope::{resolve_local_name, FnScopes}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub(crate) struct FnId(SyntaxPtr); @@ -26,14 +22,13 @@ impl FnId { } } - #[derive(Debug, Clone)] pub struct FnDescriptor { pub name: String, pub label: String, pub ret_type: Option, pub params: Vec, - pub doc: Option + pub doc: Option, } impl FnDescriptor { @@ -57,7 +52,9 @@ impl FnDescriptor { }; if let Some((comment_range, docs)) = FnDescriptor::extract_doc_comments(node) { - let comment_range = comment_range.checked_sub(node.syntax().range().start()).unwrap(); + let comment_range = comment_range + .checked_sub(node.syntax().range().start()) + .unwrap(); let start = comment_range.start().to_usize(); let end = comment_range.end().to_usize(); @@ -94,7 +91,7 @@ impl FnDescriptor { ret_type, params, label: label.trim().to_owned(), - doc + doc, }) } @@ -105,10 +102,13 @@ impl FnDescriptor { let comment_text = node.doc_comment_text(); - let (begin, end) = node.doc_comments() + let (begin, end) = node + .doc_comments() .map(|comment| comment.syntax().range()) .map(|range| (range.start().to_usize(), range.end().to_usize())) - .fold((std::usize::MAX, std::usize::MIN), |acc, range| (min(acc.0, range.0), max(acc.1, range.1))); + .fold((std::usize::MAX, std::usize::MIN), |acc, range| { + (min(acc.0, range.0), max(acc.1, range.1)) + }); let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end)); @@ -134,4 +134,3 @@ impl FnDescriptor { res } } - diff --git a/crates/ra_analysis/src/descriptors/function/scope.rs b/crates/ra_analysis/src/descriptors/function/scope.rs index d9929414c..62b46ffba 100644 --- a/crates/ra_analysis/src/descriptors/function/scope.rs +++ b/crates/ra_analysis/src/descriptors/function/scope.rs @@ -51,9 +51,7 @@ impl FnScopes { &self.get(scope).entries } pub fn scope_chain<'a>(&'a self, node: SyntaxNodeRef) -> impl Iterator + 'a { - generate(self.scope_for(node), move |&scope| { - self.get(scope).parent - }) + generate(self.scope_for(node), move |&scope| self.get(scope).parent) } fn root_scope(&mut self) -> ScopeId { let res = ScopeId(self.scopes.len() as u32); @@ -273,13 +271,12 @@ pub fn resolve_local_name<'a>( #[cfg(test)] mod tests { + use ra_editor::find_node_at_offset; use ra_syntax::File; use test_utils::extract_offset; - use ra_editor::{find_node_at_offset}; use super::*; - fn do_check(code: &str, expected: &[&str]) { let (off, code) = extract_offset(code); let code = { -- cgit v1.2.3