diff options
author | Aleksey Kladov <[email protected]> | 2020-07-30 17:28:28 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-30 17:28:28 +0100 |
commit | c5798c4d75aa807aec47208a49101bdec3affcca (patch) | |
tree | 1af0efdcee857e1ba91e76f4cc7fd7c043916ebb /crates/ra_assists/src | |
parent | c83467796b6c7365ea4f41900d74444384a9e618 (diff) |
Finalize impl Grammar
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/ast_transform.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/generate_new.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/introduce_named_lifetime.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/move_bounds.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/utils.rs | 4 |
6 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 01adb834c..5ea4f9f5b 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs | |||
@@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> { | |||
41 | source_scope: &'a SemanticsScope<'a>, | 41 | source_scope: &'a SemanticsScope<'a>, |
42 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... | 42 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... |
43 | trait_: hir::Trait, | 43 | trait_: hir::Trait, |
44 | impl_def: ast::ImplDef, | 44 | impl_def: ast::Impl, |
45 | ) -> SubstituteTypeParams<'a> { | 45 | ) -> SubstituteTypeParams<'a> { |
46 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); | 46 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); |
47 | let generic_def: hir::GenericDef = trait_.into(); | 47 | let generic_def: hir::GenericDef = trait_.into(); |
@@ -80,7 +80,7 @@ impl<'a> SubstituteTypeParams<'a> { | |||
80 | 80 | ||
81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the | 81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the |
82 | // trait ref, and then go from the types in the substs back to the syntax) | 82 | // trait ref, and then go from the types in the substs back to the syntax) |
83 | fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> { | 83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::TypeRef>> { |
84 | let target_trait = impl_def.target_trait()?; | 84 | let target_trait = impl_def.target_trait()?; |
85 | let path_type = match target_trait { | 85 | let path_type = match target_trait { |
86 | ast::TypeRef::PathType(path) => path, | 86 | ast::TypeRef::PathType(path) => path, |
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 1ab176c26..95a750aee 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -111,7 +111,7 @@ fn add_missing_impl_members_inner( | |||
111 | label: &'static str, | 111 | label: &'static str, |
112 | ) -> Option<()> { | 112 | ) -> Option<()> { |
113 | let _p = ra_prof::profile("add_missing_impl_members_inner"); | 113 | let _p = ra_prof::profile("add_missing_impl_members_inner"); |
114 | let impl_def = ctx.find_node_at_offset::<ast::ImplDef>()?; | 114 | let impl_def = ctx.find_node_at_offset::<ast::Impl>()?; |
115 | let impl_item_list = impl_def.assoc_item_list()?; | 115 | let impl_item_list = impl_def.assoc_item_list()?; |
116 | 116 | ||
117 | let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; | 117 | let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; |
diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index 22b47d254..3c67749ee 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs | |||
@@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String { | |||
122 | // | 122 | // |
123 | // FIXME: change the new fn checking to a more semantic approach when that's more | 123 | // FIXME: change the new fn checking to a more semantic approach when that's more |
124 | // viable (e.g. we process proc macros, etc) | 124 | // viable (e.g. we process proc macros, etc) |
125 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::ImplDef>> { | 125 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::Impl>> { |
126 | let db = ctx.db(); | 126 | let db = ctx.db(); |
127 | let module = strukt.syntax().ancestors().find(|node| { | 127 | let module = strukt.syntax().ancestors().find(|node| { |
128 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) | 128 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) |
@@ -130,7 +130,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option< | |||
130 | 130 | ||
131 | let struct_def = ctx.sema.to_def(strukt)?; | 131 | let struct_def = ctx.sema.to_def(strukt)?; |
132 | 132 | ||
133 | let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| { | 133 | let block = module.descendants().filter_map(ast::Impl::cast).find_map(|impl_blk| { |
134 | let blk = ctx.sema.to_def(&impl_blk)?; | 134 | let blk = ctx.sema.to_def(&impl_blk)?; |
135 | 135 | ||
136 | // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` | 136 | // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` |
@@ -158,7 +158,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option< | |||
158 | Some(block) | 158 | Some(block) |
159 | } | 159 | } |
160 | 160 | ||
161 | fn has_new_fn(imp: &ast::ImplDef) -> bool { | 161 | fn has_new_fn(imp: &ast::Impl) -> bool { |
162 | if let Some(il) = imp.assoc_item_list() { | 162 | if let Some(il) = imp.assoc_item_list() { |
163 | for item in il.assoc_items() { | 163 | for item in il.assoc_items() { |
164 | if let ast::AssocItem::Fn(f) = item { | 164 | if let ast::AssocItem::Fn(f) = item { |
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index 4ad173ef0..92a1a5925 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs | |||
@@ -40,7 +40,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - | |||
40 | .filter(|lifetime| lifetime.text() == "'_")?; | 40 | .filter(|lifetime| lifetime.text() == "'_")?; |
41 | if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { | 41 | if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { |
42 | generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) | 42 | generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) |
43 | } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { | 43 | } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::Impl::cast) { |
44 | generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) | 44 | generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) |
45 | } else { | 45 | } else { |
46 | None | 46 | None |
@@ -93,7 +93,7 @@ fn generate_fn_def_assist( | |||
93 | /// Generate the assist for the impl def case | 93 | /// Generate the assist for the impl def case |
94 | fn generate_impl_def_assist( | 94 | fn generate_impl_def_assist( |
95 | acc: &mut Assists, | 95 | acc: &mut Assists, |
96 | impl_def: &ast::ImplDef, | 96 | impl_def: &ast::Impl, |
97 | lifetime_loc: TextRange, | 97 | lifetime_loc: TextRange, |
98 | ) -> Option<()> { | 98 | ) -> Option<()> { |
99 | let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; | 99 | let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; |
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index fd1d87423..6d394443e 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs | |||
@@ -39,7 +39,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext | |||
39 | match parent { | 39 | match parent { |
40 | ast::Fn(it) => it.body()?.syntax().clone().into(), | 40 | ast::Fn(it) => it.body()?.syntax().clone().into(), |
41 | ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(), | 41 | ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(), |
42 | ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), | 42 | ast::Impl(it) => it.assoc_item_list()?.syntax().clone().into(), |
43 | ast::Enum(it) => it.variant_list()?.syntax().clone().into(), | 43 | ast::Enum(it) => it.variant_list()?.syntax().clone().into(), |
44 | ast::Struct(it) => { | 44 | ast::Struct(it) => { |
45 | it.syntax().children_with_tokens() | 45 | it.syntax().children_with_tokens() |
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 337e3474f..bb16ebd4e 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs | |||
@@ -56,7 +56,7 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor | |||
56 | 56 | ||
57 | pub fn get_missing_assoc_items( | 57 | pub fn get_missing_assoc_items( |
58 | sema: &Semantics<RootDatabase>, | 58 | sema: &Semantics<RootDatabase>, |
59 | impl_def: &ast::ImplDef, | 59 | impl_def: &ast::Impl, |
60 | ) -> Vec<hir::AssocItem> { | 60 | ) -> Vec<hir::AssocItem> { |
61 | // Names must be unique between constants and functions. However, type aliases | 61 | // Names must be unique between constants and functions. However, type aliases |
62 | // may share the same name as a function or constant. | 62 | // may share the same name as a function or constant. |
@@ -109,7 +109,7 @@ pub fn get_missing_assoc_items( | |||
109 | 109 | ||
110 | pub(crate) fn resolve_target_trait( | 110 | pub(crate) fn resolve_target_trait( |
111 | sema: &Semantics<RootDatabase>, | 111 | sema: &Semantics<RootDatabase>, |
112 | impl_def: &ast::ImplDef, | 112 | impl_def: &ast::Impl, |
113 | ) -> Option<hir::Trait> { | 113 | ) -> Option<hir::Trait> { |
114 | let ast_path = impl_def | 114 | let ast_path = impl_def |
115 | .target_trait() | 115 | .target_trait() |