9790: fix: extract_type_alias extracts generics correctly r=Veykril a=Veykril

Fixes #8335
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-08-05 00:54:49 +00:00 committed by GitHub
commit 80f522091a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 175 additions and 17 deletions

View file

@ -8,7 +8,10 @@ use parser::SyntaxKind;
use rowan::{GreenNodeData, GreenTokenData, WalkEvent};
use crate::{
ast::{self, support, AstChildren, AstNode, AstToken, AttrsOwner, NameOwner, SyntaxNode},
ast::{
self, support, AstChildren, AstNode, AstToken, AttrsOwner, GenericParamsOwner, NameOwner,
SyntaxNode,
},
NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, TokenText, T,
};
@ -593,6 +596,21 @@ impl ast::Variant {
}
}
impl ast::Item {
pub fn generic_param_list(&self) -> Option<ast::GenericParamList> {
match self {
ast::Item::Enum(it) => it.generic_param_list(),
ast::Item::Fn(it) => it.generic_param_list(),
ast::Item::Impl(it) => it.generic_param_list(),
ast::Item::Struct(it) => it.generic_param_list(),
ast::Item::Trait(it) => it.generic_param_list(),
ast::Item::TypeAlias(it) => it.generic_param_list(),
ast::Item::Union(it) => it.generic_param_list(),
_ => None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FieldKind {
Name(ast::NameRef),