Merge #9038
9038: Folding range for return types r=Veykril a=MozarellaMan For issue #8957  Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
This commit is contained in:
@@ -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,18 @@ where
|
|||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fold_return_type() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
fn foo()<fold returntype>-> (
|
||||||
|
bool,
|
||||||
|
bool,
|
||||||
|
)</fold> { (true, true) }
|
||||||
|
|
||||||
|
fn bar() -> (bool, bool) { (true, true) }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user