Folding range for return types

This commit is contained in:
Ayomide Bamidele 2021-05-28 12:39:02 +01:00
parent bca00ac340
commit 156d995423
2 changed files with 16 additions and 0 deletions

View file

@ -19,6 +19,7 @@ pub enum FoldKind {
Statics, Statics,
Array, Array,
WhereClause, WhereClause,
ReturnType,
} }
#[derive(Debug)] #[derive(Debug)]
@ -131,6 +132,7 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
COMMENT => Some(FoldKind::Comment), COMMENT => Some(FoldKind::Comment),
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
ARRAY_EXPR => Some(FoldKind::Array), ARRAY_EXPR => Some(FoldKind::Array),
RET_TYPE => Some(FoldKind::ReturnType),
ASSOC_ITEM_LIST ASSOC_ITEM_LIST
| RECORD_FIELD_LIST | RECORD_FIELD_LIST
| RECORD_PAT_FIELD_LIST | RECORD_PAT_FIELD_LIST
@ -300,6 +302,7 @@ mod tests {
FoldKind::Statics => "statics", FoldKind::Statics => "statics",
FoldKind::Array => "array", FoldKind::Array => "array",
FoldKind::WhereClause => "whereclause", FoldKind::WhereClause => "whereclause",
FoldKind::ReturnType => "returntype",
}; };
assert_eq!(kind, &attr.unwrap()); assert_eq!(kind, &attr.unwrap());
} }
@ -560,4 +563,16 @@ where
"#, "#,
) )
} }
#[test]
fn fold_return_type() {
check(
r#"
fn foo()<fold returntype>-> (
bool,
bool,
)</fold> { (true, true) }
"#,
)
}
} }

View file

@ -534,6 +534,7 @@ pub(crate) fn folding_range(
| FoldKind::Consts | FoldKind::Consts
| FoldKind::Statics | FoldKind::Statics
| FoldKind::WhereClause | FoldKind::WhereClause
| FoldKind::ReturnType
| FoldKind::Array => None, | FoldKind::Array => None,
}; };