From 1142112c70b705f59b7d559d9d72cdc831865158 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 14:51:08 +0200 Subject: Rename FnDef -> Fn --- crates/ra_ide/src/file_structure.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 1f6a3febf..41603480e 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -111,7 +111,7 @@ fn structure_node(node: &SyntaxNode) -> Option { match_ast! { match node { - ast::FnDef(it) => { + ast::Fn(it) => { let mut detail = String::from("fn"); if let Some(type_param_list) = it.type_param_list() { collapse_ws(type_param_list.syntax(), &mut detail); @@ -271,7 +271,7 @@ fn very_obsolete() {} label: "bar1", navigation_range: 43..47, node_range: 40..52, - kind: FN_DEF, + kind: FN, detail: Some( "fn()", ), @@ -284,7 +284,7 @@ fn very_obsolete() {} label: "bar2", navigation_range: 60..64, node_range: 57..81, - kind: FN_DEF, + kind: FN, detail: Some( "fn(t: T) -> T", ), @@ -297,7 +297,7 @@ fn very_obsolete() {} label: "bar3", navigation_range: 89..93, node_range: 86..156, - kind: FN_DEF, + kind: FN, detail: Some( "fn(a: A, b: B) -> Vec< u32 >", ), @@ -417,7 +417,7 @@ fn very_obsolete() {} label: "obsolete", navigation_range: 428..436, node_range: 411..441, - kind: FN_DEF, + kind: FN, detail: Some( "fn()", ), @@ -428,7 +428,7 @@ fn very_obsolete() {} label: "very_obsolete", navigation_range: 481..494, node_range: 443..499, - kind: FN_DEF, + kind: FN, detail: Some( "fn()", ), -- cgit v1.2.3 From eb2f8063444b11257111f4f8ade990ec810e0361 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 15:25:46 +0200 Subject: Rename TypeAliasDef -> TypeAlias --- crates/ra_ide/src/file_structure.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 41603480e..8ef977761 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -132,7 +132,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::EnumVariant(it) => decl(it), ast::TraitDef(it) => decl(it), ast::Module(it) => decl(it), - ast::TypeAliasDef(it) => { + ast::TypeAlias(it) => { let ty = it.type_ref(); decl_with_type_ref(it, ty) }, @@ -339,7 +339,7 @@ fn very_obsolete() {} label: "T", navigation_range: 186..187, node_range: 181..193, - kind: TYPE_ALIAS_DEF, + kind: TYPE_ALIAS, detail: Some( "()", ), -- cgit v1.2.3 From 28ef4c375a9f56d69daf885504aea3df7012bb81 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 15:36:21 +0200 Subject: Rename TypeParamList -> GenericParamList --- crates/ra_ide/src/file_structure.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 8ef977761..05ccc0b73 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -1,5 +1,5 @@ use ra_syntax::{ - ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, + ast::{self, AttrsOwner, GenericParamsOwner, NameOwner, TypeAscriptionOwner}, match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, }; @@ -113,7 +113,7 @@ fn structure_node(node: &SyntaxNode) -> Option { match node { ast::Fn(it) => { let mut detail = String::from("fn"); - if let Some(type_param_list) = it.type_param_list() { + if let Some(type_param_list) = it.generic_param_list() { collapse_ws(type_param_list.syntax(), &mut detail); } if let Some(param_list) = it.param_list() { -- cgit v1.2.3 From 0a9e3ccc262fbcbd4cdaab30384f8cb71584544b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 16:49:13 +0200 Subject: Rename FieldDef -> Field --- crates/ra_ide/src/file_structure.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 05ccc0b73..a8fd1a2fd 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -136,7 +136,7 @@ fn structure_node(node: &SyntaxNode) -> Option { let ty = it.type_ref(); decl_with_type_ref(it, ty) }, - ast::RecordFieldDef(it) => decl_with_ascription(it), + ast::RecordField(it) => decl_with_ascription(it), ast::ConstDef(it) => decl_with_ascription(it), ast::StaticDef(it) => decl_with_ascription(it), ast::ImplDef(it) => { @@ -249,7 +249,7 @@ fn very_obsolete() {} label: "x", navigation_range: 18..19, node_range: 18..24, - kind: RECORD_FIELD_DEF, + kind: RECORD_FIELD, detail: Some( "i32", ), -- cgit v1.2.3 From 1ae4721c9cfea746fce59a816b1c266bf373d6cf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:36:46 +0200 Subject: Finalize union grammar --- crates/ra_ide/src/file_structure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index a8fd1a2fd..874cf72ef 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -127,7 +127,7 @@ fn structure_node(node: &SyntaxNode) -> Option { decl_with_detail(it, Some(detail)) }, ast::StructDef(it) => decl(it), - ast::UnionDef(it) => decl(it), + ast::Union(it) => decl(it), ast::EnumDef(it) => decl(it), ast::EnumVariant(it) => decl(it), ast::TraitDef(it) => decl(it), -- cgit v1.2.3 From 216a5344c8ef3c3e430d2761dc8b1a7b60250a15 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:50:40 +0200 Subject: Rename StructDef -> Struct --- crates/ra_ide/src/file_structure.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 874cf72ef..6f198fcbc 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -126,7 +126,7 @@ fn structure_node(node: &SyntaxNode) -> Option { 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, }, -- cgit v1.2.3 From 609680ef97dbf82c07b6b06e21aa366423892304 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:52:53 +0200 Subject: Rename EnumDef -> Enum --- crates/ra_ide/src/file_structure.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 6f198fcbc..c909f96aa 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -128,7 +128,7 @@ fn structure_node(node: &SyntaxNode) -> Option { }, ast::Struct(it) => decl(it), ast::Union(it) => decl(it), - ast::EnumDef(it) => decl(it), + ast::Enum(it) => decl(it), ast::EnumVariant(it) => decl(it), ast::TraitDef(it) => decl(it), ast::Module(it) => decl(it), @@ -308,7 +308,7 @@ fn very_obsolete() {} label: "E", navigation_range: 165..166, node_range: 160..180, - kind: ENUM_DEF, + kind: ENUM, detail: None, deprecated: false, }, -- cgit v1.2.3 From 1766aae145c6925a33e427f2fe6ef2a56c301665 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:56:53 +0200 Subject: Rename EnumVariant -> Variant --- crates/ra_ide/src/file_structure.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index c909f96aa..43202499d 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -129,7 +129,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::Struct(it) => decl(it), ast::Union(it) => decl(it), ast::Enum(it) => decl(it), - ast::EnumVariant(it) => decl(it), + ast::Variant(it) => decl(it), ast::TraitDef(it) => decl(it), ast::Module(it) => decl(it), ast::TypeAlias(it) => { @@ -319,7 +319,7 @@ fn very_obsolete() {} label: "X", navigation_range: 169..170, node_range: 169..170, - kind: ENUM_VARIANT, + kind: VARIANT, detail: None, deprecated: false, }, @@ -330,7 +330,7 @@ fn very_obsolete() {} label: "Y", navigation_range: 172..173, node_range: 172..178, - kind: ENUM_VARIANT, + kind: VARIANT, detail: None, deprecated: false, }, -- cgit v1.2.3 From 3cd4112bdc924c132cb0eab9d064511a215421ec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:02:20 +0200 Subject: Finalize const&static grammar --- crates/ra_ide/src/file_structure.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 43202499d..77384b6ec 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -137,8 +137,8 @@ fn structure_node(node: &SyntaxNode) -> Option { decl_with_type_ref(it, ty) }, ast::RecordField(it) => decl_with_ascription(it), - ast::ConstDef(it) => decl_with_ascription(it), - ast::StaticDef(it) => decl_with_ascription(it), + ast::Const(it) => decl_with_ascription(it), + ast::Static(it) => decl_with_ascription(it), ast::ImplDef(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); @@ -350,7 +350,7 @@ fn very_obsolete() {} label: "S", navigation_range: 201..202, node_range: 194..213, - kind: STATIC_DEF, + kind: STATIC, detail: Some( "i32", ), @@ -361,7 +361,7 @@ fn very_obsolete() {} label: "C", navigation_range: 220..221, node_range: 214..232, - kind: CONST_DEF, + kind: CONST, detail: Some( "i32", ), -- cgit v1.2.3 From c83467796b6c7365ea4f41900d74444384a9e618 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:17:28 +0200 Subject: Finalize Trait grammar --- crates/ra_ide/src/file_structure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 77384b6ec..3fc972460 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -130,7 +130,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::Union(it) => decl(it), ast::Enum(it) => decl(it), ast::Variant(it) => decl(it), - ast::TraitDef(it) => decl(it), + ast::Trait(it) => decl(it), ast::Module(it) => decl(it), ast::TypeAlias(it) => { let ty = it.type_ref(); -- cgit v1.2.3 From c5798c4d75aa807aec47208a49101bdec3affcca Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:28:28 +0200 Subject: Finalize impl Grammar --- crates/ra_ide/src/file_structure.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 3fc972460..7d378f2d0 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -139,7 +139,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::RecordField(it) => decl_with_ascription(it), ast::Const(it) => decl_with_ascription(it), ast::Static(it) => decl_with_ascription(it), - ast::ImplDef(it) => { + ast::Impl(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); let label = match target_trait { @@ -372,7 +372,7 @@ fn very_obsolete() {} label: "impl E", navigation_range: 239..240, node_range: 234..243, - kind: IMPL_DEF, + kind: IMPL, detail: None, deprecated: false, }, @@ -381,7 +381,7 @@ fn very_obsolete() {} label: "impl fmt::Debug for E", navigation_range: 265..266, node_range: 245..269, - kind: IMPL_DEF, + kind: IMPL, detail: None, deprecated: false, }, -- cgit v1.2.3 From 2e2642efccd5855e4158b01a006e7884a96982bb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 20:51:43 +0200 Subject: Remove TypeAscriptionOwner --- crates/ra_ide/src/file_structure.rs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 7d378f2d0..22cf8637a 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -1,5 +1,5 @@ use ra_syntax::{ - ast::{self, AttrsOwner, GenericParamsOwner, NameOwner, TypeAscriptionOwner}, + ast::{self, AttrsOwner, GenericParamsOwner, NameOwner}, match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, }; @@ -52,18 +52,11 @@ pub fn file_structure(file: &SourceFile) -> Vec { fn structure_node(node: &SyntaxNode) -> Option { fn decl(node: N) -> Option { - decl_with_detail(node, None) - } - - fn decl_with_ascription( - node: N, - ) -> Option { - let ty = node.ascribed_type(); - decl_with_type_ref(node, ty) + decl_with_detail(&node, None) } fn decl_with_type_ref( - node: N, + node: &N, type_ref: Option, ) -> Option { let detail = type_ref.map(|type_ref| { @@ -75,7 +68,7 @@ fn structure_node(node: &SyntaxNode) -> Option { } fn decl_with_detail( - node: N, + node: &N, detail: Option, ) -> Option { let name = node.name()?; @@ -124,7 +117,7 @@ fn structure_node(node: &SyntaxNode) -> Option { collapse_ws(ret_type.syntax(), &mut detail); } - decl_with_detail(it, Some(detail)) + decl_with_detail(&it, Some(detail)) }, ast::Struct(it) => decl(it), ast::Union(it) => decl(it), @@ -132,13 +125,10 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::Variant(it) => decl(it), ast::Trait(it) => decl(it), ast::Module(it) => decl(it), - ast::TypeAlias(it) => { - let ty = it.type_ref(); - decl_with_type_ref(it, ty) - }, - ast::RecordField(it) => decl_with_ascription(it), - ast::Const(it) => decl_with_ascription(it), - ast::Static(it) => decl_with_ascription(it), + ast::TypeAlias(it) => decl_with_type_ref(&it, it.type_ref()), + ast::RecordField(it) => decl_with_type_ref(&it, it.ty()), + ast::Const(it) => decl_with_type_ref(&it, it.ty()), + ast::Static(it) => decl_with_type_ref(&it, it.ty()), ast::Impl(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); -- cgit v1.2.3 From f95f425ae4199e814e6956be1d9bb59a14758c07 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 21:02:55 +0200 Subject: Use ty to access most TypeRefs --- crates/ra_ide/src/file_structure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 22cf8637a..91765140a 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -125,7 +125,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::Variant(it) => decl(it), ast::Trait(it) => decl(it), ast::Module(it) => decl(it), - ast::TypeAlias(it) => decl_with_type_ref(&it, it.type_ref()), + ast::TypeAlias(it) => decl_with_type_ref(&it, it.ty()), ast::RecordField(it) => decl_with_type_ref(&it, it.ty()), ast::Const(it) => decl_with_type_ref(&it, it.ty()), ast::Static(it) => decl_with_type_ref(&it, it.ty()), -- cgit v1.2.3 From 08ea2271e8050165d0aaf4c994ed3dd746aff3ba Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 12:06:38 +0200 Subject: Rename TypeRef -> Type The TypeRef name comes from IntelliJ days, where you often have both type *syntax* as well as *semantical* representation of types in scope. And naming both Type is confusing. In rust-analyzer however, we use ast types as `ast::Type`, and have many more semantic counterparts to ast types, so avoiding name clash here is just confusing. --- crates/ra_ide/src/file_structure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 91765140a..ef368651a 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -57,7 +57,7 @@ fn structure_node(node: &SyntaxNode) -> Option { fn decl_with_type_ref( node: &N, - type_ref: Option, + type_ref: Option, ) -> Option { let detail = type_ref.map(|type_ref| { let mut detail = String::new(); -- cgit v1.2.3 From af53d5f4b081ad50d8fe08fc1e107aa6025b2491 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 20:23:52 +0200 Subject: Rename --- crates/ra_ide/src/file_structure.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/file_structure.rs') diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index ef368651a..87cab4503 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -130,8 +130,8 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::Const(it) => decl_with_type_ref(&it, it.ty()), ast::Static(it) => decl_with_type_ref(&it, it.ty()), ast::Impl(it) => { - let target_type = it.target_type()?; - let target_trait = it.target_trait(); + let target_type = it.self_ty()?; + let target_trait = it.trait_(); let label = match target_trait { None => format!("impl {}", target_type.syntax().text()), Some(t) => { -- cgit v1.2.3