diff options
author | Aleksey Kladov <[email protected]> | 2019-11-15 22:14:56 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-15 22:14:56 +0000 |
commit | f36ac059f362050dae36569940b94a331387294a (patch) | |
tree | 895770caf6ae51bf9fad7766924212ff5f326758 /crates/ra_assists/src/assists | |
parent | 892671926bcb5fd9cd5df6fd2b8c7efb5f25582d (diff) |
Reduce some duplication
Diffstat (limited to 'crates/ra_assists/src/assists')
4 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_assists/src/assists/add_explicit_type.rs b/crates/ra_assists/src/assists/add_explicit_type.rs index ddda1a0f2..562a09685 100644 --- a/crates/ra_assists/src/assists/add_explicit_type.rs +++ b/crates/ra_assists/src/assists/add_explicit_type.rs | |||
@@ -40,7 +40,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx<impl HirDatabase>) -> Option<Assi | |||
40 | } | 40 | } |
41 | // Infer type | 41 | // Infer type |
42 | let db = ctx.db; | 42 | let db = ctx.db; |
43 | let analyzer = hir::SourceAnalyzer::new(db, ctx.frange.file_id, stmt.syntax(), None); | 43 | let analyzer = ctx.source_analyzer(stmt.syntax(), None); |
44 | let ty = analyzer.type_of(db, &expr)?; | 44 | let ty = analyzer.type_of(db, &expr)?; |
45 | // Assist not applicable if the type is unknown | 45 | // Assist not applicable if the type is unknown |
46 | if is_unknown(&ty) { | 46 | if is_unknown(&ty) { |
diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs index 41de23921..91af161ee 100644 --- a/crates/ra_assists/src/assists/add_missing_impl_members.rs +++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs | |||
@@ -100,8 +100,7 @@ fn add_missing_impl_members_inner( | |||
100 | let impl_item_list = impl_node.item_list()?; | 100 | let impl_item_list = impl_node.item_list()?; |
101 | 101 | ||
102 | let trait_def = { | 102 | let trait_def = { |
103 | let file_id = ctx.frange.file_id; | 103 | let analyzer = ctx.source_analyzer(impl_node.syntax(), None); |
104 | let analyzer = hir::SourceAnalyzer::new(ctx.db, file_id, impl_node.syntax(), None); | ||
105 | 104 | ||
106 | resolve_target_trait_def(ctx.db, &analyzer, &impl_node)? | 105 | resolve_target_trait_def(ctx.db, &analyzer, &impl_node)? |
107 | }; | 106 | }; |
diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs index 2b74f355c..b851c2082 100644 --- a/crates/ra_assists/src/assists/fill_match_arms.rs +++ b/crates/ra_assists/src/assists/fill_match_arms.rs | |||
@@ -47,8 +47,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist | |||
47 | 47 | ||
48 | let expr = match_expr.expr()?; | 48 | let expr = match_expr.expr()?; |
49 | let enum_def = { | 49 | let enum_def = { |
50 | let file_id = ctx.frange.file_id; | 50 | let analyzer = ctx.source_analyzer(expr.syntax(), None); |
51 | let analyzer = hir::SourceAnalyzer::new(ctx.db, file_id, expr.syntax(), None); | ||
52 | resolve_enum_def(ctx.db, &analyzer, &expr)? | 51 | resolve_enum_def(ctx.db, &analyzer, &expr)? |
53 | }; | 52 | }; |
54 | let variant_list = enum_def.variant_list()?; | 53 | let variant_list = enum_def.variant_list()?; |
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs index a7fd9b6d2..18a34502c 100644 --- a/crates/ra_assists/src/assists/inline_local_variable.rs +++ b/crates/ra_assists/src/assists/inline_local_variable.rs | |||
@@ -45,7 +45,7 @@ pub(crate) fn inline_local_varialbe(ctx: AssistCtx<impl HirDatabase>) -> Option< | |||
45 | } else { | 45 | } else { |
46 | let_stmt.syntax().text_range() | 46 | let_stmt.syntax().text_range() |
47 | }; | 47 | }; |
48 | let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, bind_pat.syntax(), None); | 48 | let analyzer = ctx.source_analyzer(bind_pat.syntax(), None); |
49 | let refs = analyzer.find_all_refs(&bind_pat); | 49 | let refs = analyzer.find_all_refs(&bind_pat); |
50 | 50 | ||
51 | let mut wrap_in_parens = vec![true; refs.len()]; | 51 | let mut wrap_in_parens = vec![true; refs.len()]; |