Skip to content

Commit 7723dd0

Browse files
author
Jonas Schievink
committed
Rename convert_location -> location
1 parent 9b41eff commit 7723dd0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

crates/rust-analyzer/src/diagnostics/to_proto.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn diagnostic_severity(
3535
}
3636

3737
/// Converts a Rust span to a LSP location
38-
fn convert_location(workspace_root: &Path, span: &DiagnosticSpan) -> lsp_types::Location {
38+
fn location(workspace_root: &Path, span: &DiagnosticSpan) -> lsp_types::Location {
3939
let file_name = workspace_root.join(&span.file_name);
4040
let uri = url_from_abs_path(&file_name);
4141

@@ -56,7 +56,7 @@ fn diagnostic_related_information(
5656
span: &DiagnosticSpan,
5757
) -> Option<lsp_types::DiagnosticRelatedInformation> {
5858
let message = span.label.clone()?;
59-
let location = convert_location(workspace_root, span);
59+
let location = location(workspace_root, span);
6060
Some(lsp_types::DiagnosticRelatedInformation { location, message })
6161
}
6262

@@ -84,7 +84,7 @@ fn map_rust_child_diagnostic(
8484
let mut edit_map: HashMap<lsp_types::Url, Vec<lsp_types::TextEdit>> = HashMap::new();
8585
for &span in &spans {
8686
if let Some(suggested_replacement) = &span.suggested_replacement {
87-
let location = convert_location(workspace_root, span);
87+
let location = location(workspace_root, span);
8888
let edit = lsp_types::TextEdit::new(location.range, suggested_replacement.clone());
8989
edit_map.entry(location.uri).or_default().push(edit);
9090
}
@@ -93,15 +93,15 @@ fn map_rust_child_diagnostic(
9393
if edit_map.is_empty() {
9494
MappedRustChildDiagnostic::SubDiagnostic(SubDiagnostic {
9595
related: lsp_types::DiagnosticRelatedInformation {
96-
location: convert_location(workspace_root, spans[0]),
96+
location: location(workspace_root, spans[0]),
9797
message: rd.message.clone(),
9898
},
9999
suggested_fix: None,
100100
})
101101
} else {
102102
MappedRustChildDiagnostic::SubDiagnostic(SubDiagnostic {
103103
related: lsp_types::DiagnosticRelatedInformation {
104-
location: convert_location(workspace_root, spans[0]),
104+
location: location(workspace_root, spans[0]),
105105
message: rd.message.clone(),
106106
},
107107
suggested_fix: Some(lsp_ext::CodeAction {
@@ -217,7 +217,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
217217
primary_spans
218218
.iter()
219219
.flat_map(|primary_span| {
220-
let location = convert_location(workspace_root, &primary_span);
220+
let primary_location = location(workspace_root, &primary_span);
221221

222222
let mut message = message.clone();
223223
if needs_primary_span_label {
@@ -240,15 +240,15 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
240240
})
241241
.skip(1);
242242
for macro_span in macro_calls {
243-
let in_macro_location = convert_location(workspace_root, &macro_span);
243+
let in_macro_location = location(workspace_root, &macro_span);
244244
related_info_macro_calls.push(lsp_types::DiagnosticRelatedInformation {
245245
location: in_macro_location.clone(),
246246
message: "Error originated from macro call here".to_string(),
247247
});
248248
// For the additional in-macro diagnostic we add the inverse message pointing to the error location in code.
249249
let information_for_additional_diagnostic =
250250
vec![lsp_types::DiagnosticRelatedInformation {
251-
location: location.clone(),
251+
location: primary_location.clone(),
252252
message: "Exact error occurred here".to_string(),
253253
}];
254254

@@ -273,9 +273,9 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
273273

274274
// Emit the primary diagnostic.
275275
diagnostics.push(MappedRustDiagnostic {
276-
url: location.uri.clone(),
276+
url: primary_location.uri.clone(),
277277
diagnostic: lsp_types::Diagnostic {
278-
range: location.range,
278+
range: primary_location.range,
279279
severity,
280280
code: code.clone().map(lsp_types::NumberOrString::String),
281281
code_description: code_description.clone(),
@@ -303,7 +303,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
303303
// This is useful because they will show up in the user's editor, unlike
304304
// `related_information`, which just produces hard-to-read links, at least in VS Code.
305305
let back_ref = lsp_types::DiagnosticRelatedInformation {
306-
location,
306+
location: primary_location,
307307
message: "original diagnostic".to_string(),
308308
};
309309
for sub in &subdiagnostics {

0 commit comments

Comments
 (0)