diff options
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function/scope.rs | 31 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 31 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 15 | ||||
-rw-r--r-- | crates/ra_ide_api/src/runnables.rs | 5 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/cargo_target_spec.rs | 9 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 74 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 2 | ||||
-rw-r--r-- | editors/code/src/commands/apply_source_change.ts | 4 | ||||
-rw-r--r-- | editors/code/src/commands/on_enter.ts | 1 | ||||
-rw-r--r-- | editors/code/src/commands/runnables.ts | 14 | ||||
-rw-r--r-- | editors/code/src/extension.ts | 6 |
14 files changed, 151 insertions, 65 deletions
diff --git a/crates/ra_hir/src/code_model_impl/function/scope.rs b/crates/ra_hir/src/code_model_impl/function/scope.rs index 7d938c0dd..afca1e9f8 100644 --- a/crates/ra_hir/src/code_model_impl/function/scope.rs +++ b/crates/ra_hir/src/code_model_impl/function/scope.rs | |||
@@ -422,6 +422,9 @@ mod tests { | |||
422 | fn do_check_local_name(code: &str, expected_offset: u32) { | 422 | fn do_check_local_name(code: &str, expected_offset: u32) { |
423 | let (off, code) = extract_offset(code); | 423 | let (off, code) = extract_offset(code); |
424 | let file = SourceFile::parse(&code); | 424 | let file = SourceFile::parse(&code); |
425 | let expected_name = find_node_at_offset::<ast::Name>(file.syntax(), expected_offset.into()) | ||
426 | .expect("failed to find a name at the target offset"); | ||
427 | |||
425 | let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | 428 | let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); |
426 | let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); | 429 | let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); |
427 | 430 | ||
@@ -431,11 +434,8 @@ mod tests { | |||
431 | scopes: Arc::new(scopes), | 434 | scopes: Arc::new(scopes), |
432 | syntax_mapping: Arc::new(body_hir), | 435 | syntax_mapping: Arc::new(body_hir), |
433 | }; | 436 | }; |
434 | |||
435 | let local_name_entry = scopes.resolve_local_name(name_ref).unwrap(); | 437 | let local_name_entry = scopes.resolve_local_name(name_ref).unwrap(); |
436 | let local_name = local_name_entry.ptr(); | 438 | let local_name = local_name_entry.ptr(); |
437 | let expected_name = | ||
438 | find_node_at_offset::<ast::Name>(file.syntax(), expected_offset.into()).unwrap(); | ||
439 | assert_eq!(local_name.range(), expected_name.syntax().range()); | 439 | assert_eq!(local_name.range(), expected_name.syntax().range()); |
440 | } | 440 | } |
441 | 441 | ||
@@ -470,11 +470,26 @@ mod tests { | |||
470 | fn test_resolve_local_name_shadow() { | 470 | fn test_resolve_local_name_shadow() { |
471 | do_check_local_name( | 471 | do_check_local_name( |
472 | r" | 472 | r" |
473 | fn foo(x: String) { | 473 | fn foo(x: String) { |
474 | let x : &str = &x; | 474 | let x : &str = &x; |
475 | x<|> | 475 | x<|> |
476 | }", | 476 | } |
477 | 46, | 477 | ", |
478 | 53, | ||
479 | ); | ||
480 | } | ||
481 | |||
482 | #[test] | ||
483 | fn ref_patterns_contribute_bindings() { | ||
484 | do_check_local_name( | ||
485 | r" | ||
486 | fn foo() { | ||
487 | if let Some(&from) = bar() { | ||
488 | from<|>; | ||
489 | } | ||
490 | } | ||
491 | ", | ||
492 | 53, | ||
478 | ); | 493 | ); |
479 | } | 494 | } |
480 | } | 495 | } |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 67e123e4d..593fe1598 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -315,15 +315,20 @@ pub enum Pat { | |||
315 | path: Option<Path>, | 315 | path: Option<Path>, |
316 | args: Vec<PatId>, | 316 | args: Vec<PatId>, |
317 | }, | 317 | }, |
318 | Ref { | ||
319 | pat: PatId, | ||
320 | mutability: Mutability, | ||
321 | }, | ||
318 | } | 322 | } |
319 | 323 | ||
320 | impl Pat { | 324 | impl Pat { |
321 | pub fn walk_child_pats(&self, f: impl FnMut(PatId)) { | 325 | pub fn walk_child_pats(&self, mut f: impl FnMut(PatId)) { |
322 | match self { | 326 | match self { |
323 | Pat::Missing | Pat::Bind { .. } => {} | 327 | Pat::Missing | Pat::Bind { .. } => {} |
324 | Pat::TupleStruct { args, .. } => { | 328 | Pat::TupleStruct { args, .. } => { |
325 | args.iter().map(|pat| *pat).for_each(f); | 329 | args.iter().map(|pat| *pat).for_each(f); |
326 | } | 330 | } |
331 | Pat::Ref { pat, .. } => f(*pat), | ||
327 | } | 332 | } |
328 | } | 333 | } |
329 | } | 334 | } |
@@ -684,6 +689,11 @@ impl ExprCollector { | |||
684 | let args = p.args().map(|p| self.collect_pat(p)).collect(); | 689 | let args = p.args().map(|p| self.collect_pat(p)).collect(); |
685 | self.alloc_pat(Pat::TupleStruct { path, args }, syntax_ptr) | 690 | self.alloc_pat(Pat::TupleStruct { path, args }, syntax_ptr) |
686 | } | 691 | } |
692 | ast::PatKind::RefPat(p) => { | ||
693 | let pat = self.collect_pat_opt(p.pat()); | ||
694 | let mutability = Mutability::from_mutable(p.is_mut()); | ||
695 | self.alloc_pat(Pat::Ref { pat, mutability }, syntax_ptr) | ||
696 | } | ||
687 | _ => { | 697 | _ => { |
688 | // TODO | 698 | // TODO |
689 | self.alloc_pat(Pat::Missing, syntax_ptr) | 699 | self.alloc_pat(Pat::Missing, syntax_ptr) |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 8d2ff561a..e2537758d 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -13,8 +13,11 @@ pub(crate) fn goto_definition( | |||
13 | let file = db.source_file(position.file_id); | 13 | let file = db.source_file(position.file_id); |
14 | let syntax = file.syntax(); | 14 | let syntax = file.syntax(); |
15 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { | 15 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { |
16 | let navs = reference_definition(db, position.file_id, name_ref)?; | 16 | let navs = reference_definition(db, position.file_id, name_ref)?.to_vec(); |
17 | return Ok(Some(RangeInfo::new(name_ref.syntax().range(), navs))); | 17 | return Ok(Some(RangeInfo::new( |
18 | name_ref.syntax().range(), | ||
19 | navs.to_vec(), | ||
20 | ))); | ||
18 | } | 21 | } |
19 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { | 22 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { |
20 | let navs = ctry!(name_definition(db, position.file_id, name)?); | 23 | let navs = ctry!(name_definition(db, position.file_id, name)?); |
@@ -23,11 +26,27 @@ pub(crate) fn goto_definition( | |||
23 | Ok(None) | 26 | Ok(None) |
24 | } | 27 | } |
25 | 28 | ||
29 | pub(crate) enum ReferenceResult { | ||
30 | Exact(NavigationTarget), | ||
31 | Approximate(Vec<NavigationTarget>), | ||
32 | } | ||
33 | |||
34 | impl ReferenceResult { | ||
35 | fn to_vec(self) -> Vec<NavigationTarget> { | ||
36 | use self::ReferenceResult::*; | ||
37 | match self { | ||
38 | Exact(target) => vec![target], | ||
39 | Approximate(vec) => vec, | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | |||
26 | pub(crate) fn reference_definition( | 44 | pub(crate) fn reference_definition( |
27 | db: &RootDatabase, | 45 | db: &RootDatabase, |
28 | file_id: FileId, | 46 | file_id: FileId, |
29 | name_ref: &ast::NameRef, | 47 | name_ref: &ast::NameRef, |
30 | ) -> Cancelable<Vec<NavigationTarget>> { | 48 | ) -> Cancelable<ReferenceResult> { |
49 | use self::ReferenceResult::*; | ||
31 | if let Some(fn_descr) = | 50 | if let Some(fn_descr) = |
32 | hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())? | 51 | hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())? |
33 | { | 52 | { |
@@ -35,7 +54,7 @@ pub(crate) fn reference_definition( | |||
35 | // First try to resolve the symbol locally | 54 | // First try to resolve the symbol locally |
36 | if let Some(entry) = scope.resolve_local_name(name_ref) { | 55 | if let Some(entry) = scope.resolve_local_name(name_ref) { |
37 | let nav = NavigationTarget::from_scope_entry(file_id, &entry); | 56 | let nav = NavigationTarget::from_scope_entry(file_id, &entry); |
38 | return Ok(vec![nav]); | 57 | return Ok(Exact(nav)); |
39 | }; | 58 | }; |
40 | } | 59 | } |
41 | // Then try module name resolution | 60 | // Then try module name resolution |
@@ -51,7 +70,7 @@ pub(crate) fn reference_definition( | |||
51 | let resolved = module.resolve_path(db, &path)?; | 70 | let resolved = module.resolve_path(db, &path)?; |
52 | if let Some(def_id) = resolved.take_types().or(resolved.take_values()) { | 71 | if let Some(def_id) = resolved.take_types().or(resolved.take_values()) { |
53 | if let Some(target) = NavigationTarget::from_def(db, def_id.resolve(db)?)? { | 72 | if let Some(target) = NavigationTarget::from_def(db, def_id.resolve(db)?)? { |
54 | return Ok(vec![target]); | 73 | return Ok(Exact(target)); |
55 | } | 74 | } |
56 | } | 75 | } |
57 | } | 76 | } |
@@ -62,7 +81,7 @@ pub(crate) fn reference_definition( | |||
62 | .into_iter() | 81 | .into_iter() |
63 | .map(NavigationTarget::from_symbol) | 82 | .map(NavigationTarget::from_symbol) |
64 | .collect(); | 83 | .collect(); |
65 | Ok(navs) | 84 | Ok(Approximate(navs)) |
66 | } | 85 | } |
67 | 86 | ||
68 | fn name_definition( | 87 | fn name_definition( |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index b66774cdf..2968b807c 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -16,9 +16,16 @@ pub(crate) fn hover( | |||
16 | 16 | ||
17 | let mut range = None; | 17 | let mut range = None; |
18 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { | 18 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { |
19 | let navs = crate::goto_definition::reference_definition(db, position.file_id, name_ref)?; | 19 | use crate::goto_definition::{ReferenceResult::*, reference_definition}; |
20 | for nav in navs { | 20 | let ref_result = reference_definition(db, position.file_id, name_ref)?; |
21 | res.extend(doc_text_for(db, nav)?) | 21 | match ref_result { |
22 | Exact(nav) => res.extend(doc_text_for(db, nav)?), | ||
23 | Approximate(navs) => { | ||
24 | res.push("Failed to exactly resolve the symbol. This is probably because rust_analyzer does not yet support glob imports or traits. \nThese methods were found instead:".to_string()); | ||
25 | for nav in navs { | ||
26 | res.extend(doc_text_for(db, nav)?) | ||
27 | } | ||
28 | } | ||
22 | } | 29 | } |
23 | if !res.is_empty() { | 30 | if !res.is_empty() { |
24 | range = Some(name_ref.syntax().range()) | 31 | range = Some(name_ref.syntax().range()) |
@@ -34,7 +41,7 @@ pub(crate) fn hover( | |||
34 | file_id: position.file_id, | 41 | file_id: position.file_id, |
35 | range: node.range(), | 42 | range: node.range(), |
36 | }; | 43 | }; |
37 | res.extend(type_of(db, frange)?); | 44 | res.extend(type_of(db, frange)?.map(Into::into)); |
38 | range = Some(node.range()); | 45 | range = Some(node.range()); |
39 | }; | 46 | }; |
40 | 47 | ||
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 98b1d2d55..53e49da5b 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs | |||
@@ -17,6 +17,7 @@ pub struct Runnable { | |||
17 | pub enum RunnableKind { | 17 | pub enum RunnableKind { |
18 | Test { name: String }, | 18 | Test { name: String }, |
19 | TestMod { path: String }, | 19 | TestMod { path: String }, |
20 | Bench { name: String }, | ||
20 | Bin, | 21 | Bin, |
21 | } | 22 | } |
22 | 23 | ||
@@ -48,6 +49,10 @@ fn runnable_fn(fn_def: &ast::FnDef) -> Option<Runnable> { | |||
48 | RunnableKind::Test { | 49 | RunnableKind::Test { |
49 | name: name.to_string(), | 50 | name: name.to_string(), |
50 | } | 51 | } |
52 | } else if fn_def.has_atom_attr("bench") { | ||
53 | RunnableKind::Bench { | ||
54 | name: name.to_string(), | ||
55 | } | ||
51 | } else { | 56 | } else { |
52 | return None; | 57 | return None; |
53 | }; | 58 | }; |
diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index a66f14b82..db9496bbe 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs | |||
@@ -32,6 +32,15 @@ pub(crate) fn runnable_args( | |||
32 | res.push(path.to_string()); | 32 | res.push(path.to_string()); |
33 | res.push("--nocapture".to_string()); | 33 | res.push("--nocapture".to_string()); |
34 | } | 34 | } |
35 | RunnableKind::Bench { name } => { | ||
36 | res.push("bench".to_string()); | ||
37 | if let Some(spec) = spec { | ||
38 | spec.push_to(&mut res); | ||
39 | } | ||
40 | res.push("--".to_string()); | ||
41 | res.push(name.to_string()); | ||
42 | res.push("--nocapture".to_string()); | ||
43 | } | ||
35 | RunnableKind::Bin => { | 44 | RunnableKind::Bin => { |
36 | res.push("run".to_string()); | 45 | res.push("run".to_string()); |
37 | if let Some(spec) = spec { | 46 | if let Some(spec) = spec { |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index a781df181..7326a727d 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -2,22 +2,23 @@ use std::collections::HashMap; | |||
2 | 2 | ||
3 | use gen_lsp_server::ErrorCode; | 3 | use gen_lsp_server::ErrorCode; |
4 | use languageserver_types::{ | 4 | use languageserver_types::{ |
5 | CodeActionResponse, Command, CodeLens, Diagnostic, DiagnosticSeverity, DocumentFormattingParams, | 5 | CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, |
6 | DocumentHighlight, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, | 6 | DocumentFormattingParams, DocumentHighlight, DocumentSymbol, Documentation, FoldingRange, |
7 | FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, | 7 | FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, |
8 | ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, RenameParams, | 8 | MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, |
9 | SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, | 9 | RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, |
10 | WorkspaceEdit, | ||
10 | }; | 11 | }; |
11 | use ra_ide_api::{ | 12 | use ra_ide_api::{ |
12 | FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, RangeInfo, | 13 | FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, |
13 | }; | 14 | }; |
14 | use ra_syntax::{TextUnit, AstNode}; | 15 | use ra_syntax::{AstNode, TextUnit}; |
15 | use rustc_hash::FxHashMap; | 16 | use rustc_hash::FxHashMap; |
16 | use serde_json::to_value; | 17 | use serde_json::to_value; |
17 | use std::io::Write; | 18 | use std::io::Write; |
18 | 19 | ||
19 | use crate::{ | 20 | use crate::{ |
20 | cargo_target_spec::{CargoTargetSpec, runnable_args}, | 21 | cargo_target_spec::{runnable_args, CargoTargetSpec}, |
21 | conv::{to_location, to_location_link, Conv, ConvWith, MapConvWith, TryConvWith}, | 22 | conv::{to_location, to_location_link, Conv, ConvWith, MapConvWith, TryConvWith}, |
22 | req::{self, Decoration}, | 23 | req::{self, Decoration}, |
23 | server_world::ServerWorld, | 24 | server_world::ServerWorld, |
@@ -258,6 +259,7 @@ pub fn handle_runnables( | |||
258 | label: match &runnable.kind { | 259 | label: match &runnable.kind { |
259 | RunnableKind::Test { name } => format!("test {}", name), | 260 | RunnableKind::Test { name } => format!("test {}", name), |
260 | RunnableKind::TestMod { path } => format!("test-mod {}", path), | 261 | RunnableKind::TestMod { path } => format!("test-mod {}", path), |
262 | RunnableKind::Bench { name } => format!("bench {}", name), | ||
261 | RunnableKind::Bin => "run binary".to_string(), | 263 | RunnableKind::Bin => "run binary".to_string(), |
262 | }, | 264 | }, |
263 | bin: "cargo".to_string(), | 265 | bin: "cargo".to_string(), |
@@ -586,35 +588,37 @@ pub fn handle_code_lens( | |||
586 | let mut lenses: Vec<CodeLens> = Default::default(); | 588 | let mut lenses: Vec<CodeLens> = Default::default(); |
587 | 589 | ||
588 | for runnable in world.analysis().runnables(file_id)? { | 590 | for runnable in world.analysis().runnables(file_id)? { |
589 | match &runnable.kind { | 591 | let title = match &runnable.kind { |
590 | RunnableKind::Test { name: _ } | RunnableKind::TestMod { path: _ } => { | 592 | RunnableKind::Test { name: _ } | RunnableKind::TestMod { path: _ } => Some("Run Test"), |
591 | let args = runnable_args(&world, file_id, &runnable.kind)?; | 593 | RunnableKind::Bench { name: _ } => Some("Run Bench"), |
592 | 594 | _ => None, | |
593 | let range = runnable.range.conv_with(&line_index); | 595 | }; |
594 | |||
595 | // This represents the actual command that will be run. | ||
596 | let r: req::Runnable = req::Runnable { | ||
597 | range, | ||
598 | label: Default::default(), | ||
599 | bin: "cargo".into(), | ||
600 | args, | ||
601 | env: Default::default(), | ||
602 | }; | ||
603 | 596 | ||
604 | let lens = CodeLens { | 597 | if let Some(title) = title { |
605 | range, | 598 | let args = runnable_args(&world, file_id, &runnable.kind)?; |
606 | command: Some(Command { | 599 | let range = runnable.range.conv_with(&line_index); |
607 | title: "Run Test".into(), | 600 | |
608 | command: "ra-lsp.run-single".into(), | 601 | // This represents the actual command that will be run. |
609 | arguments: Some(vec![to_value(r).unwrap()]), | 602 | let r: req::Runnable = req::Runnable { |
610 | }), | 603 | range, |
611 | data: None, | 604 | label: Default::default(), |
612 | }; | 605 | bin: "cargo".into(), |
606 | args, | ||
607 | env: Default::default(), | ||
608 | }; | ||
613 | 609 | ||
614 | lenses.push(lens); | 610 | let lens = CodeLens { |
615 | } | 611 | range, |
616 | _ => continue, | 612 | command: Some(Command { |
617 | }; | 613 | title: title.into(), |
614 | command: "ra-lsp.run-single".into(), | ||
615 | arguments: Some(vec![to_value(r).unwrap()]), | ||
616 | }), | ||
617 | data: None, | ||
618 | }; | ||
619 | |||
620 | lenses.push(lens); | ||
621 | } | ||
618 | } | 622 | } |
619 | 623 | ||
620 | return Ok(Some(lenses)); | 624 | return Ok(Some(lenses)); |
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 123a7a6b9..8bf439b60 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -348,6 +348,12 @@ impl UseTreeList { | |||
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | impl RefPat { | ||
352 | pub fn is_mut(&self) -> bool { | ||
353 | self.syntax().children().any(|n| n.kind() == MUT_KW) | ||
354 | } | ||
355 | } | ||
356 | |||
351 | fn child_opt<P: AstNode, C: AstNode>(parent: &P) -> Option<&C> { | 357 | fn child_opt<P: AstNode, C: AstNode>(parent: &P) -> Option<&C> { |
352 | children(parent).next() | 358 | children(parent).next() |
353 | } | 359 | } |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 1f6055115..f745cb1cb 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -2456,7 +2456,11 @@ impl AstNode for RefPat { | |||
2456 | } | 2456 | } |
2457 | 2457 | ||
2458 | 2458 | ||
2459 | impl RefPat {} | 2459 | impl RefPat { |
2460 | pub fn pat(&self) -> Option<&Pat> { | ||
2461 | super::child_opt(self) | ||
2462 | } | ||
2463 | } | ||
2460 | 2464 | ||
2461 | // ReferenceType | 2465 | // ReferenceType |
2462 | #[derive(Debug, PartialEq, Eq, Hash)] | 2466 | #[derive(Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index bddd96a5c..bac62fa04 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -462,7 +462,7 @@ Grammar( | |||
462 | ], | 462 | ], |
463 | ), | 463 | ), |
464 | 464 | ||
465 | "RefPat": (), | 465 | "RefPat": ( options: [ "Pat" ]), |
466 | "BindPat": ( traits: ["NameOwner"] ), | 466 | "BindPat": ( traits: ["NameOwner"] ), |
467 | "PlaceholderPat": (), | 467 | "PlaceholderPat": (), |
468 | "PathPat": (), | 468 | "PathPat": (), |
diff --git a/editors/code/src/commands/apply_source_change.ts b/editors/code/src/commands/apply_source_change.ts index d96ace979..675a534c8 100644 --- a/editors/code/src/commands/apply_source_change.ts +++ b/editors/code/src/commands/apply_source_change.ts | |||
@@ -10,7 +10,9 @@ export interface SourceChange { | |||
10 | } | 10 | } |
11 | 11 | ||
12 | export async function handle(change: SourceChange) { | 12 | export async function handle(change: SourceChange) { |
13 | const wsEdit = Server.client.protocol2CodeConverter.asWorkspaceEdit(change.workspaceEdit); | 13 | const wsEdit = Server.client.protocol2CodeConverter.asWorkspaceEdit( |
14 | change.workspaceEdit | ||
15 | ); | ||
14 | let created; | 16 | let created; |
15 | let moved; | 17 | let moved; |
16 | if (change.workspaceEdit.documentChanges) { | 18 | if (change.workspaceEdit.documentChanges) { |
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts index 64401b684..bb376e3cb 100644 --- a/editors/code/src/commands/on_enter.ts +++ b/editors/code/src/commands/on_enter.ts | |||
@@ -6,7 +6,6 @@ import { | |||
6 | SourceChange | 6 | SourceChange |
7 | } from './apply_source_change'; | 7 | } from './apply_source_change'; |
8 | 8 | ||
9 | |||
10 | export async function handle(event: { text: string }): Promise<boolean> { | 9 | export async function handle(event: { text: string }): Promise<boolean> { |
11 | const editor = vscode.window.activeTextEditor; | 10 | const editor = vscode.window.activeTextEditor; |
12 | if ( | 11 | if ( |
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index f9a4e2fc9..aa5817c21 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -48,7 +48,11 @@ function createTask(spec: Runnable): vscode.Task { | |||
48 | cwd: '.', | 48 | cwd: '.', |
49 | env: definition.env | 49 | env: definition.env |
50 | }; | 50 | }; |
51 | const exec = new vscode.ShellExecution(definition.command, definition.args, execOption); | 51 | const exec = new vscode.ShellExecution( |
52 | definition.command, | ||
53 | definition.args, | ||
54 | execOption | ||
55 | ); | ||
52 | 56 | ||
53 | const f = vscode.workspace.workspaceFolders![0]; | 57 | const f = vscode.workspace.workspaceFolders![0]; |
54 | const t = new vscode.Task( | 58 | const t = new vscode.Task( |
@@ -59,7 +63,7 @@ function createTask(spec: Runnable): vscode.Task { | |||
59 | exec, | 63 | exec, |
60 | ['$rustc'] | 64 | ['$rustc'] |
61 | ); | 65 | ); |
62 | t.presentationOptions.clear = true | 66 | t.presentationOptions.clear = true; |
63 | return t; | 67 | return t; |
64 | } | 68 | } |
65 | 69 | ||
@@ -114,8 +118,8 @@ export async function handleSingle(runnable: Runnable) { | |||
114 | task.group = vscode.TaskGroup.Build; | 118 | task.group = vscode.TaskGroup.Build; |
115 | task.presentationOptions = { | 119 | task.presentationOptions = { |
116 | reveal: vscode.TaskRevealKind.Always, | 120 | reveal: vscode.TaskRevealKind.Always, |
117 | panel: vscode.TaskPanelKind.Dedicated, | 121 | panel: vscode.TaskPanelKind.Dedicated |
118 | }; | 122 | }; |
119 | 123 | ||
120 | return vscode.tasks.executeTask(task); | 124 | return vscode.tasks.executeTask(task); |
121 | } \ No newline at end of file | 125 | } |
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 9edfb13b5..0098c9454 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -37,8 +37,10 @@ export function activate(context: vscode.ExtensionContext) { | |||
37 | return await original(...args); | 37 | return await original(...args); |
38 | } | 38 | } |
39 | }); | 39 | }); |
40 | } catch(_) { | 40 | } catch (_) { |
41 | vscode.window.showWarningMessage('Enhanced typing feature is disabled because of incompatibility with VIM extension'); | 41 | vscode.window.showWarningMessage( |
42 | 'Enhanced typing feature is disabled because of incompatibility with VIM extension' | ||
43 | ); | ||
42 | } | 44 | } |
43 | } | 45 | } |
44 | 46 | ||