9038: Folding range for return types r=Veykril a=MozarellaMan

For issue #8957 

![return type fold](https://user-images.githubusercontent.com/48062697/119979082-5c62e100-bfb2-11eb-9729-1dea1ce74de1.gif)


Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
This commit is contained in:
bors[bot] 2021-05-28 12:16:18 +00:00 committed by GitHub
commit b5d41ba0e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

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

View File

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