diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 9 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/rename.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 2 |
6 files changed, 17 insertions, 16 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 5d1851da6..8abab0221 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -130,12 +130,9 @@ impl<'a> CompletionContext<'a> { | |||
130 | .ancestors() | 130 | .ancestors() |
131 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) | 131 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) |
132 | .find_map(ast::FnDef::cast); | 132 | .find_map(ast::FnDef::cast); |
133 | match (self.module, self.function_syntax) { | 133 | if let (Some(module), Some(fn_def)) = (self.module, self.function_syntax) { |
134 | (Some(module), Some(fn_def)) => { | 134 | let function = source_binder::function_from_module(self.db, module, fn_def); |
135 | let function = source_binder::function_from_module(self.db, module, fn_def); | 135 | self.function = Some(function); |
136 | self.function = Some(function); | ||
137 | } | ||
138 | _ => (), | ||
139 | } | 136 | } |
140 | 137 | ||
141 | let parent = match name_ref.syntax().parent() { | 138 | let parent = match name_ref.syntax().parent() { |
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index bada6a33b..92e6e78bf 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -108,11 +108,11 @@ impl CompletionItem { | |||
108 | self.lookup | 108 | self.lookup |
109 | .as_ref() | 109 | .as_ref() |
110 | .map(|it| it.as_str()) | 110 | .map(|it| it.as_str()) |
111 | .unwrap_or(self.label()) | 111 | .unwrap_or_else(|| self.label()) |
112 | } | 112 | } |
113 | 113 | ||
114 | pub fn insert_text_format(&self) -> InsertTextFormat { | 114 | pub fn insert_text_format(&self) -> InsertTextFormat { |
115 | self.insert_text_format.clone() | 115 | self.insert_text_format |
116 | } | 116 | } |
117 | pub fn insert_text(&self) -> String { | 117 | pub fn insert_text(&self) -> String { |
118 | match &self.insert_text { | 118 | match &self.insert_text { |
@@ -217,7 +217,7 @@ impl Builder { | |||
217 | let def = resolution | 217 | let def = resolution |
218 | .as_ref() | 218 | .as_ref() |
219 | .take_types() | 219 | .take_types() |
220 | .or(resolution.as_ref().take_values()); | 220 | .or_else(|| resolution.as_ref().take_values()); |
221 | let def = match def { | 221 | let def = match def { |
222 | None => return self, | 222 | None => return self, |
223 | Some(it) => it, | 223 | Some(it) => it, |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 88efcea2a..681f36623 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -89,7 +89,11 @@ pub(crate) fn reference_definition( | |||
89 | .and_then(hir::Path::from_ast) | 89 | .and_then(hir::Path::from_ast) |
90 | { | 90 | { |
91 | let resolved = resolver.resolve_path(db, &path); | 91 | let resolved = resolver.resolve_path(db, &path); |
92 | match resolved.clone().take_types().or(resolved.take_values()) { | 92 | match resolved |
93 | .clone() | ||
94 | .take_types() | ||
95 | .or_else(|| resolved.take_values()) | ||
96 | { | ||
93 | Some(Resolution::Def(def)) => return Exact(NavigationTarget::from_def(db, def)), | 97 | Some(Resolution::Def(def)) => return Exact(NavigationTarget::from_def(db, def)), |
94 | Some(Resolution::LocalBinding(pat)) => { | 98 | Some(Resolution::LocalBinding(pat)) => { |
95 | let body = resolver.body().expect("no body for local binding"); | 99 | let body = resolver.body().expect("no body for local binding"); |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 8beaba5de..68d59aae1 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -117,7 +117,7 @@ impl fmt::Debug for AnalysisChange { | |||
117 | if !self.libraries_added.is_empty() { | 117 | if !self.libraries_added.is_empty() { |
118 | d.field("libraries_added", &self.libraries_added.len()); | 118 | d.field("libraries_added", &self.libraries_added.len()); |
119 | } | 119 | } |
120 | if !self.crate_graph.is_some() { | 120 | if self.crate_graph.is_none() { |
121 | d.field("crate_graph", &self.crate_graph); | 121 | d.field("crate_graph", &self.crate_graph); |
122 | } | 122 | } |
123 | d.finish() | 123 | d.finish() |
diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs index db5ccf969..1c9491a0a 100644 --- a/crates/ra_ide_api/src/rename.rs +++ b/crates/ra_ide_api/src/rename.rs | |||
@@ -95,12 +95,12 @@ fn rename_mod( | |||
95 | }; | 95 | }; |
96 | source_file_edits.push(edit); | 96 | source_file_edits.push(edit); |
97 | 97 | ||
98 | return Some(SourceChange { | 98 | Some(SourceChange { |
99 | label: "rename".to_string(), | 99 | label: "rename".to_string(), |
100 | source_file_edits, | 100 | source_file_edits, |
101 | file_system_edits, | 101 | file_system_edits, |
102 | cursor_position: None, | 102 | cursor_position: None, |
103 | }); | 103 | }) |
104 | } | 104 | } |
105 | 105 | ||
106 | fn rename_reference( | 106 | fn rename_reference( |
@@ -124,12 +124,12 @@ fn rename_reference( | |||
124 | return None; | 124 | return None; |
125 | } | 125 | } |
126 | 126 | ||
127 | return Some(SourceChange { | 127 | Some(SourceChange { |
128 | label: "rename".to_string(), | 128 | label: "rename".to_string(), |
129 | source_file_edits: edit, | 129 | source_file_edits: edit, |
130 | file_system_edits: Vec::new(), | 130 | file_system_edits: Vec::new(), |
131 | cursor_position: None, | 131 | cursor_position: None, |
132 | }); | 132 | }) |
133 | } | 133 | } |
134 | 134 | ||
135 | #[cfg(test)] | 135 | #[cfg(test)] |
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 72c93f530..9f939c650 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs | |||
@@ -137,7 +137,7 @@ impl SymbolIndex { | |||
137 | symbols.par_sort_by(cmp); | 137 | symbols.par_sort_by(cmp); |
138 | symbols.dedup_by(|s1, s2| cmp(s1, s2) == Ordering::Equal); | 138 | symbols.dedup_by(|s1, s2| cmp(s1, s2) == Ordering::Equal); |
139 | let names = symbols.iter().map(|it| it.name.as_str().to_lowercase()); | 139 | let names = symbols.iter().map(|it| it.name.as_str().to_lowercase()); |
140 | let map = fst::Map::from_iter(names.into_iter().zip(0u64..)).unwrap(); | 140 | let map = fst::Map::from_iter(names.zip(0u64..)).unwrap(); |
141 | SymbolIndex { symbols, map } | 141 | SymbolIndex { symbols, map } |
142 | } | 142 | } |
143 | 143 | ||