aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/mod.rs16
1 files changed, 11 insertions, 5 deletions
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