aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-31 20:41:43 +0000
committerAleksey Kladov <[email protected]>2018-10-31 20:41:43 +0000
commit6be50f7d5de3737464853a589673375fc0cafa97 (patch)
tree2c6da7f3a1234c3f2fd3f330d2c9445953979598 /crates/ra_syntax
parent857c1650efdb51650458f9ec1119adaa49b34371 (diff)
Reformat all
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/algo/mod.rs5
-rw-r--r--crates/ra_syntax/src/ast/mod.rs16
-rw-r--r--crates/ra_syntax/src/lib.rs4
-rw-r--r--crates/ra_syntax/src/utils.rs4
4 files changed, 16 insertions, 13 deletions
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs
index f92529d3e..faf5a6211 100644
--- a/crates/ra_syntax/src/algo/mod.rs
+++ b/crates/ra_syntax/src/algo/mod.rs
@@ -1,10 +1,7 @@
1pub mod visit; 1pub mod visit;
2// pub mod walk; 2// pub mod walk;
3 3
4use crate::{ 4use crate::{text_utils::contains_offset_nonstrict, SyntaxNodeRef, TextRange, TextUnit};
5 text_utils::{contains_offset_nonstrict},
6 SyntaxNodeRef, TextRange, TextUnit,
7};
8 5
9pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffset { 6pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffset {
10 let range = node.range(); 7 let range = node.range();
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs
index 3aa11b9dd..688ffff47 100644
--- a/crates/ra_syntax/src/ast/mod.rs
+++ b/crates/ra_syntax/src/ast/mod.rs
@@ -66,7 +66,9 @@ pub trait AttrsOwner<'a>: AstNode<'a> {
66} 66}
67 67
68pub trait DocCommentsOwner<'a>: AstNode<'a> { 68pub trait DocCommentsOwner<'a>: AstNode<'a> {
69 fn doc_comments(self) -> AstChildren<'a, Comment<'a>> { children(self) } 69 fn doc_comments(self) -> AstChildren<'a, Comment<'a>> {
70 children(self)
71 }
70 72
71 /// Returns the textual content of a doc comment block as a single string. 73 /// Returns the textual content of a doc comment block as a single string.
72 /// That is, strips leading `///` and joins lines 74 /// That is, strips leading `///` and joins lines
@@ -74,12 +76,15 @@ pub trait DocCommentsOwner<'a>: AstNode<'a> {
74 self.doc_comments() 76 self.doc_comments()
75 .map(|comment| { 77 .map(|comment| {
76 let prefix = comment.prefix(); 78 let prefix = comment.prefix();
77 let trimmed = comment.text().as_str() 79 let trimmed = comment
80 .text()
81 .as_str()
78 .trim() 82 .trim()
79 .trim_start_matches(prefix) 83 .trim_start_matches(prefix)
80 .trim_start(); 84 .trim_start();
81 trimmed.to_owned() 85 trimmed.to_owned()
82 }).join("\n") 86 })
87 .join("\n")
83 } 88 }
84} 89}
85 90
@@ -250,7 +255,6 @@ impl<'a> IfExpr<'a> {
250 } 255 }
251} 256}
252 257
253
254#[derive(Debug, Clone, Copy)] 258#[derive(Debug, Clone, Copy)]
255pub enum PathSegmentKind<'a> { 259pub enum PathSegmentKind<'a> {
256 Name(NameRef<'a>), 260 Name(NameRef<'a>),
@@ -261,7 +265,9 @@ pub enum PathSegmentKind<'a> {
261 265
262impl<'a> PathSegment<'a> { 266impl<'a> PathSegment<'a> {
263 pub fn parent_path(self) -> Path<'a> { 267 pub fn parent_path(self) -> Path<'a> {
264 self.syntax().parent().and_then(Path::cast) 268 self.syntax()
269 .parent()
270 .and_then(Path::cast)
265 .expect("segments are always nested in paths") 271 .expect("segments are always nested in paths")
266 } 272 }
267 273
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 3698eccd7..79394fd53 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -52,7 +52,9 @@ pub use crate::{
52 reparsing::AtomEdit, 52 reparsing::AtomEdit,
53 rowan::{SmolStr, TextRange, TextUnit}, 53 rowan::{SmolStr, TextRange, TextUnit},
54 syntax_kinds::SyntaxKind, 54 syntax_kinds::SyntaxKind,
55 yellow::{Direction, OwnedRoot, RefRoot, SyntaxError, SyntaxNode, SyntaxNodeRef, TreeRoot, WalkEvent}, 55 yellow::{
56 Direction, OwnedRoot, RefRoot, SyntaxError, SyntaxNode, SyntaxNodeRef, TreeRoot, WalkEvent,
57 },
56}; 58};
57 59
58use crate::yellow::GreenNode; 60use crate::yellow::GreenNode;
diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs
index 8ee02724d..00f00139a 100644
--- a/crates/ra_syntax/src/utils.rs
+++ b/crates/ra_syntax/src/utils.rs
@@ -1,6 +1,4 @@
1use crate::{ 1use crate::{File, SyntaxKind, SyntaxNodeRef, WalkEvent};
2 File, SyntaxKind, SyntaxNodeRef, WalkEvent
3};
4use std::fmt::Write; 2use std::fmt::Write;
5 3
6/// Parse a file and create a string representation of the resulting parse tree. 4/// Parse a file and create a string representation of the resulting parse tree.