aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_cargo_watch/src/lib.rs14
-rw-r--r--crates/ra_ide/src/completion.rs10
-rw-r--r--crates/ra_ide/src/completion/complete_postfix.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs8
-rw-r--r--crates/ra_ide/src/completion/presentation.rs12
-rw-r--r--crates/ra_ide/src/completion/test_utils.rs6
-rw-r--r--crates/ra_ide/src/inlay_hints.rs68
-rw-r--r--crates/ra_ide/src/lib.rs12
-rw-r--r--crates/rust-analyzer/src/cli/analysis_bench.rs4
-rw-r--r--crates/rust-analyzer/src/conv.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs22
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs14
-rw-r--r--crates/rust-analyzer/src/world.rs32
13 files changed, 102 insertions, 104 deletions
diff --git a/crates/ra_cargo_watch/src/lib.rs b/crates/ra_cargo_watch/src/lib.rs
index 2692c1bf5..77ede8f63 100644
--- a/crates/ra_cargo_watch/src/lib.rs
+++ b/crates/ra_cargo_watch/src/lib.rs
@@ -22,7 +22,7 @@ use crate::conv::{map_rust_diagnostic_to_lsp, MappedRustDiagnostic};
22pub use crate::conv::url_from_path_with_drive_lowercasing; 22pub use crate::conv::url_from_path_with_drive_lowercasing;
23 23
24#[derive(Clone, Debug)] 24#[derive(Clone, Debug)]
25pub struct CheckOptions { 25pub struct CheckConfig {
26 pub enable: bool, 26 pub enable: bool,
27 pub args: Vec<String>, 27 pub args: Vec<String>,
28 pub command: String, 28 pub command: String,
@@ -42,13 +42,11 @@ pub struct CheckWatcher {
42} 42}
43 43
44impl CheckWatcher { 44impl CheckWatcher {
45 pub fn new(options: &CheckOptions, workspace_root: PathBuf) -> CheckWatcher { 45 pub fn new(config: CheckConfig, workspace_root: PathBuf) -> CheckWatcher {
46 let options = options.clone();
47
48 let (task_send, task_recv) = unbounded::<CheckTask>(); 46 let (task_send, task_recv) = unbounded::<CheckTask>();
49 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); 47 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
50 let handle = jod_thread::spawn(move || { 48 let handle = jod_thread::spawn(move || {
51 let mut check = CheckWatcherThread::new(options, workspace_root); 49 let mut check = CheckWatcherThread::new(config, workspace_root);
52 check.run(&task_send, &cmd_recv); 50 check.run(&task_send, &cmd_recv);
53 }); 51 });
54 CheckWatcher { task_recv, cmd_send, handle: Some(handle) } 52 CheckWatcher { task_recv, cmd_send, handle: Some(handle) }
@@ -78,14 +76,14 @@ pub enum CheckCommand {
78} 76}
79 77
80struct CheckWatcherThread { 78struct CheckWatcherThread {
81 options: CheckOptions, 79 options: CheckConfig,
82 workspace_root: PathBuf, 80 workspace_root: PathBuf,
83 watcher: WatchThread, 81 watcher: WatchThread,
84 last_update_req: Option<Instant>, 82 last_update_req: Option<Instant>,
85} 83}
86 84
87impl CheckWatcherThread { 85impl CheckWatcherThread {
88 fn new(options: CheckOptions, workspace_root: PathBuf) -> CheckWatcherThread { 86 fn new(options: CheckConfig, workspace_root: PathBuf) -> CheckWatcherThread {
89 CheckWatcherThread { 87 CheckWatcherThread {
90 options, 88 options,
91 workspace_root, 89 workspace_root,
@@ -324,7 +322,7 @@ impl WatchThread {
324 WatchThread { message_recv: never(), _handle: None } 322 WatchThread { message_recv: never(), _handle: None }
325 } 323 }
326 324
327 fn new(options: &CheckOptions, workspace_root: &Path) -> WatchThread { 325 fn new(options: &CheckConfig, workspace_root: &Path) -> WatchThread {
328 let mut args: Vec<String> = vec![ 326 let mut args: Vec<String> = vec![
329 options.command.clone(), 327 options.command.clone(),
330 "--workspace".to_string(), 328 "--workspace".to_string(),
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs
index cd0757be5..b683572fb 100644
--- a/crates/ra_ide/src/completion.rs
+++ b/crates/ra_ide/src/completion.rs
@@ -34,15 +34,15 @@ pub use crate::completion::completion_item::{
34}; 34};
35 35
36#[derive(Clone, Debug, PartialEq, Eq)] 36#[derive(Clone, Debug, PartialEq, Eq)]
37pub struct CompletionOptions { 37pub struct CompletionConfig {
38 pub enable_postfix_completions: bool, 38 pub enable_postfix_completions: bool,
39 pub add_call_parenthesis: bool, 39 pub add_call_parenthesis: bool,
40 pub add_call_argument_snippets: bool, 40 pub add_call_argument_snippets: bool,
41} 41}
42 42
43impl Default for CompletionOptions { 43impl Default for CompletionConfig {
44 fn default() -> Self { 44 fn default() -> Self {
45 CompletionOptions { 45 CompletionConfig {
46 enable_postfix_completions: true, 46 enable_postfix_completions: true,
47 add_call_parenthesis: true, 47 add_call_parenthesis: true,
48 add_call_argument_snippets: true, 48 add_call_argument_snippets: true,
@@ -75,9 +75,9 @@ impl Default for CompletionOptions {
75pub(crate) fn completions( 75pub(crate) fn completions(
76 db: &RootDatabase, 76 db: &RootDatabase,
77 position: FilePosition, 77 position: FilePosition,
78 options: &CompletionOptions, 78 config: &CompletionConfig,
79) -> Option<Completions> { 79) -> Option<Completions> {
80 let ctx = CompletionContext::new(db, position, options)?; 80 let ctx = CompletionContext::new(db, position, config)?;
81 81
82 let mut acc = Completions::default(); 82 let mut acc = Completions::default();
83 83
diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs
index 0a00054b2..29c2881c6 100644
--- a/crates/ra_ide/src/completion/complete_postfix.rs
+++ b/crates/ra_ide/src/completion/complete_postfix.rs
@@ -15,7 +15,7 @@ use crate::{
15}; 15};
16 16
17pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { 17pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
18 if !ctx.options.enable_postfix_completions { 18 if !ctx.config.enable_postfix_completions {
19 return; 19 return;
20 } 20 }
21 21
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 319e33b61..fdc0da2c5 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -11,7 +11,7 @@ use ra_syntax::{
11}; 11};
12use ra_text_edit::AtomTextEdit; 12use ra_text_edit::AtomTextEdit;
13 13
14use crate::{completion::CompletionOptions, FilePosition}; 14use crate::{completion::CompletionConfig, FilePosition};
15 15
16/// `CompletionContext` is created early during completion to figure out, where 16/// `CompletionContext` is created early during completion to figure out, where
17/// exactly is the cursor, syntax-wise. 17/// exactly is the cursor, syntax-wise.
@@ -19,7 +19,7 @@ use crate::{completion::CompletionOptions, FilePosition};
19pub(crate) struct CompletionContext<'a> { 19pub(crate) struct CompletionContext<'a> {
20 pub(super) sema: Semantics<'a, RootDatabase>, 20 pub(super) sema: Semantics<'a, RootDatabase>,
21 pub(super) db: &'a RootDatabase, 21 pub(super) db: &'a RootDatabase,
22 pub(super) options: &'a CompletionOptions, 22 pub(super) config: &'a CompletionConfig,
23 pub(super) offset: TextUnit, 23 pub(super) offset: TextUnit,
24 /// The token before the cursor, in the original file. 24 /// The token before the cursor, in the original file.
25 pub(super) original_token: SyntaxToken, 25 pub(super) original_token: SyntaxToken,
@@ -61,7 +61,7 @@ impl<'a> CompletionContext<'a> {
61 pub(super) fn new( 61 pub(super) fn new(
62 db: &'a RootDatabase, 62 db: &'a RootDatabase,
63 position: FilePosition, 63 position: FilePosition,
64 options: &'a CompletionOptions, 64 config: &'a CompletionConfig,
65 ) -> Option<CompletionContext<'a>> { 65 ) -> Option<CompletionContext<'a>> {
66 let sema = Semantics::new(db); 66 let sema = Semantics::new(db);
67 67
@@ -85,7 +85,7 @@ impl<'a> CompletionContext<'a> {
85 let mut ctx = CompletionContext { 85 let mut ctx = CompletionContext {
86 sema, 86 sema,
87 db, 87 db,
88 options, 88 config,
89 original_token, 89 original_token,
90 token, 90 token,
91 offset: position.offset, 91 offset: position.offset,
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index 60f1b83f3..1c7c0924d 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -106,7 +106,7 @@ impl Completions {
106 }; 106 };
107 107
108 // Add `<>` for generic types 108 // Add `<>` for generic types
109 if ctx.is_path_type && !ctx.has_type_args && ctx.options.add_call_parenthesis { 109 if ctx.is_path_type && !ctx.has_type_args && ctx.config.add_call_parenthesis {
110 let has_non_default_type_params = match resolution { 110 let has_non_default_type_params = match resolution {
111 ScopeDef::ModuleDef(Adt(it)) => it.has_non_default_type_params(ctx.db), 111 ScopeDef::ModuleDef(Adt(it)) => it.has_non_default_type_params(ctx.db),
112 ScopeDef::ModuleDef(TypeAlias(it)) => it.has_non_default_type_params(ctx.db), 112 ScopeDef::ModuleDef(TypeAlias(it)) => it.has_non_default_type_params(ctx.db),
@@ -211,14 +211,14 @@ impl Completions {
211 .detail(function_signature.to_string()); 211 .detail(function_signature.to_string());
212 212
213 // If not an import, add parenthesis automatically. 213 // If not an import, add parenthesis automatically.
214 if ctx.use_item_syntax.is_none() && !ctx.is_call && ctx.options.add_call_parenthesis { 214 if ctx.use_item_syntax.is_none() && !ctx.is_call && ctx.config.add_call_parenthesis {
215 tested_by!(inserts_parens_for_function_calls); 215 tested_by!(inserts_parens_for_function_calls);
216 216
217 let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 { 217 let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 {
218 (format!("{}()$0", name), format!("{}()", name)) 218 (format!("{}()$0", name), format!("{}()", name))
219 } else { 219 } else {
220 builder = builder.trigger_call_info(); 220 builder = builder.trigger_call_info();
221 let snippet = if ctx.options.add_call_argument_snippets { 221 let snippet = if ctx.config.add_call_argument_snippets {
222 let to_skip = if has_self_param { 1 } else { 0 }; 222 let to_skip = if has_self_param { 1 } else { 0 };
223 let function_params_snippet = function_signature 223 let function_params_snippet = function_signature
224 .parameter_names 224 .parameter_names
@@ -311,7 +311,7 @@ mod tests {
311 311
312 use crate::completion::{ 312 use crate::completion::{
313 test_utils::{do_completion, do_completion_with_options}, 313 test_utils::{do_completion, do_completion_with_options},
314 CompletionItem, CompletionKind, CompletionOptions, 314 CompletionConfig, CompletionItem, CompletionKind,
315 }; 315 };
316 316
317 fn do_reference_completion(ra_fixture: &str) -> Vec<CompletionItem> { 317 fn do_reference_completion(ra_fixture: &str) -> Vec<CompletionItem> {
@@ -320,7 +320,7 @@ mod tests {
320 320
321 fn do_reference_completion_with_options( 321 fn do_reference_completion_with_options(
322 ra_fixture: &str, 322 ra_fixture: &str,
323 options: CompletionOptions, 323 options: CompletionConfig,
324 ) -> Vec<CompletionItem> { 324 ) -> Vec<CompletionItem> {
325 do_completion_with_options(ra_fixture, CompletionKind::Reference, &options) 325 do_completion_with_options(ra_fixture, CompletionKind::Reference, &options)
326 } 326 }
@@ -589,7 +589,7 @@ mod tests {
589 s.f<|> 589 s.f<|>
590 } 590 }
591 ", 591 ",
592 CompletionOptions { 592 CompletionConfig {
593 add_call_argument_snippets: false, 593 add_call_argument_snippets: false,
594 .. Default::default() 594 .. Default::default()
595 } 595 }
diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs
index 136857315..eb90b5279 100644
--- a/crates/ra_ide/src/completion/test_utils.rs
+++ b/crates/ra_ide/src/completion/test_utils.rs
@@ -1,19 +1,19 @@
1//! Runs completion for testing purposes. 1//! Runs completion for testing purposes.
2 2
3use crate::{ 3use crate::{
4 completion::{completion_item::CompletionKind, CompletionOptions}, 4 completion::{completion_item::CompletionKind, CompletionConfig},
5 mock_analysis::{analysis_and_position, single_file_with_position}, 5 mock_analysis::{analysis_and_position, single_file_with_position},
6 CompletionItem, 6 CompletionItem,
7}; 7};
8 8
9pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { 9pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
10 do_completion_with_options(code, kind, &CompletionOptions::default()) 10 do_completion_with_options(code, kind, &CompletionConfig::default())
11} 11}
12 12
13pub(crate) fn do_completion_with_options( 13pub(crate) fn do_completion_with_options(
14 code: &str, 14 code: &str,
15 kind: CompletionKind, 15 kind: CompletionKind,
16 options: &CompletionOptions, 16 options: &CompletionConfig,
17) -> Vec<CompletionItem> { 17) -> Vec<CompletionItem> {
18 let (analysis, position) = if code.contains("//-") { 18 let (analysis, position) = if code.contains("//-") {
19 analysis_and_position(code) 19 analysis_and_position(code)
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index f4f0751c0..d06fc03d3 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -11,14 +11,14 @@ use ra_syntax::{
11use crate::{FileId, FunctionSignature}; 11use crate::{FileId, FunctionSignature};
12 12
13#[derive(Clone, Debug, PartialEq, Eq)] 13#[derive(Clone, Debug, PartialEq, Eq)]
14pub struct InlayHintsOptions { 14pub struct InlayHintsConfig {
15 pub type_hints: bool, 15 pub type_hints: bool,
16 pub parameter_hints: bool, 16 pub parameter_hints: bool,
17 pub chaining_hints: bool, 17 pub chaining_hints: bool,
18 pub max_length: Option<usize>, 18 pub max_length: Option<usize>,
19} 19}
20 20
21impl Default for InlayHintsOptions { 21impl Default for InlayHintsConfig {
22 fn default() -> Self { 22 fn default() -> Self {
23 Self { type_hints: true, parameter_hints: true, chaining_hints: true, max_length: None } 23 Self { type_hints: true, parameter_hints: true, chaining_hints: true, max_length: None }
24 } 24 }
@@ -41,7 +41,7 @@ pub struct InlayHint {
41pub(crate) fn inlay_hints( 41pub(crate) fn inlay_hints(
42 db: &RootDatabase, 42 db: &RootDatabase,
43 file_id: FileId, 43 file_id: FileId,
44 options: &InlayHintsOptions, 44 config: &InlayHintsConfig,
45) -> Vec<InlayHint> { 45) -> Vec<InlayHint> {
46 let _p = profile("inlay_hints"); 46 let _p = profile("inlay_hints");
47 let sema = Semantics::new(db); 47 let sema = Semantics::new(db);
@@ -50,14 +50,14 @@ pub(crate) fn inlay_hints(
50 let mut res = Vec::new(); 50 let mut res = Vec::new();
51 for node in file.syntax().descendants() { 51 for node in file.syntax().descendants() {
52 if let Some(expr) = ast::Expr::cast(node.clone()) { 52 if let Some(expr) = ast::Expr::cast(node.clone()) {
53 get_chaining_hints(&mut res, &sema, options, expr); 53 get_chaining_hints(&mut res, &sema, config, expr);
54 } 54 }
55 55
56 match_ast! { 56 match_ast! {
57 match node { 57 match node {
58 ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); }, 58 ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); },
59 ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); }, 59 ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, config, ast::Expr::from(it)); },
60 ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, options, it); }, 60 ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, config, it); },
61 _ => (), 61 _ => (),
62 } 62 }
63 } 63 }
@@ -68,10 +68,10 @@ pub(crate) fn inlay_hints(
68fn get_chaining_hints( 68fn get_chaining_hints(
69 acc: &mut Vec<InlayHint>, 69 acc: &mut Vec<InlayHint>,
70 sema: &Semantics<RootDatabase>, 70 sema: &Semantics<RootDatabase>,
71 options: &InlayHintsOptions, 71 config: &InlayHintsConfig,
72 expr: ast::Expr, 72 expr: ast::Expr,
73) -> Option<()> { 73) -> Option<()> {
74 if !options.chaining_hints { 74 if !config.chaining_hints {
75 return None; 75 return None;
76 } 76 }
77 77
@@ -95,7 +95,7 @@ fn get_chaining_hints(
95 let next = tokens.next()?.kind(); 95 let next = tokens.next()?.kind();
96 let next_next = tokens.next()?.kind(); 96 let next_next = tokens.next()?.kind();
97 if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT { 97 if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT {
98 let label = ty.display_truncated(sema.db, options.max_length).to_string(); 98 let label = ty.display_truncated(sema.db, config.max_length).to_string();
99 acc.push(InlayHint { 99 acc.push(InlayHint {
100 range: expr.syntax().text_range(), 100 range: expr.syntax().text_range(),
101 kind: InlayKind::ChainingHint, 101 kind: InlayKind::ChainingHint,
@@ -108,10 +108,10 @@ fn get_chaining_hints(
108fn get_param_name_hints( 108fn get_param_name_hints(
109 acc: &mut Vec<InlayHint>, 109 acc: &mut Vec<InlayHint>,
110 sema: &Semantics<RootDatabase>, 110 sema: &Semantics<RootDatabase>,
111 options: &InlayHintsOptions, 111 config: &InlayHintsConfig,
112 expr: ast::Expr, 112 expr: ast::Expr,
113) -> Option<()> { 113) -> Option<()> {
114 if !options.parameter_hints { 114 if !config.parameter_hints {
115 return None; 115 return None;
116 } 116 }
117 117
@@ -148,10 +148,10 @@ fn get_param_name_hints(
148fn get_bind_pat_hints( 148fn get_bind_pat_hints(
149 acc: &mut Vec<InlayHint>, 149 acc: &mut Vec<InlayHint>,
150 sema: &Semantics<RootDatabase>, 150 sema: &Semantics<RootDatabase>,
151 options: &InlayHintsOptions, 151 config: &InlayHintsConfig,
152 pat: ast::BindPat, 152 pat: ast::BindPat,
153) -> Option<()> { 153) -> Option<()> {
154 if !options.type_hints { 154 if !config.type_hints {
155 return None; 155 return None;
156 } 156 }
157 157
@@ -164,7 +164,7 @@ fn get_bind_pat_hints(
164 acc.push(InlayHint { 164 acc.push(InlayHint {
165 range: pat.syntax().text_range(), 165 range: pat.syntax().text_range(),
166 kind: InlayKind::TypeHint, 166 kind: InlayKind::TypeHint,
167 label: ty.display_truncated(sema.db, options.max_length).to_string().into(), 167 label: ty.display_truncated(sema.db, config.max_length).to_string().into(),
168 }); 168 });
169 Some(()) 169 Some(())
170} 170}
@@ -270,7 +270,7 @@ fn get_fn_signature(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
270 270
271#[cfg(test)] 271#[cfg(test)]
272mod tests { 272mod tests {
273 use crate::inlay_hints::InlayHintsOptions; 273 use crate::inlay_hints::InlayHintsConfig;
274 use insta::assert_debug_snapshot; 274 use insta::assert_debug_snapshot;
275 275
276 use crate::mock_analysis::single_file; 276 use crate::mock_analysis::single_file;
@@ -284,7 +284,7 @@ mod tests {
284 let _x = foo(4, 4); 284 let _x = foo(4, 4);
285 }"#, 285 }"#,
286 ); 286 );
287 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: true, type_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###" 287 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: true, type_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###"
288 [ 288 [
289 InlayHint { 289 InlayHint {
290 range: [106; 107), 290 range: [106; 107),
@@ -308,7 +308,7 @@ mod tests {
308 let _x = foo(4, 4); 308 let _x = foo(4, 4);
309 }"#, 309 }"#,
310 ); 310 );
311 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: false, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###"[]"###); 311 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ type_hints: false, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###"[]"###);
312 } 312 }
313 313
314 #[test] 314 #[test]
@@ -320,7 +320,7 @@ mod tests {
320 let _x = foo(4, 4); 320 let _x = foo(4, 4);
321 }"#, 321 }"#,
322 ); 322 );
323 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: true, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###" 323 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ type_hints: true, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###"
324 [ 324 [
325 InlayHint { 325 InlayHint {
326 range: [97; 99), 326 range: [97; 99),
@@ -344,7 +344,7 @@ fn main() {
344}"#, 344}"#,
345 ); 345 );
346 346
347 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 347 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
348 [ 348 [
349 InlayHint { 349 InlayHint {
350 range: [69; 71), 350 range: [69; 71),
@@ -401,7 +401,7 @@ fn main() {
401}"#, 401}"#,
402 ); 402 );
403 403
404 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 404 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
405 [ 405 [
406 InlayHint { 406 InlayHint {
407 range: [193; 197), 407 range: [193; 197),
@@ -481,7 +481,7 @@ fn main() {
481}"#, 481}"#,
482 ); 482 );
483 483
484 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 484 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
485 [ 485 [
486 InlayHint { 486 InlayHint {
487 range: [21; 30), 487 range: [21; 30),
@@ -545,7 +545,7 @@ fn main() {
545}"#, 545}"#,
546 ); 546 );
547 547
548 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 548 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
549 [ 549 [
550 InlayHint { 550 InlayHint {
551 range: [21; 30), 551 range: [21; 30),
@@ -595,7 +595,7 @@ fn main() {
595}"#, 595}"#,
596 ); 596 );
597 597
598 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 598 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
599 [ 599 [
600 InlayHint { 600 InlayHint {
601 range: [188; 192), 601 range: [188; 192),
@@ -690,7 +690,7 @@ fn main() {
690}"#, 690}"#,
691 ); 691 );
692 692
693 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 693 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
694 [ 694 [
695 InlayHint { 695 InlayHint {
696 range: [188; 192), 696 range: [188; 192),
@@ -785,7 +785,7 @@ fn main() {
785}"#, 785}"#,
786 ); 786 );
787 787
788 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 788 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
789 [ 789 [
790 InlayHint { 790 InlayHint {
791 range: [252; 256), 791 range: [252; 256),
@@ -857,7 +857,7 @@ fn main() {
857}"#, 857}"#,
858 ); 858 );
859 859
860 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" 860 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
861 [ 861 [
862 InlayHint { 862 InlayHint {
863 range: [74; 75), 863 range: [74; 75),
@@ -945,7 +945,7 @@ fn main() {
945}"#, 945}"#,
946 ); 946 );
947 947
948 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###" 948 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###"
949 [ 949 [
950 InlayHint { 950 InlayHint {
951 range: [798; 809), 951 range: [798; 809),
@@ -1067,7 +1067,7 @@ fn main() {
1067}"#, 1067}"#,
1068 ); 1068 );
1069 1069
1070 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" 1070 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
1071 [] 1071 []
1072 "### 1072 "###
1073 ); 1073 );
@@ -1093,7 +1093,7 @@ fn main() {
1093}"#, 1093}"#,
1094 ); 1094 );
1095 1095
1096 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###" 1096 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
1097 [] 1097 []
1098 "### 1098 "###
1099 ); 1099 );
@@ -1115,7 +1115,7 @@ fn main() {
1115 .into_c(); 1115 .into_c();
1116 }"#, 1116 }"#,
1117 ); 1117 );
1118 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" 1118 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
1119 [ 1119 [
1120 InlayHint { 1120 InlayHint {
1121 range: [232; 269), 1121 range: [232; 269),
@@ -1144,7 +1144,7 @@ fn main() {
1144 let c = A(B(C)).into_b().into_c(); 1144 let c = A(B(C)).into_b().into_c();
1145 }"#, 1145 }"#,
1146 ); 1146 );
1147 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"[]"###); 1147 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"[]"###);
1148 } 1148 }
1149 1149
1150 #[test] 1150 #[test]
@@ -1162,7 +1162,7 @@ fn main() {
1162 .0; 1162 .0;
1163 }"#, 1163 }"#,
1164 ); 1164 );
1165 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" 1165 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
1166 [ 1166 [
1167 InlayHint { 1167 InlayHint {
1168 range: [150; 221), 1168 range: [150; 221),
@@ -1204,7 +1204,7 @@ fn main() {
1204 .into_c(); 1204 .into_c();
1205 }"#, 1205 }"#,
1206 ); 1206 );
1207 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" 1207 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
1208 [ 1208 [
1209 InlayHint { 1209 InlayHint {
1210 range: [403; 452), 1210 range: [403; 452),
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 937c9caa5..285381086 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -62,13 +62,13 @@ use crate::display::ToNav;
62pub use crate::{ 62pub use crate::{
63 assists::{Assist, AssistId}, 63 assists::{Assist, AssistId},
64 call_hierarchy::CallItem, 64 call_hierarchy::CallItem,
65 completion::{CompletionItem, CompletionItemKind, CompletionOptions, InsertTextFormat}, 65 completion::{CompletionConfig, CompletionItem, CompletionItemKind, InsertTextFormat},
66 diagnostics::Severity, 66 diagnostics::Severity,
67 display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, 67 display::{file_structure, FunctionSignature, NavigationTarget, StructureNode},
68 expand_macro::ExpandedMacro, 68 expand_macro::ExpandedMacro,
69 folding_ranges::{Fold, FoldKind}, 69 folding_ranges::{Fold, FoldKind},
70 hover::HoverResult, 70 hover::HoverResult,
71 inlay_hints::{InlayHint, InlayHintsOptions, InlayKind}, 71 inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
72 references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, 72 references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult},
73 runnables::{Runnable, RunnableKind, TestId}, 73 runnables::{Runnable, RunnableKind, TestId},
74 source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, 74 source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
@@ -325,9 +325,9 @@ impl Analysis {
325 pub fn inlay_hints( 325 pub fn inlay_hints(
326 &self, 326 &self,
327 file_id: FileId, 327 file_id: FileId,
328 inlay_hint_opts: &InlayHintsOptions, 328 config: &InlayHintsConfig,
329 ) -> Cancelable<Vec<InlayHint>> { 329 ) -> Cancelable<Vec<InlayHint>> {
330 self.with_db(|db| inlay_hints::inlay_hints(db, file_id, inlay_hint_opts)) 330 self.with_db(|db| inlay_hints::inlay_hints(db, file_id, config))
331 } 331 }
332 332
333 /// Returns the set of folding ranges. 333 /// Returns the set of folding ranges.
@@ -450,9 +450,9 @@ impl Analysis {
450 pub fn completions( 450 pub fn completions(
451 &self, 451 &self,
452 position: FilePosition, 452 position: FilePosition,
453 options: &CompletionOptions, 453 config: &CompletionConfig,
454 ) -> Cancelable<Option<Vec<CompletionItem>>> { 454 ) -> Cancelable<Option<Vec<CompletionItem>>> {
455 self.with_db(|db| completion::completions(db, position, options).map(Into::into)) 455 self.with_db(|db| completion::completions(db, position, config).map(Into::into))
456 } 456 }
457 457
458 /// Computes assists (aka code actions aka intentions) for the given 458 /// Computes assists (aka code actions aka intentions) for the given
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs
index 7164b0ade..7667873d5 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};
15use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CompletionOptions, FilePosition, LineCol}; 15use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CompletionConfig, FilePosition, LineCol};
16 16
17use crate::cli::{load_cargo::load_cargo, Verbosity}; 17use crate::cli::{load_cargo::load_cargo, Verbosity};
18 18
@@ -102,7 +102,7 @@ pub fn analysis_bench(
102 let file_position = FilePosition { file_id, offset }; 102 let file_position = FilePosition { file_id, offset };
103 103
104 if is_completion { 104 if is_completion {
105 let options = CompletionOptions::default(); 105 let options = CompletionConfig::default();
106 let res = do_work(&mut host, file_id, |analysis| { 106 let res = do_work(&mut host, file_id, |analysis| {
107 analysis.completions(file_position, &options) 107 analysis.completions(file_position, &options)
108 }); 108 });
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs
index 6edc03fe0..e8dc953c3 100644
--- a/crates/rust-analyzer/src/conv.rs
+++ b/crates/rust-analyzer/src/conv.rs
@@ -579,7 +579,7 @@ impl TryConvWith<&WorldSnapshot> for (FileId, RangeInfo<Vec<NavigationTarget>>)
579 .into_iter() 579 .into_iter()
580 .map(|nav| (file_id, RangeInfo::new(range, nav))) 580 .map(|nav| (file_id, RangeInfo::new(range, nav)))
581 .try_conv_with_to_vec(world)?; 581 .try_conv_with_to_vec(world)?;
582 if world.options.supports_location_link { 582 if world.config.supports_location_link {
583 Ok(links.into()) 583 Ok(links.into())
584 } else { 584 } else {
585 let locations: Vec<Location> = links 585 let locations: Vec<Location> = links
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index d818243e3..c233f72ff 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -21,8 +21,8 @@ use lsp_types::{
21 WorkDoneProgressBegin, WorkDoneProgressCreateParams, WorkDoneProgressEnd, 21 WorkDoneProgressBegin, WorkDoneProgressCreateParams, WorkDoneProgressEnd,
22 WorkDoneProgressReport, 22 WorkDoneProgressReport,
23}; 23};
24use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckTask}; 24use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckConfig, CheckTask};
25use ra_ide::{Canceled, FileId, InlayHintsOptions, LibraryData, SourceRootId}; 25use ra_ide::{Canceled, FileId, InlayHintsConfig, LibraryData, SourceRootId};
26use ra_prof::profile; 26use ra_prof::profile;
27use ra_vfs::{VfsFile, VfsTask, Watch}; 27use ra_vfs::{VfsFile, VfsTask, Watch};
28use relative_path::RelativePathBuf; 28use relative_path::RelativePathBuf;
@@ -38,7 +38,7 @@ use crate::{
38 subscriptions::Subscriptions, 38 subscriptions::Subscriptions,
39 }, 39 },
40 req, 40 req,
41 world::{Options, WorldSnapshot, WorldState}, 41 world::{Config, WorldSnapshot, WorldState},
42 Result, ServerConfig, 42 Result, ServerConfig,
43}; 43};
44use req::ConfigurationParams; 44use req::ConfigurationParams;
@@ -81,11 +81,11 @@ fn get_feature_flags(config: &ServerConfig, connection: &Connection) -> FeatureF
81 ff 81 ff
82} 82}
83 83
84fn get_options( 84fn get_config(
85 config: &ServerConfig, 85 config: &ServerConfig,
86 text_document_caps: Option<&TextDocumentClientCapabilities>, 86 text_document_caps: Option<&TextDocumentClientCapabilities>,
87) -> Options { 87) -> Config {
88 Options { 88 Config {
89 publish_decorations: config.publish_decorations, 89 publish_decorations: config.publish_decorations,
90 supports_location_link: text_document_caps 90 supports_location_link: text_document_caps
91 .and_then(|it| it.definition) 91 .and_then(|it| it.definition)
@@ -95,13 +95,13 @@ fn get_options(
95 .and_then(|it| it.folding_range.as_ref()) 95 .and_then(|it| it.folding_range.as_ref())
96 .and_then(|it| it.line_folding_only) 96 .and_then(|it| it.line_folding_only)
97 .unwrap_or(false), 97 .unwrap_or(false),
98 inlay_hints: InlayHintsOptions { 98 inlay_hints: InlayHintsConfig {
99 type_hints: config.inlay_hints_type, 99 type_hints: config.inlay_hints_type,
100 parameter_hints: config.inlay_hints_parameter, 100 parameter_hints: config.inlay_hints_parameter,
101 chaining_hints: config.inlay_hints_chaining, 101 chaining_hints: config.inlay_hints_chaining,
102 max_length: config.inlay_hints_max_length, 102 max_length: config.inlay_hints_max_length,
103 }, 103 },
104 cargo_watch: CheckOptions { 104 check: CheckConfig {
105 enable: config.cargo_watch_enable, 105 enable: config.cargo_watch_enable,
106 args: config.cargo_watch_args.clone(), 106 args: config.cargo_watch_args.clone(),
107 command: config.cargo_watch_command.clone(), 107 command: config.cargo_watch_command.clone(),
@@ -210,7 +210,7 @@ pub fn main_loop(
210 config.lru_capacity, 210 config.lru_capacity,
211 &globs, 211 &globs,
212 Watch(!config.use_client_watching), 212 Watch(!config.use_client_watching),
213 get_options(&config, text_document_caps), 213 get_config(&config, text_document_caps),
214 feature_flags, 214 feature_flags,
215 ) 215 )
216 }; 216 };
@@ -435,7 +435,7 @@ fn loop_turn(
435 .to_owned(); 435 .to_owned();
436 world_state.update_configuration( 436 world_state.update_configuration(
437 new_config.lru_capacity, 437 new_config.lru_capacity,
438 get_options(&new_config, text_document_caps), 438 get_config(&new_config, text_document_caps),
439 get_feature_flags(&new_config, connection), 439 get_feature_flags(&new_config, connection),
440 ); 440 );
441 } 441 }
@@ -498,7 +498,7 @@ fn loop_turn(
498 update_file_notifications_on_threadpool( 498 update_file_notifications_on_threadpool(
499 pool, 499 pool,
500 world_state.snapshot(), 500 world_state.snapshot(),
501 world_state.options.publish_decorations, 501 world_state.config.publish_decorations,
502 task_sender.clone(), 502 task_sender.clone(),
503 loop_state.subscriptions.subscriptions(), 503 loop_state.subscriptions.subscriptions(),
504 ) 504 )
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index f60a3f0a0..d5cb5d137 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -19,7 +19,7 @@ use lsp_types::{
19 TextEdit, WorkspaceEdit, 19 TextEdit, WorkspaceEdit,
20}; 20};
21use ra_ide::{ 21use ra_ide::{
22 Assist, AssistId, CompletionOptions, FileId, FilePosition, FileRange, Query, RangeInfo, 22 Assist, AssistId, CompletionConfig, FileId, FilePosition, FileRange, Query, RangeInfo,
23 Runnable, RunnableKind, SearchScope, 23 Runnable, RunnableKind, SearchScope,
24}; 24};
25use ra_prof::profile; 25use ra_prof::profile;
@@ -425,7 +425,7 @@ pub fn handle_completion(
425 return Ok(None); 425 return Ok(None);
426 } 426 }
427 427
428 let options = CompletionOptions { 428 let config = CompletionConfig {
429 enable_postfix_completions: world.feature_flags.get("completion.enable-postfix"), 429 enable_postfix_completions: world.feature_flags.get("completion.enable-postfix"),
430 add_call_parenthesis: world.feature_flags.get("completion.insertion.add-call-parenthesis"), 430 add_call_parenthesis: world.feature_flags.get("completion.insertion.add-call-parenthesis"),
431 add_call_argument_snippets: world 431 add_call_argument_snippets: world
@@ -433,7 +433,7 @@ pub fn handle_completion(
433 .get("completion.insertion.add-argument-snippets"), 433 .get("completion.insertion.add-argument-snippets"),
434 }; 434 };
435 435
436 let items = match world.analysis().completions(position, &options)? { 436 let items = match world.analysis().completions(position, &config)? {
437 None => return Ok(None), 437 None => return Ok(None),
438 Some(items) => items, 438 Some(items) => items,
439 }; 439 };
@@ -457,7 +457,7 @@ pub fn handle_folding_range(
457 let ctx = FoldConvCtx { 457 let ctx = FoldConvCtx {
458 text: &text, 458 text: &text,
459 line_index: &line_index, 459 line_index: &line_index,
460 line_folding_only: world.options.line_folding_only, 460 line_folding_only: world.config.line_folding_only,
461 }; 461 };
462 let res = Some(folds.into_iter().map_conv_with(&ctx).collect()); 462 let res = Some(folds.into_iter().map_conv_with(&ctx).collect());
463 Ok(res) 463 Ok(res)
@@ -611,7 +611,7 @@ pub fn handle_formatting(
611 let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); 611 let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
612 612
613 let mut rustfmt = process::Command::new("rustfmt"); 613 let mut rustfmt = process::Command::new("rustfmt");
614 rustfmt.args(&world.options.rustfmt_args); 614 rustfmt.args(&world.config.rustfmt_args);
615 if let Some(&crate_id) = crate_ids.first() { 615 if let Some(&crate_id) = crate_ids.first() {
616 // Assume all crates are in the same edition 616 // Assume all crates are in the same edition
617 let edition = world.analysis().crate_edition(crate_id)?; 617 let edition = world.analysis().crate_edition(crate_id)?;
@@ -815,7 +815,7 @@ pub fn handle_code_lens(
815 }; 815 };
816 lenses.push(lens); 816 lenses.push(lens);
817 817
818 if world.options.vscode_lldb { 818 if world.config.vscode_lldb {
819 if r.args[0] == "run" { 819 if r.args[0] == "run" {
820 r.args[0] = "build".into(); 820 r.args[0] = "build".into();
821 } else { 821 } else {
@@ -1028,7 +1028,7 @@ pub fn handle_inlay_hints(
1028 let analysis = world.analysis(); 1028 let analysis = world.analysis();
1029 let line_index = analysis.file_line_index(file_id)?; 1029 let line_index = analysis.file_line_index(file_id)?;
1030 Ok(analysis 1030 Ok(analysis
1031 .inlay_hints(file_id, &world.options.inlay_hints)? 1031 .inlay_hints(file_id, &world.config.inlay_hints)?
1032 .into_iter() 1032 .into_iter()
1033 .map_conv_with(&line_index) 1033 .map_conv_with(&line_index)
1034 .collect()) 1034 .collect())
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index ad096a1d8..a15a7085f 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -11,9 +11,9 @@ use std::{
11use crossbeam_channel::{unbounded, Receiver}; 11use crossbeam_channel::{unbounded, Receiver};
12use lsp_types::Url; 12use lsp_types::Url;
13use parking_lot::RwLock; 13use parking_lot::RwLock;
14use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckWatcher}; 14use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckConfig, CheckWatcher};
15use ra_ide::{ 15use ra_ide::{
16 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayHintsOptions, LibraryData, 16 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayHintsConfig, LibraryData,
17 SourceRootId, 17 SourceRootId,
18}; 18};
19use ra_project_model::{get_rustc_cfg_options, ProcMacroClient, ProjectWorkspace}; 19use ra_project_model::{get_rustc_cfg_options, ProcMacroClient, ProjectWorkspace};
@@ -31,7 +31,7 @@ use crate::{
31use ra_db::ExternSourceId; 31use ra_db::ExternSourceId;
32use rustc_hash::{FxHashMap, FxHashSet}; 32use rustc_hash::{FxHashMap, FxHashSet};
33 33
34fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> Option<CheckWatcher> { 34fn create_watcher(workspaces: &[ProjectWorkspace], config: &Config) -> Option<CheckWatcher> {
35 // FIXME: Figure out the multi-workspace situation 35 // FIXME: Figure out the multi-workspace situation
36 workspaces 36 workspaces
37 .iter() 37 .iter()
@@ -41,7 +41,7 @@ fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> Option<
41 }) 41 })
42 .map(|cargo| { 42 .map(|cargo| {
43 let cargo_project_root = cargo.workspace_root().to_path_buf(); 43 let cargo_project_root = cargo.workspace_root().to_path_buf();
44 Some(CheckWatcher::new(&options.cargo_watch, cargo_project_root)) 44 Some(CheckWatcher::new(config.check.clone(), cargo_project_root))
45 }) 45 })
46 .unwrap_or_else(|| { 46 .unwrap_or_else(|| {
47 log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); 47 log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
@@ -50,13 +50,13 @@ fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> Option<
50} 50}
51 51
52#[derive(Debug, Clone)] 52#[derive(Debug, Clone)]
53pub struct Options { 53pub struct Config {
54 pub publish_decorations: bool, 54 pub publish_decorations: bool,
55 pub supports_location_link: bool, 55 pub supports_location_link: bool,
56 pub line_folding_only: bool, 56 pub line_folding_only: bool,
57 pub inlay_hints: InlayHintsOptions, 57 pub inlay_hints: InlayHintsConfig,
58 pub rustfmt_args: Vec<String>, 58 pub rustfmt_args: Vec<String>,
59 pub cargo_watch: CheckOptions, 59 pub check: CheckConfig,
60 pub vscode_lldb: bool, 60 pub vscode_lldb: bool,
61} 61}
62 62
@@ -67,7 +67,7 @@ pub struct Options {
67/// incremental salsa database. 67/// incremental salsa database.
68#[derive(Debug)] 68#[derive(Debug)]
69pub struct WorldState { 69pub struct WorldState {
70 pub options: Options, 70 pub config: Config,
71 pub feature_flags: Arc<FeatureFlags>, 71 pub feature_flags: Arc<FeatureFlags>,
72 pub roots: Vec<PathBuf>, 72 pub roots: Vec<PathBuf>,
73 pub workspaces: Arc<Vec<ProjectWorkspace>>, 73 pub workspaces: Arc<Vec<ProjectWorkspace>>,
@@ -81,7 +81,7 @@ pub struct WorldState {
81 81
82/// An immutable snapshot of the world's state at a point in time. 82/// An immutable snapshot of the world's state at a point in time.
83pub struct WorldSnapshot { 83pub struct WorldSnapshot {
84 pub options: Options, 84 pub config: Config,
85 pub feature_flags: Arc<FeatureFlags>, 85 pub feature_flags: Arc<FeatureFlags>,
86 pub workspaces: Arc<Vec<ProjectWorkspace>>, 86 pub workspaces: Arc<Vec<ProjectWorkspace>>,
87 pub analysis: Analysis, 87 pub analysis: Analysis,
@@ -97,7 +97,7 @@ impl WorldState {
97 lru_capacity: Option<usize>, 97 lru_capacity: Option<usize>,
98 exclude_globs: &[Glob], 98 exclude_globs: &[Glob],
99 watch: Watch, 99 watch: Watch,
100 options: Options, 100 config: Config,
101 feature_flags: FeatureFlags, 101 feature_flags: FeatureFlags,
102 ) -> WorldState { 102 ) -> WorldState {
103 let mut change = AnalysisChange::new(); 103 let mut change = AnalysisChange::new();
@@ -185,12 +185,12 @@ impl WorldState {
185 }); 185 });
186 change.set_crate_graph(crate_graph); 186 change.set_crate_graph(crate_graph);
187 187
188 let check_watcher = create_watcher(&workspaces, &options); 188 let check_watcher = create_watcher(&workspaces, &config);
189 189
190 let mut analysis_host = AnalysisHost::new(lru_capacity); 190 let mut analysis_host = AnalysisHost::new(lru_capacity);
191 analysis_host.apply_change(change); 191 analysis_host.apply_change(change);
192 WorldState { 192 WorldState {
193 options, 193 config: config,
194 feature_flags: Arc::new(feature_flags), 194 feature_flags: Arc::new(feature_flags),
195 roots: folder_roots, 195 roots: folder_roots,
196 workspaces: Arc::new(workspaces), 196 workspaces: Arc::new(workspaces),
@@ -206,13 +206,13 @@ impl WorldState {
206 pub fn update_configuration( 206 pub fn update_configuration(
207 &mut self, 207 &mut self,
208 lru_capacity: Option<usize>, 208 lru_capacity: Option<usize>,
209 options: Options, 209 config: Config,
210 feature_flags: FeatureFlags, 210 feature_flags: FeatureFlags,
211 ) { 211 ) {
212 self.feature_flags = Arc::new(feature_flags); 212 self.feature_flags = Arc::new(feature_flags);
213 self.analysis_host.update_lru_capacity(lru_capacity); 213 self.analysis_host.update_lru_capacity(lru_capacity);
214 self.check_watcher = create_watcher(&self.workspaces, &options); 214 self.check_watcher = create_watcher(&self.workspaces, &config);
215 self.options = options; 215 self.config = config;
216 } 216 }
217 217
218 /// Returns a vec of libraries 218 /// Returns a vec of libraries
@@ -268,7 +268,7 @@ impl WorldState {
268 268
269 pub fn snapshot(&self) -> WorldSnapshot { 269 pub fn snapshot(&self) -> WorldSnapshot {
270 WorldSnapshot { 270 WorldSnapshot {
271 options: self.options.clone(), 271 config: self.config.clone(),
272 feature_flags: Arc::clone(&self.feature_flags), 272 feature_flags: Arc::clone(&self.feature_flags),
273 workspaces: Arc::clone(&self.workspaces), 273 workspaces: Arc::clone(&self.workspaces),
274 analysis: self.analysis_host.analysis(), 274 analysis: self.analysis_host.analysis(),