Skip to content

Commit 98f7842

Browse files
bors[bot]matklad
andauthored
Merge #3820
3820: Remove old syntax highlighting r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 2883b29 + 309fc70 commit 98f7842

File tree

9 files changed

+3
-359
lines changed

9 files changed

+3
-359
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use serde::Deserialize;
1616
#[derive(Debug, Clone)]
1717
pub struct Config {
1818
pub client_caps: ClientCapsConfig,
19-
pub publish_decorations: bool,
2019
pub publish_diagnostics: bool,
2120
pub notifications: NotificationsConfig,
2221
pub inlay_hints: InlayHintsConfig,
@@ -60,7 +59,6 @@ pub struct ClientCapsConfig {
6059
impl Default for Config {
6160
fn default() -> Self {
6261
Config {
63-
publish_decorations: false,
6462
publish_diagnostics: true,
6563
notifications: NotificationsConfig {
6664
workspace_loaded: true,
@@ -105,7 +103,6 @@ impl Config {
105103
*self = Default::default();
106104
self.client_caps = client_caps;
107105

108-
set(value, "/publishDecorations", &mut self.publish_decorations);
109106
set(value, "/excludeGlobs", &mut self.exclude_globs);
110107
set(value, "/useClientWatching", &mut self.use_client_watching);
111108
set(value, "/lruCapacity", &mut self.lru_capacity);

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ impl fmt::Debug for Event {
250250
}
251251
}
252252
Event::Task(Task::Notify(not)) => {
253-
if notification_is::<req::PublishDecorations>(not)
254-
|| notification_is::<req::PublishDiagnostics>(not)
255-
{
253+
if notification_is::<req::PublishDiagnostics>(not) {
256254
return debug_verbose_not(not, f);
257255
}
258256
}
@@ -427,7 +425,6 @@ fn loop_turn(
427425
update_file_notifications_on_threadpool(
428426
pool,
429427
world_state.snapshot(),
430-
world_state.config.publish_decorations,
431428
task_sender.clone(),
432429
loop_state.subscriptions.subscriptions(),
433430
)
@@ -508,7 +505,6 @@ fn on_request(
508505
.on::<req::GotoTypeDefinition>(handlers::handle_goto_type_definition)?
509506
.on::<req::ParentModule>(handlers::handle_parent_module)?
510507
.on::<req::Runnables>(handlers::handle_runnables)?
511-
.on::<req::DecorationsRequest>(handlers::handle_decorations)?
512508
.on::<req::Completion>(handlers::handle_completion)?
513509
.on::<req::CodeActionRequest>(handlers::handle_code_action)?
514510
.on::<req::CodeLensRequest>(handlers::handle_code_lens)?
@@ -884,7 +880,6 @@ where
884880
fn update_file_notifications_on_threadpool(
885881
pool: &ThreadPool,
886882
world: WorldSnapshot,
887-
publish_decorations: bool,
888883
task_sender: Sender<Task>,
889884
subscriptions: Vec<FileId>,
890885
) {
@@ -904,19 +899,6 @@ fn update_file_notifications_on_threadpool(
904899
}
905900
}
906901
}
907-
if publish_decorations {
908-
match handlers::publish_decorations(&world, file_id) {
909-
Err(e) => {
910-
if !is_canceled(&e) {
911-
log::error!("failed to compute decorations: {:?}", e);
912-
}
913-
}
914-
Ok(params) => {
915-
let not = notification_new::<req::PublishDecorations>(params);
916-
task_sender.send(Task::Notify(not)).unwrap();
917-
}
918-
}
919-
}
920902
}
921903
});
922904
}

crates/rust-analyzer/src/main_loop/handlers.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::{
3838
},
3939
diagnostics::DiagnosticTask,
4040
from_json,
41-
req::{self, Decoration, InlayHint, InlayHintsParams},
41+
req::{self, InlayHint, InlayHintsParams},
4242
semantic_tokens::SemanticTokensBuilder,
4343
world::WorldSnapshot,
4444
LspError, Result,
@@ -389,15 +389,6 @@ pub fn handle_runnables(
389389
Ok(res)
390390
}
391391

392-
pub fn handle_decorations(
393-
world: WorldSnapshot,
394-
params: TextDocumentIdentifier,
395-
) -> Result<Vec<Decoration>> {
396-
let _p = profile("handle_decorations");
397-
let file_id = params.try_conv_with(&world)?;
398-
highlight(&world, file_id)
399-
}
400-
401392
pub fn handle_completion(
402393
world: WorldSnapshot,
403394
params: req::CompletionParams,
@@ -970,15 +961,6 @@ pub fn publish_diagnostics(world: &WorldSnapshot, file_id: FileId) -> Result<Dia
970961
Ok(DiagnosticTask::SetNative(file_id, diagnostics))
971962
}
972963

973-
pub fn publish_decorations(
974-
world: &WorldSnapshot,
975-
file_id: FileId,
976-
) -> Result<req::PublishDecorationsParams> {
977-
let _p = profile("publish_decorations");
978-
let uri = world.file_id_to_uri(file_id)?;
979-
Ok(req::PublishDecorationsParams { uri, decorations: highlight(&world, file_id)? })
980-
}
981-
982964
fn to_lsp_runnable(
983965
world: &WorldSnapshot,
984966
file_id: FileId,
@@ -1008,21 +990,6 @@ fn to_lsp_runnable(
1008990
})
1009991
}
1010992

1011-
fn highlight(world: &WorldSnapshot, file_id: FileId) -> Result<Vec<Decoration>> {
1012-
let line_index = world.analysis().file_line_index(file_id)?;
1013-
let res = world
1014-
.analysis()
1015-
.highlight(file_id)?
1016-
.into_iter()
1017-
.map(|h| Decoration {
1018-
range: h.range.conv_with(&line_index),
1019-
tag: h.highlight.to_string(),
1020-
binding_hash: h.binding_hash.map(|x| x.to_string()),
1021-
})
1022-
.collect();
1023-
Ok(res)
1024-
}
1025-
1026993
pub fn handle_inlay_hints(
1027994
world: WorldSnapshot,
1028995
params: InlayHintsParams,

crates/rust-analyzer/src/req.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Defines `rust-analyzer` specific custom messages.
22
3-
use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
3+
use lsp_types::{Location, Position, Range, TextDocumentIdentifier};
44
use rustc_hash::FxHashMap;
55
use serde::{Deserialize, Serialize};
66

@@ -86,36 +86,6 @@ pub struct FindMatchingBraceParams {
8686
pub offsets: Vec<Position>,
8787
}
8888

89-
pub enum DecorationsRequest {}
90-
91-
impl Request for DecorationsRequest {
92-
type Params = TextDocumentIdentifier;
93-
type Result = Vec<Decoration>;
94-
const METHOD: &'static str = "rust-analyzer/decorationsRequest";
95-
}
96-
97-
pub enum PublishDecorations {}
98-
99-
impl Notification for PublishDecorations {
100-
type Params = PublishDecorationsParams;
101-
const METHOD: &'static str = "rust-analyzer/publishDecorations";
102-
}
103-
104-
#[derive(Deserialize, Serialize, Debug)]
105-
#[serde(rename_all = "camelCase")]
106-
pub struct PublishDecorationsParams {
107-
pub uri: Url,
108-
pub decorations: Vec<Decoration>,
109-
}
110-
111-
#[derive(Deserialize, Serialize, Debug)]
112-
#[serde(rename_all = "camelCase")]
113-
pub struct Decoration {
114-
pub range: Range,
115-
pub tag: String,
116-
pub binding_hash: Option<String>,
117-
}
118-
11989
pub enum ParentModule {}
12090

12191
impl Request for ParentModule {

editors/code/package.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,6 @@
182182
"default": false,
183183
"description": "Use proposed semantic tokens API for syntax highlighting"
184184
},
185-
"rust-analyzer.highlightingOn": {
186-
"type": "boolean",
187-
"default": false,
188-
"description": "Highlight Rust code (overrides built-in syntax highlighting)"
189-
},
190-
"rust-analyzer.rainbowHighlightingOn": {
191-
"type": "boolean",
192-
"default": false,
193-
"description": "When highlighting Rust code, use a unique color per identifier"
194-
},
195185
"rust-analyzer.featureFlags": {
196186
"type": "object",
197187
"default": {},

editors/code/src/client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-
77

88
export function configToServerOptions(config: Config) {
99
return {
10-
publishDecorations: !config.highlightingSemanticTokens,
1110
lruCapacity: config.lruCapacity,
1211

1312
inlayHintsType: config.inlayHints.typeHints,

editors/code/src/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ export class Config {
7171
get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; }
7272
get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; }
7373
get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; }
74-
get highlightingOn() { return this.cfg.get<boolean>("highlightingOn")!; }
75-
get rainbowHighlightingOn() { return this.cfg.get<boolean>("rainbowHighlightingOn")!; }
7674
get lruCapacity() { return this.cfg.get<null | number>("lruCapacity")!; }
7775
get excludeGlobs() { return this.cfg.get<string[]>("excludeGlobs")!; }
7876
get useClientWatching() { return this.cfg.get<boolean>("useClientWatching")!; }

0 commit comments

Comments
 (0)