Code review fixes

Co-Authored-By: Veetaha <veetaha2@gmail.com>
This commit is contained in:
Kirill Bulatov 2020-03-22 00:40:07 +02:00
parent 590af37bff
commit b892a48740
5 changed files with 18 additions and 18 deletions

View file

@ -417,22 +417,19 @@ fn loop_turn(
if Some(resp.id) == loop_state.configuration_request_id { if Some(resp.id) == loop_state.configuration_request_id {
loop_state.configuration_request_id = None; loop_state.configuration_request_id = None;
if let Some(err) = resp.error { if let Some(err) = resp.error {
log::error!("failed fetch the server settings: {:?}", err) log::error!("failed to fetch the server settings: {:?}", err)
} else if resp.result.is_none() { } else if let Some(result) = resp.result {
log::error!("received empty server settings response from the client") let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)?
} else {
let new_config =
serde_json::from_value::<Vec<ServerConfig>>(resp.result.unwrap())?
.first() .first()
.expect( .expect("The client is expected to always send a non-empty config data")
"The client is expected to always send a non-empty config data",
)
.to_owned(); .to_owned();
world_state.update_configuration( world_state.update_configuration(
new_config.lru_capacity, new_config.lru_capacity,
get_options(&new_config, text_document_caps), get_options(&new_config, text_document_caps),
get_feature_flags(&new_config, connection), get_feature_flags(&new_config, connection),
); );
} else {
log::error!("received empty server settings response from the client")
} }
} }
} }
@ -673,7 +670,7 @@ fn on_notification(
ConfigurationParams::default(), ConfigurationParams::default(),
); );
msg_sender.send(request.into())?; msg_sender.send(request.into())?;
loop_state.configuration_request_id.replace(request_id); loop_state.configuration_request_id = Some(request_id);
return Ok(()); return Ok(());
} }

View file

@ -32,6 +32,7 @@ use ra_db::ExternSourceId;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher { fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher {
// FIXME: Figure out the multi-workspace situation
workspaces workspaces
.iter() .iter()
.find_map(|w| match w { .find_map(|w| match w {

View file

@ -5,7 +5,7 @@ import { Config } from './config';
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
export function configToServerOptions(config: Config): object { export function configToServerOptions(config: Config) {
return { return {
publishDecorations: !config.highlightingSemanticTokens, publishDecorations: !config.highlightingSemanticTokens,
lruCapacity: config.lruCapacity, lruCapacity: config.lruCapacity,

View file

@ -17,9 +17,11 @@ export function activateInlayHints(ctx: Ctx) {
) { ) {
return this.dispose(); return this.dispose();
} }
if (!this.updater) this.updater = new HintsUpdater(ctx); if (this.updater) {
this.updater.syncCacheAndRenderHints(); this.updater.syncCacheAndRenderHints();
} else {
this.updater = new HintsUpdater(ctx);
}
}, },
dispose() { dispose() {
this.updater?.dispose(); this.updater?.dispose();
@ -126,7 +128,7 @@ class HintsUpdater implements Disposable {
this.syncCacheAndRenderHints(); this.syncCacheAndRenderHints();
} }
public syncCacheAndRenderHints() { syncCacheAndRenderHints() {
// FIXME: make inlayHints request pass an array of files? // FIXME: make inlayHints request pass an array of files?
this.sourceFiles.forEach((file, uri) => this.fetchHints(file).then(hints => { this.sourceFiles.forEach((file, uri) => this.fetchHints(file).then(hints => {
if (!hints) return; if (!hints) return;

View file

@ -95,7 +95,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.workspace.onDidChangeConfiguration( vscode.workspace.onDidChangeConfiguration(
_ => ctx?.client?.sendNotification('workspace/didChangeConfiguration', { settings: "" }), _ => ctx?.client?.sendNotification('workspace/didChangeConfiguration', { settings: "" }),
null, null,
ctx?.subscriptions, ctx.subscriptions,
); );
} }