diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_lsp_server/src/caps.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 26 | ||||
-rw-r--r-- | crates/tools/src/lib.rs | 17 | ||||
-rw-r--r-- | crates/tools/src/main.rs | 7 |
6 files changed, 48 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index 8d508a3ba..a74f9f27b 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs | |||
@@ -28,7 +28,7 @@ pub fn server_capabilities() -> ServerCapabilities { | |||
28 | type_definition_provider: None, | 28 | type_definition_provider: None, |
29 | implementation_provider: None, | 29 | implementation_provider: None, |
30 | references_provider: Some(true), | 30 | references_provider: Some(true), |
31 | document_highlight_provider: None, | 31 | document_highlight_provider: Some(true), |
32 | document_symbol_provider: Some(true), | 32 | document_symbol_provider: Some(true), |
33 | workspace_symbol_provider: Some(true), | 33 | workspace_symbol_provider: Some(true), |
34 | code_action_provider: Some(CodeActionProviderCapability::Simple(true)), | 34 | code_action_provider: Some(CodeActionProviderCapability::Simple(true)), |
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 0d6e62727..618486250 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -82,7 +82,6 @@ impl Conv for CompletionItem { | |||
82 | InsertText::Snippet { text } => { | 82 | InsertText::Snippet { text } => { |
83 | res.insert_text = Some(text); | 83 | res.insert_text = Some(text); |
84 | res.insert_text_format = Some(InsertTextFormat::Snippet); | 84 | res.insert_text_format = Some(InsertTextFormat::Snippet); |
85 | res.kind = Some(languageserver_types::CompletionItemKind::Keyword); | ||
86 | } | 85 | } |
87 | } | 86 | } |
88 | res | 87 | res |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index d425b6733..06dd373c0 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -300,6 +300,7 @@ fn on_request( | |||
300 | .on::<req::Rename>(handlers::handle_rename)? | 300 | .on::<req::Rename>(handlers::handle_rename)? |
301 | .on::<req::References>(handlers::handle_references)? | 301 | .on::<req::References>(handlers::handle_references)? |
302 | .on::<req::Formatting>(handlers::handle_formatting)? | 302 | .on::<req::Formatting>(handlers::handle_formatting)? |
303 | .on::<req::DocumentHighlightRequest>(handlers::handle_document_highlight)? | ||
303 | .finish(); | 304 | .finish(); |
304 | match req { | 305 | match req { |
305 | Ok(id) => { | 306 | Ok(id) => { |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 1d93e8f4d..11825d74e 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -6,9 +6,8 @@ use languageserver_types::{ | |||
6 | DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, | 6 | DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, |
7 | FoldingRangeParams, Location, MarkupContent, MarkupKind, MarkedString, Position, | 7 | FoldingRangeParams, Location, MarkupContent, MarkupKind, MarkedString, Position, |
8 | PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, | 8 | PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, |
9 | Range, | 9 | Range, WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, |
10 | WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, | 10 | HoverContents, DocumentFormattingParams, DocumentHighlight, |
11 | DocumentFormattingParams, | ||
12 | }; | 11 | }; |
13 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FileRange, FilePosition, Severity}; | 12 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FileRange, FilePosition, Severity}; |
14 | use ra_syntax::{TextUnit, text_utils::intersect}; | 13 | use ra_syntax::{TextUnit, text_utils::intersect}; |
@@ -678,6 +677,27 @@ pub fn handle_code_action( | |||
678 | Ok(Some(CodeActionResponse::Commands(res))) | 677 | Ok(Some(CodeActionResponse::Commands(res))) |
679 | } | 678 | } |
680 | 679 | ||
680 | pub fn handle_document_highlight( | ||
681 | world: ServerWorld, | ||
682 | params: req::TextDocumentPositionParams, | ||
683 | ) -> Result<Option<Vec<DocumentHighlight>>> { | ||
684 | let file_id = params.text_document.try_conv_with(&world)?; | ||
685 | let line_index = world.analysis().file_line_index(file_id); | ||
686 | |||
687 | let refs = world | ||
688 | .analysis() | ||
689 | .find_all_refs(params.try_conv_with(&world)?)?; | ||
690 | |||
691 | Ok(Some( | ||
692 | refs.into_iter() | ||
693 | .map(|r| DocumentHighlight { | ||
694 | range: r.1.conv_with(&line_index), | ||
695 | kind: None, | ||
696 | }) | ||
697 | .collect(), | ||
698 | )) | ||
699 | } | ||
700 | |||
681 | pub fn publish_diagnostics( | 701 | pub fn publish_diagnostics( |
682 | world: &ServerWorld, | 702 | world: &ServerWorld, |
683 | file_id: FileId, | 703 | file_id: FileId, |
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index e5b32c25c..fa619af33 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs | |||
@@ -139,3 +139,20 @@ pub fn install_format_hook() -> Result<()> { | |||
139 | } | 139 | } |
140 | Ok(()) | 140 | Ok(()) |
141 | } | 141 | } |
142 | |||
143 | pub fn run_fuzzer() -> Result<()> { | ||
144 | match Command::new("cargo") | ||
145 | .args(&["fuzz", "--help"]) | ||
146 | .stderr(Stdio::null()) | ||
147 | .stdout(Stdio::null()) | ||
148 | .status() | ||
149 | { | ||
150 | Ok(status) if status.success() => (), | ||
151 | _ => run("cargo install cargo-fuzz", ".")?, | ||
152 | }; | ||
153 | |||
154 | run( | ||
155 | "rustup run nightly -- cargo fuzz run parser", | ||
156 | "./crates/ra_syntax", | ||
157 | ) | ||
158 | } | ||
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index 7edf8f52d..9d73d57c4 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
@@ -7,7 +7,10 @@ use std::{ | |||
7 | use clap::{App, Arg, SubCommand}; | 7 | use clap::{App, Arg, SubCommand}; |
8 | use failure::bail; | 8 | use failure::bail; |
9 | 9 | ||
10 | use tools::{collect_tests, generate, install_format_hook, run, run_rustfmt, Mode, Overwrite, Result, Test, Verify, project_root}; | 10 | use tools::{ |
11 | collect_tests, generate,install_format_hook, run, run_rustfmt, | ||
12 | Mode, Overwrite, Result, Test, Verify, project_root, run_fuzzer | ||
13 | }; | ||
11 | 14 | ||
12 | const GRAMMAR_DIR: &str = "crates/ra_syntax/src/grammar"; | 15 | const GRAMMAR_DIR: &str = "crates/ra_syntax/src/grammar"; |
13 | const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/tests/data/parser/inline/ok"; | 16 | const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/tests/data/parser/inline/ok"; |
@@ -27,6 +30,7 @@ fn main() -> Result<()> { | |||
27 | .subcommand(SubCommand::with_name("install-code")) | 30 | .subcommand(SubCommand::with_name("install-code")) |
28 | .subcommand(SubCommand::with_name("format")) | 31 | .subcommand(SubCommand::with_name("format")) |
29 | .subcommand(SubCommand::with_name("format-hook")) | 32 | .subcommand(SubCommand::with_name("format-hook")) |
33 | .subcommand(SubCommand::with_name("fuzz-tests")) | ||
30 | .get_matches(); | 34 | .get_matches(); |
31 | let mode = if matches.is_present("verify") { | 35 | let mode = if matches.is_present("verify") { |
32 | Verify | 36 | Verify |
@@ -42,6 +46,7 @@ fn main() -> Result<()> { | |||
42 | "gen-syntax" => generate(Overwrite)?, | 46 | "gen-syntax" => generate(Overwrite)?, |
43 | "format" => run_rustfmt(mode)?, | 47 | "format" => run_rustfmt(mode)?, |
44 | "format-hook" => install_format_hook()?, | 48 | "format-hook" => install_format_hook()?, |
49 | "fuzz-tests" => run_fuzzer()?, | ||
45 | _ => unreachable!(), | 50 | _ => unreachable!(), |
46 | } | 51 | } |
47 | Ok(()) | 52 | Ok(()) |