diff options
Diffstat (limited to 'crates/ra_hir_def/src/item_tree.rs')
-rw-r--r-- | crates/ra_hir_def/src/item_tree.rs | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 3e603bd55..a67e75dac 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs | |||
@@ -13,7 +13,7 @@ use std::{ | |||
13 | sync::Arc, | 13 | sync::Arc, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | use ast::{AstNode, AttrsOwner, NameOwner, StructKind, TypeAscriptionOwner}; | 16 | use ast::{AstNode, AttrsOwner, NameOwner, StructKind}; |
17 | use either::Either; | 17 | use either::Either; |
18 | use hir_expand::{ | 18 | use hir_expand::{ |
19 | ast_id_map::FileAstId, | 19 | ast_id_map::FileAstId, |
@@ -70,7 +70,7 @@ impl GenericParamsId { | |||
70 | pub struct ItemTree { | 70 | pub struct ItemTree { |
71 | top_level: SmallVec<[ModItem; 1]>, | 71 | top_level: SmallVec<[ModItem; 1]>, |
72 | attrs: FxHashMap<AttrOwner, Attrs>, | 72 | attrs: FxHashMap<AttrOwner, Attrs>, |
73 | inner_items: FxHashMap<FileAstId<ast::ModuleItem>, SmallVec<[ModItem; 1]>>, | 73 | inner_items: FxHashMap<FileAstId<ast::Item>, SmallVec<[ModItem; 1]>>, |
74 | 74 | ||
75 | data: Option<Box<ItemTreeData>>, | 75 | data: Option<Box<ItemTreeData>>, |
76 | } | 76 | } |
@@ -187,7 +187,7 @@ impl ItemTree { | |||
187 | /// | 187 | /// |
188 | /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered | 188 | /// Most AST items are lowered to a single `ModItem`, but some (eg. `use` items) may be lowered |
189 | /// to multiple items in the `ItemTree`. | 189 | /// to multiple items in the `ItemTree`. |
190 | pub fn inner_items(&self, ast: FileAstId<ast::ModuleItem>) -> &[ModItem] { | 190 | pub fn inner_items(&self, ast: FileAstId<ast::Item>) -> &[ModItem] { |
191 | &self.inner_items[&ast] | 191 | &self.inner_items[&ast] |
192 | } | 192 | } |
193 | 193 | ||
@@ -310,7 +310,7 @@ from_attrs!(ModItem(ModItem), Variant(Idx<Variant>), Field(Idx<Field>)); | |||
310 | 310 | ||
311 | /// Trait implemented by all item nodes in the item tree. | 311 | /// Trait implemented by all item nodes in the item tree. |
312 | pub trait ItemTreeNode: Clone { | 312 | pub trait ItemTreeNode: Clone { |
313 | type Source: AstNode + Into<ast::ModuleItem>; | 313 | type Source: AstNode + Into<ast::Item>; |
314 | 314 | ||
315 | fn ast_id(&self) -> FileAstId<Self::Source>; | 315 | fn ast_id(&self) -> FileAstId<Self::Source>; |
316 | 316 | ||
@@ -411,17 +411,17 @@ macro_rules! mod_items { | |||
411 | } | 411 | } |
412 | 412 | ||
413 | mod_items! { | 413 | mod_items! { |
414 | Import in imports -> ast::UseItem, | 414 | Import in imports -> ast::Use, |
415 | ExternCrate in extern_crates -> ast::ExternCrateItem, | 415 | ExternCrate in extern_crates -> ast::ExternCrate, |
416 | Function in functions -> ast::FnDef, | 416 | Function in functions -> ast::Fn, |
417 | Struct in structs -> ast::StructDef, | 417 | Struct in structs -> ast::Struct, |
418 | Union in unions -> ast::UnionDef, | 418 | Union in unions -> ast::Union, |
419 | Enum in enums -> ast::EnumDef, | 419 | Enum in enums -> ast::Enum, |
420 | Const in consts -> ast::ConstDef, | 420 | Const in consts -> ast::Const, |
421 | Static in statics -> ast::StaticDef, | 421 | Static in statics -> ast::Static, |
422 | Trait in traits -> ast::TraitDef, | 422 | Trait in traits -> ast::Trait, |
423 | Impl in impls -> ast::ImplDef, | 423 | Impl in impls -> ast::Impl, |
424 | TypeAlias in type_aliases -> ast::TypeAliasDef, | 424 | TypeAlias in type_aliases -> ast::TypeAlias, |
425 | Mod in mods -> ast::Module, | 425 | Mod in mods -> ast::Module, |
426 | MacroCall in macro_calls -> ast::MacroCall, | 426 | MacroCall in macro_calls -> ast::MacroCall, |
427 | } | 427 | } |
@@ -482,7 +482,7 @@ pub struct Import { | |||
482 | pub is_prelude: bool, | 482 | pub is_prelude: bool, |
483 | /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many | 483 | /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many |
484 | /// `Import`s can map to the same `use` item. | 484 | /// `Import`s can map to the same `use` item. |
485 | pub ast_id: FileAstId<ast::UseItem>, | 485 | pub ast_id: FileAstId<ast::Use>, |
486 | } | 486 | } |
487 | 487 | ||
488 | #[derive(Debug, Clone, Eq, PartialEq)] | 488 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -492,7 +492,7 @@ pub struct ExternCrate { | |||
492 | pub visibility: RawVisibilityId, | 492 | pub visibility: RawVisibilityId, |
493 | /// Whether this is a `#[macro_use] extern crate ...`. | 493 | /// Whether this is a `#[macro_use] extern crate ...`. |
494 | pub is_macro_use: bool, | 494 | pub is_macro_use: bool, |
495 | pub ast_id: FileAstId<ast::ExternCrateItem>, | 495 | pub ast_id: FileAstId<ast::ExternCrate>, |
496 | } | 496 | } |
497 | 497 | ||
498 | #[derive(Debug, Clone, Eq, PartialEq)] | 498 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -503,8 +503,9 @@ pub struct Function { | |||
503 | pub has_self_param: bool, | 503 | pub has_self_param: bool, |
504 | pub is_unsafe: bool, | 504 | pub is_unsafe: bool, |
505 | pub params: Box<[TypeRef]>, | 505 | pub params: Box<[TypeRef]>, |
506 | pub is_varargs: bool, | ||
506 | pub ret_type: TypeRef, | 507 | pub ret_type: TypeRef, |
507 | pub ast_id: FileAstId<ast::FnDef>, | 508 | pub ast_id: FileAstId<ast::Fn>, |
508 | } | 509 | } |
509 | 510 | ||
510 | #[derive(Debug, Clone, Eq, PartialEq)] | 511 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -513,7 +514,7 @@ pub struct Struct { | |||
513 | pub visibility: RawVisibilityId, | 514 | pub visibility: RawVisibilityId, |
514 | pub generic_params: GenericParamsId, | 515 | pub generic_params: GenericParamsId, |
515 | pub fields: Fields, | 516 | pub fields: Fields, |
516 | pub ast_id: FileAstId<ast::StructDef>, | 517 | pub ast_id: FileAstId<ast::Struct>, |
517 | pub kind: StructDefKind, | 518 | pub kind: StructDefKind, |
518 | } | 519 | } |
519 | 520 | ||
@@ -533,7 +534,7 @@ pub struct Union { | |||
533 | pub visibility: RawVisibilityId, | 534 | pub visibility: RawVisibilityId, |
534 | pub generic_params: GenericParamsId, | 535 | pub generic_params: GenericParamsId, |
535 | pub fields: Fields, | 536 | pub fields: Fields, |
536 | pub ast_id: FileAstId<ast::UnionDef>, | 537 | pub ast_id: FileAstId<ast::Union>, |
537 | } | 538 | } |
538 | 539 | ||
539 | #[derive(Debug, Clone, Eq, PartialEq)] | 540 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -542,7 +543,7 @@ pub struct Enum { | |||
542 | pub visibility: RawVisibilityId, | 543 | pub visibility: RawVisibilityId, |
543 | pub generic_params: GenericParamsId, | 544 | pub generic_params: GenericParamsId, |
544 | pub variants: IdRange<Variant>, | 545 | pub variants: IdRange<Variant>, |
545 | pub ast_id: FileAstId<ast::EnumDef>, | 546 | pub ast_id: FileAstId<ast::Enum>, |
546 | } | 547 | } |
547 | 548 | ||
548 | #[derive(Debug, Clone, Eq, PartialEq)] | 549 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -551,7 +552,7 @@ pub struct Const { | |||
551 | pub name: Option<Name>, | 552 | pub name: Option<Name>, |
552 | pub visibility: RawVisibilityId, | 553 | pub visibility: RawVisibilityId, |
553 | pub type_ref: TypeRef, | 554 | pub type_ref: TypeRef, |
554 | pub ast_id: FileAstId<ast::ConstDef>, | 555 | pub ast_id: FileAstId<ast::Const>, |
555 | } | 556 | } |
556 | 557 | ||
557 | #[derive(Debug, Clone, Eq, PartialEq)] | 558 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -560,7 +561,7 @@ pub struct Static { | |||
560 | pub visibility: RawVisibilityId, | 561 | pub visibility: RawVisibilityId, |
561 | pub mutable: bool, | 562 | pub mutable: bool, |
562 | pub type_ref: TypeRef, | 563 | pub type_ref: TypeRef, |
563 | pub ast_id: FileAstId<ast::StaticDef>, | 564 | pub ast_id: FileAstId<ast::Static>, |
564 | } | 565 | } |
565 | 566 | ||
566 | #[derive(Debug, Clone, Eq, PartialEq)] | 567 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -570,7 +571,7 @@ pub struct Trait { | |||
570 | pub generic_params: GenericParamsId, | 571 | pub generic_params: GenericParamsId, |
571 | pub auto: bool, | 572 | pub auto: bool, |
572 | pub items: Box<[AssocItem]>, | 573 | pub items: Box<[AssocItem]>, |
573 | pub ast_id: FileAstId<ast::TraitDef>, | 574 | pub ast_id: FileAstId<ast::Trait>, |
574 | } | 575 | } |
575 | 576 | ||
576 | #[derive(Debug, Clone, Eq, PartialEq)] | 577 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -580,7 +581,7 @@ pub struct Impl { | |||
580 | pub target_type: TypeRef, | 581 | pub target_type: TypeRef, |
581 | pub is_negative: bool, | 582 | pub is_negative: bool, |
582 | pub items: Box<[AssocItem]>, | 583 | pub items: Box<[AssocItem]>, |
583 | pub ast_id: FileAstId<ast::ImplDef>, | 584 | pub ast_id: FileAstId<ast::Impl>, |
584 | } | 585 | } |
585 | 586 | ||
586 | #[derive(Debug, Clone, PartialEq, Eq)] | 587 | #[derive(Debug, Clone, PartialEq, Eq)] |
@@ -591,7 +592,7 @@ pub struct TypeAlias { | |||
591 | pub bounds: Box<[TypeBound]>, | 592 | pub bounds: Box<[TypeBound]>, |
592 | pub generic_params: GenericParamsId, | 593 | pub generic_params: GenericParamsId, |
593 | pub type_ref: Option<TypeRef>, | 594 | pub type_ref: Option<TypeRef>, |
594 | pub ast_id: FileAstId<ast::TypeAliasDef>, | 595 | pub ast_id: FileAstId<ast::TypeAlias>, |
595 | } | 596 | } |
596 | 597 | ||
597 | #[derive(Debug, Clone, Eq, PartialEq)] | 598 | #[derive(Debug, Clone, Eq, PartialEq)] |