diff options
-rw-r--r-- | crates/ra_analysis/src/completion/mod.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/mod.rs | 1 | ||||
-rw-r--r-- | crates/ra_editor/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/items/mod.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/paths.rs | 2 |
5 files changed, 5 insertions, 9 deletions
diff --git a/crates/ra_analysis/src/completion/mod.rs b/crates/ra_analysis/src/completion/mod.rs index 8034060de..c7717ab61 100644 --- a/crates/ra_analysis/src/completion/mod.rs +++ b/crates/ra_analysis/src/completion/mod.rs | |||
@@ -224,7 +224,7 @@ mod tests { | |||
224 | fn test_completion_self_path() { | 224 | fn test_completion_self_path() { |
225 | check_scope_completion( | 225 | check_scope_completion( |
226 | r" | 226 | r" |
227 | use self::m::B<|>; | 227 | use self::m::<|>; |
228 | 228 | ||
229 | mod m { | 229 | mod m { |
230 | struct Bar; | 230 | struct Bar; |
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index a7e41e3db..acc6c1c5a 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs | |||
@@ -110,6 +110,7 @@ impl ModuleDescriptor { | |||
110 | } | 110 | } |
111 | 111 | ||
112 | /// `name` is `None` for the crate's root module | 112 | /// `name` is `None` for the crate's root module |
113 | #[allow(unused)] | ||
113 | pub fn name(&self) -> Option<SmolStr> { | 114 | pub fn name(&self) -> Option<SmolStr> { |
114 | let link = self.module_id.parent_link(&self.tree)?; | 115 | let link = self.module_id.parent_link(&self.tree)?; |
115 | Some(link.name(&self.tree)) | 116 | Some(link.name(&self.tree)) |
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index ff4e8303d..c6b116159 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -148,12 +148,7 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>( | |||
148 | syntax: SyntaxNodeRef<'a>, | 148 | syntax: SyntaxNodeRef<'a>, |
149 | offset: TextUnit, | 149 | offset: TextUnit, |
150 | ) -> Option<N> { | 150 | ) -> Option<N> { |
151 | let leaves = find_leaf_at_offset(syntax, offset); | 151 | find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast)) |
152 | let leaf = leaves | ||
153 | .clone() | ||
154 | .find(|leaf| !leaf.kind().is_trivia()) | ||
155 | .or_else(|| leaves.right_biased())?; | ||
156 | leaf.ancestors().filter_map(N::cast).next() | ||
157 | } | 152 | } |
158 | 153 | ||
159 | #[cfg(test)] | 154 | #[cfg(test)] |
diff --git a/crates/ra_syntax/src/grammar/items/mod.rs b/crates/ra_syntax/src/grammar/items/mod.rs index 06c6b5e6e..682266908 100644 --- a/crates/ra_syntax/src/grammar/items/mod.rs +++ b/crates/ra_syntax/src/grammar/items/mod.rs | |||
@@ -29,7 +29,7 @@ pub(super) enum ItemFlavor { | |||
29 | Trait, | 29 | Trait, |
30 | } | 30 | } |
31 | 31 | ||
32 | const ITEM_RECOVERY_SET: TokenSet = token_set![ | 32 | pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ |
33 | FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, | 33 | FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, |
34 | CRATE_KW | 34 | CRATE_KW |
35 | ]; | 35 | ]; |
diff --git a/crates/ra_syntax/src/grammar/paths.rs b/crates/ra_syntax/src/grammar/paths.rs index a35a339cc..33a11886c 100644 --- a/crates/ra_syntax/src/grammar/paths.rs +++ b/crates/ra_syntax/src/grammar/paths.rs | |||
@@ -78,7 +78,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) { | |||
78 | // use crate::foo; | 78 | // use crate::foo; |
79 | SELF_KW | SUPER_KW | CRATE_KW => p.bump(), | 79 | SELF_KW | SUPER_KW | CRATE_KW => p.bump(), |
80 | _ => { | 80 | _ => { |
81 | p.err_and_bump("expected identifier"); | 81 | p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); |
82 | } | 82 | } |
83 | }; | 83 | }; |
84 | } | 84 | } |