aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-01 14:19:47 +0000
committerGitHub <[email protected]>2019-11-01 14:19:47 +0000
commited5212e1ac71e959d802a9a7ad28d06c8b18e022 (patch)
treee0f1f37fe95f8607dbb7e12728535a68d7550121 /crates/ra_syntax/src
parent363718ba42d1eb906577a0a03c14248a0962a06a (diff)
parentdcc0a9cd7ed5521aa521920c4b67e149523beb7f (diff)
Merge #2150
2150: Attach docs to statics r=matklad a=kjeremy Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs14
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs2
2 files changed, 15 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index a12da5be2..1ec9881b9 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -113,6 +113,20 @@ fn test_doc_comment_of_items() {
113} 113}
114 114
115#[test] 115#[test]
116fn test_doc_comment_of_statics() {
117 let file = SourceFile::parse(
118 r#"
119 /// Number of levels
120 static LEVELS: i32 = 0;
121 "#,
122 )
123 .ok()
124 .unwrap();
125 let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap();
126 assert_eq!("Number of levels", st.doc_comment_text().unwrap());
127}
128
129#[test]
116fn test_doc_comment_preserves_indents() { 130fn test_doc_comment_preserves_indents() {
117 let file = SourceFile::parse( 131 let file = SourceFile::parse(
118 r#" 132 r#"
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index 142164316..c36756d6c 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -147,7 +147,7 @@ fn n_attached_trivias<'a>(
147) -> usize { 147) -> usize {
148 match kind { 148 match kind {
149 MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF 149 MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF
150 | TRAIT_DEF | MODULE | RECORD_FIELD_DEF => { 150 | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => {
151 let mut res = 0; 151 let mut res = 0;
152 for (i, (kind, text)) in trivias.enumerate() { 152 for (i, (kind, text)) in trivias.enumerate() {
153 match kind { 153 match kind {