Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env_logger = { version = "0.8.1", default-features = false }
itertools = "0.9.0"
jod-thread = "0.1.0"
log = "0.4.8"
lsp-types = { version = "0.82.0", features = ["proposed"] }
lsp-types = { version = "0.83.0", features = ["proposed"] }
parking_lot = "0.11.0"
pico-args = "0.3.1"
oorandom = "11.1.2"
Expand Down
3 changes: 2 additions & 1 deletion crates/rust-analyzer/src/caps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
references_provider: Some(OneOf::Left(true)),
document_highlight_provider: Some(OneOf::Left(true)),
document_symbol_provider: Some(OneOf::Left(true)),
workspace_symbol_provider: Some(true),
workspace_symbol_provider: Some(OneOf::Left(true)),
code_action_provider: Some(code_action_provider),
code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(true) }),
document_formatting_provider: Some(OneOf::Left(true)),
Expand Down Expand Up @@ -113,6 +113,7 @@ fn code_action_capabilities(client_caps: &ClientCapabilities) -> CodeActionProvi
CodeActionKind::REFACTOR_INLINE,
CodeActionKind::REFACTOR_REWRITE,
]),
resolve_provider: None,
work_done_progress_options: Default::default(),
})
})
Expand Down
10 changes: 10 additions & 0 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct Config {
pub call_info_full: bool,
pub lens: LensConfig,
pub hover: HoverConfig,
pub semantic_tokens_refresh: bool,

pub with_sysroot: bool,
pub linked_projects: Vec<LinkedProject>,
Expand Down Expand Up @@ -193,6 +194,7 @@ impl Config {
call_info_full: true,
lens: LensConfig::default(),
hover: HoverConfig::default(),
semantic_tokens_refresh: false,
linked_projects: Vec::new(),
root_path,
}
Expand Down Expand Up @@ -402,6 +404,14 @@ impl Config {
self.client_caps.hover_actions = get_bool("hoverActions");
self.client_caps.status_notification = get_bool("statusNotification");
}

if let Some(workspace_caps) = caps.workspace.as_ref() {
if let Some(refresh_support) =
workspace_caps.semantic_tokens.as_ref().and_then(|it| it.refresh_support)
{
self.semantic_tokens_refresh = refresh_support;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"trivially_copy_pass_by_ref",
),
),
code_description: None,
source: Some(
"clippy",
),
Expand Down Expand Up @@ -61,6 +62,7 @@
],
),
tags: None,
data: None,
},
fixes: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
"E0277",
),
),
code_description: None,
source: Some(
"rustc",
),
message: "can\'t compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`",
related_information: None,
tags: None,
data: None,
},
fixes: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Error,
),
code: None,
code_description: None,
source: Some(
"rustc",
),
Expand All @@ -41,6 +42,7 @@
],
),
tags: None,
data: None,
},
fixes: [],
},
Expand All @@ -61,6 +63,7 @@
Error,
),
code: None,
code_description: None,
source: Some(
"rustc",
),
Expand All @@ -86,6 +89,7 @@
],
),
tags: None,
data: None,
},
fixes: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
"E0053",
),
),
code_description: None,
source: Some(
"rustc",
),
message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&ty::Ref<M>>`\n found type `fn(&ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&\'list ty::Ref<M>>`",
related_information: None,
tags: None,
data: None,
},
fixes: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
"E0308",
),
),
code_description: None,
source: Some(
"rustc",
),
message: "mismatched types\nexpected usize, found u32",
related_information: None,
tags: None,
data: None,
},
fixes: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"unused_variables",
),
),
code_description: None,
source: Some(
"rustc",
),
Expand All @@ -30,6 +31,7 @@
Unnecessary,
],
),
data: None,
},
fixes: [
CodeAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"unused_variables",
),
),
code_description: None,
source: Some(
"rustc",
),
Expand All @@ -30,6 +31,7 @@
Unnecessary,
],
),
data: None,
},
fixes: [
CodeAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"unused_variables",
),
),
code_description: None,
source: Some(
"rustc",
),
Expand All @@ -30,6 +31,7 @@
Unnecessary,
],
),
data: None,
},
fixes: [
CodeAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"E0061",
),
),
code_description: None,
source: Some(
"rustc",
),
Expand All @@ -45,6 +46,7 @@
],
),
tags: None,
data: None,
},
fixes: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"let_and_return",
),
),
code_description: None,
source: Some(
"clippy",
),
Expand All @@ -45,6 +46,7 @@
],
),
tags: None,
data: None,
},
fixes: [
CodeAction {
Expand Down
4 changes: 4 additions & 0 deletions crates/rust-analyzer/src/diagnostics/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,12 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
range: in_macro_location.range,
severity,
code: code.clone().map(lsp_types::NumberOrString::String),
code_description: None,
source: Some(source.clone()),
message: message.clone(),
related_information: Some(information_for_additional_diagnostic),
tags: if tags.is_empty() { None } else { Some(tags.clone()) },
data: None,
};

Some(MappedRustDiagnostic {
Expand All @@ -267,6 +269,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
range: location.range,
severity,
code: code.clone().map(lsp_types::NumberOrString::String),
code_description: None,
source: Some(source.clone()),
message,
related_information: if related_information.is_empty() {
Expand All @@ -275,6 +278,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
Some(related_information.clone())
},
tags: if tags.is_empty() { None } else { Some(tags.clone()) },
data: None,
};

let main_diagnostic =
Expand Down
2 changes: 2 additions & 0 deletions crates/rust-analyzer/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,12 @@ pub(crate) fn publish_diagnostics(
range: to_proto::range(&line_index, d.range),
severity: Some(to_proto::diagnostic_severity(d.severity)),
code: None,
code_description: None,
source: Some("rust-analyzer".to_string()),
message: d.message,
related_information: None,
tags: if d.unused { Some(vec![DiagnosticTag::Unnecessary]) } else { None },
data: None,
})
.collect();
Ok(diagnostics)
Expand Down
6 changes: 6 additions & 0 deletions crates/rust-analyzer/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ impl GlobalState {
.collect::<Vec<_>>();

self.update_file_notifications_on_threadpool(subscriptions);

// Refresh semantic tokens if the client supports it.
if self.config.semantic_tokens_refresh {
self.semantic_tokens_cache.lock().clear();
self.send_request::<lsp_types::request::SemanticTokensRefesh>((), |_, _| ());
}
Copy link
Contributor Author

@kjeremy kjeremy Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matklad I think this is the right spot to send a refresh request but am not 100% sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this is correct.

}

if let Some(diagnostic_changes) = self.diagnostics.take_changes() {
Expand Down
11 changes: 10 additions & 1 deletion crates/rust-analyzer/src/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,16 @@ pub(crate) fn call_hierarchy_item(
let detail = target.description.clone();
let kind = symbol_kind(target.kind);
let (uri, range, selection_range) = location_info(snap, target)?;
Ok(lsp_types::CallHierarchyItem { name, kind, tags: None, detail, uri, range, selection_range })
Ok(lsp_types::CallHierarchyItem {
name,
kind,
tags: None,
detail,
uri,
range,
selection_range,
data: None,
})
}

pub(crate) fn code_action_kind(kind: AssistKind) -> lsp_types::CodeActionKind {
Expand Down
30 changes: 15 additions & 15 deletions editors/code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"node-fetch": "^2.6.1",
"vscode-languageclient": "7.0.0-next.9"
"vscode-languageclient": "7.0.0-next.12"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^13.0.2",
Expand Down
5 changes: 2 additions & 3 deletions editors/code/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ export async function sendRequestWithRetry<TParam, TRet>(
log.warn("LSP request timed out", { method: reqType.method, param, error });
throw error;
}

if (error.code === lc.ErrorCodes.RequestCancelled) {
if (error.code === lc.LSPErrorCodes.RequestCancelled) {
throw error;
}

if (error.code !== lc.ErrorCodes.ContentModified) {
if (error.code !== lc.LSPErrorCodes.ContentModified) {
log.warn("LSP request failed", { method: reqType.method, param, error });
throw error;
}
Expand Down