aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-25 10:38:52 +0000
committerAleksey Kladov <[email protected]>2019-02-25 10:49:32 +0000
commit78f10fcdc41d5c58e386bc99a94b34a2bdbaa4cd (patch)
treed813eb7be81dadbeced5ea0cf056d974cfd0fea5 /crates/ra_syntax/src
parent7ffff9c74caae108db53366e3b90857b7c405c6c (diff)
rename type to type_alias in the AST as well
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs94
-rw-r--r--crates/ra_syntax/src/grammar.ron8
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs2
3 files changed, 52 insertions, 52 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index aa88b1e28..4e2705d09 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1508,7 +1508,7 @@ unsafe impl TransparentNewType for ImplItem {
1508#[derive(Debug, Clone, Copy, PartialEq, Eq)] 1508#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1509pub enum ImplItemKind<'a> { 1509pub enum ImplItemKind<'a> {
1510 FnDef(&'a FnDef), 1510 FnDef(&'a FnDef),
1511 TypeDef(&'a TypeDef), 1511 TypeAliasDef(&'a TypeAliasDef),
1512 ConstDef(&'a ConstDef), 1512 ConstDef(&'a ConstDef),
1513} 1513}
1514impl<'a> From<&'a FnDef> for &'a ImplItem { 1514impl<'a> From<&'a FnDef> for &'a ImplItem {
@@ -1516,8 +1516,8 @@ impl<'a> From<&'a FnDef> for &'a ImplItem {
1516 ImplItem::cast(&n.syntax).unwrap() 1516 ImplItem::cast(&n.syntax).unwrap()
1517 } 1517 }
1518} 1518}
1519impl<'a> From<&'a TypeDef> for &'a ImplItem { 1519impl<'a> From<&'a TypeAliasDef> for &'a ImplItem {
1520 fn from(n: &'a TypeDef) -> &'a ImplItem { 1520 fn from(n: &'a TypeAliasDef) -> &'a ImplItem {
1521 ImplItem::cast(&n.syntax).unwrap() 1521 ImplItem::cast(&n.syntax).unwrap()
1522 } 1522 }
1523} 1523}
@@ -1532,7 +1532,7 @@ impl AstNode for ImplItem {
1532 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 1532 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1533 match syntax.kind() { 1533 match syntax.kind() {
1534 | FN_DEF 1534 | FN_DEF
1535 | TYPE_DEF 1535 | TYPE_ALIAS_DEF
1536 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())), 1536 | CONST_DEF => Some(ImplItem::from_repr(syntax.into_repr())),
1537 _ => None, 1537 _ => None,
1538 } 1538 }
@@ -1549,7 +1549,7 @@ impl ImplItem {
1549 pub fn kind(&self) -> ImplItemKind { 1549 pub fn kind(&self) -> ImplItemKind {
1550 match self.syntax.kind() { 1550 match self.syntax.kind() {
1551 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()), 1551 FN_DEF => ImplItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
1552 TYPE_DEF => ImplItemKind::TypeDef(TypeDef::cast(&self.syntax).unwrap()), 1552 TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
1553 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()), 1553 CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
1554 _ => unreachable!(), 1554 _ => unreachable!(),
1555 } 1555 }
@@ -2359,7 +2359,7 @@ pub enum ModuleItemKind<'a> {
2359 EnumDef(&'a EnumDef), 2359 EnumDef(&'a EnumDef),
2360 FnDef(&'a FnDef), 2360 FnDef(&'a FnDef),
2361 TraitDef(&'a TraitDef), 2361 TraitDef(&'a TraitDef),
2362 TypeDef(&'a TypeDef), 2362 TypeAliasDef(&'a TypeAliasDef),
2363 ImplBlock(&'a ImplBlock), 2363 ImplBlock(&'a ImplBlock),
2364 UseItem(&'a UseItem), 2364 UseItem(&'a UseItem),
2365 ExternCrateItem(&'a ExternCrateItem), 2365 ExternCrateItem(&'a ExternCrateItem),
@@ -2387,8 +2387,8 @@ impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2387 ModuleItem::cast(&n.syntax).unwrap() 2387 ModuleItem::cast(&n.syntax).unwrap()
2388 } 2388 }
2389} 2389}
2390impl<'a> From<&'a TypeDef> for &'a ModuleItem { 2390impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2391 fn from(n: &'a TypeDef) -> &'a ModuleItem { 2391 fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2392 ModuleItem::cast(&n.syntax).unwrap() 2392 ModuleItem::cast(&n.syntax).unwrap()
2393 } 2393 }
2394} 2394}
@@ -2431,7 +2431,7 @@ impl AstNode for ModuleItem {
2431 | ENUM_DEF 2431 | ENUM_DEF
2432 | FN_DEF 2432 | FN_DEF
2433 | TRAIT_DEF 2433 | TRAIT_DEF
2434 | TYPE_DEF 2434 | TYPE_ALIAS_DEF
2435 | IMPL_BLOCK 2435 | IMPL_BLOCK
2436 | USE_ITEM 2436 | USE_ITEM
2437 | EXTERN_CRATE_ITEM 2437 | EXTERN_CRATE_ITEM
@@ -2456,7 +2456,7 @@ impl ModuleItem {
2456 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()), 2456 ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2457 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()), 2457 FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2458 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()), 2458 TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2459 TYPE_DEF => ModuleItemKind::TypeDef(TypeDef::cast(&self.syntax).unwrap()), 2459 TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2460 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()), 2460 IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2461 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()), 2461 USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2462 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()), 2462 EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
@@ -4273,6 +4273,43 @@ impl TupleType {
4273 } 4273 }
4274} 4274}
4275 4275
4276// TypeAliasDef
4277#[derive(Debug, PartialEq, Eq, Hash)]
4278#[repr(transparent)]
4279pub struct TypeAliasDef {
4280 pub(crate) syntax: SyntaxNode,
4281}
4282unsafe impl TransparentNewType for TypeAliasDef {
4283 type Repr = rowan::SyntaxNode<RaTypes>;
4284}
4285
4286impl AstNode for TypeAliasDef {
4287 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4288 match syntax.kind() {
4289 TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
4290 _ => None,
4291 }
4292 }
4293 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4294}
4295
4296impl ToOwned for TypeAliasDef {
4297 type Owned = TreeArc<TypeAliasDef>;
4298 fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
4299}
4300
4301
4302impl ast::VisibilityOwner for TypeAliasDef {}
4303impl ast::NameOwner for TypeAliasDef {}
4304impl ast::TypeParamsOwner for TypeAliasDef {}
4305impl ast::AttrsOwner for TypeAliasDef {}
4306impl ast::DocCommentsOwner for TypeAliasDef {}
4307impl TypeAliasDef {
4308 pub fn type_ref(&self) -> Option<&TypeRef> {
4309 super::child_opt(self)
4310 }
4311}
4312
4276// TypeArg 4313// TypeArg
4277#[derive(Debug, PartialEq, Eq, Hash)] 4314#[derive(Debug, PartialEq, Eq, Hash)]
4278#[repr(transparent)] 4315#[repr(transparent)]
@@ -4345,43 +4382,6 @@ impl TypeArgList {
4345 } 4382 }
4346} 4383}
4347 4384
4348// TypeDef
4349#[derive(Debug, PartialEq, Eq, Hash)]
4350#[repr(transparent)]
4351pub struct TypeDef {
4352 pub(crate) syntax: SyntaxNode,
4353}
4354unsafe impl TransparentNewType for TypeDef {
4355 type Repr = rowan::SyntaxNode<RaTypes>;
4356}
4357
4358impl AstNode for TypeDef {
4359 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4360 match syntax.kind() {
4361 TYPE_DEF => Some(TypeDef::from_repr(syntax.into_repr())),
4362 _ => None,
4363 }
4364 }
4365 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4366}
4367
4368impl ToOwned for TypeDef {
4369 type Owned = TreeArc<TypeDef>;
4370 fn to_owned(&self) -> TreeArc<TypeDef> { TreeArc::cast(self.syntax.to_owned()) }
4371}
4372
4373
4374impl ast::VisibilityOwner for TypeDef {}
4375impl ast::NameOwner for TypeDef {}
4376impl ast::TypeParamsOwner for TypeDef {}
4377impl ast::AttrsOwner for TypeDef {}
4378impl ast::DocCommentsOwner for TypeDef {}
4379impl TypeDef {
4380 pub fn type_ref(&self) -> Option<&TypeRef> {
4381 super::child_opt(self)
4382 }
4383}
4384
4385// TypeParam 4385// TypeParam
4386#[derive(Debug, PartialEq, Eq, Hash)] 4386#[derive(Debug, PartialEq, Eq, Hash)]
4387#[repr(transparent)] 4387#[repr(transparent)]
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index b1775d0f8..c7acbbd6c 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -132,7 +132,7 @@ Grammar(
132 "CONST_DEF", 132 "CONST_DEF",
133 "TRAIT_DEF", 133 "TRAIT_DEF",
134 "IMPL_BLOCK", 134 "IMPL_BLOCK",
135 "TYPE_DEF", 135 "TYPE_ALIAS_DEF",
136 "MACRO_CALL", 136 "MACRO_CALL",
137 "TOKEN_TREE", 137 "TOKEN_TREE",
138 138
@@ -312,7 +312,7 @@ Grammar(
312 ], 312 ],
313 options: ["TypeRef"] 313 options: ["TypeRef"]
314 ), 314 ),
315 "TypeDef": ( 315 "TypeAliasDef": (
316 traits: [ 316 traits: [
317 "VisibilityOwner", 317 "VisibilityOwner",
318 "NameOwner", 318 "NameOwner",
@@ -363,11 +363,11 @@ Grammar(
363 ], 363 ],
364 ), 364 ),
365 "ModuleItem": ( 365 "ModuleItem": (
366 enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeDef", "ImplBlock", 366 enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeAliasDef", "ImplBlock",
367 "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ] 367 "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ]
368 ), 368 ),
369 "ImplItem": ( 369 "ImplItem": (
370 enum: ["FnDef", "TypeDef", "ConstDef"] 370 enum: ["FnDef", "TypeAliasDef", "ConstDef"]
371 ), 371 ),
372 372
373 "TupleExpr": ( 373 "TupleExpr": (
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index 961a91d41..b17d06c61 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -143,7 +143,7 @@ fn n_attached_trivias<'a>(
143 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 143 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
144) -> usize { 144) -> usize {
145 match kind { 145 match kind {
146 CONST_DEF | TYPE_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF 146 CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF
147 | MODULE | NAMED_FIELD_DEF => { 147 | MODULE | NAMED_FIELD_DEF => {
148 let mut res = 0; 148 let mut res = 0;
149 for (i, (kind, text)) in trivias.enumerate() { 149 for (i, (kind, text)) in trivias.enumerate() {