Rename StructDef -> Struct

This commit is contained in:
Aleksey Kladov 2020-07-30 17:50:40 +02:00
parent 1ae4721c9c
commit 216a5344c8
63 changed files with 163 additions and 163 deletions

View File

@ -1,7 +1,7 @@
use ra_syntax::{
ast::{self, NameOwner, VisibilityOwner},
AstNode,
SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY},
SyntaxKind::{CONST_DEF, ENUM_DEF, 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_DEF, ENUM_DEF, TRAIT_DEF];
let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT, ENUM_DEF, TRAIT_DEF];
// Parent is not a definition, can't add visibility
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
return None;

View File

@ -31,7 +31,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
//
// ```
pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
let strukt = ctx.find_node_at_offset::<ast::StructDef>()?;
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
// We want to only apply this to non-union structs with named fields
let field_list = match strukt.kind() {
@ -91,7 +91,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
// Generates the surrounding `impl Type { <code> }` including type and lifetime
// parameters
fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String {
let type_params = strukt.generic_param_list();
let mut buf = String::with_capacity(code.len());
buf.push_str("\n\nimpl");
@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
//
// FIXME: change the new fn checking to a more semantic approach when that's more
// viable (e.g. we process proc macros, etc)
fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> {
fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::ImplDef>> {
let db = ctx.db();
let module = strukt.syntax().ancestors().find(|node| {
ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind())

View File

@ -41,7 +41,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext
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::StructDef(it) => {
ast::Struct(it) => {
it.syntax().children_with_tokens()
.find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])?
},

View File

@ -57,8 +57,8 @@ impl HasSource for Field {
}
}
impl HasSource for Struct {
type Ast = ast::StructDef;
fn source(self, db: &dyn HirDatabase) -> InFile<ast::StructDef> {
type Ast = ast::Struct;
fn source(self, db: &dyn HirDatabase) -> InFile<ast::Struct> {
self.id.lookup(db.upcast()).source(db.upcast())
}
}

View File

@ -580,7 +580,7 @@ macro_rules! to_def_impls {
to_def_impls![
(crate::Module, ast::Module, module_to_def),
(crate::Struct, ast::StructDef, struct_to_def),
(crate::Struct, ast::Struct, struct_to_def),
(crate::Enum, ast::EnumDef, enum_to_def),
(crate::Union, ast::Union, union_to_def),
(crate::Trait, ast::TraitDef, trait_to_def),

View File

@ -74,7 +74,7 @@ impl SourceToDefCtx<'_, '_> {
pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> {
self.to_def(src, keys::FUNCTION)
}
pub(super) fn struct_to_def(&mut self, src: InFile<ast::StructDef>) -> Option<StructId> {
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> {
@ -166,7 +166,7 @@ impl SourceToDefCtx<'_, '_> {
let def = self.fn_to_def(container.with_value(it))?;
DefWithBodyId::from(def).into()
},
ast::StructDef(it) => {
ast::Struct(it) => {
let def = self.struct_to_def(container.with_value(it))?;
VariantId::from(def).into()
},
@ -205,7 +205,7 @@ impl SourceToDefCtx<'_, '_> {
let res: GenericDefId = match_ast! {
match (container.value) {
ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(),
ast::StructDef(it) => self.struct_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::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(),
ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(),

View File

@ -652,7 +652,7 @@ impl ExprCollector<'_> {
let id = self.find_inner_item(&def)?;
(StaticLoc { container, id }.intern(self.db).into(), def.name())
}
ast::Item::StructDef(def) => {
ast::Item::Struct(def) => {
let id = self.find_inner_item(&def)?;
(StructLoc { container, id }.intern(self.db).into(), def.name())
}

View File

@ -414,7 +414,7 @@ mod_items! {
Import in imports -> ast::Use,
ExternCrate in extern_crates -> ast::ExternCrate,
Function in functions -> ast::Fn,
Struct in structs -> ast::StructDef,
Struct in structs -> ast::Struct,
Union in unions -> ast::Union,
Enum in enums -> ast::EnumDef,
Const in consts -> ast::ConstDef,
@ -514,7 +514,7 @@ pub struct Struct {
pub visibility: RawVisibilityId,
pub generic_params: GenericParamsId,
pub fields: Fields,
pub ast_id: FileAstId<ast::StructDef>,
pub ast_id: FileAstId<ast::Struct>,
pub kind: StructDefKind,
}

View File

@ -78,7 +78,7 @@ impl Ctx {
// Collect inner items for 1-to-1-lowered items.
match item {
ast::Item::StructDef(_)
ast::Item::Struct(_)
| ast::Item::Union(_)
| ast::Item::EnumDef(_)
| ast::Item::Fn(_)
@ -103,7 +103,7 @@ impl Ctx {
let attrs = Attrs::new(item, &self.hygiene);
let items = match item {
ast::Item::StructDef(ast) => self.lower_struct(ast).map(Into::into),
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::Fn(ast) => self.lower_function(ast).map(Into::into),
@ -165,7 +165,7 @@ impl Ctx {
}
}
fn lower_struct(&mut self, strukt: &ast::StructDef) -> Option<FileItemTreeId<Struct>> {
fn lower_struct(&mut self, strukt: &ast::Struct) -> Option<FileItemTreeId<Struct>> {
let visibility = self.lower_visibility(strukt);
let name = strukt.name()?.as_name();
let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt);

View File

@ -244,11 +244,11 @@ fn smoke() {
> #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }]
> Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(11) }
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }]
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit }
Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(3), kind: Unit }
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }]
Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(4), kind: Tuple }
Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(4), kind: Tuple }
#[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::StructDef>(5), kind: Record }
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) }
#[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }]

View File

@ -20,7 +20,7 @@ pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new();
pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new();
pub const IMPL: Key<ast::ImplDef, ImplId> = Key::new();
pub const TRAIT: Key<ast::TraitDef, TraitId> = Key::new();
pub const STRUCT: Key<ast::StructDef, StructId> = 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();

View File

@ -72,7 +72,7 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> {
let node = item.syntax();
let (name, params) = match_ast! {
match node {
ast::StructDef(it) => (it.name(), it.generic_param_list()),
ast::Struct(it) => (it.name(), it.generic_param_list()),
ast::EnumDef(it) => (it.name(), it.generic_param_list()),
ast::Union(it) => (it.name(), it.generic_param_list()),
_ => {

View File

@ -380,7 +380,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option
match_ast! {
match node {
ast::Fn(it) => it.doc_comment_text(),
ast::StructDef(it) => it.doc_comment_text(),
ast::Struct(it) => it.doc_comment_text(),
ast::EnumDef(it) => it.doc_comment_text(),
ast::TraitDef(it) => it.doc_comment_text(),
ast::Module(it) => it.doc_comment_text(),
@ -405,7 +405,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
match_ast! {
match node {
ast::Fn(it) => it.short_label(),
ast::StructDef(it) => it.short_label(),
ast::Struct(it) => it.short_label(),
ast::EnumDef(it) => it.short_label(),
ast::TraitDef(it) => it.short_label(),
ast::Module(it) => it.short_label(),

View File

@ -13,7 +13,7 @@ impl ShortLabel for ast::Fn {
}
}
impl ShortLabel for ast::StructDef {
impl ShortLabel for ast::Struct {
fn short_label(&self) -> Option<String> {
short_label_from_node(self, "struct ")
}

View File

@ -126,7 +126,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
decl_with_detail(it, Some(detail))
},
ast::StructDef(it) => decl(it),
ast::Struct(it) => decl(it),
ast::Union(it) => decl(it),
ast::EnumDef(it) => decl(it),
ast::EnumVariant(it) => decl(it),
@ -238,7 +238,7 @@ fn very_obsolete() {}
label: "Foo",
navigation_range: 8..11,
node_range: 1..26,
kind: STRUCT_DEF,
kind: STRUCT,
detail: None,
deprecated: false,
},

View File

@ -44,7 +44,7 @@ fn impls_for_def(
krate: Crate,
) -> Option<Vec<NavigationTarget>> {
let ty = match node {
ast::AdtDef::StructDef(def) => sema.to_def(def)?.ty(sema.db),
ast::AdtDef::Struct(def) => sema.to_def(def)?.ty(sema.db),
ast::AdtDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db),
ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db),
};

View File

@ -1443,7 +1443,7 @@ fn main() { let s<|>t = S{ f1:0 }; }
7..8,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -1482,7 +1482,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
24..25,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -1501,7 +1501,7 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; }
7..10,
),
name: "Arg",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct Arg",
@ -1540,7 +1540,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
24..25,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -1559,7 +1559,7 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; }
7..10,
),
name: "Arg",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct Arg",
@ -1601,7 +1601,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
7..8,
),
name: "A",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct A",
@ -1620,7 +1620,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
22..23,
),
name: "B",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct B",
@ -1639,7 +1639,7 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); }
53..54,
),
name: "C",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"pub struct C",
@ -1737,7 +1737,7 @@ fn main() { let s<|>t = foo(); }
23..24,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -1877,7 +1877,7 @@ fn main() { let s<|>t = foo(); }
39..41,
),
name: "S1",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S1",
@ -1896,7 +1896,7 @@ fn main() { let s<|>t = foo(); }
52..54,
),
name: "S2",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S2",
@ -2011,7 +2011,7 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
36..37,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -2068,7 +2068,7 @@ fn foo(ar<|>g: &impl Foo<S>) {}
23..24,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -2111,7 +2111,7 @@ fn main() { let s<|>t = foo(); }
49..50,
),
name: "B",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct B",
@ -2224,7 +2224,7 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
23..24,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",
@ -2284,7 +2284,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
50..51,
),
name: "B",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct B",
@ -2322,7 +2322,7 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
65..66,
),
name: "S",
kind: STRUCT_DEF,
kind: STRUCT,
container_name: None,
description: Some(
"struct S",

View File

@ -172,7 +172,7 @@ fn get_struct_def_name_for_struct_literal_search(
if let Some(name) =
sema.find_node_at_offset_with_descend::<ast::Name>(&syntax, left.text_range().start())
{
return name.syntax().ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name());
return name.syntax().ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
}
if sema
.find_node_at_offset_with_descend::<ast::GenericParamList>(
@ -181,7 +181,7 @@ fn get_struct_def_name_for_struct_literal_search(
)
.is_some()
{
return left.ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name());
return left.ancestors().find_map(ast::Struct::cast).and_then(|l| l.name());
}
}
None
@ -212,7 +212,7 @@ fn main() {
);
check_result(
refs,
"Foo STRUCT_DEF FileId(1) 0..26 7..10 Other",
"Foo STRUCT FileId(1) 0..26 7..10 Other",
&["FileId(1) 101..104 StructLiteral"],
);
}
@ -230,7 +230,7 @@ struct Foo<|> {}
);
check_result(
refs,
"Foo STRUCT_DEF FileId(1) 0..13 7..10 Other",
"Foo STRUCT FileId(1) 0..13 7..10 Other",
&["FileId(1) 41..44 Other", "FileId(1) 54..57 StructLiteral"],
);
}
@ -248,7 +248,7 @@ struct Foo<T> <|>{}
);
check_result(
refs,
"Foo STRUCT_DEF FileId(1) 0..16 7..10 Other",
"Foo STRUCT FileId(1) 0..16 7..10 Other",
&["FileId(1) 64..67 StructLiteral"],
);
}
@ -267,7 +267,7 @@ fn main() {
);
check_result(
refs,
"Foo STRUCT_DEF FileId(1) 0..16 7..10 Other",
"Foo STRUCT FileId(1) 0..16 7..10 Other",
&["FileId(1) 54..57 StructLiteral"],
);
}
@ -431,7 +431,7 @@ fn f() {
let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
check_result(
refs,
"Foo STRUCT_DEF FileId(2) 17..51 28..31 Other",
"Foo STRUCT FileId(2) 17..51 28..31 Other",
&["FileId(1) 53..56 StructLiteral", "FileId(3) 79..82 StructLiteral"],
);
}
@ -486,7 +486,7 @@ pub(super) struct Foo<|> {
let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
check_result(
refs,
"Foo STRUCT_DEF FileId(3) 0..41 18..21 Other",
"Foo STRUCT FileId(3) 0..41 18..21 Other",
&["FileId(2) 20..23 Other", "FileId(2) 47..50 StructLiteral"],
);
}

View File

@ -705,7 +705,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
};
let tag = match parent.kind() {
STRUCT_DEF => HighlightTag::Struct,
STRUCT => HighlightTag::Struct,
ENUM_DEF => HighlightTag::Enum,
UNION => HighlightTag::Union,
TRAIT_DEF => HighlightTag::Trait,

View File

@ -150,7 +150,7 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
let def = sema.to_def(&it)?;
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
},
ast::StructDef(it) => {
ast::Struct(it) => {
let def: hir::Struct = sema.to_def(&it)?;
Some(NameClass::Definition(Definition::ModuleDef(def.into())))
},

View File

@ -344,7 +344,7 @@ impl Query {
}
fn is_type(kind: SyntaxKind) -> bool {
matches!(kind, STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS)
matches!(kind, STRUCT | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS)
}
/// The actual data that is stored in the index. It should be as compact as
@ -398,7 +398,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
match_ast! {
match node {
ast::Fn(it) => decl(it),
ast::StructDef(it) => decl(it),
ast::Struct(it) => decl(it),
ast::EnumDef(it) => decl(it),
ast::TraitDef(it) => decl(it),
ast::Module(it) => decl(it),

View File

@ -825,7 +825,7 @@ mod tests {
#[test]
fn test_token_tree_multi_char_punct() {
let source_file = ast::SourceFile::parse("struct Foo { a: x::Y }").ok().unwrap();
let struct_def = source_file.syntax().descendants().find_map(ast::StructDef::cast).unwrap();
let struct_def = source_file.syntax().descendants().find_map(ast::Struct::cast).unwrap();
let tt = ast_to_token_tree(&struct_def).unwrap().0;
token_tree_to_syntax_node(&tt, FragmentKind::Item).unwrap();
}

View File

@ -490,7 +490,7 @@ fn test_expand_to_item_list() {
format!("{:#?}", tree).trim(),
r#"
MACRO_ITEMS@0..40
STRUCT_DEF@0..20
STRUCT@0..20
STRUCT_KW@0..6 "struct"
NAME@6..9
IDENT@6..9 "Foo"
@ -506,7 +506,7 @@ MACRO_ITEMS@0..40
NAME_REF@16..19
IDENT@16..19 "u32"
R_CURLY@19..20 "}"
STRUCT_DEF@20..40
STRUCT@20..40
STRUCT_KW@20..26 "struct"
NAME@26..29
IDENT@26..29 "Bar"

View File

@ -5,7 +5,7 @@ use super::*;
pub(super) fn struct_def(p: &mut Parser, m: Marker) {
assert!(p.at(T![struct]));
p.bump(T![struct]);
struct_or_union(p, m, T![struct], STRUCT_DEF);
struct_or_union(p, m, T![struct], STRUCT);
}
pub(super) fn union_def(p: &mut Parser, m: Marker) {

View File

@ -1,7 +1,7 @@
//! Generated file, do not edit by hand, see `xtask/src/codegen`
#![allow(bad_style, missing_docs, unreachable_pub)]
#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`."]
#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`."]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[repr(u16)]
pub enum SyntaxKind {
@ -123,7 +123,7 @@ pub enum SyntaxKind {
L_DOLLAR,
R_DOLLAR,
SOURCE_FILE,
STRUCT_DEF,
STRUCT,
UNION,
ENUM_DEF,
FN,

View File

@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() {
)
.ok()
.unwrap();
let def = file.syntax().descendants().find_map(StructDef::cast).unwrap();
let def = file.syntax().descendants().find_map(Struct::cast).unwrap();
assert_eq!(
"Representation of a Realm. \nIn the specification these are called Realm Records.",
def.doc_comment_text().unwrap()

View File

@ -155,14 +155,14 @@ impl StaticDef {
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StructDef {
pub struct Struct {
pub(crate) syntax: SyntaxNode,
}
impl ast::AttrsOwner for StructDef {}
impl ast::NameOwner for StructDef {}
impl ast::VisibilityOwner for StructDef {}
impl ast::GenericParamsOwner for StructDef {}
impl StructDef {
impl ast::AttrsOwner for Struct {}
impl ast::NameOwner for Struct {}
impl ast::VisibilityOwner for Struct {}
impl ast::GenericParamsOwner for Struct {}
impl Struct {
pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
@ -1281,7 +1281,7 @@ pub enum Item {
MacroCall(MacroCall),
Module(Module),
StaticDef(StaticDef),
StructDef(StructDef),
Struct(Struct),
TraitDef(TraitDef),
TypeAlias(TypeAlias),
Union(Union),
@ -1391,7 +1391,7 @@ impl ast::NameOwner for ExternItem {}
impl ast::VisibilityOwner for ExternItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AdtDef {
StructDef(StructDef),
Struct(Struct),
EnumDef(EnumDef),
Union(Union),
}
@ -1520,8 +1520,8 @@ impl AstNode for StaticDef {
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl AstNode for StructDef {
fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
impl AstNode for Struct {
fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT }
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
@ -2801,8 +2801,8 @@ impl From<Module> for Item {
impl From<StaticDef> for Item {
fn from(node: StaticDef) -> Item { Item::StaticDef(node) }
}
impl From<StructDef> for Item {
fn from(node: StructDef) -> Item { Item::StructDef(node) }
impl From<Struct> for Item {
fn from(node: Struct) -> Item { Item::Struct(node) }
}
impl From<TraitDef> for Item {
fn from(node: TraitDef) -> Item { Item::TraitDef(node) }
@ -2820,7 +2820,7 @@ 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
| MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true,
| MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true,
_ => false,
}
}
@ -2835,7 +2835,7 @@ impl AstNode for Item {
MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
MODULE => Item::Module(Module { syntax }),
STATIC_DEF => Item::StaticDef(StaticDef { syntax }),
STRUCT_DEF => Item::StructDef(StructDef { syntax }),
STRUCT => Item::Struct(Struct { syntax }),
TRAIT_DEF => Item::TraitDef(TraitDef { syntax }),
TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }),
UNION => Item::Union(Union { syntax }),
@ -2855,7 +2855,7 @@ impl AstNode for Item {
Item::MacroCall(it) => &it.syntax,
Item::Module(it) => &it.syntax,
Item::StaticDef(it) => &it.syntax,
Item::StructDef(it) => &it.syntax,
Item::Struct(it) => &it.syntax,
Item::TraitDef(it) => &it.syntax,
Item::TypeAlias(it) => &it.syntax,
Item::Union(it) => &it.syntax,
@ -3372,8 +3372,8 @@ impl AstNode for ExternItem {
}
}
}
impl From<StructDef> for AdtDef {
fn from(node: StructDef) -> AdtDef { AdtDef::StructDef(node) }
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) }
@ -3384,13 +3384,13 @@ impl From<Union> for AdtDef {
impl AstNode for AdtDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRUCT_DEF | ENUM_DEF | UNION => true,
STRUCT | ENUM_DEF | UNION => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }),
STRUCT => AdtDef::Struct(Struct { syntax }),
ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }),
UNION => AdtDef::Union(Union { syntax }),
_ => return None,
@ -3399,7 +3399,7 @@ impl AstNode for AdtDef {
}
fn syntax(&self) -> &SyntaxNode {
match self {
AdtDef::StructDef(it) => &it.syntax,
AdtDef::Struct(it) => &it.syntax,
AdtDef::EnumDef(it) => &it.syntax,
AdtDef::Union(it) => &it.syntax,
}
@ -3510,7 +3510,7 @@ impl std::fmt::Display for StaticDef {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl std::fmt::Display for StructDef {
impl std::fmt::Display for Struct {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}

View File

@ -183,7 +183,7 @@ impl StructKind {
}
}
impl ast::StructDef {
impl ast::Struct {
pub fn kind(&self) -> StructKind {
StructKind::from_node(self)
}
@ -475,7 +475,7 @@ impl ast::TokenTree {
impl ast::DocCommentsOwner for ast::SourceFile {}
impl ast::DocCommentsOwner for ast::Fn {}
impl ast::DocCommentsOwner for ast::StructDef {}
impl ast::DocCommentsOwner for ast::Struct {}
impl ast::DocCommentsOwner for ast::Union {}
impl ast::DocCommentsOwner for ast::RecordField {}
impl ast::DocCommentsOwner for ast::TupleField {}

View File

@ -146,8 +146,8 @@ fn n_attached_trivias<'a>(
trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
) -> usize {
match kind {
MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN
| TRAIT_DEF | MODULE | RECORD_FIELD | STATIC_DEF => {
MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF
| MODULE | RECORD_FIELD | STATIC_DEF => {
let mut res = 0;
let mut trivias = trivias.enumerate().peekable();

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..34
STRUCT_DEF@0..34
STRUCT@0..34
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -5,7 +5,7 @@ SOURCE_FILE@0..21
ERROR@3..8
MATCH_KW@3..8 "match"
WHITESPACE@8..10 "\n\n"
STRUCT_DEF@10..21
STRUCT@10..21
STRUCT_KW@10..16 "struct"
WHITESPACE@16..17 " "
NAME@17..18

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..40
STRUCT_DEF@0..39
STRUCT@0..39
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..74
STRUCT_DEF@0..73
STRUCT@0..73
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -2,7 +2,7 @@ SOURCE_FILE@0..31
ERROR@0..1
R_CURLY@0..1 "}"
WHITESPACE@1..3 "\n\n"
STRUCT_DEF@3..12
STRUCT@3..12
STRUCT_KW@3..9 "struct"
WHITESPACE@9..10 " "
NAME@10..11

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..43
STRUCT_DEF@0..11
STRUCT@0..11
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8
@ -38,7 +38,7 @@ SOURCE_FILE@0..43
WHITESPACE@29..30 "\n"
R_CURLY@30..31 "}"
WHITESPACE@31..33 "\n\n"
STRUCT_DEF@33..42
STRUCT@33..42
STRUCT_KW@33..39 "struct"
WHITESPACE@39..40 " "
NAME@40..41

View File

@ -3,7 +3,7 @@ SOURCE_FILE@0..19
ABI@0..6
EXTERN_KW@0..6 "extern"
WHITESPACE@6..7 " "
STRUCT_DEF@7..18
STRUCT@7..18
STRUCT_KW@7..13 "struct"
WHITESPACE@13..14 " "
NAME@14..17

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..86
STRUCT_DEF@0..72
STRUCT@0..72
VISIBILITY@0..3
PUB_KW@0..3 "pub"
WHITESPACE@3..4 " "

View File

@ -28,7 +28,7 @@ SOURCE_FILE@0..112
ERROR@17..18
COMMA@17..18 ","
WHITESPACE@18..19 " "
STRUCT_DEF@19..26
STRUCT@19..26
STRUCT_KW@19..25 "struct"
ERROR@25..26
COMMA@25..26 ","

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..35
STRUCT_DEF@0..34
STRUCT@0..34
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..81
STRUCT_DEF@0..20
STRUCT@0..20
VISIBILITY@0..10
PUB_KW@0..3 "pub"
L_PAREN@3..4 "("
@ -12,7 +12,7 @@ SOURCE_FILE@0..81
IDENT@18..19 "S"
SEMICOLON@19..20 ";"
WHITESPACE@20..21 "\n"
STRUCT_DEF@21..40
STRUCT@21..40
VISIBILITY@21..30
PUB_KW@21..24 "pub"
L_PAREN@24..25 "("
@ -25,7 +25,7 @@ SOURCE_FILE@0..81
IDENT@38..39 "S"
SEMICOLON@39..40 ";"
WHITESPACE@40..41 "\n"
STRUCT_DEF@41..60
STRUCT@41..60
VISIBILITY@41..50
PUB_KW@41..44 "pub"
L_PAREN@44..45 "("
@ -38,7 +38,7 @@ SOURCE_FILE@0..81
IDENT@58..59 "S"
SEMICOLON@59..60 ";"
WHITESPACE@60..61 "\n"
STRUCT_DEF@61..80
STRUCT@61..80
VISIBILITY@61..70
PUB_KW@61..64 "pub"
L_PAREN@64..65 "("

View File

@ -16,7 +16,7 @@ SOURCE_FILE@0..71
WHITESPACE@17..18 " "
R_CURLY@18..19 "}"
WHITESPACE@19..20 "\n"
STRUCT_DEF@20..49
STRUCT@20..49
STRUCT_KW@20..26 "struct"
WHITESPACE@26..27 " "
NAME@27..28
@ -41,7 +41,7 @@ SOURCE_FILE@0..71
WHITESPACE@47..48 " "
R_CURLY@48..49 "}"
WHITESPACE@49..50 "\n"
STRUCT_DEF@50..70
STRUCT@50..70
STRUCT_KW@50..56 "struct"
WHITESPACE@56..57 " "
NAME@57..58

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..64
STRUCT_DEF@0..63
STRUCT@0..63
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -57,7 +57,7 @@ SOURCE_FILE@0..70
L_CURLY@57..58 "{"
R_CURLY@58..59 "}"
WHITESPACE@59..60 "\n"
STRUCT_DEF@60..69
STRUCT@60..69
STRUCT_KW@60..66 "struct"
WHITESPACE@66..67 " "
NAME@67..68

View File

@ -1,12 +1,12 @@
SOURCE_FILE@0..106
STRUCT_DEF@0..11
STRUCT@0..11
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..10
IDENT@7..10 "Foo"
SEMICOLON@10..11 ";"
WHITESPACE@11..12 "\n"
STRUCT_DEF@12..25
STRUCT@12..25
STRUCT_KW@12..18 "struct"
WHITESPACE@18..19 " "
NAME@19..22
@ -16,7 +16,7 @@ SOURCE_FILE@0..106
L_CURLY@23..24 "{"
R_CURLY@24..25 "}"
WHITESPACE@25..26 "\n"
STRUCT_DEF@26..39
STRUCT@26..39
STRUCT_KW@26..32 "struct"
WHITESPACE@32..33 " "
NAME@33..36
@ -26,7 +26,7 @@ SOURCE_FILE@0..106
R_PAREN@37..38 ")"
SEMICOLON@38..39 ";"
WHITESPACE@39..40 "\n"
STRUCT_DEF@40..66
STRUCT@40..66
STRUCT_KW@40..46 "struct"
WHITESPACE@46..47 " "
NAME@47..50
@ -50,7 +50,7 @@ SOURCE_FILE@0..106
R_PAREN@64..65 ")"
SEMICOLON@65..66 ";"
WHITESPACE@66..67 "\n"
STRUCT_DEF@67..105
STRUCT@67..105
STRUCT_KW@67..73 "struct"
WHITESPACE@73..74 " "
NAME@74..77

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..19
STRUCT_DEF@0..18
STRUCT@0..18
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..53
STRUCT_DEF@0..33
STRUCT@0..33
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..11
@ -40,7 +40,7 @@ SOURCE_FILE@0..53
IDENT@27..32 "Clone"
SEMICOLON@32..33 ";"
WHITESPACE@33..34 "\n"
STRUCT_DEF@34..52
STRUCT@34..52
STRUCT_KW@34..40 "struct"
WHITESPACE@40..41 " "
NAME@41..45

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..60
STRUCT_DEF@0..59
STRUCT@0..59
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -47,7 +47,7 @@ SOURCE_FILE@0..111
R_CURLY@89..90 "}"
SEMICOLON@90..91 ";"
WHITESPACE@91..96 "\n "
STRUCT_DEF@96..107
STRUCT@96..107
STRUCT_KW@96..102 "struct"
WHITESPACE@102..103 " "
NAME@103..104

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..24
STRUCT_DEF@0..23
STRUCT@0..23
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..32
STRUCT_DEF@0..31
STRUCT@0..31
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..25
STRUCT_DEF@0..25
STRUCT@0..25
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -40,7 +40,7 @@ SOURCE_FILE@0..118
WHITESPACE@41..46 "\n "
R_CURLY@46..47 "}"
WHITESPACE@47..52 "\n "
STRUCT_DEF@52..63
STRUCT@52..63
STRUCT_KW@52..58 "struct"
WHITESPACE@58..59 " "
NAME@59..60

View File

@ -1,12 +1,12 @@
SOURCE_FILE@0..97
STRUCT_DEF@0..9
STRUCT@0..9
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8
IDENT@7..8 "A"
SEMICOLON@8..9 ";"
WHITESPACE@9..10 "\n"
STRUCT_DEF@10..21
STRUCT@10..21
STRUCT_KW@10..16 "struct"
WHITESPACE@16..17 " "
NAME@17..18
@ -16,7 +16,7 @@ SOURCE_FILE@0..97
L_CURLY@19..20 "{"
R_CURLY@20..21 "}"
WHITESPACE@21..22 "\n"
STRUCT_DEF@22..33
STRUCT@22..33
STRUCT_KW@22..28 "struct"
WHITESPACE@28..29 " "
NAME@29..30
@ -26,7 +26,7 @@ SOURCE_FILE@0..97
R_PAREN@31..32 ")"
SEMICOLON@32..33 ";"
WHITESPACE@33..35 "\n\n"
STRUCT_DEF@35..74
STRUCT@35..74
STRUCT_KW@35..41 "struct"
WHITESPACE@41..42 " "
NAME@42..43
@ -63,7 +63,7 @@ SOURCE_FILE@0..97
WHITESPACE@72..73 "\n"
R_CURLY@73..74 "}"
WHITESPACE@74..76 "\n\n"
STRUCT_DEF@76..96
STRUCT@76..96
STRUCT_KW@76..82 "struct"
WHITESPACE@82..83 " "
NAME@83..84

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..290
STRUCT_DEF@0..13
STRUCT@0..13
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..9
@ -12,7 +12,7 @@ SOURCE_FILE@0..290
R_ANGLE@11..12 ">"
SEMICOLON@12..13 ";"
WHITESPACE@13..14 "\n"
STRUCT_DEF@14..32
STRUCT@14..32
STRUCT_KW@14..20 "struct"
WHITESPACE@20..21 " "
NAME@21..23
@ -34,7 +34,7 @@ SOURCE_FILE@0..290
R_PAREN@30..31 ")"
SEMICOLON@31..32 ";"
WHITESPACE@32..33 "\n"
STRUCT_DEF@33..56
STRUCT@33..56
STRUCT_KW@33..39 "struct"
WHITESPACE@39..40 " "
NAME@40..42
@ -62,7 +62,7 @@ SOURCE_FILE@0..290
WHITESPACE@54..55 " "
R_CURLY@55..56 "}"
WHITESPACE@56..58 "\n\n"
STRUCT_DEF@58..70
STRUCT@58..70
STRUCT_KW@58..64 "struct"
WHITESPACE@64..65 " "
NAME@65..67
@ -72,7 +72,7 @@ SOURCE_FILE@0..290
R_ANGLE@68..69 ">"
SEMICOLON@69..70 ";"
WHITESPACE@70..71 "\n"
STRUCT_DEF@71..85
STRUCT@71..85
STRUCT_KW@71..77 "struct"
WHITESPACE@77..78 " "
NAME@78..80
@ -84,7 +84,7 @@ SOURCE_FILE@0..290
R_ANGLE@83..84 ">"
SEMICOLON@84..85 ";"
WHITESPACE@85..86 "\n"
STRUCT_DEF@86..101
STRUCT@86..101
STRUCT_KW@86..92 "struct"
WHITESPACE@92..93 " "
NAME@93..95
@ -97,7 +97,7 @@ SOURCE_FILE@0..290
R_ANGLE@99..100 ">"
SEMICOLON@100..101 ";"
WHITESPACE@101..102 "\n"
STRUCT_DEF@102..120
STRUCT@102..120
STRUCT_KW@102..108 "struct"
WHITESPACE@108..109 " "
NAME@109..111
@ -112,7 +112,7 @@ SOURCE_FILE@0..290
R_ANGLE@118..119 ">"
SEMICOLON@119..120 ";"
WHITESPACE@120..121 "\n"
STRUCT_DEF@121..142
STRUCT@121..142
STRUCT_KW@121..127 "struct"
WHITESPACE@127..128 " "
NAME@128..130
@ -130,7 +130,7 @@ SOURCE_FILE@0..290
R_ANGLE@140..141 ">"
SEMICOLON@141..142 ";"
WHITESPACE@142..143 "\n"
STRUCT_DEF@143..166
STRUCT@143..166
STRUCT_KW@143..149 "struct"
WHITESPACE@149..150 " "
NAME@150..152
@ -149,7 +149,7 @@ SOURCE_FILE@0..290
R_ANGLE@164..165 ">"
SEMICOLON@165..166 ";"
WHITESPACE@166..167 "\n"
STRUCT_DEF@167..183
STRUCT@167..183
STRUCT_KW@167..173 "struct"
WHITESPACE@173..174 " "
NAME@174..177
@ -162,7 +162,7 @@ SOURCE_FILE@0..290
R_ANGLE@181..182 ">"
SEMICOLON@182..183 ";"
WHITESPACE@183..184 "\n"
STRUCT_DEF@184..203
STRUCT@184..203
STRUCT_KW@184..190 "struct"
WHITESPACE@190..191 " "
NAME@191..194
@ -178,7 +178,7 @@ SOURCE_FILE@0..290
R_ANGLE@201..202 ">"
SEMICOLON@202..203 ";"
WHITESPACE@203..204 "\n"
STRUCT_DEF@204..233
STRUCT@204..233
STRUCT_KW@204..210 "struct"
WHITESPACE@210..211 " "
NAME@211..214
@ -202,7 +202,7 @@ SOURCE_FILE@0..290
R_ANGLE@231..232 ">"
SEMICOLON@232..233 ";"
WHITESPACE@233..235 "\n\n"
STRUCT_DEF@235..249
STRUCT@235..249
STRUCT_KW@235..241 "struct"
WHITESPACE@241..242 " "
NAME@242..245
@ -215,7 +215,7 @@ SOURCE_FILE@0..290
R_ANGLE@247..248 ">"
SEMICOLON@248..249 ";"
WHITESPACE@249..250 "\n"
STRUCT_DEF@250..267
STRUCT@250..267
STRUCT_KW@250..256 "struct"
WHITESPACE@256..257 " "
NAME@257..260
@ -233,7 +233,7 @@ SOURCE_FILE@0..290
R_ANGLE@265..266 ">"
SEMICOLON@266..267 ";"
WHITESPACE@267..268 "\n"
STRUCT_DEF@268..289
STRUCT@268..289
STRUCT_KW@268..274 "struct"
WHITESPACE@274..275 " "
NAME@275..278

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..250
STRUCT_DEF@0..12
STRUCT@0..12
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8
@ -12,7 +12,7 @@ SOURCE_FILE@0..250
R_ANGLE@10..11 ">"
SEMICOLON@11..12 ";"
WHITESPACE@12..13 "\n"
STRUCT_DEF@13..26
STRUCT@13..26
STRUCT_KW@13..19 "struct"
WHITESPACE@19..20 " "
NAME@20..21
@ -27,7 +27,7 @@ SOURCE_FILE@0..250
R_ANGLE@24..25 ">"
SEMICOLON@25..26 ";"
WHITESPACE@26..27 "\n"
STRUCT_DEF@27..43
STRUCT@27..43
STRUCT_KW@27..33 "struct"
WHITESPACE@33..34 " "
NAME@34..35
@ -45,7 +45,7 @@ SOURCE_FILE@0..250
R_ANGLE@41..42 ">"
SEMICOLON@42..43 ";"
WHITESPACE@43..44 "\n"
STRUCT_DEF@44..63
STRUCT@44..63
STRUCT_KW@44..50 "struct"
WHITESPACE@50..51 " "
NAME@51..52
@ -66,7 +66,7 @@ SOURCE_FILE@0..250
R_ANGLE@61..62 ">"
SEMICOLON@62..63 ";"
WHITESPACE@63..64 "\n"
STRUCT_DEF@64..86
STRUCT@64..86
STRUCT_KW@64..70 "struct"
WHITESPACE@70..71 " "
NAME@71..72
@ -90,7 +90,7 @@ SOURCE_FILE@0..250
R_ANGLE@84..85 ">"
SEMICOLON@85..86 ";"
WHITESPACE@86..87 "\n"
STRUCT_DEF@87..116
STRUCT@87..116
STRUCT_KW@87..93 "struct"
WHITESPACE@93..94 " "
NAME@94..95
@ -122,7 +122,7 @@ SOURCE_FILE@0..250
R_ANGLE@114..115 ">"
SEMICOLON@115..116 ";"
WHITESPACE@116..117 "\n"
STRUCT_DEF@117..143
STRUCT@117..143
STRUCT_KW@117..123 "struct"
WHITESPACE@123..124 " "
NAME@124..125
@ -153,7 +153,7 @@ SOURCE_FILE@0..250
R_ANGLE@141..142 ">"
SEMICOLON@142..143 ";"
WHITESPACE@143..144 "\n"
STRUCT_DEF@144..180
STRUCT@144..180
STRUCT_KW@144..150 "struct"
WHITESPACE@150..151 " "
NAME@151..152
@ -194,7 +194,7 @@ SOURCE_FILE@0..250
R_ANGLE@178..179 ">"
SEMICOLON@179..180 ";"
WHITESPACE@180..181 "\n"
STRUCT_DEF@181..199
STRUCT@181..199
STRUCT_KW@181..187 "struct"
WHITESPACE@187..188 " "
NAME@188..189
@ -217,7 +217,7 @@ SOURCE_FILE@0..250
R_ANGLE@197..198 ">"
SEMICOLON@198..199 ";"
WHITESPACE@199..200 "\n"
STRUCT_DEF@200..250
STRUCT@200..250
STRUCT_KW@200..206 "struct"
WHITESPACE@206..207 " "
NAME@207..208

View File

@ -1,5 +1,5 @@
SOURCE_FILE@0..27
STRUCT_DEF@0..27
STRUCT@0..27
STRUCT_KW@0..6 "struct"
WHITESPACE@6..7 " "
NAME@7..8

View File

@ -1,7 +1,7 @@
SOURCE_FILE@0..199
COMMENT@0..60 "// https://github.com ..."
WHITESPACE@60..62 "\n\n"
STRUCT_DEF@62..73
STRUCT@62..73
STRUCT_KW@62..68 "struct"
WHITESPACE@68..69 " "
NAME@69..72

View File

@ -1,7 +1,7 @@
SOURCE_FILE@0..160
COMMENT@0..60 "// https://github.com ..."
WHITESPACE@60..62 "\n\n"
STRUCT_DEF@62..90
STRUCT@62..90
STRUCT_KW@62..68 "struct"
WHITESPACE@68..69 " "
NAME@69..73

View File

@ -925,7 +925,7 @@ pub(crate) fn handle_code_lens(
matches!(
it.kind,
SyntaxKind::TRAIT_DEF
| SyntaxKind::STRUCT_DEF
| SyntaxKind::STRUCT
| SyntaxKind::ENUM_DEF
| SyntaxKind::UNION
)

View File

@ -32,7 +32,7 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang
pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind {
match syntax_kind {
SyntaxKind::FN => lsp_types::SymbolKind::Function,
SyntaxKind::STRUCT_DEF => lsp_types::SymbolKind::Struct,
SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct,
SyntaxKind::ENUM_DEF => lsp_types::SymbolKind::Enum,
SyntaxKind::ENUM_VARIANT => lsp_types::SymbolKind::EnumMember,
SyntaxKind::TRAIT_DEF => lsp_types::SymbolKind::Interface,

View File

@ -93,7 +93,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
],
nodes: &[
"SOURCE_FILE",
"STRUCT_DEF",
"STRUCT",
"UNION",
"ENUM_DEF",
"FN",

View File

@ -307,7 +307,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> Result<String> {
let ast = quote! {
#![allow(bad_style, missing_docs, unreachable_pub)]
/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[repr(u16)]
pub enum SyntaxKind {

View File

@ -13,7 +13,7 @@ Item =
| MacroCall
| Module
| StaticDef
| StructDef
| Struct
| TraitDef
| TypeAlias
| Union
@ -76,7 +76,7 @@ TypeAlias =
Attr* Visibility? 'default'? 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause?
'=' TypeRef ';'
StructDef =
Struct =
Attr* Visibility? 'struct' Name GenericParamList? (
WhereClause? (RecordFieldList | ';')
| TupleFieldList WhereClause? ';'
@ -453,7 +453,7 @@ MetaItem =
Path '=' AttrInput nested_meta_items:MetaItem*
AdtDef =
StructDef
Struct
| EnumDef
| Union