diff options
-rw-r--r-- | crates/ra_batch/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 25 | ||||
-rw-r--r-- | crates/ra_cli/src/help.rs | 145 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 38 | ||||
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs | 32 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_scope.rs | 34 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 21 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 4 | ||||
-rw-r--r-- | crates/ra_tools/src/help.rs | 90 |
11 files changed, 244 insertions, 163 deletions
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index a14139b26..ffc9e16bb 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs | |||
@@ -89,6 +89,10 @@ pub fn load( | |||
89 | vfs.root2path(root) | 89 | vfs.root2path(root) |
90 | ); | 90 | ); |
91 | analysis_change.add_root(source_root_id, is_local); | 91 | analysis_change.add_root(source_root_id, is_local); |
92 | analysis_change.set_debug_root_path( | ||
93 | source_root_id, | ||
94 | source_roots[&source_root_id].path().display().to_string(), | ||
95 | ); | ||
92 | 96 | ||
93 | let mut file_map = FxHashMap::default(); | 97 | let mut file_map = FxHashMap::default(); |
94 | for (vfs_file, path, text) in files { | 98 | for (vfs_file, path, text) in files { |
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index 1fad5b233..8f4ce42da 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -4,9 +4,14 @@ use ra_db::SourceDatabase; | |||
4 | use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty, TypeWalk}; | 4 | use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty, TypeWalk}; |
5 | use ra_syntax::AstNode; | 5 | use ra_syntax::AstNode; |
6 | 6 | ||
7 | use crate::Result; | 7 | use crate::{Result, Verbosity}; |
8 | 8 | ||
9 | pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -> Result<()> { | 9 | pub fn run( |
10 | verbosity: Verbosity, | ||
11 | memory_usage: bool, | ||
12 | path: &Path, | ||
13 | only: Option<&str>, | ||
14 | ) -> Result<()> { | ||
10 | let db_load_time = Instant::now(); | 15 | let db_load_time = Instant::now(); |
11 | let (mut host, roots) = ra_batch::load_cargo(path)?; | 16 | let (mut host, roots) = ra_batch::load_cargo(path)?; |
12 | let db = host.raw_database(); | 17 | let db = host.raw_database(); |
@@ -55,10 +60,14 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
55 | println!("Item Collection: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); | 60 | println!("Item Collection: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); |
56 | 61 | ||
57 | let inference_time = Instant::now(); | 62 | let inference_time = Instant::now(); |
58 | let bar = indicatif::ProgressBar::with_draw_target( | 63 | let bar = match verbosity { |
59 | funcs.len() as u64, | 64 | Verbosity::Verbose | Verbosity::Normal => indicatif::ProgressBar::with_draw_target( |
60 | indicatif::ProgressDrawTarget::stderr_nohz(), | 65 | funcs.len() as u64, |
61 | ); | 66 | indicatif::ProgressDrawTarget::stderr_nohz(), |
67 | ), | ||
68 | Verbosity::Quiet => indicatif::ProgressBar::hidden(), | ||
69 | }; | ||
70 | |||
62 | bar.set_style( | 71 | bar.set_style( |
63 | indicatif::ProgressStyle::default_bar().template("{wide_bar} {pos}/{len}\n{msg}"), | 72 | indicatif::ProgressStyle::default_bar().template("{wide_bar} {pos}/{len}\n{msg}"), |
64 | ); | 73 | ); |
@@ -70,7 +79,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
70 | for f in funcs { | 79 | for f in funcs { |
71 | let name = f.name(db); | 80 | let name = f.name(db); |
72 | let mut msg = format!("processing: {}", name); | 81 | let mut msg = format!("processing: {}", name); |
73 | if verbose { | 82 | if verbosity.is_verbose() { |
74 | let src = f.source(db); | 83 | let src = f.source(db); |
75 | let original_file = src.file_id.original_file(db); | 84 | let original_file = src.file_id.original_file(db); |
76 | let path = db.file_relative_path(original_file); | 85 | let path = db.file_relative_path(original_file); |
@@ -103,7 +112,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
103 | } | 112 | } |
104 | if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) { | 113 | if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) { |
105 | num_type_mismatches += 1; | 114 | num_type_mismatches += 1; |
106 | if verbose { | 115 | if verbosity.is_verbose() { |
107 | let src = f.expr_source(db, expr_id); | 116 | let src = f.expr_source(db, expr_id); |
108 | if let Some(src) = src { | 117 | if let Some(src) = src { |
109 | // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly | 118 | // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly |
diff --git a/crates/ra_cli/src/help.rs b/crates/ra_cli/src/help.rs index 5171578f0..2a74b8733 100644 --- a/crates/ra_cli/src/help.rs +++ b/crates/ra_cli/src/help.rs | |||
@@ -1,72 +1,73 @@ | |||
1 | pub const GLOBAL_HELP: &str = "ra-cli | 1 | pub const GLOBAL_HELP: &str = "ra-cli |
2 | 2 | ||
3 | USAGE: | 3 | USAGE: |
4 | ra_cli <SUBCOMMAND> | 4 | ra_cli <SUBCOMMAND> |
5 | 5 | ||
6 | FLAGS: | 6 | FLAGS: |
7 | -h, --help Prints help information | 7 | -h, --help Prints help information |
8 | 8 | ||
9 | SUBCOMMANDS: | 9 | SUBCOMMANDS: |
10 | analysis-bench | 10 | analysis-bench |
11 | analysis-stats | 11 | analysis-stats |
12 | highlight | 12 | highlight |
13 | parse | 13 | parse |
14 | symbols"; | 14 | symbols"; |
15 | 15 | ||
16 | pub const ANALYSIS_BENCH_HELP: &str = "ra_cli-analysis-bench | 16 | pub const ANALYSIS_BENCH_HELP: &str = "ra_cli-analysis-bench |
17 | 17 | ||
18 | USAGE: | 18 | USAGE: |
19 | ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH] | 19 | ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH] |
20 | 20 | ||
21 | FLAGS: | 21 | FLAGS: |
22 | -h, --help Prints help information | 22 | -h, --help Prints help information |
23 | -v, --verbose | 23 | -v, --verbose |
24 | 24 | ||
25 | OPTIONS: | 25 | OPTIONS: |
26 | --complete <PATH:LINE:COLUMN> Compute completions at this location | 26 | --complete <PATH:LINE:COLUMN> Compute completions at this location |
27 | --highlight <PATH> Hightlight this file | 27 | --highlight <PATH> Hightlight this file |
28 | 28 | ||
29 | ARGS: | 29 | ARGS: |
30 | <PATH> Project to analyse"; | 30 | <PATH> Project to analyse"; |
31 | 31 | ||
32 | pub const ANALYSIS_STATS_HELP: &str = "ra-cli-analysis-stats | 32 | pub const ANALYSIS_STATS_HELP: &str = "ra-cli-analysis-stats |
33 | 33 | ||
34 | USAGE: | 34 | USAGE: |
35 | ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH] | 35 | ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH] |
36 | 36 | ||
37 | FLAGS: | 37 | FLAGS: |
38 | -h, --help Prints help information | 38 | -h, --help Prints help information |
39 | --memory-usage | 39 | --memory-usage |
40 | -v, --verbose | 40 | -v, --verbose |
41 | 41 | -q, --quiet | |
42 | OPTIONS: | 42 | |
43 | -o <ONLY> | 43 | OPTIONS: |
44 | 44 | -o <ONLY> | |
45 | ARGS: | 45 | |
46 | <PATH>"; | 46 | ARGS: |
47 | 47 | <PATH>"; | |
48 | pub const HIGHLIGHT_HELP: &str = "ra-cli-highlight | 48 | |
49 | 49 | pub const HIGHLIGHT_HELP: &str = "ra-cli-highlight | |
50 | USAGE: | 50 | |
51 | ra_cli highlight [FLAGS] | 51 | USAGE: |
52 | 52 | ra_cli highlight [FLAGS] | |
53 | FLAGS: | 53 | |
54 | -h, --help Prints help information | 54 | FLAGS: |
55 | -r, --rainbow"; | 55 | -h, --help Prints help information |
56 | 56 | -r, --rainbow"; | |
57 | pub const SYMBOLS_HELP: &str = "ra-cli-symbols | 57 | |
58 | 58 | pub const SYMBOLS_HELP: &str = "ra-cli-symbols | |
59 | USAGE: | 59 | |
60 | ra_cli highlight [FLAGS] | 60 | USAGE: |
61 | 61 | ra_cli highlight [FLAGS] | |
62 | FLAGS: | 62 | |
63 | -h, --help Prints help inforamtion"; | 63 | FLAGS: |
64 | 64 | -h, --help Prints help inforamtion"; | |
65 | pub const PARSE_HELP: &str = "ra-cli-parse | 65 | |
66 | 66 | pub const PARSE_HELP: &str = "ra-cli-parse | |
67 | USAGE: | 67 | |
68 | ra_cli parse [FLAGS] | 68 | USAGE: |
69 | 69 | ra_cli parse [FLAGS] | |
70 | FLAGS: | 70 | |
71 | -h, --help Prints help inforamtion | 71 | FLAGS: |
72 | --no-dump"; | 72 | -h, --help Prints help inforamtion |
73 | --no-dump"; | ||
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index e6334cf56..ca9275cd4 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -12,6 +12,22 @@ use ra_syntax::{AstNode, SourceFile}; | |||
12 | 12 | ||
13 | type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; | 13 | type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; |
14 | 14 | ||
15 | #[derive(Clone, Copy)] | ||
16 | pub enum Verbosity { | ||
17 | Verbose, | ||
18 | Normal, | ||
19 | Quiet, | ||
20 | } | ||
21 | |||
22 | impl Verbosity { | ||
23 | fn is_verbose(&self) -> bool { | ||
24 | match self { | ||
25 | Verbosity::Verbose => true, | ||
26 | _ => false, | ||
27 | } | ||
28 | } | ||
29 | } | ||
30 | |||
15 | fn main() -> Result<()> { | 31 | fn main() -> Result<()> { |
16 | Logger::with_env().start()?; | 32 | Logger::with_env().start()?; |
17 | 33 | ||
@@ -67,13 +83,27 @@ fn main() -> Result<()> { | |||
67 | eprintln!("{}", help::ANALYSIS_STATS_HELP); | 83 | eprintln!("{}", help::ANALYSIS_STATS_HELP); |
68 | return Ok(()); | 84 | return Ok(()); |
69 | } | 85 | } |
70 | let verbose = matches.contains(["-v", "--verbose"]); | 86 | let verbosity = match ( |
87 | matches.contains(["-v", "--verbose"]), | ||
88 | matches.contains(["-q", "--quiet"]), | ||
89 | ) { | ||
90 | (false, false) => Verbosity::Normal, | ||
91 | (false, true) => Verbosity::Quiet, | ||
92 | (true, false) => Verbosity::Verbose, | ||
93 | (true, true) => Err("Invalid flags: -q conflicts with -v")?, | ||
94 | }; | ||
71 | let memory_usage = matches.contains("--memory-usage"); | 95 | let memory_usage = matches.contains("--memory-usage"); |
72 | let path: String = matches.value_from_str("--path")?.unwrap_or_default(); | ||
73 | let only = matches.value_from_str(["-o", "--only"])?.map(|v: String| v.to_owned()); | 96 | let only = matches.value_from_str(["-o", "--only"])?.map(|v: String| v.to_owned()); |
74 | matches.finish().or_else(handle_extra_flags)?; | 97 | let path = { |
98 | let mut trailing = matches.free()?; | ||
99 | if trailing.len() != 1 { | ||
100 | eprintln!("{}", help::ANALYSIS_STATS_HELP); | ||
101 | Err("Invalid flags")?; | ||
102 | } | ||
103 | trailing.pop().unwrap() | ||
104 | }; | ||
75 | analysis_stats::run( | 105 | analysis_stats::run( |
76 | verbose, | 106 | verbosity, |
77 | memory_usage, | 107 | memory_usage, |
78 | path.as_ref(), | 108 | path.as_ref(), |
79 | only.as_ref().map(String::as_ref), | 109 | only.as_ref().map(String::as_ref), |
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 162ab02b1..d26a024ed 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -4,7 +4,7 @@ use std::sync::Arc; | |||
4 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; | 4 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; |
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | ast::{self, AstNode}, | 6 | ast::{self, AstNode}, |
7 | AstPtr, SourceFile, | 7 | AstPtr, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -29,12 +29,12 @@ impl ImplSourceMap { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | pub fn get(&self, source: &ModuleSource, impl_id: ImplId) -> ast::ImplBlock { | 31 | pub fn get(&self, source: &ModuleSource, impl_id: ImplId) -> ast::ImplBlock { |
32 | let file = match source { | 32 | let root = match source { |
33 | ModuleSource::SourceFile(file) => file.clone(), | 33 | ModuleSource::SourceFile(file) => file.syntax().clone(), |
34 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), | 34 | ModuleSource::Module(m) => m.syntax().ancestors().last().unwrap(), |
35 | }; | 35 | }; |
36 | 36 | ||
37 | self.map[impl_id].to_node(file.syntax()).to_owned() | 37 | self.map[impl_id].to_node(&root) |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
diff --git a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs index 708dc9777..6fcef4a72 100644 --- a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs +++ b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs | |||
@@ -37,14 +37,42 @@ mod tests { | |||
37 | ), | 37 | ), |
38 | @r##"[ | 38 | @r##"[ |
39 | CompletionItem { | 39 | CompletionItem { |
40 | label: "foo", | 40 | label: "foo!", |
41 | source_range: [46; 46), | 41 | source_range: [46; 46), |
42 | delete: [46; 46), | 42 | delete: [46; 46), |
43 | insert: "foo!", | 43 | insert: "foo!($0)", |
44 | kind: Macro, | 44 | kind: Macro, |
45 | detail: "macro_rules! foo", | 45 | detail: "macro_rules! foo", |
46 | }, | 46 | }, |
47 | ]"## | 47 | ]"## |
48 | ); | 48 | ); |
49 | } | 49 | } |
50 | |||
51 | #[test] | ||
52 | fn completes_vec_macros_with_square_brackets() { | ||
53 | assert_debug_snapshot!( | ||
54 | do_reference_completion( | ||
55 | " | ||
56 | //- /main.rs | ||
57 | macro_rules! vec { | ||
58 | () => {} | ||
59 | } | ||
60 | |||
61 | fn foo() {} | ||
62 | |||
63 | <|> | ||
64 | " | ||
65 | ), | ||
66 | @r##"[ | ||
67 | CompletionItem { | ||
68 | label: "vec!", | ||
69 | source_range: [46; 46), | ||
70 | delete: [46; 46), | ||
71 | insert: "vec![$0]", | ||
72 | kind: Macro, | ||
73 | detail: "macro_rules! vec", | ||
74 | }, | ||
75 | ]"## | ||
76 | ); | ||
77 | } | ||
50 | } | 78 | } |
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 31e7dffe8..457a3d10c 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -605,10 +605,10 @@ mod tests { | |||
605 | ), | 605 | ), |
606 | @r###"[ | 606 | @r###"[ |
607 | CompletionItem { | 607 | CompletionItem { |
608 | label: "foo", | 608 | label: "foo!", |
609 | source_range: [179; 179), | 609 | source_range: [179; 179), |
610 | delete: [179; 179), | 610 | delete: [179; 179), |
611 | insert: "foo!", | 611 | insert: "foo!($0)", |
612 | kind: Macro, | 612 | kind: Macro, |
613 | detail: "#[macro_export]\nmacro_rules! foo", | 613 | detail: "#[macro_export]\nmacro_rules! foo", |
614 | }, | 614 | }, |
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 2062e7300..2ea22876f 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs | |||
@@ -568,26 +568,26 @@ mod tests { | |||
568 | ), | 568 | ), |
569 | @r##"[ | 569 | @r##"[ |
570 | CompletionItem { | 570 | CompletionItem { |
571 | label: "bar", | 571 | label: "bar!", |
572 | source_range: [252; 252), | 572 | source_range: [252; 252), |
573 | delete: [252; 252), | 573 | delete: [252; 252), |
574 | insert: "bar!", | 574 | insert: "bar!($0)", |
575 | kind: Macro, | 575 | kind: Macro, |
576 | detail: "macro_rules! bar", | 576 | detail: "macro_rules! bar", |
577 | }, | 577 | }, |
578 | CompletionItem { | 578 | CompletionItem { |
579 | label: "baz", | 579 | label: "baz!", |
580 | source_range: [252; 252), | 580 | source_range: [252; 252), |
581 | delete: [252; 252), | 581 | delete: [252; 252), |
582 | insert: "baz!", | 582 | insert: "baz!($0)", |
583 | kind: Macro, | 583 | kind: Macro, |
584 | detail: "#[macro_export]\nmacro_rules! baz", | 584 | detail: "#[macro_export]\nmacro_rules! baz", |
585 | }, | 585 | }, |
586 | CompletionItem { | 586 | CompletionItem { |
587 | label: "foo", | 587 | label: "foo!", |
588 | source_range: [252; 252), | 588 | source_range: [252; 252), |
589 | delete: [252; 252), | 589 | delete: [252; 252), |
590 | insert: "foo!", | 590 | insert: "foo!($0)", |
591 | kind: Macro, | 591 | kind: Macro, |
592 | detail: "macro_rules! foo", | 592 | detail: "macro_rules! foo", |
593 | }, | 593 | }, |
@@ -637,17 +637,17 @@ mod tests { | |||
637 | label: "foo", | 637 | label: "foo", |
638 | source_range: [49; 49), | 638 | source_range: [49; 49), |
639 | delete: [49; 49), | 639 | delete: [49; 49), |
640 | insert: "foo!", | 640 | insert: "foo()$0", |
641 | kind: Macro, | 641 | kind: Function, |
642 | detail: "macro_rules! foo", | 642 | detail: "fn foo()", |
643 | }, | 643 | }, |
644 | CompletionItem { | 644 | CompletionItem { |
645 | label: "foo", | 645 | label: "foo!", |
646 | source_range: [49; 49), | 646 | source_range: [49; 49), |
647 | delete: [49; 49), | 647 | delete: [49; 49), |
648 | insert: "foo()$0", | 648 | insert: "foo!($0)", |
649 | kind: Function, | 649 | kind: Macro, |
650 | detail: "fn foo()", | 650 | detail: "macro_rules! foo", |
651 | }, | 651 | }, |
652 | ]"## | 652 | ]"## |
653 | ); | 653 | ); |
@@ -670,10 +670,10 @@ mod tests { | |||
670 | ), | 670 | ), |
671 | @r##"[ | 671 | @r##"[ |
672 | CompletionItem { | 672 | CompletionItem { |
673 | label: "foo", | 673 | label: "foo!", |
674 | source_range: [57; 57), | 674 | source_range: [57; 57), |
675 | delete: [57; 57), | 675 | delete: [57; 57), |
676 | insert: "foo!", | 676 | insert: "foo!($0)", |
677 | kind: Macro, | 677 | kind: Macro, |
678 | detail: "macro_rules! foo", | 678 | detail: "macro_rules! foo", |
679 | }, | 679 | }, |
@@ -706,10 +706,10 @@ mod tests { | |||
706 | ), | 706 | ), |
707 | @r##"[ | 707 | @r##"[ |
708 | CompletionItem { | 708 | CompletionItem { |
709 | label: "foo", | 709 | label: "foo!", |
710 | source_range: [50; 50), | 710 | source_range: [50; 50), |
711 | delete: [50; 50), | 711 | delete: [50; 50), |
712 | insert: "foo!", | 712 | insert: "foo!($0)", |
713 | kind: Macro, | 713 | kind: Macro, |
714 | detail: "macro_rules! foo", | 714 | detail: "macro_rules! foo", |
715 | }, | 715 | }, |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 1b706bb13..5cabe9a32 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -109,12 +109,21 @@ impl Completions { | |||
109 | if let Some(name) = name { | 109 | if let Some(name) = name { |
110 | let detail = macro_label(&ast_node); | 110 | let detail = macro_label(&ast_node); |
111 | 111 | ||
112 | let builder = | 112 | let macro_braces_to_insert = match name.as_str() { |
113 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.clone()) | 113 | "vec" => "[$0]", |
114 | .kind(CompletionItemKind::Macro) | 114 | _ => "($0)", |
115 | .set_documentation(macro_.docs(ctx.db)) | 115 | }; |
116 | .detail(detail) | 116 | let macro_declaration = name + "!"; |
117 | .insert_snippet(format!("{}!", name)); | 117 | |
118 | let builder = CompletionItem::new( | ||
119 | CompletionKind::Reference, | ||
120 | ctx.source_range(), | ||
121 | ¯o_declaration, | ||
122 | ) | ||
123 | .kind(CompletionItemKind::Macro) | ||
124 | .set_documentation(macro_.docs(ctx.db)) | ||
125 | .detail(detail) | ||
126 | .insert_snippet(macro_declaration + macro_braces_to_insert); | ||
118 | 127 | ||
119 | self.add(builder); | 128 | self.add(builder); |
120 | } | 129 | } |
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index a2ac363fb..f8fba6860 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -5,7 +5,7 @@ use drop_bomb::DropBomb; | |||
5 | use crate::{ | 5 | use crate::{ |
6 | event::Event, | 6 | event::Event, |
7 | ParseError, | 7 | ParseError, |
8 | SyntaxKind::{self, EOF, ERROR, L_DOLLAR, R_DOLLAR, TOMBSTONE}, | 8 | SyntaxKind::{self, EOF, ERROR, TOMBSTONE}, |
9 | TokenSet, TokenSource, T, | 9 | TokenSet, TokenSource, T, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -212,7 +212,7 @@ impl<'t> Parser<'t> { | |||
212 | /// Create an error node and consume the next token. | 212 | /// Create an error node and consume the next token. |
213 | pub(crate) fn err_recover(&mut self, message: &str, recovery: TokenSet) { | 213 | pub(crate) fn err_recover(&mut self, message: &str, recovery: TokenSet) { |
214 | match self.current() { | 214 | match self.current() { |
215 | T!['{'] | T!['}'] | L_DOLLAR | R_DOLLAR => { | 215 | T!['{'] | T!['}'] => { |
216 | self.error(message); | 216 | self.error(message); |
217 | return; | 217 | return; |
218 | } | 218 | } |
diff --git a/crates/ra_tools/src/help.rs b/crates/ra_tools/src/help.rs index 6dde6c2d2..9eb4dfbe4 100644 --- a/crates/ra_tools/src/help.rs +++ b/crates/ra_tools/src/help.rs | |||
@@ -1,45 +1,45 @@ | |||
1 | pub const GLOBAL_HELP: &str = "tasks | 1 | pub const GLOBAL_HELP: &str = "tasks |
2 | 2 | ||
3 | USAGE: | 3 | USAGE: |
4 | ra_tools <SUBCOMMAND> | 4 | ra_tools <SUBCOMMAND> |
5 | 5 | ||
6 | FLAGS: | 6 | FLAGS: |
7 | -h, --help Prints help information | 7 | -h, --help Prints help information |
8 | 8 | ||
9 | SUBCOMMANDS: | 9 | SUBCOMMANDS: |
10 | format | 10 | format |
11 | format-hook | 11 | format-hook |
12 | fuzz-tests | 12 | fuzz-tests |
13 | gen-syntax | 13 | gen-syntax |
14 | gen-tests | 14 | gen-tests |
15 | install-ra | 15 | install-ra |
16 | lint"; | 16 | lint"; |
17 | 17 | ||
18 | pub const INSTALL_RA_HELP: &str = "ra_tools-install-ra | 18 | pub const INSTALL_RA_HELP: &str = "ra_tools-install-ra |
19 | 19 | ||
20 | USAGE: | 20 | USAGE: |
21 | ra_tools.exe install-ra [FLAGS] | 21 | ra_tools.exe install-ra [FLAGS] |
22 | 22 | ||
23 | FLAGS: | 23 | FLAGS: |
24 | --client-code | 24 | --client-code |
25 | -h, --help Prints help information | 25 | -h, --help Prints help information |
26 | --jemalloc | 26 | --jemalloc |
27 | --server"; | 27 | --server"; |
28 | 28 | ||
29 | pub fn print_no_param_subcommand_help(subcommand: &str) { | 29 | pub fn print_no_param_subcommand_help(subcommand: &str) { |
30 | eprintln!( | 30 | eprintln!( |
31 | "ra_tools-{} | 31 | "ra_tools-{} |
32 | 32 | ||
33 | USAGE: | 33 | USAGE: |
34 | ra_tools {} | 34 | ra_tools {} |
35 | 35 | ||
36 | FLAGS: | 36 | FLAGS: |
37 | -h, --help Prints help information", | 37 | -h, --help Prints help information", |
38 | subcommand, subcommand | 38 | subcommand, subcommand |
39 | ); | 39 | ); |
40 | } | 40 | } |
41 | 41 | ||
42 | pub const INSTALL_RA_CONFLICT: &str = | 42 | pub const INSTALL_RA_CONFLICT: &str = |
43 | "error: The argument `--server` cannot be used with `--client-code` | 43 | "error: The argument `--server` cannot be used with `--client-code` |
44 | 44 | ||
45 | For more information try --help"; | 45 | For more information try --help"; |