From 78f10fcdc41d5c58e386bc99a94b34a2bdbaa4cd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 25 Feb 2019 13:38:52 +0300 Subject: rename type to type_alias in the AST as well --- .../src/snapshots/tests__file_structure.snap | 2 +- .../src/snapshots/tests__file_structure.snap.new | 182 +++++++++++++++++++++ crates/ra_ide_api_light/src/structure.rs | 2 +- 3 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap.new (limited to 'crates/ra_ide_api_light/src') diff --git a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap index 413f4a5ff..8e4184b31 100644 --- a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap +++ b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap @@ -111,7 +111,7 @@ expression: structure label: "T", navigation_range: [186; 187), node_range: [181; 193), - kind: TYPE_DEF, + kind: TYPE_ALIAS_DEF, detail: Some( "()" ), diff --git a/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap.new b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap.new new file mode 100644 index 000000000..a3c6cd9ce --- /dev/null +++ b/crates/ra_ide_api_light/src/snapshots/tests__file_structure.snap.new @@ -0,0 +1,182 @@ +--- +created: "2019-02-25T10:38:16.909647631Z" +creator: insta@0.6.3 +source: crates/ra_ide_api_light/src/structure.rs +expression: structure +--- +[ + StructureNode { + parent: None, + label: "Foo", + navigation_range: [8; 11), + node_range: [1; 26), + kind: STRUCT_DEF, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 0 + ), + label: "x", + navigation_range: [18; 19), + node_range: [18; 24), + kind: NAMED_FIELD_DEF, + detail: Some( + "i32" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "m", + navigation_range: [32; 33), + node_range: [28; 158), + kind: MODULE, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 2 + ), + label: "bar1", + navigation_range: [43; 47), + node_range: [40; 52), + kind: FN_DEF, + detail: Some( + "fn()" + ), + deprecated: false + }, + StructureNode { + parent: Some( + 2 + ), + label: "bar2", + navigation_range: [60; 64), + node_range: [57; 81), + kind: FN_DEF, + detail: Some( + "fn(t: T) -> T" + ), + deprecated: false + }, + StructureNode { + parent: Some( + 2 + ), + label: "bar3", + navigation_range: [89; 93), + node_range: [86; 156), + kind: FN_DEF, + detail: Some( + "fn(a: A, b: B) -> Vec< u32 >" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "E", + navigation_range: [165; 166), + node_range: [160; 180), + kind: ENUM_DEF, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 6 + ), + label: "X", + navigation_range: [169; 170), + node_range: [169; 170), + kind: ENUM_VARIANT, + detail: None, + deprecated: false + }, + StructureNode { + parent: Some( + 6 + ), + label: "Y", + navigation_range: [172; 173), + node_range: [172; 178), + kind: ENUM_VARIANT, + detail: None, + deprecated: false + }, + StructureNode { + parent: None, + label: "T", + navigation_range: [186; 187), + node_range: [181; 193), + kind: TYPE_ALIAS_DEF, + detail: Some( + "()" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "S", + navigation_range: [201; 202), + node_range: [194; 213), + kind: STATIC_DEF, + detail: Some( + "i32" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "C", + navigation_range: [220; 221), + node_range: [214; 232), + kind: CONST_DEF, + detail: Some( + "i32" + ), + deprecated: false + }, + StructureNode { + parent: None, + label: "impl E", + navigation_range: [239; 240), + node_range: [234; 243), + kind: IMPL_BLOCK, + detail: None, + deprecated: false + }, + StructureNode { + parent: None, + label: "impl fmt::Debug for E", + navigation_range: [265; 266), + node_range: [245; 269), + kind: IMPL_BLOCK, + detail: None, + deprecated: false + }, + StructureNode { + parent: None, + label: "obsolete", + navigation_range: [288; 296), + node_range: [271; 301), + kind: FN_DEF, + detail: Some( + "fn()" + ), + deprecated: true + }, + StructureNode { + parent: None, + label: "very_obsolete", + navigation_range: [341; 354), + node_range: [303; 359), + kind: FN_DEF, + detail: Some( + "fn()" + ), + deprecated: true + } +] diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs index 75afd1181..dea494daa 100644 --- a/crates/ra_ide_api_light/src/structure.rs +++ b/crates/ra_ide_api_light/src/structure.rs @@ -112,7 +112,7 @@ fn structure_node(node: &SyntaxNode) -> Option { .visit(decl::) .visit(decl::) .visit(decl::) - .visit(|td: &ast::TypeDef| decl_with_type_ref(td, td.type_ref())) + .visit(|td: &ast::TypeAliasDef| decl_with_type_ref(td, td.type_ref())) .visit(|cd: &ast::ConstDef| decl_with_type_ref(cd, cd.type_ref())) .visit(|sd: &ast::StaticDef| decl_with_type_ref(sd, sd.type_ref())) .visit(|im: &ast::ImplBlock| { -- cgit v1.2.3