diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide/src/lib.rs | 17 | ||||
-rw-r--r-- | crates/ra_ide_db/src/feature_flags.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli/analysis_bench.rs | 12 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 16 |
5 files changed, 31 insertions, 23 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 25aff329e..3dc56e4a3 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -104,10 +104,7 @@ impl Completions { | |||
104 | }; | 104 | }; |
105 | 105 | ||
106 | // Add `<>` for generic types | 106 | // Add `<>` for generic types |
107 | if ctx.is_path_type | 107 | if ctx.is_path_type && !ctx.has_type_args && ctx.options.add_call_parenthesis { |
108 | && !ctx.has_type_args | ||
109 | && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") | ||
110 | { | ||
111 | let has_non_default_type_params = match resolution { | 108 | let has_non_default_type_params = match resolution { |
112 | ScopeDef::ModuleDef(Adt(it)) => it.has_non_default_type_params(ctx.db), | 109 | ScopeDef::ModuleDef(Adt(it)) => it.has_non_default_type_params(ctx.db), |
113 | ScopeDef::ModuleDef(TypeAlias(it)) => it.has_non_default_type_params(ctx.db), | 110 | ScopeDef::ModuleDef(TypeAlias(it)) => it.has_non_default_type_params(ctx.db), |
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 0d91ea749..d888bb745 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -450,17 +450,12 @@ impl Analysis { | |||
450 | } | 450 | } |
451 | 451 | ||
452 | /// Computes completions at the given position. | 452 | /// Computes completions at the given position. |
453 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { | 453 | pub fn completions( |
454 | let opts = CompletionOptions { | 454 | &self, |
455 | enable_postfix_completions: self.feature_flags().get("completion.enable-postfix"), | 455 | position: FilePosition, |
456 | add_call_parenthesis: self | 456 | options: &CompletionOptions, |
457 | .feature_flags() | 457 | ) -> Cancelable<Option<Vec<CompletionItem>>> { |
458 | .get("completion.insertion.add-call-parenthesis"), | 458 | self.with_db(|db| completion::completions(db, position, options).map(Into::into)) |
459 | add_call_argument_snippets: self | ||
460 | .feature_flags() | ||
461 | .get("completion.insertion.add-argument-snippets"), | ||
462 | }; | ||
463 | self.with_db(|db| completion::completions(db, position, &opts).map(Into::into)) | ||
464 | } | 459 | } |
465 | 460 | ||
466 | /// Computes assists (aka code actions aka intentions) for the given | 461 | /// Computes assists (aka code actions aka intentions) for the given |
diff --git a/crates/ra_ide_db/src/feature_flags.rs b/crates/ra_ide_db/src/feature_flags.rs index 968415072..dbb3f50a0 100644 --- a/crates/ra_ide_db/src/feature_flags.rs +++ b/crates/ra_ide_db/src/feature_flags.rs | |||
@@ -2,6 +2,10 @@ | |||
2 | 2 | ||
3 | use rustc_hash::FxHashMap; | 3 | use rustc_hash::FxHashMap; |
4 | 4 | ||
5 | // FIXME: looks like a much better design is to pass options to each call, | ||
6 | // rather than to have a global ambient feature flags -- that way, the clients | ||
7 | // can issue two successive calls with different options. | ||
8 | |||
5 | /// Feature flags hold fine-grained toggles for all *user-visible* features of | 9 | /// Feature flags hold fine-grained toggles for all *user-visible* features of |
6 | /// rust-analyzer. | 10 | /// rust-analyzer. |
7 | /// | 11 | /// |
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index 91855e592..28a23934f 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs | |||
@@ -12,7 +12,7 @@ use ra_db::{ | |||
12 | salsa::{Database, Durability}, | 12 | salsa::{Database, Durability}, |
13 | FileId, SourceDatabaseExt, | 13 | FileId, SourceDatabaseExt, |
14 | }; | 14 | }; |
15 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; | 15 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CompletionOptions, FilePosition, LineCol}; |
16 | 16 | ||
17 | use crate::cli::{load_cargo::load_cargo, Verbosity}; | 17 | use crate::cli::{load_cargo::load_cargo, Verbosity}; |
18 | 18 | ||
@@ -94,17 +94,19 @@ pub fn analysis_bench(verbosity: Verbosity, path: &Path, what: BenchWhat) -> Res | |||
94 | .analysis() | 94 | .analysis() |
95 | .file_line_index(file_id)? | 95 | .file_line_index(file_id)? |
96 | .offset(LineCol { line: pos.line - 1, col_utf16: pos.column }); | 96 | .offset(LineCol { line: pos.line - 1, col_utf16: pos.column }); |
97 | let file_postion = FilePosition { file_id, offset }; | 97 | let file_position = FilePosition { file_id, offset }; |
98 | 98 | ||
99 | if is_completion { | 99 | if is_completion { |
100 | let res = | 100 | let options = CompletionOptions::default(); |
101 | do_work(&mut host, file_id, |analysis| analysis.completions(file_postion)); | 101 | let res = do_work(&mut host, file_id, |analysis| { |
102 | analysis.completions(file_position, &options) | ||
103 | }); | ||
102 | if verbosity.is_verbose() { | 104 | if verbosity.is_verbose() { |
103 | println!("\n{:#?}", res); | 105 | println!("\n{:#?}", res); |
104 | } | 106 | } |
105 | } else { | 107 | } else { |
106 | let res = | 108 | let res = |
107 | do_work(&mut host, file_id, |analysis| analysis.goto_definition(file_postion)); | 109 | do_work(&mut host, file_id, |analysis| analysis.goto_definition(file_position)); |
108 | if verbosity.is_verbose() { | 110 | if verbosity.is_verbose() { |
109 | println!("\n{:#?}", res); | 111 | println!("\n{:#?}", res); |
110 | } | 112 | } |
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 8dc6e8dc0..155f677a6 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs | |||
@@ -20,8 +20,8 @@ use lsp_types::{ | |||
20 | TextEdit, WorkspaceEdit, | 20 | TextEdit, WorkspaceEdit, |
21 | }; | 21 | }; |
22 | use ra_ide::{ | 22 | use ra_ide::{ |
23 | Assist, AssistId, FileId, FilePosition, FileRange, Query, RangeInfo, Runnable, RunnableKind, | 23 | Assist, AssistId, CompletionOptions, FileId, FilePosition, FileRange, Query, RangeInfo, |
24 | SearchScope, | 24 | Runnable, RunnableKind, SearchScope, |
25 | }; | 25 | }; |
26 | use ra_prof::profile; | 26 | use ra_prof::profile; |
27 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; | 27 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; |
@@ -424,7 +424,17 @@ pub fn handle_completion( | |||
424 | return Ok(None); | 424 | return Ok(None); |
425 | } | 425 | } |
426 | 426 | ||
427 | let items = match world.analysis().completions(position)? { | 427 | let options = CompletionOptions { |
428 | enable_postfix_completions: world.feature_flags().get("completion.enable-postfix"), | ||
429 | add_call_parenthesis: world | ||
430 | .feature_flags() | ||
431 | .get("completion.insertion.add-call-parenthesis"), | ||
432 | add_call_argument_snippets: world | ||
433 | .feature_flags() | ||
434 | .get("completion.insertion.add-argument-snippets"), | ||
435 | }; | ||
436 | |||
437 | let items = match world.analysis().completions(position, &options)? { | ||
428 | None => return Ok(None), | 438 | None => return Ok(None), |
429 | Some(items) => items, | 439 | Some(items) => items, |
430 | }; | 440 | }; |