diff options
author | Aleksey Kladov <[email protected]> | 2018-10-31 20:41:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-31 20:41:43 +0000 |
commit | 6be50f7d5de3737464853a589673375fc0cafa97 (patch) | |
tree | 2c6da7f3a1234c3f2fd3f330d2c9445953979598 /crates/ra_analysis/src/descriptors/function/mod.rs | |
parent | 857c1650efdb51650458f9ec1119adaa49b34371 (diff) |
Reformat all
Diffstat (limited to 'crates/ra_analysis/src/descriptors/function/mod.rs')
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/mod.rs | 29 |
1 files changed, 14 insertions, 15 deletions
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 @@ | |||
1 | pub(super) mod imp; | 1 | pub(super) mod imp; |
2 | mod scope; | 2 | mod scope; |
3 | 3 | ||
4 | use std::cmp::{min, max}; | 4 | use std::cmp::{max, min}; |
5 | 5 | ||
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | ast::{self, AstNode, DocCommentsOwner, NameOwner}, | 7 | ast::{self, AstNode, DocCommentsOwner, NameOwner}, |
8 | TextRange, TextUnit | 8 | TextRange, TextUnit, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{syntax_ptr::SyntaxPtr, FileId}; |
12 | FileId, | ||
13 | syntax_ptr::SyntaxPtr | ||
14 | }; | ||
15 | |||
16 | pub(crate) use self::scope::{FnScopes, resolve_local_name}; | ||
17 | 12 | ||
13 | pub(crate) use self::scope::{resolve_local_name, FnScopes}; | ||
18 | 14 | ||
19 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
20 | pub(crate) struct FnId(SyntaxPtr); | 16 | pub(crate) struct FnId(SyntaxPtr); |
@@ -26,14 +22,13 @@ impl FnId { | |||
26 | } | 22 | } |
27 | } | 23 | } |
28 | 24 | ||
29 | |||
30 | #[derive(Debug, Clone)] | 25 | #[derive(Debug, Clone)] |
31 | pub struct FnDescriptor { | 26 | pub struct FnDescriptor { |
32 | pub name: String, | 27 | pub name: String, |
33 | pub label: String, | 28 | pub label: String, |
34 | pub ret_type: Option<String>, | 29 | pub ret_type: Option<String>, |
35 | pub params: Vec<String>, | 30 | pub params: Vec<String>, |
36 | pub doc: Option<String> | 31 | pub doc: Option<String>, |
37 | } | 32 | } |
38 | 33 | ||
39 | impl FnDescriptor { | 34 | impl FnDescriptor { |
@@ -57,7 +52,9 @@ impl FnDescriptor { | |||
57 | }; | 52 | }; |
58 | 53 | ||
59 | if let Some((comment_range, docs)) = FnDescriptor::extract_doc_comments(node) { | 54 | if let Some((comment_range, docs)) = FnDescriptor::extract_doc_comments(node) { |
60 | let comment_range = comment_range.checked_sub(node.syntax().range().start()).unwrap(); | 55 | let comment_range = comment_range |
56 | .checked_sub(node.syntax().range().start()) | ||
57 | .unwrap(); | ||
61 | let start = comment_range.start().to_usize(); | 58 | let start = comment_range.start().to_usize(); |
62 | let end = comment_range.end().to_usize(); | 59 | let end = comment_range.end().to_usize(); |
63 | 60 | ||
@@ -94,7 +91,7 @@ impl FnDescriptor { | |||
94 | ret_type, | 91 | ret_type, |
95 | params, | 92 | params, |
96 | label: label.trim().to_owned(), | 93 | label: label.trim().to_owned(), |
97 | doc | 94 | doc, |
98 | }) | 95 | }) |
99 | } | 96 | } |
100 | 97 | ||
@@ -105,10 +102,13 @@ impl FnDescriptor { | |||
105 | 102 | ||
106 | let comment_text = node.doc_comment_text(); | 103 | let comment_text = node.doc_comment_text(); |
107 | 104 | ||
108 | let (begin, end) = node.doc_comments() | 105 | let (begin, end) = node |
106 | .doc_comments() | ||
109 | .map(|comment| comment.syntax().range()) | 107 | .map(|comment| comment.syntax().range()) |
110 | .map(|range| (range.start().to_usize(), range.end().to_usize())) | 108 | .map(|range| (range.start().to_usize(), range.end().to_usize())) |
111 | .fold((std::usize::MAX, std::usize::MIN), |acc, range| (min(acc.0, range.0), max(acc.1, range.1))); | 109 | .fold((std::usize::MAX, std::usize::MIN), |acc, range| { |
110 | (min(acc.0, range.0), max(acc.1, range.1)) | ||
111 | }); | ||
112 | 112 | ||
113 | let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end)); | 113 | let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end)); |
114 | 114 | ||
@@ -134,4 +134,3 @@ impl FnDescriptor { | |||
134 | res | 134 | res |
135 | } | 135 | } |
136 | } | 136 | } |
137 | |||