mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Merge #5603
5603: Rename EnumDef -> Enum r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
8de0eb904b
35 changed files with 83 additions and 83 deletions
|
@ -1,7 +1,7 @@
|
|||
use ra_syntax::{
|
||||
ast::{self, NameOwner, VisibilityOwner},
|
||||
AstNode,
|
||||
SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT, TRAIT_DEF, VISIBILITY},
|
||||
SyntaxKind::{CONST_DEF, ENUM, FN, MODULE, STATIC_DEF, STRUCT, TRAIT_DEF, VISIBILITY},
|
||||
T,
|
||||
};
|
||||
use test_utils::mark;
|
||||
|
@ -36,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
|||
|
||||
let (offset, target) = if let Some(keyword) = item_keyword {
|
||||
let parent = keyword.parent();
|
||||
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT, ENUM_DEF, TRAIT_DEF];
|
||||
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT, ENUM, TRAIT_DEF];
|
||||
// Parent is not a definition, can't add visibility
|
||||
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
|
||||
return None;
|
||||
|
|
|
@ -40,7 +40,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
|
|||
ast::Fn(it) => it.body()?.syntax().clone().into(),
|
||||
ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(),
|
||||
ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(),
|
||||
ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),
|
||||
ast::Enum(it) => it.variant_list()?.syntax().clone().into(),
|
||||
ast::Struct(it) => {
|
||||
it.syntax().children_with_tokens()
|
||||
.find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])?
|
||||
|
|
|
@ -69,8 +69,8 @@ impl HasSource for Union {
|
|||
}
|
||||
}
|
||||
impl HasSource for Enum {
|
||||
type Ast = ast::EnumDef;
|
||||
fn source(self, db: &dyn HirDatabase) -> InFile<ast::EnumDef> {
|
||||
type Ast = ast::Enum;
|
||||
fn source(self, db: &dyn HirDatabase) -> InFile<ast::Enum> {
|
||||
self.id.lookup(db.upcast()).source(db.upcast())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -581,7 +581,7 @@ macro_rules! to_def_impls {
|
|||
to_def_impls![
|
||||
(crate::Module, ast::Module, module_to_def),
|
||||
(crate::Struct, ast::Struct, struct_to_def),
|
||||
(crate::Enum, ast::EnumDef, enum_to_def),
|
||||
(crate::Enum, ast::Enum, enum_to_def),
|
||||
(crate::Union, ast::Union, union_to_def),
|
||||
(crate::Trait, ast::TraitDef, trait_to_def),
|
||||
(crate::ImplDef, ast::ImplDef, impl_to_def),
|
||||
|
|
|
@ -77,7 +77,7 @@ impl SourceToDefCtx<'_, '_> {
|
|||
pub(super) fn struct_to_def(&mut self, src: InFile<ast::Struct>) -> Option<StructId> {
|
||||
self.to_def(src, keys::STRUCT)
|
||||
}
|
||||
pub(super) fn enum_to_def(&mut self, src: InFile<ast::EnumDef>) -> Option<EnumId> {
|
||||
pub(super) fn enum_to_def(&mut self, src: InFile<ast::Enum>) -> Option<EnumId> {
|
||||
self.to_def(src, keys::ENUM)
|
||||
}
|
||||
pub(super) fn union_to_def(&mut self, src: InFile<ast::Union>) -> Option<UnionId> {
|
||||
|
@ -170,7 +170,7 @@ impl SourceToDefCtx<'_, '_> {
|
|||
let def = self.struct_to_def(container.with_value(it))?;
|
||||
VariantId::from(def).into()
|
||||
},
|
||||
ast::EnumDef(it) => {
|
||||
ast::Enum(it) => {
|
||||
let def = self.enum_to_def(container.with_value(it))?;
|
||||
def.into()
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ impl SourceToDefCtx<'_, '_> {
|
|||
match (container.value) {
|
||||
ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
|
||||
ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(),
|
||||
ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(),
|
||||
ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(),
|
||||
ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(),
|
||||
ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(),
|
||||
ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(),
|
||||
|
|
|
@ -124,7 +124,7 @@ impl HasChildSource for EnumId {
|
|||
fn lower_enum(
|
||||
db: &dyn DefDatabase,
|
||||
trace: &mut Trace<EnumVariantData, ast::EnumVariant>,
|
||||
ast: &InFile<ast::EnumDef>,
|
||||
ast: &InFile<ast::Enum>,
|
||||
module_id: ModuleId,
|
||||
) {
|
||||
let expander = CfgExpander::new(db, ast.file_id, module_id.krate);
|
||||
|
|
|
@ -656,7 +656,7 @@ impl ExprCollector<'_> {
|
|||
let id = self.find_inner_item(&def)?;
|
||||
(StructLoc { container, id }.intern(self.db).into(), def.name())
|
||||
}
|
||||
ast::Item::EnumDef(def) => {
|
||||
ast::Item::Enum(def) => {
|
||||
let id = self.find_inner_item(&def)?;
|
||||
(EnumLoc { container, id }.intern(self.db).into(), def.name())
|
||||
}
|
||||
|
|
|
@ -416,7 +416,7 @@ mod_items! {
|
|||
Function in functions -> ast::Fn,
|
||||
Struct in structs -> ast::Struct,
|
||||
Union in unions -> ast::Union,
|
||||
Enum in enums -> ast::EnumDef,
|
||||
Enum in enums -> ast::Enum,
|
||||
Const in consts -> ast::ConstDef,
|
||||
Static in statics -> ast::StaticDef,
|
||||
Trait in traits -> ast::TraitDef,
|
||||
|
@ -543,7 +543,7 @@ pub struct Enum {
|
|||
pub visibility: RawVisibilityId,
|
||||
pub generic_params: GenericParamsId,
|
||||
pub variants: IdRange<Variant>,
|
||||
pub ast_id: FileAstId<ast::EnumDef>,
|
||||
pub ast_id: FileAstId<ast::Enum>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Ctx {
|
|||
match item {
|
||||
ast::Item::Struct(_)
|
||||
| ast::Item::Union(_)
|
||||
| ast::Item::EnumDef(_)
|
||||
| ast::Item::Enum(_)
|
||||
| ast::Item::Fn(_)
|
||||
| ast::Item::TypeAlias(_)
|
||||
| ast::Item::ConstDef(_)
|
||||
|
@ -105,7 +105,7 @@ impl Ctx {
|
|||
let items = match item {
|
||||
ast::Item::Struct(ast) => self.lower_struct(ast).map(Into::into),
|
||||
ast::Item::Union(ast) => self.lower_union(ast).map(Into::into),
|
||||
ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into),
|
||||
ast::Item::Enum(ast) => self.lower_enum(ast).map(Into::into),
|
||||
ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into),
|
||||
ast::Item::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into),
|
||||
ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into),
|
||||
|
@ -246,7 +246,7 @@ impl Ctx {
|
|||
Some(id(self.data().unions.alloc(res)))
|
||||
}
|
||||
|
||||
fn lower_enum(&mut self, enum_: &ast::EnumDef) -> Option<FileItemTreeId<Enum>> {
|
||||
fn lower_enum(&mut self, enum_: &ast::Enum) -> Option<FileItemTreeId<Enum>> {
|
||||
let visibility = self.lower_visibility(enum_);
|
||||
let name = enum_.name()?.as_name();
|
||||
let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_);
|
||||
|
|
|
@ -250,7 +250,7 @@ fn smoke() {
|
|||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }]
|
||||
Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(5), kind: Record }
|
||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }]
|
||||
Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::EnumDef>(6) }
|
||||
Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Enum>(6) }
|
||||
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }]
|
||||
Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Union>(7) }
|
||||
"##]],
|
||||
|
|
|
@ -22,7 +22,7 @@ pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new();
|
|||
pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new();
|
||||
pub const STRUCT: Key<ast::Struct, StructId> = Key::new();
|
||||
pub const UNION: Key<ast::Union, UnionId> = Key::new();
|
||||
pub const ENUM: Key<ast::EnumDef, EnumId> = Key::new();
|
||||
pub const ENUM: Key<ast::Enum, EnumId> = Key::new();
|
||||
|
||||
pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new();
|
||||
pub const TUPLE_FIELD: Key<ast::TupleField, FieldId> = Key::new();
|
||||
|
|
|
@ -73,7 +73,7 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> {
|
|||
let (name, params) = match_ast! {
|
||||
match node {
|
||||
ast::Struct(it) => (it.name(), it.generic_param_list()),
|
||||
ast::EnumDef(it) => (it.name(), it.generic_param_list()),
|
||||
ast::Enum(it) => (it.name(), it.generic_param_list()),
|
||||
ast::Union(it) => (it.name(), it.generic_param_list()),
|
||||
_ => {
|
||||
debug!("unexpected node is {:?}", node);
|
||||
|
|
|
@ -381,7 +381,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
|
|||
match node {
|
||||
ast::Fn(it) => it.doc_comment_text(),
|
||||
ast::Struct(it) => it.doc_comment_text(),
|
||||
ast::EnumDef(it) => it.doc_comment_text(),
|
||||
ast::Enum(it) => it.doc_comment_text(),
|
||||
ast::TraitDef(it) => it.doc_comment_text(),
|
||||
ast::Module(it) => it.doc_comment_text(),
|
||||
ast::TypeAlias(it) => it.doc_comment_text(),
|
||||
|
@ -406,7 +406,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
|
|||
match node {
|
||||
ast::Fn(it) => it.short_label(),
|
||||
ast::Struct(it) => it.short_label(),
|
||||
ast::EnumDef(it) => it.short_label(),
|
||||
ast::Enum(it) => it.short_label(),
|
||||
ast::TraitDef(it) => it.short_label(),
|
||||
ast::Module(it) => it.short_label(),
|
||||
ast::TypeAlias(it) => it.short_label(),
|
||||
|
@ -446,7 +446,7 @@ fn foo() { enum FooInner { } }
|
|||
5..13,
|
||||
),
|
||||
name: "FooInner",
|
||||
kind: ENUM_DEF,
|
||||
kind: ENUM,
|
||||
container_name: None,
|
||||
description: Some(
|
||||
"enum FooInner",
|
||||
|
@ -462,7 +462,7 @@ fn foo() { enum FooInner { } }
|
|||
34..42,
|
||||
),
|
||||
name: "FooInner",
|
||||
kind: ENUM_DEF,
|
||||
kind: ENUM,
|
||||
container_name: Some(
|
||||
"foo",
|
||||
),
|
||||
|
|
|
@ -25,7 +25,7 @@ impl ShortLabel for ast::Union {
|
|||
}
|
||||
}
|
||||
|
||||
impl ShortLabel for ast::EnumDef {
|
||||
impl ShortLabel for ast::Enum {
|
||||
fn short_label(&self) -> Option<String> {
|
||||
short_label_from_node(self, "enum ")
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
|||
},
|
||||
ast::Struct(it) => decl(it),
|
||||
ast::Union(it) => decl(it),
|
||||
ast::EnumDef(it) => decl(it),
|
||||
ast::Enum(it) => decl(it),
|
||||
ast::EnumVariant(it) => decl(it),
|
||||
ast::TraitDef(it) => decl(it),
|
||||
ast::Module(it) => decl(it),
|
||||
|
@ -308,7 +308,7 @@ fn very_obsolete() {}
|
|||
label: "E",
|
||||
navigation_range: 165..166,
|
||||
node_range: 160..180,
|
||||
kind: ENUM_DEF,
|
||||
kind: ENUM,
|
||||
detail: None,
|
||||
deprecated: false,
|
||||
},
|
||||
|
|
|
@ -45,7 +45,7 @@ fn impls_for_def(
|
|||
) -> Option<Vec<NavigationTarget>> {
|
||||
let ty = match node {
|
||||
ast::AdtDef::Struct(def) => sema.to_def(def)?.ty(sema.db),
|
||||
ast::AdtDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db),
|
||||
ast::AdtDef::Enum(def) => sema.to_def(def)?.ty(sema.db),
|
||||
ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db),
|
||||
};
|
||||
|
||||
|
|
|
@ -706,7 +706,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
|
|||
|
||||
let tag = match parent.kind() {
|
||||
STRUCT => HighlightTag::Struct,
|
||||
ENUM_DEF => HighlightTag::Enum,
|
||||
ENUM => HighlightTag::Enum,
|
||||
UNION => HighlightTag::Union,
|
||||
TRAIT_DEF => HighlightTag::Trait,
|
||||
TYPE_ALIAS => HighlightTag::TypeAlias,
|
||||
|
|
|
@ -158,7 +158,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
|
|||
let def: hir::Union = sema.to_def(&it)?;
|
||||
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
|
||||
},
|
||||
ast::EnumDef(it) => {
|
||||
ast::Enum(it) => {
|
||||
let def: hir::Enum = sema.to_def(&it)?;
|
||||
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
|
||||
},
|
||||
|
|
|
@ -344,7 +344,7 @@ impl Query {
|
|||
}
|
||||
|
||||
fn is_type(kind: SyntaxKind) -> bool {
|
||||
matches!(kind, STRUCT | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS)
|
||||
matches!(kind, STRUCT | ENUM | TRAIT_DEF | TYPE_ALIAS)
|
||||
}
|
||||
|
||||
/// The actual data that is stored in the index. It should be as compact as
|
||||
|
@ -399,7 +399,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
|
|||
match node {
|
||||
ast::Fn(it) => decl(it),
|
||||
ast::Struct(it) => decl(it),
|
||||
ast::EnumDef(it) => decl(it),
|
||||
ast::Enum(it) => decl(it),
|
||||
ast::TraitDef(it) => decl(it),
|
||||
ast::Module(it) => decl(it),
|
||||
ast::TypeAlias(it) => decl(it),
|
||||
|
|
|
@ -1467,7 +1467,7 @@ macro_rules! quick_error {
|
|||
buf [ ]
|
||||
queue [ ]
|
||||
) => {
|
||||
quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*]
|
||||
quick_error!(ENUMINITION [enum $name $( #[$meta] )*]
|
||||
body []
|
||||
queue [$(
|
||||
$( #[$imeta] )*
|
||||
|
@ -1489,7 +1489,7 @@ quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [
|
|||
"#,
|
||||
);
|
||||
|
||||
assert_eq!(expanded.to_string(), "quick_error ! (ENUM_DEFINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;");
|
||||
assert_eq!(expanded.to_string(), "quick_error ! (ENUMINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -64,7 +64,7 @@ pub(super) fn enum_def(p: &mut Parser, m: Marker) {
|
|||
} else {
|
||||
p.error("expected `{`")
|
||||
}
|
||||
m.complete(p, ENUM_DEF);
|
||||
m.complete(p, ENUM);
|
||||
}
|
||||
|
||||
pub(crate) fn enum_variant_list(p: &mut Parser) {
|
||||
|
|
|
@ -125,7 +125,7 @@ pub enum SyntaxKind {
|
|||
SOURCE_FILE,
|
||||
STRUCT,
|
||||
UNION,
|
||||
ENUM_DEF,
|
||||
ENUM,
|
||||
FN,
|
||||
RET_TYPE,
|
||||
EXTERN_CRATE,
|
||||
|
|
|
@ -44,14 +44,14 @@ impl ConstDef {
|
|||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct EnumDef {
|
||||
pub struct Enum {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for EnumDef {}
|
||||
impl ast::NameOwner for EnumDef {}
|
||||
impl ast::VisibilityOwner for EnumDef {}
|
||||
impl ast::GenericParamsOwner for EnumDef {}
|
||||
impl EnumDef {
|
||||
impl ast::AttrsOwner for Enum {}
|
||||
impl ast::NameOwner for Enum {}
|
||||
impl ast::VisibilityOwner for Enum {}
|
||||
impl ast::GenericParamsOwner for Enum {}
|
||||
impl Enum {
|
||||
pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
|
||||
pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ impl MetaItem {
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Item {
|
||||
ConstDef(ConstDef),
|
||||
EnumDef(EnumDef),
|
||||
Enum(Enum),
|
||||
ExternBlock(ExternBlock),
|
||||
ExternCrate(ExternCrate),
|
||||
Fn(Fn),
|
||||
|
@ -1392,7 +1392,7 @@ impl ast::VisibilityOwner for ExternItem {}
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum AdtDef {
|
||||
Struct(Struct),
|
||||
EnumDef(EnumDef),
|
||||
Enum(Enum),
|
||||
Union(Union),
|
||||
}
|
||||
impl ast::AttrsOwner for AdtDef {}
|
||||
|
@ -1432,8 +1432,8 @@ impl AstNode for ConstDef {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for EnumDef {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
|
||||
impl AstNode for Enum {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -2777,8 +2777,8 @@ impl AstNode for MetaItem {
|
|||
impl From<ConstDef> for Item {
|
||||
fn from(node: ConstDef) -> Item { Item::ConstDef(node) }
|
||||
}
|
||||
impl From<EnumDef> for Item {
|
||||
fn from(node: EnumDef) -> Item { Item::EnumDef(node) }
|
||||
impl From<Enum> for Item {
|
||||
fn from(node: Enum) -> Item { Item::Enum(node) }
|
||||
}
|
||||
impl From<ExternBlock> for Item {
|
||||
fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) }
|
||||
|
@ -2819,7 +2819,7 @@ impl From<Use> for Item {
|
|||
impl AstNode for Item {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL
|
||||
CONST_DEF | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL
|
||||
| MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true,
|
||||
_ => false,
|
||||
}
|
||||
|
@ -2827,7 +2827,7 @@ impl AstNode for Item {
|
|||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
CONST_DEF => Item::ConstDef(ConstDef { syntax }),
|
||||
ENUM_DEF => Item::EnumDef(EnumDef { syntax }),
|
||||
ENUM => Item::Enum(Enum { syntax }),
|
||||
EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
|
||||
EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
|
||||
FN => Item::Fn(Fn { syntax }),
|
||||
|
@ -2847,7 +2847,7 @@ impl AstNode for Item {
|
|||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
Item::ConstDef(it) => &it.syntax,
|
||||
Item::EnumDef(it) => &it.syntax,
|
||||
Item::Enum(it) => &it.syntax,
|
||||
Item::ExternBlock(it) => &it.syntax,
|
||||
Item::ExternCrate(it) => &it.syntax,
|
||||
Item::Fn(it) => &it.syntax,
|
||||
|
@ -3375,8 +3375,8 @@ impl AstNode for ExternItem {
|
|||
impl From<Struct> for AdtDef {
|
||||
fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) }
|
||||
}
|
||||
impl From<EnumDef> for AdtDef {
|
||||
fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) }
|
||||
impl From<Enum> for AdtDef {
|
||||
fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) }
|
||||
}
|
||||
impl From<Union> for AdtDef {
|
||||
fn from(node: Union) -> AdtDef { AdtDef::Union(node) }
|
||||
|
@ -3384,14 +3384,14 @@ impl From<Union> for AdtDef {
|
|||
impl AstNode for AdtDef {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
STRUCT | ENUM_DEF | UNION => true,
|
||||
STRUCT | ENUM | UNION => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
STRUCT => AdtDef::Struct(Struct { syntax }),
|
||||
ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }),
|
||||
ENUM => AdtDef::Enum(Enum { syntax }),
|
||||
UNION => AdtDef::Union(Union { syntax }),
|
||||
_ => return None,
|
||||
};
|
||||
|
@ -3400,7 +3400,7 @@ impl AstNode for AdtDef {
|
|||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
AdtDef::Struct(it) => &it.syntax,
|
||||
AdtDef::EnumDef(it) => &it.syntax,
|
||||
AdtDef::Enum(it) => &it.syntax,
|
||||
AdtDef::Union(it) => &it.syntax,
|
||||
}
|
||||
}
|
||||
|
@ -3470,7 +3470,7 @@ impl std::fmt::Display for ConstDef {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for EnumDef {
|
||||
impl std::fmt::Display for Enum {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
|
|
|
@ -248,11 +248,11 @@ impl ast::RecordFieldPat {
|
|||
}
|
||||
|
||||
impl ast::EnumVariant {
|
||||
pub fn parent_enum(&self) -> ast::EnumDef {
|
||||
pub fn parent_enum(&self) -> ast::Enum {
|
||||
self.syntax()
|
||||
.parent()
|
||||
.and_then(|it| it.parent())
|
||||
.and_then(ast::EnumDef::cast)
|
||||
.and_then(ast::Enum::cast)
|
||||
.expect("EnumVariants are always nested in Enums")
|
||||
}
|
||||
pub fn kind(&self) -> StructKind {
|
||||
|
@ -479,7 +479,7 @@ impl ast::DocCommentsOwner for ast::Struct {}
|
|||
impl ast::DocCommentsOwner for ast::Union {}
|
||||
impl ast::DocCommentsOwner for ast::RecordField {}
|
||||
impl ast::DocCommentsOwner for ast::TupleField {}
|
||||
impl ast::DocCommentsOwner for ast::EnumDef {}
|
||||
impl ast::DocCommentsOwner for ast::Enum {}
|
||||
impl ast::DocCommentsOwner for ast::EnumVariant {}
|
||||
impl ast::DocCommentsOwner for ast::TraitDef {}
|
||||
impl ast::DocCommentsOwner for ast::Module {}
|
||||
|
|
|
@ -146,7 +146,7 @@ fn n_attached_trivias<'a>(
|
|||
trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
|
||||
) -> usize {
|
||||
match kind {
|
||||
MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF
|
||||
MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM | ENUM_VARIANT | FN | TRAIT_DEF
|
||||
| MODULE | RECORD_FIELD | STATIC_DEF => {
|
||||
let mut res = 0;
|
||||
let mut trivias = trivias.enumerate().peekable();
|
||||
|
|
|
@ -11,7 +11,7 @@ SOURCE_FILE@0..575
|
|||
BLOCK_EXPR@10..574
|
||||
L_CURLY@10..11 "{"
|
||||
WHITESPACE@11..16 "\n "
|
||||
ENUM_DEF@16..152
|
||||
ENUM@16..152
|
||||
ENUM_KW@16..20 "enum"
|
||||
WHITESPACE@20..21 " "
|
||||
NAME@21..25
|
||||
|
@ -79,7 +79,7 @@ SOURCE_FILE@0..575
|
|||
INT_NUMBER@184..185 "1"
|
||||
SEMICOLON@185..186 ";"
|
||||
WHITESPACE@186..191 "\n "
|
||||
ENUM_DEF@191..223
|
||||
ENUM@191..223
|
||||
ENUM_KW@191..195 "enum"
|
||||
WHITESPACE@195..196 " "
|
||||
NAME@196..201
|
||||
|
@ -95,7 +95,7 @@ SOURCE_FILE@0..575
|
|||
WHITESPACE@217..222 "\n "
|
||||
R_CURLY@222..223 "}"
|
||||
WHITESPACE@223..229 "\n\n "
|
||||
ENUM_DEF@229..300
|
||||
ENUM@229..300
|
||||
ENUM_KW@229..233 "enum"
|
||||
WHITESPACE@233..234 " "
|
||||
NAME@234..239
|
||||
|
@ -132,7 +132,7 @@ SOURCE_FILE@0..575
|
|||
BLOCK_EXPR@306..459
|
||||
L_CURLY@306..307 "{"
|
||||
WHITESPACE@307..316 "\n "
|
||||
ENUM_DEF@316..453
|
||||
ENUM@316..453
|
||||
COMMENT@316..329 "// fail again"
|
||||
WHITESPACE@329..338 "\n "
|
||||
ENUM_KW@338..342 "enum"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_FILE@0..94
|
||||
ENUM_DEF@0..8
|
||||
ENUM@0..8
|
||||
ENUM_KW@0..4 "enum"
|
||||
WHITESPACE@4..5 " "
|
||||
NAME@5..6
|
||||
|
|
|
@ -11,7 +11,7 @@ SOURCE_FILE@0..111
|
|||
BLOCK_EXPR@21..110
|
||||
L_CURLY@21..22 "{"
|
||||
WHITESPACE@22..27 "\n "
|
||||
ENUM_DEF@27..75
|
||||
ENUM@27..75
|
||||
ENUM_KW@27..31 "enum"
|
||||
WHITESPACE@31..32 " "
|
||||
NAME@32..41
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_FILE@0..23
|
||||
ENUM_DEF@0..22
|
||||
ENUM@0..22
|
||||
ENUM_KW@0..4 "enum"
|
||||
WHITESPACE@4..5 " "
|
||||
NAME@5..6
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_FILE@0..182
|
||||
ENUM_DEF@0..11
|
||||
ENUM@0..11
|
||||
ENUM_KW@0..4 "enum"
|
||||
WHITESPACE@4..5 " "
|
||||
NAME@5..7
|
||||
|
@ -10,7 +10,7 @@ SOURCE_FILE@0..182
|
|||
WHITESPACE@9..10 "\n"
|
||||
R_CURLY@10..11 "}"
|
||||
WHITESPACE@11..13 "\n\n"
|
||||
ENUM_DEF@13..27
|
||||
ENUM@13..27
|
||||
ENUM_KW@13..17 "enum"
|
||||
WHITESPACE@17..18 " "
|
||||
NAME@18..20
|
||||
|
@ -27,7 +27,7 @@ SOURCE_FILE@0..182
|
|||
WHITESPACE@25..26 "\n"
|
||||
R_CURLY@26..27 "}"
|
||||
WHITESPACE@27..29 "\n\n"
|
||||
ENUM_DEF@29..46
|
||||
ENUM@29..46
|
||||
ENUM_KW@29..33 "enum"
|
||||
WHITESPACE@33..34 " "
|
||||
NAME@34..36
|
||||
|
@ -42,7 +42,7 @@ SOURCE_FILE@0..182
|
|||
WHITESPACE@44..45 "\n"
|
||||
R_CURLY@45..46 "}"
|
||||
WHITESPACE@46..48 "\n\n"
|
||||
ENUM_DEF@48..66
|
||||
ENUM@48..66
|
||||
ENUM_KW@48..52 "enum"
|
||||
WHITESPACE@52..53 " "
|
||||
NAME@53..55
|
||||
|
@ -58,7 +58,7 @@ SOURCE_FILE@0..182
|
|||
WHITESPACE@64..65 "\n"
|
||||
R_CURLY@65..66 "}"
|
||||
WHITESPACE@66..68 "\n\n"
|
||||
ENUM_DEF@68..181
|
||||
ENUM@68..181
|
||||
ENUM_KW@68..72 "enum"
|
||||
WHITESPACE@72..73 " "
|
||||
NAME@73..75
|
||||
|
|
|
@ -256,7 +256,7 @@ SOURCE_FILE@0..395
|
|||
WHITESPACE@339..340 "\n"
|
||||
R_CURLY@340..341 "}"
|
||||
WHITESPACE@341..343 "\n\n"
|
||||
ENUM_DEF@343..367
|
||||
ENUM@343..367
|
||||
ENUM_KW@343..347 "enum"
|
||||
WHITESPACE@347..348 " "
|
||||
NAME@348..349
|
||||
|
|
|
@ -926,7 +926,7 @@ pub(crate) fn handle_code_lens(
|
|||
it.kind,
|
||||
SyntaxKind::TRAIT_DEF
|
||||
| SyntaxKind::STRUCT
|
||||
| SyntaxKind::ENUM_DEF
|
||||
| SyntaxKind::ENUM
|
||||
| SyntaxKind::UNION
|
||||
)
|
||||
})
|
||||
|
|
|
@ -33,7 +33,7 @@ pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind {
|
|||
match syntax_kind {
|
||||
SyntaxKind::FN => lsp_types::SymbolKind::Function,
|
||||
SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct,
|
||||
SyntaxKind::ENUM_DEF => lsp_types::SymbolKind::Enum,
|
||||
SyntaxKind::ENUM => lsp_types::SymbolKind::Enum,
|
||||
SyntaxKind::ENUM_VARIANT => lsp_types::SymbolKind::EnumMember,
|
||||
SyntaxKind::TRAIT_DEF => lsp_types::SymbolKind::Interface,
|
||||
SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function,
|
||||
|
|
|
@ -95,7 +95,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
|
|||
"SOURCE_FILE",
|
||||
"STRUCT",
|
||||
"UNION",
|
||||
"ENUM_DEF",
|
||||
"ENUM",
|
||||
"FN",
|
||||
"RET_TYPE",
|
||||
"EXTERN_CRATE",
|
||||
|
|
|
@ -5,7 +5,7 @@ SourceFile =
|
|||
|
||||
Item =
|
||||
ConstDef
|
||||
| EnumDef
|
||||
| Enum
|
||||
| ExternBlock
|
||||
| ExternCrate
|
||||
| Fn
|
||||
|
@ -98,11 +98,7 @@ FieldList =
|
|||
RecordFieldList
|
||||
| TupleFieldList
|
||||
|
||||
Union =
|
||||
Attr* Visibility? 'union' Name GenericParamList? WhereClause?
|
||||
RecordFieldList
|
||||
|
||||
EnumDef =
|
||||
Enum =
|
||||
Attr* Visibility? 'enum' Name GenericParamList? WhereClause?
|
||||
variant_list:EnumVariantList
|
||||
|
||||
|
@ -112,6 +108,10 @@ EnumVariantList =
|
|||
EnumVariant =
|
||||
Attr* Visibility? Name FieldList ('=' Expr)?
|
||||
|
||||
Union =
|
||||
Attr* Visibility? 'union' Name GenericParamList? WhereClause?
|
||||
RecordFieldList
|
||||
|
||||
TraitDef =
|
||||
Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name GenericParamList
|
||||
(':' TypeBoundList?)? WhereClause
|
||||
|
@ -454,7 +454,7 @@ MetaItem =
|
|||
|
||||
AdtDef =
|
||||
Struct
|
||||
| EnumDef
|
||||
| Enum
|
||||
| Union
|
||||
|
||||
TypeRef =
|
||||
|
|
Loading…
Reference in a new issue