diff options
Diffstat (limited to 'crates/ra_ide_api_light')
-rw-r--r-- | crates/ra_ide_api_light/src/structure.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs index dea494daa..ec2c9bbc6 100644 --- a/crates/ra_ide_api_light/src/structure.rs +++ b/crates/ra_ide_api_light/src/structure.rs | |||
@@ -2,7 +2,7 @@ use crate::TextRange; | |||
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::visit::{visitor, Visitor}, | 4 | algo::visit::{visitor, Visitor}, |
5 | ast::{self, AttrsOwner, NameOwner, TypeParamsOwner}, | 5 | ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, |
6 | AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, | 6 | AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -45,6 +45,12 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
45 | decl_with_detail(node, None) | 45 | decl_with_detail(node, None) |
46 | } | 46 | } |
47 | 47 | ||
48 | fn decl_with_ascription<N: NameOwner + AttrsOwner + TypeAscriptionOwner>( | ||
49 | node: &N, | ||
50 | ) -> Option<StructureNode> { | ||
51 | decl_with_type_ref(node, node.ascribed_type()) | ||
52 | } | ||
53 | |||
48 | fn decl_with_type_ref<N: NameOwner + AttrsOwner>( | 54 | fn decl_with_type_ref<N: NameOwner + AttrsOwner>( |
49 | node: &N, | 55 | node: &N, |
50 | type_ref: Option<&ast::TypeRef>, | 56 | type_ref: Option<&ast::TypeRef>, |
@@ -107,14 +113,14 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
107 | decl_with_detail(fn_def, Some(detail)) | 113 | decl_with_detail(fn_def, Some(detail)) |
108 | }) | 114 | }) |
109 | .visit(decl::<ast::StructDef>) | 115 | .visit(decl::<ast::StructDef>) |
110 | .visit(|nfd: &ast::NamedFieldDef| decl_with_type_ref(nfd, nfd.type_ref())) | ||
111 | .visit(decl::<ast::EnumDef>) | 116 | .visit(decl::<ast::EnumDef>) |
112 | .visit(decl::<ast::EnumVariant>) | 117 | .visit(decl::<ast::EnumVariant>) |
113 | .visit(decl::<ast::TraitDef>) | 118 | .visit(decl::<ast::TraitDef>) |
114 | .visit(decl::<ast::Module>) | 119 | .visit(decl::<ast::Module>) |
115 | .visit(|td: &ast::TypeAliasDef| decl_with_type_ref(td, td.type_ref())) | 120 | .visit(|td: &ast::TypeAliasDef| decl_with_type_ref(td, td.type_ref())) |
116 | .visit(|cd: &ast::ConstDef| decl_with_type_ref(cd, cd.type_ref())) | 121 | .visit(decl_with_ascription::<ast::NamedFieldDef>) |
117 | .visit(|sd: &ast::StaticDef| decl_with_type_ref(sd, sd.type_ref())) | 122 | .visit(decl_with_ascription::<ast::ConstDef>) |
123 | .visit(decl_with_ascription::<ast::StaticDef>) | ||
118 | .visit(|im: &ast::ImplBlock| { | 124 | .visit(|im: &ast::ImplBlock| { |
119 | let target_type = im.target_type()?; | 125 | let target_type = im.target_type()?; |
120 | let target_trait = im.target_trait(); | 126 | let target_trait = im.target_trait(); |