mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Folding range for return types
This commit is contained in:
parent
bca00ac340
commit
156d995423
2 changed files with 16 additions and 0 deletions
|
@ -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) }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue