mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 12:24:29 +00:00
Preserve order of generic args
This commit is contained in:
parent
9d473a0b9f
commit
4fa8749c44
39 changed files with 714 additions and 427 deletions
|
|
@ -22,7 +22,7 @@ pub use self::{
|
|||
generated::{nodes::*, tokens::*},
|
||||
node_ext::{
|
||||
AttrKind, FieldKind, Macro, NameLike, NameOrNameRef, PathSegmentKind, SelfParamKind,
|
||||
SlicePatComponents, StructKind, TypeBoundKind, VisibilityKind,
|
||||
SlicePatComponents, StructKind, TypeBoundKind, TypeOrConstParam, VisibilityKind,
|
||||
},
|
||||
operators::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp},
|
||||
token_ext::{CommentKind, CommentPlacement, CommentShape, IsString, QuoteOffsets, Radix},
|
||||
|
|
|
|||
|
|
@ -638,6 +638,21 @@ impl ast::TypeBound {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum TypeOrConstParam {
|
||||
Type(ast::TypeParam),
|
||||
Const(ast::ConstParam),
|
||||
}
|
||||
|
||||
impl TypeOrConstParam {
|
||||
pub fn name(&self) -> Option<ast::Name> {
|
||||
match self {
|
||||
TypeOrConstParam::Type(x) => x.name(),
|
||||
TypeOrConstParam::Const(x) => x.name(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum VisibilityKind {
|
||||
In(ast::Path),
|
||||
PubCrate,
|
||||
|
|
@ -746,16 +761,11 @@ impl ast::GenericParamList {
|
|||
ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None,
|
||||
})
|
||||
}
|
||||
pub fn type_params(&self) -> impl Iterator<Item = ast::TypeParam> {
|
||||
pub fn type_or_const_params(&self) -> impl Iterator<Item = ast::TypeOrConstParam> {
|
||||
self.generic_params().filter_map(|param| match param {
|
||||
ast::GenericParam::TypeParam(it) => Some(it),
|
||||
ast::GenericParam::LifetimeParam(_) | ast::GenericParam::ConstParam(_) => None,
|
||||
})
|
||||
}
|
||||
pub fn const_params(&self) -> impl Iterator<Item = ast::ConstParam> {
|
||||
self.generic_params().filter_map(|param| match param {
|
||||
ast::GenericParam::ConstParam(it) => Some(it),
|
||||
ast::GenericParam::TypeParam(_) | ast::GenericParam::LifetimeParam(_) => None,
|
||||
ast::GenericParam::TypeParam(it) => Some(ast::TypeOrConstParam::Type(it)),
|
||||
ast::GenericParam::LifetimeParam(_) => None,
|
||||
ast::GenericParam::ConstParam(it) => Some(ast::TypeOrConstParam::Const(it)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue