diff options
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/diagnostics/fixes/create_field.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/diagnostics/fixes/fill_missing_fields.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/doc_links.rs | 20 | ||||
-rw-r--r-- | crates/ide/src/extend_selection.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/hover.rs | 8 | ||||
-rw-r--r-- | crates/ide/src/inlay_hints.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/join_lines.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/lib.rs | 12 | ||||
-rw-r--r-- | crates/ide/src/references.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/references/rename.rs | 8 | ||||
-rw-r--r-- | crates/ide/src/runnables.rs | 8 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/html.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/inject.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/typing/on_enter.rs | 6 |
18 files changed, 51 insertions, 51 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 4193aabf5..31d5cfedc 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -208,7 +208,7 @@ pub(crate) fn diagnostics( | |||
208 | match sema.to_module_def(file_id) { | 208 | match sema.to_module_def(file_id) { |
209 | Some(m) => m.diagnostics(db, &mut sink, internal_diagnostics), | 209 | Some(m) => m.diagnostics(db, &mut sink, internal_diagnostics), |
210 | None => { | 210 | None => { |
211 | sink.push(UnlinkedFile { file_id, node: SyntaxNodePtr::new(&parse.tree().syntax()) }); | 211 | sink.push(UnlinkedFile { file_id, node: SyntaxNodePtr::new(parse.tree().syntax()) }); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
@@ -222,7 +222,7 @@ fn diagnostic_with_fix<D: DiagnosticWithFixes>( | |||
222 | resolve: &AssistResolveStrategy, | 222 | resolve: &AssistResolveStrategy, |
223 | ) -> Diagnostic { | 223 | ) -> Diagnostic { |
224 | Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message()) | 224 | Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message()) |
225 | .with_fixes(d.fixes(&sema, resolve)) | 225 | .with_fixes(d.fixes(sema, resolve)) |
226 | .with_code(Some(d.code())) | 226 | .with_code(Some(d.code())) |
227 | } | 227 | } |
228 | 228 | ||
@@ -232,7 +232,7 @@ fn warning_with_fix<D: DiagnosticWithFixes>( | |||
232 | resolve: &AssistResolveStrategy, | 232 | resolve: &AssistResolveStrategy, |
233 | ) -> Diagnostic { | 233 | ) -> Diagnostic { |
234 | Diagnostic::hint(sema.diagnostics_display_range(d.display_source()).range, d.message()) | 234 | Diagnostic::hint(sema.diagnostics_display_range(d.display_source()).range, d.message()) |
235 | .with_fixes(d.fixes(&sema, resolve)) | 235 | .with_fixes(d.fixes(sema, resolve)) |
236 | .with_code(Some(d.code())) | 236 | .with_code(Some(d.code())) |
237 | } | 237 | } |
238 | 238 | ||
diff --git a/crates/ide/src/diagnostics/fixes/create_field.rs b/crates/ide/src/diagnostics/fixes/create_field.rs index a5f457dce..f6e45967a 100644 --- a/crates/ide/src/diagnostics/fixes/create_field.rs +++ b/crates/ide/src/diagnostics/fixes/create_field.rs | |||
@@ -18,7 +18,7 @@ impl DiagnosticWithFixes for NoSuchField { | |||
18 | ) -> Option<Vec<Assist>> { | 18 | ) -> Option<Vec<Assist>> { |
19 | let root = sema.db.parse_or_expand(self.file)?; | 19 | let root = sema.db.parse_or_expand(self.file)?; |
20 | missing_record_expr_field_fixes( | 20 | missing_record_expr_field_fixes( |
21 | &sema, | 21 | sema, |
22 | self.file.original_file(sema.db), | 22 | self.file.original_file(sema.db), |
23 | &self.field.to_node(&root), | 23 | &self.field.to_node(&root), |
24 | ) | 24 | ) |
diff --git a/crates/ide/src/diagnostics/fixes/fill_missing_fields.rs b/crates/ide/src/diagnostics/fixes/fill_missing_fields.rs index b5dd64c08..c76f6008a 100644 --- a/crates/ide/src/diagnostics/fixes/fill_missing_fields.rs +++ b/crates/ide/src/diagnostics/fixes/fill_missing_fields.rs | |||
@@ -37,7 +37,7 @@ impl DiagnosticWithFixes for MissingFields { | |||
37 | 37 | ||
38 | let edit = { | 38 | let edit = { |
39 | let mut builder = TextEdit::builder(); | 39 | let mut builder = TextEdit::builder(); |
40 | algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) | 40 | algo::diff(old_field_list.syntax(), new_field_list.syntax()) |
41 | .into_text_edit(&mut builder); | 41 | .into_text_edit(&mut builder); |
42 | builder.finish() | 42 | builder.finish() |
43 | }; | 43 | }; |
@@ -45,7 +45,7 @@ impl DiagnosticWithFixes for MissingFields { | |||
45 | "fill_missing_fields", | 45 | "fill_missing_fields", |
46 | "Fill struct fields", | 46 | "Fill struct fields", |
47 | SourceChange::from_text_edit(self.file.original_file(sema.db), edit), | 47 | SourceChange::from_text_edit(self.file.original_file(sema.db), edit), |
48 | sema.original_range(&field_list_parent.syntax()).range, | 48 | sema.original_range(field_list_parent.syntax()).range, |
49 | )]) | 49 | )]) |
50 | } | 50 | } |
51 | } | 51 | } |
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index ec3828ab2..774952d96 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs | |||
@@ -151,18 +151,18 @@ pub(crate) fn resolve_doc_path_for_def( | |||
151 | ) -> Option<hir::ModuleDef> { | 151 | ) -> Option<hir::ModuleDef> { |
152 | match def { | 152 | match def { |
153 | Definition::ModuleDef(def) => match def { | 153 | Definition::ModuleDef(def) => match def { |
154 | hir::ModuleDef::Module(it) => it.resolve_doc_path(db, &link, ns), | 154 | hir::ModuleDef::Module(it) => it.resolve_doc_path(db, link, ns), |
155 | hir::ModuleDef::Function(it) => it.resolve_doc_path(db, &link, ns), | 155 | hir::ModuleDef::Function(it) => it.resolve_doc_path(db, link, ns), |
156 | hir::ModuleDef::Adt(it) => it.resolve_doc_path(db, &link, ns), | 156 | hir::ModuleDef::Adt(it) => it.resolve_doc_path(db, link, ns), |
157 | hir::ModuleDef::Variant(it) => it.resolve_doc_path(db, &link, ns), | 157 | hir::ModuleDef::Variant(it) => it.resolve_doc_path(db, link, ns), |
158 | hir::ModuleDef::Const(it) => it.resolve_doc_path(db, &link, ns), | 158 | hir::ModuleDef::Const(it) => it.resolve_doc_path(db, link, ns), |
159 | hir::ModuleDef::Static(it) => it.resolve_doc_path(db, &link, ns), | 159 | hir::ModuleDef::Static(it) => it.resolve_doc_path(db, link, ns), |
160 | hir::ModuleDef::Trait(it) => it.resolve_doc_path(db, &link, ns), | 160 | hir::ModuleDef::Trait(it) => it.resolve_doc_path(db, link, ns), |
161 | hir::ModuleDef::TypeAlias(it) => it.resolve_doc_path(db, &link, ns), | 161 | hir::ModuleDef::TypeAlias(it) => it.resolve_doc_path(db, link, ns), |
162 | hir::ModuleDef::BuiltinType(_) => None, | 162 | hir::ModuleDef::BuiltinType(_) => None, |
163 | }, | 163 | }, |
164 | Definition::Macro(it) => it.resolve_doc_path(db, &link, ns), | 164 | Definition::Macro(it) => it.resolve_doc_path(db, link, ns), |
165 | Definition::Field(it) => it.resolve_doc_path(db, &link, ns), | 165 | Definition::Field(it) => it.resolve_doc_path(db, link, ns), |
166 | Definition::SelfType(_) | 166 | Definition::SelfType(_) |
167 | | Definition::Local(_) | 167 | | Definition::Local(_) |
168 | | Definition::GenericParam(_) | 168 | | Definition::GenericParam(_) |
diff --git a/crates/ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs index 7032889ac..c7ec87edf 100644 --- a/crates/ide/src/extend_selection.rs +++ b/crates/ide/src/extend_selection.rs | |||
@@ -328,7 +328,7 @@ mod tests { | |||
328 | use super::*; | 328 | use super::*; |
329 | 329 | ||
330 | fn do_check(before: &str, afters: &[&str]) { | 330 | fn do_check(before: &str, afters: &[&str]) { |
331 | let (analysis, position) = fixture::position(&before); | 331 | let (analysis, position) = fixture::position(before); |
332 | let before = analysis.file_text(position.file_id).unwrap(); | 332 | let before = analysis.file_text(position.file_id).unwrap(); |
333 | let range = TextRange::empty(position.offset); | 333 | let range = TextRange::empty(position.offset); |
334 | let mut frange = FileRange { file_id: position.file_id, range }; | 334 | let mut frange = FileRange { file_id: position.file_id, range }; |
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index 2d36c34e9..27a292d83 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -57,7 +57,7 @@ pub(crate) fn goto_definition( | |||
57 | }, | 57 | }, |
58 | ast::Name(name) => { | 58 | ast::Name(name) => { |
59 | let def = NameClass::classify(&sema, &name)?.referenced_or_defined(sema.db); | 59 | let def = NameClass::classify(&sema, &name)?.referenced_or_defined(sema.db); |
60 | try_find_trait_item_definition(&sema.db, &def) | 60 | try_find_trait_item_definition(sema.db, &def) |
61 | .or_else(|| def.try_to_nav(sema.db)) | 61 | .or_else(|| def.try_to_nav(sema.db)) |
62 | }, | 62 | }, |
63 | ast::Lifetime(lt) => if let Some(name_class) = NameClass::classify_lifetime(&sema, <) { | 63 | ast::Lifetime(lt) => if let Some(name_class) = NameClass::classify_lifetime(&sema, <) { |
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 1c6d36939..b4b3b45b5 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -288,7 +288,7 @@ fn runnable_action( | |||
288 | ) -> Option<HoverAction> { | 288 | ) -> Option<HoverAction> { |
289 | match def { | 289 | match def { |
290 | Definition::ModuleDef(it) => match it { | 290 | Definition::ModuleDef(it) => match it { |
291 | ModuleDef::Module(it) => runnable_mod(&sema, it).map(|it| HoverAction::Runnable(it)), | 291 | ModuleDef::Module(it) => runnable_mod(sema, it).map(|it| HoverAction::Runnable(it)), |
292 | ModuleDef::Function(func) => { | 292 | ModuleDef::Function(func) => { |
293 | let src = func.source(sema.db)?; | 293 | let src = func.source(sema.db)?; |
294 | if src.file_id != file_id.into() { | 294 | if src.file_id != file_id.into() { |
@@ -297,7 +297,7 @@ fn runnable_action( | |||
297 | return None; | 297 | return None; |
298 | } | 298 | } |
299 | 299 | ||
300 | runnable_fn(&sema, func).map(HoverAction::Runnable) | 300 | runnable_fn(sema, func).map(HoverAction::Runnable) |
301 | } | 301 | } |
302 | _ => None, | 302 | _ => None, |
303 | }, | 303 | }, |
@@ -432,7 +432,7 @@ fn hover_for_definition( | |||
432 | return match def { | 432 | return match def { |
433 | Definition::Macro(it) => match &it.source(db)?.value { | 433 | Definition::Macro(it) => match &it.source(db)?.value { |
434 | Either::Left(mac) => { | 434 | Either::Left(mac) => { |
435 | let label = macro_label(&mac); | 435 | let label = macro_label(mac); |
436 | from_def_source_labeled(db, it, Some(label), mod_path) | 436 | from_def_source_labeled(db, it, Some(label), mod_path) |
437 | } | 437 | } |
438 | Either::Right(_) => { | 438 | Either::Right(_) => { |
@@ -516,7 +516,7 @@ fn hover_for_keyword( | |||
516 | if !token.kind().is_keyword() { | 516 | if !token.kind().is_keyword() { |
517 | return None; | 517 | return None; |
518 | } | 518 | } |
519 | let famous_defs = FamousDefs(&sema, sema.scope(&token.parent()?).krate()); | 519 | let famous_defs = FamousDefs(sema, sema.scope(&token.parent()?).krate()); |
520 | // std exposes {}_keyword modules with docstrings on the root to document keywords | 520 | // std exposes {}_keyword modules with docstrings on the root to document keywords |
521 | let keyword_mod = format!("{}_keyword", token.text()); | 521 | let keyword_mod = format!("{}_keyword", token.text()); |
522 | let doc_owner = find_std_module(&famous_defs, &keyword_mod)?; | 522 | let doc_owner = find_std_module(&famous_defs, &keyword_mod)?; |
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 821c61403..9cd33d0e4 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs | |||
@@ -96,7 +96,7 @@ fn get_chaining_hints( | |||
96 | } | 96 | } |
97 | 97 | ||
98 | let krate = sema.scope(expr.syntax()).module().map(|it| it.krate()); | 98 | let krate = sema.scope(expr.syntax()).module().map(|it| it.krate()); |
99 | let famous_defs = FamousDefs(&sema, krate); | 99 | let famous_defs = FamousDefs(sema, krate); |
100 | 100 | ||
101 | let mut tokens = expr | 101 | let mut tokens = expr |
102 | .syntax() | 102 | .syntax() |
@@ -165,7 +165,7 @@ fn get_param_name_hints( | |||
165 | }; | 165 | }; |
166 | Some((param_name, arg)) | 166 | Some((param_name, arg)) |
167 | }) | 167 | }) |
168 | .filter(|(param_name, arg)| !should_hide_param_name_hint(sema, &callable, param_name, &arg)) | 168 | .filter(|(param_name, arg)| !should_hide_param_name_hint(sema, &callable, param_name, arg)) |
169 | .map(|(param_name, arg)| InlayHint { | 169 | .map(|(param_name, arg)| InlayHint { |
170 | range: arg.syntax().text_range(), | 170 | range: arg.syntax().text_range(), |
171 | kind: InlayKind::ParameterHint, | 171 | kind: InlayKind::ParameterHint, |
@@ -187,7 +187,7 @@ fn get_bind_pat_hints( | |||
187 | } | 187 | } |
188 | 188 | ||
189 | let krate = sema.scope(pat.syntax()).module().map(|it| it.krate()); | 189 | let krate = sema.scope(pat.syntax()).module().map(|it| it.krate()); |
190 | let famous_defs = FamousDefs(&sema, krate); | 190 | let famous_defs = FamousDefs(sema, krate); |
191 | 191 | ||
192 | let ty = sema.type_of_pat(&pat.clone().into())?; | 192 | let ty = sema.type_of_pat(&pat.clone().into())?; |
193 | 193 | ||
diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index c67ccd1a9..93d3760bf 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs | |||
@@ -60,7 +60,7 @@ fn remove_newlines(edit: &mut TextEditBuilder, token: &SyntaxToken, range: TextR | |||
60 | let pos: TextSize = (pos as u32).into(); | 60 | let pos: TextSize = (pos as u32).into(); |
61 | let offset = token.text_range().start() + range.start() + pos; | 61 | let offset = token.text_range().start() + range.start() + pos; |
62 | if !edit.invalidates_offset(offset) { | 62 | if !edit.invalidates_offset(offset) { |
63 | remove_newline(edit, &token, offset); | 63 | remove_newline(edit, token, offset); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 97c9e5d2b..0511efae3 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -282,20 +282,20 @@ impl Analysis { | |||
282 | file_id: FileId, | 282 | file_id: FileId, |
283 | text_range: Option<TextRange>, | 283 | text_range: Option<TextRange>, |
284 | ) -> Cancellable<String> { | 284 | ) -> Cancellable<String> { |
285 | self.with_db(|db| syntax_tree::syntax_tree(&db, file_id, text_range)) | 285 | self.with_db(|db| syntax_tree::syntax_tree(db, file_id, text_range)) |
286 | } | 286 | } |
287 | 287 | ||
288 | pub fn view_hir(&self, position: FilePosition) -> Cancellable<String> { | 288 | pub fn view_hir(&self, position: FilePosition) -> Cancellable<String> { |
289 | self.with_db(|db| view_hir::view_hir(&db, position)) | 289 | self.with_db(|db| view_hir::view_hir(db, position)) |
290 | } | 290 | } |
291 | 291 | ||
292 | pub fn view_item_tree(&self, file_id: FileId) -> Cancellable<String> { | 292 | pub fn view_item_tree(&self, file_id: FileId) -> Cancellable<String> { |
293 | self.with_db(|db| view_item_tree::view_item_tree(&db, file_id)) | 293 | self.with_db(|db| view_item_tree::view_item_tree(db, file_id)) |
294 | } | 294 | } |
295 | 295 | ||
296 | /// Renders the crate graph to GraphViz "dot" syntax. | 296 | /// Renders the crate graph to GraphViz "dot" syntax. |
297 | pub fn view_crate_graph(&self) -> Cancellable<Result<String, String>> { | 297 | pub fn view_crate_graph(&self) -> Cancellable<Result<String, String>> { |
298 | self.with_db(|db| view_crate_graph::view_crate_graph(&db)) | 298 | self.with_db(|db| view_crate_graph::view_crate_graph(db)) |
299 | } | 299 | } |
300 | 300 | ||
301 | pub fn expand_macro(&self, position: FilePosition) -> Cancellable<Option<ExpandedMacro>> { | 301 | pub fn expand_macro(&self, position: FilePosition) -> Cancellable<Option<ExpandedMacro>> { |
@@ -315,7 +315,7 @@ impl Analysis { | |||
315 | /// up minor stuff like continuing the comment. | 315 | /// up minor stuff like continuing the comment. |
316 | /// The edit will be a snippet (with `$0`). | 316 | /// The edit will be a snippet (with `$0`). |
317 | pub fn on_enter(&self, position: FilePosition) -> Cancellable<Option<TextEdit>> { | 317 | pub fn on_enter(&self, position: FilePosition) -> Cancellable<Option<TextEdit>> { |
318 | self.with_db(|db| typing::on_enter(&db, position)) | 318 | self.with_db(|db| typing::on_enter(db, position)) |
319 | } | 319 | } |
320 | 320 | ||
321 | /// Returns an edit which should be applied after a character was typed. | 321 | /// Returns an edit which should be applied after a character was typed. |
@@ -331,7 +331,7 @@ impl Analysis { | |||
331 | if !typing::TRIGGER_CHARS.contains(char_typed) { | 331 | if !typing::TRIGGER_CHARS.contains(char_typed) { |
332 | return Ok(None); | 332 | return Ok(None); |
333 | } | 333 | } |
334 | self.with_db(|db| typing::on_char_typed(&db, position, char_typed)) | 334 | self.with_db(|db| typing::on_char_typed(db, position, char_typed)) |
335 | } | 335 | } |
336 | 336 | ||
337 | /// Returns a tree representation of symbols in the file. Useful to draw a | 337 | /// Returns a tree representation of symbols in the file. Useful to draw a |
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index f8b64a669..a0fdead2c 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -62,7 +62,7 @@ pub(crate) fn find_all_refs( | |||
62 | if let Some(name) = get_name_of_item_declaration(&syntax, position) { | 62 | if let Some(name) = get_name_of_item_declaration(&syntax, position) { |
63 | (NameClass::classify(sema, &name)?.referenced_or_defined(sema.db), true) | 63 | (NameClass::classify(sema, &name)?.referenced_or_defined(sema.db), true) |
64 | } else { | 64 | } else { |
65 | (find_def(&sema, &syntax, position)?, false) | 65 | (find_def(sema, &syntax, position)?, false) |
66 | }; | 66 | }; |
67 | 67 | ||
68 | let mut usages = def.usages(sema).set_scope(search_scope).include_self_refs().all(); | 68 | let mut usages = def.usages(sema).set_scope(search_scope).include_self_refs().all(); |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 7dfc5043e..02b171bda 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -64,7 +64,7 @@ pub(crate) fn prepare_rename( | |||
64 | } | 64 | } |
65 | }; | 65 | }; |
66 | let name_like = sema | 66 | let name_like = sema |
67 | .find_node_at_offset_with_descend(&syntax, position.offset) | 67 | .find_node_at_offset_with_descend(syntax, position.offset) |
68 | .ok_or_else(|| format_err!("No references found at position"))?; | 68 | .ok_or_else(|| format_err!("No references found at position"))?; |
69 | let node = match &name_like { | 69 | let node = match &name_like { |
70 | ast::NameLike::Name(it) => it.syntax(), | 70 | ast::NameLike::Name(it) => it.syntax(), |
@@ -104,7 +104,7 @@ pub(crate) fn rename_with_semantics( | |||
104 | 104 | ||
105 | let def = find_definition(sema, syntax, position)?; | 105 | let def = find_definition(sema, syntax, position)?; |
106 | match def { | 106 | match def { |
107 | Definition::ModuleDef(ModuleDef::Module(module)) => rename_mod(&sema, module, new_name), | 107 | Definition::ModuleDef(ModuleDef::Module(module)) => rename_mod(sema, module, new_name), |
108 | Definition::SelfType(_) => bail!("Cannot rename `Self`"), | 108 | Definition::SelfType(_) => bail!("Cannot rename `Self`"), |
109 | Definition::ModuleDef(ModuleDef::BuiltinType(_)) => bail!("Cannot rename builtin type"), | 109 | Definition::ModuleDef(ModuleDef::BuiltinType(_)) => bail!("Cannot rename builtin type"), |
110 | def => rename_reference(sema, def, new_name), | 110 | def => rename_reference(sema, def, new_name), |
@@ -323,7 +323,7 @@ fn rename_reference( | |||
323 | } | 323 | } |
324 | let mut source_change = SourceChange::default(); | 324 | let mut source_change = SourceChange::default(); |
325 | source_change.extend(usages.iter().map(|(&file_id, references)| { | 325 | source_change.extend(usages.iter().map(|(&file_id, references)| { |
326 | (file_id, source_edit_from_references(&references, def, new_name)) | 326 | (file_id, source_edit_from_references(references, def, new_name)) |
327 | })); | 327 | })); |
328 | 328 | ||
329 | let (file_id, edit) = source_edit_from_def(sema, def, new_name)?; | 329 | let (file_id, edit) = source_edit_from_def(sema, def, new_name)?; |
@@ -413,7 +413,7 @@ fn rename_self_to_param( | |||
413 | let mut source_change = SourceChange::default(); | 413 | let mut source_change = SourceChange::default(); |
414 | source_change.insert_source_edit(file_id.original_file(sema.db), edit); | 414 | source_change.insert_source_edit(file_id.original_file(sema.db), edit); |
415 | source_change.extend(usages.iter().map(|(&file_id, references)| { | 415 | source_change.extend(usages.iter().map(|(&file_id, references)| { |
416 | (file_id, source_edit_from_references(&references, def, new_name)) | 416 | (file_id, source_edit_from_references(references, def, new_name)) |
417 | })); | 417 | })); |
418 | Ok(source_change) | 418 | Ok(source_change) |
419 | } | 419 | } |
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 552054951..03faabadc 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -158,7 +158,7 @@ fn find_related_tests( | |||
158 | search_scope: Option<SearchScope>, | 158 | search_scope: Option<SearchScope>, |
159 | tests: &mut FxHashSet<Runnable>, | 159 | tests: &mut FxHashSet<Runnable>, |
160 | ) { | 160 | ) { |
161 | if let Some(refs) = references::find_all_refs(&sema, position, search_scope) { | 161 | if let Some(refs) = references::find_all_refs(sema, position, search_scope) { |
162 | for (file_id, refs) in refs.references { | 162 | for (file_id, refs) in refs.references { |
163 | let file = sema.parse(file_id); | 163 | let file = sema.parse(file_id); |
164 | let file = file.syntax(); | 164 | let file = file.syntax(); |
@@ -169,10 +169,10 @@ fn find_related_tests( | |||
169 | }); | 169 | }); |
170 | 170 | ||
171 | for fn_def in functions { | 171 | for fn_def in functions { |
172 | if let Some(runnable) = as_test_runnable(&sema, &fn_def) { | 172 | if let Some(runnable) = as_test_runnable(sema, &fn_def) { |
173 | // direct test | 173 | // direct test |
174 | tests.insert(runnable); | 174 | tests.insert(runnable); |
175 | } else if let Some(module) = parent_test_module(&sema, &fn_def) { | 175 | } else if let Some(module) = parent_test_module(sema, &fn_def) { |
176 | // indirect test | 176 | // indirect test |
177 | find_related_tests_in_module(sema, &fn_def, &module, tests); | 177 | find_related_tests_in_module(sema, &fn_def, &module, tests); |
178 | } | 178 | } |
@@ -203,7 +203,7 @@ fn find_related_tests_in_module( | |||
203 | } | 203 | } |
204 | 204 | ||
205 | fn as_test_runnable(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> { | 205 | fn as_test_runnable(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> { |
206 | if test_related_attribute(&fn_def).is_some() { | 206 | if test_related_attribute(fn_def).is_some() { |
207 | let function = sema.to_def(fn_def)?; | 207 | let function = sema.to_def(fn_def)?; |
208 | runnable_fn(sema, function) | 208 | runnable_fn(sema, function) |
209 | } else { | 209 | } else { |
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index b03f1c71f..e186b82b7 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs | |||
@@ -323,7 +323,7 @@ fn traverse( | |||
323 | if let Some(token) = element.as_token().cloned().and_then(ast::String::cast) { | 323 | if let Some(token) = element.as_token().cloned().and_then(ast::String::cast) { |
324 | if token.is_raw() { | 324 | if token.is_raw() { |
325 | let expanded = element_to_highlight.as_token().unwrap().clone(); | 325 | let expanded = element_to_highlight.as_token().unwrap().clone(); |
326 | if inject::ra_fixture(hl, &sema, token, expanded).is_some() { | 326 | if inject::ra_fixture(hl, sema, token, expanded).is_some() { |
327 | continue; | 327 | continue; |
328 | } | 328 | } |
329 | } | 329 | } |
@@ -334,7 +334,7 @@ fn traverse( | |||
334 | } | 334 | } |
335 | 335 | ||
336 | if let Some((mut highlight, binding_hash)) = highlight::element( | 336 | if let Some((mut highlight, binding_hash)) = highlight::element( |
337 | &sema, | 337 | sema, |
338 | krate, | 338 | krate, |
339 | &mut bindings_shadow_count, | 339 | &mut bindings_shadow_count, |
340 | syntactic_name_ref_highlighting, | 340 | syntactic_name_ref_highlighting, |
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 84012227d..8c0e553c0 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs | |||
@@ -449,12 +449,12 @@ fn highlight_method_call( | |||
449 | krate: Option<hir::Crate>, | 449 | krate: Option<hir::Crate>, |
450 | method_call: &ast::MethodCallExpr, | 450 | method_call: &ast::MethodCallExpr, |
451 | ) -> Option<Highlight> { | 451 | ) -> Option<Highlight> { |
452 | let func = sema.resolve_method_call(&method_call)?; | 452 | let func = sema.resolve_method_call(method_call)?; |
453 | 453 | ||
454 | let mut h = SymbolKind::Function.into(); | 454 | let mut h = SymbolKind::Function.into(); |
455 | h |= HlMod::Associated; | 455 | h |= HlMod::Associated; |
456 | 456 | ||
457 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { | 457 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(method_call) { |
458 | h |= HlMod::Unsafe; | 458 | h |= HlMod::Unsafe; |
459 | } | 459 | } |
460 | if func.is_async(sema.db) { | 460 | if func.is_async(sema.db) { |
diff --git a/crates/ide/src/syntax_highlighting/html.rs b/crates/ide/src/syntax_highlighting/html.rs index 5327af845..478facfee 100644 --- a/crates/ide/src/syntax_highlighting/html.rs +++ b/crates/ide/src/syntax_highlighting/html.rs | |||
@@ -23,7 +23,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo | |||
23 | let hl_ranges = highlight(db, file_id, None, false); | 23 | let hl_ranges = highlight(db, file_id, None, false); |
24 | let text = parse.tree().syntax().to_string(); | 24 | let text = parse.tree().syntax().to_string(); |
25 | let mut buf = String::new(); | 25 | let mut buf = String::new(); |
26 | buf.push_str(&STYLE); | 26 | buf.push_str(STYLE); |
27 | buf.push_str("<pre><code>"); | 27 | buf.push_str("<pre><code>"); |
28 | for r in &hl_ranges { | 28 | for r in &hl_ranges { |
29 | let chunk = html_escape(&text[r.range]); | 29 | let chunk = html_escape(&text[r.range]); |
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 4269d339e..883252c0e 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs | |||
@@ -23,7 +23,7 @@ pub(super) fn ra_fixture( | |||
23 | literal: ast::String, | 23 | literal: ast::String, |
24 | expanded: SyntaxToken, | 24 | expanded: SyntaxToken, |
25 | ) -> Option<()> { | 25 | ) -> Option<()> { |
26 | let active_parameter = ActiveParameter::at_token(&sema, expanded)?; | 26 | let active_parameter = ActiveParameter::at_token(sema, expanded)?; |
27 | if !active_parameter.ident().map_or(false, |name| name.text().starts_with("ra_fixture")) { | 27 | if !active_parameter.ident().map_or(false, |name| name.text().starts_with("ra_fixture")) { |
28 | return None; | 28 | return None; |
29 | } | 29 | } |
@@ -124,7 +124,7 @@ pub(super) fn doc_comment( | |||
124 | } | 124 | } |
125 | 125 | ||
126 | for attr in attributes.by_key("doc").attrs() { | 126 | for attr in attributes.by_key("doc").attrs() { |
127 | let InFile { file_id, value: src } = attrs_source_map.source_of(&attr); | 127 | let InFile { file_id, value: src } = attrs_source_map.source_of(attr); |
128 | if file_id != node.file_id { | 128 | if file_id != node.file_id { |
129 | continue; | 129 | continue; |
130 | } | 130 | } |
diff --git a/crates/ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs index 81c4d95b1..5cba9d11d 100644 --- a/crates/ide/src/typing/on_enter.rs +++ b/crates/ide/src/typing/on_enter.rs | |||
@@ -88,12 +88,12 @@ fn on_enter_in_comment( | |||
88 | if comment.text().ends_with(' ') { | 88 | if comment.text().ends_with(' ') { |
89 | cov_mark::hit!(continues_end_of_line_comment_with_space); | 89 | cov_mark::hit!(continues_end_of_line_comment_with_space); |
90 | remove_trailing_whitespace = true; | 90 | remove_trailing_whitespace = true; |
91 | } else if !followed_by_comment(&comment) { | 91 | } else if !followed_by_comment(comment) { |
92 | return None; | 92 | return None; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | let indent = node_indent(&file, comment.syntax())?; | 96 | let indent = node_indent(file, comment.syntax())?; |
97 | let inserted = format!("\n{}{} $0", indent, prefix); | 97 | let inserted = format!("\n{}{} $0", indent, prefix); |
98 | let delete = if remove_trailing_whitespace { | 98 | let delete = if remove_trailing_whitespace { |
99 | let trimmed_len = comment.text().trim_end().len() as u32; | 99 | let trimmed_len = comment.text().trim_end().len() as u32; |
@@ -188,7 +188,7 @@ mod tests { | |||
188 | use crate::fixture; | 188 | use crate::fixture; |
189 | 189 | ||
190 | fn apply_on_enter(before: &str) -> Option<String> { | 190 | fn apply_on_enter(before: &str) -> Option<String> { |
191 | let (analysis, position) = fixture::position(&before); | 191 | let (analysis, position) = fixture::position(before); |
192 | let result = analysis.on_enter(position).unwrap()?; | 192 | let result = analysis.on_enter(position).unwrap()?; |
193 | 193 | ||
194 | let mut actual = analysis.file_text(position.file_id).unwrap().to_string(); | 194 | let mut actual = analysis.file_text(position.file_id).unwrap().to_string(); |