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
3 changes: 0 additions & 3 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use serde::Deserialize;
#[derive(Debug, Clone)]
pub struct Config {
pub client_caps: ClientCapsConfig,
pub publish_decorations: bool,
pub publish_diagnostics: bool,
pub notifications: NotificationsConfig,
pub inlay_hints: InlayHintsConfig,
Expand Down Expand Up @@ -60,7 +59,6 @@ pub struct ClientCapsConfig {
impl Default for Config {
fn default() -> Self {
Config {
publish_decorations: false,
publish_diagnostics: true,
notifications: NotificationsConfig {
workspace_loaded: true,
Expand Down Expand Up @@ -105,7 +103,6 @@ impl Config {
*self = Default::default();
self.client_caps = client_caps;

set(value, "/publishDecorations", &mut self.publish_decorations);
set(value, "/excludeGlobs", &mut self.exclude_globs);
set(value, "/useClientWatching", &mut self.use_client_watching);
set(value, "/lruCapacity", &mut self.lru_capacity);
Expand Down
20 changes: 1 addition & 19 deletions crates/rust-analyzer/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ impl fmt::Debug for Event {
}
}
Event::Task(Task::Notify(not)) => {
if notification_is::<req::PublishDecorations>(not)
|| notification_is::<req::PublishDiagnostics>(not)
{
if notification_is::<req::PublishDiagnostics>(not) {
return debug_verbose_not(not, f);
}
}
Expand Down Expand Up @@ -427,7 +425,6 @@ fn loop_turn(
update_file_notifications_on_threadpool(
pool,
world_state.snapshot(),
world_state.config.publish_decorations,
task_sender.clone(),
loop_state.subscriptions.subscriptions(),
)
Expand Down Expand Up @@ -508,7 +505,6 @@ fn on_request(
.on::<req::GotoTypeDefinition>(handlers::handle_goto_type_definition)?
.on::<req::ParentModule>(handlers::handle_parent_module)?
.on::<req::Runnables>(handlers::handle_runnables)?
.on::<req::DecorationsRequest>(handlers::handle_decorations)?
.on::<req::Completion>(handlers::handle_completion)?
.on::<req::CodeActionRequest>(handlers::handle_code_action)?
.on::<req::CodeLensRequest>(handlers::handle_code_lens)?
Expand Down Expand Up @@ -884,7 +880,6 @@ where
fn update_file_notifications_on_threadpool(
pool: &ThreadPool,
world: WorldSnapshot,
publish_decorations: bool,
task_sender: Sender<Task>,
subscriptions: Vec<FileId>,
) {
Expand All @@ -904,19 +899,6 @@ fn update_file_notifications_on_threadpool(
}
}
}
if publish_decorations {
match handlers::publish_decorations(&world, file_id) {
Err(e) => {
if !is_canceled(&e) {
log::error!("failed to compute decorations: {:?}", e);
}
}
Ok(params) => {
let not = notification_new::<req::PublishDecorations>(params);
task_sender.send(Task::Notify(not)).unwrap();
}
}
}
}
});
}
Expand Down
35 changes: 1 addition & 34 deletions crates/rust-analyzer/src/main_loop/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::{
},
diagnostics::DiagnosticTask,
from_json,
req::{self, Decoration, InlayHint, InlayHintsParams},
req::{self, InlayHint, InlayHintsParams},
semantic_tokens::SemanticTokensBuilder,
world::WorldSnapshot,
LspError, Result,
Expand Down Expand Up @@ -389,15 +389,6 @@ pub fn handle_runnables(
Ok(res)
}

pub fn handle_decorations(
world: WorldSnapshot,
params: TextDocumentIdentifier,
) -> Result<Vec<Decoration>> {
let _p = profile("handle_decorations");
let file_id = params.try_conv_with(&world)?;
highlight(&world, file_id)
}

pub fn handle_completion(
world: WorldSnapshot,
params: req::CompletionParams,
Expand Down Expand Up @@ -970,15 +961,6 @@ pub fn publish_diagnostics(world: &WorldSnapshot, file_id: FileId) -> Result<Dia
Ok(DiagnosticTask::SetNative(file_id, diagnostics))
}

pub fn publish_decorations(
world: &WorldSnapshot,
file_id: FileId,
) -> Result<req::PublishDecorationsParams> {
let _p = profile("publish_decorations");
let uri = world.file_id_to_uri(file_id)?;
Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? })
}

fn to_lsp_runnable(
world: &WorldSnapshot,
file_id: FileId,
Expand Down Expand Up @@ -1008,21 +990,6 @@ fn to_lsp_runnable(
})
}

fn highlight(world: &WorldSnapshot, file_id: FileId) -> Result<Vec<Decoration>> {
let line_index = world.analysis().file_line_index(file_id)?;
let res = world
.analysis()
.highlight(file_id)?
.into_iter()
.map(|h| Decoration {
range: h.range.conv_with(&line_index),
tag: h.highlight.to_string(),
binding_hash: h.binding_hash.map(|x| x.to_string()),
})
.collect();
Ok(res)
}

pub fn handle_inlay_hints(
world: WorldSnapshot,
params: InlayHintsParams,
Expand Down
32 changes: 1 addition & 31 deletions crates/rust-analyzer/src/req.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Defines `rust-analyzer` specific custom messages.

use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
use lsp_types::{Location, Position, Range, TextDocumentIdentifier};
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -86,36 +86,6 @@ pub struct FindMatchingBraceParams {
pub offsets: Vec<Position>,
}

pub enum DecorationsRequest {}

impl Request for DecorationsRequest {
type Params = TextDocumentIdentifier;
type Result = Vec<Decoration>;
const METHOD: &'static str = "rust-analyzer/decorationsRequest";
}

pub enum PublishDecorations {}

impl Notification for PublishDecorations {
type Params = PublishDecorationsParams;
const METHOD: &'static str = "rust-analyzer/publishDecorations";
}

#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PublishDecorationsParams {
pub uri: Url,
pub decorations: Vec<Decoration>,
}

#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Decoration {
pub range: Range,
pub tag: String,
pub binding_hash: Option<String>,
}

pub enum ParentModule {}

impl Request for ParentModule {
Expand Down
10 changes: 0 additions & 10 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,6 @@
"default": false,
"description": "Use proposed semantic tokens API for syntax highlighting"
},
"rust-analyzer.highlightingOn": {
"type": "boolean",
"default": false,
"description": "Highlight Rust code (overrides built-in syntax highlighting)"
},
"rust-analyzer.rainbowHighlightingOn": {
"type": "boolean",
"default": false,
"description": "When highlighting Rust code, use a unique color per identifier"
},
"rust-analyzer.featureFlags": {
"type": "object",
"default": {},
Expand Down
1 change: 0 additions & 1 deletion editors/code/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-

export function configToServerOptions(config: Config) {
return {
publishDecorations: !config.highlightingSemanticTokens,
lruCapacity: config.lruCapacity,

inlayHintsType: config.inlayHints.typeHints,
Expand Down
2 changes: 0 additions & 2 deletions editors/code/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export class Config {
get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; }
get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; }
get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; }
get highlightingOn() { return this.cfg.get<boolean>("highlightingOn")!; }
get rainbowHighlightingOn() { return this.cfg.get<boolean>("rainbowHighlightingOn")!; }
get lruCapacity() { return this.cfg.get<null | number>("lruCapacity")!; }
get excludeGlobs() { return this.cfg.get<string[]>("excludeGlobs")!; }
get useClientWatching() { return this.cfg.get<boolean>("useClientWatching")!; }
Expand Down
Loading