Skip to content

Commit f7c53a2

Browse files
Revert "Prepare for omittiong parts of completion data that need to be resolved"
This reverts commit 008d513.
1 parent 4cda576 commit f7c53a2

File tree

10 files changed

+16
-99
lines changed

10 files changed

+16
-99
lines changed

src/tools/rust-analyzer/crates/ide-completion/src/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use hir::ImportPathConfig;
88
use ide_db::{imports::insert_use::InsertUseConfig, SnippetCap};
99

10-
use crate::{snippet::Snippet, CompletionFieldsToResolve};
10+
use crate::snippet::Snippet;
1111

1212
#[derive(Clone, Debug, PartialEq, Eq)]
1313
pub struct CompletionConfig {
@@ -27,7 +27,6 @@ pub struct CompletionConfig {
2727
pub prefer_absolute: bool,
2828
pub snippets: Vec<Snippet>,
2929
pub limit: Option<usize>,
30-
pub fields_to_resolve: CompletionFieldsToResolve,
3130
}
3231

3332
#[derive(Clone, Debug, PartialEq, Eq)]

src/tools/rust-analyzer/crates/ide-completion/src/lib.rs

-29
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,6 @@ pub use crate::{
3737
snippet::{Snippet, SnippetScope},
3838
};
3939

40-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
41-
pub struct CompletionFieldsToResolve {
42-
pub resolve_label_details: bool,
43-
pub resolve_tags: bool,
44-
pub resolve_detail: bool,
45-
pub resolve_documentation: bool,
46-
pub resolve_sort_text: bool,
47-
pub resolve_filter_text: bool,
48-
pub resolve_text_edit: bool,
49-
// FIXME: those are always resolved
50-
// pub resolve_additional_text_edits: bool,
51-
pub resolve_command: bool,
52-
}
53-
54-
impl CompletionFieldsToResolve {
55-
pub const fn empty() -> Self {
56-
Self {
57-
resolve_label_details: false,
58-
resolve_tags: false,
59-
resolve_detail: false,
60-
resolve_documentation: false,
61-
resolve_sort_text: false,
62-
resolve_filter_text: false,
63-
resolve_text_edit: false,
64-
resolve_command: false,
65-
}
66-
}
67-
}
68-
6940
//FIXME: split the following feature into fine-grained features.
7041

7142
// Feature: Magic Completions

src/tools/rust-analyzer/crates/ide-completion/src/tests.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ use test_fixture::ChangeFixture;
3737
use test_utils::assert_eq_text;
3838

3939
use crate::{
40-
resolve_completion_edits, CallableSnippets, CompletionConfig, CompletionFieldsToResolve,
41-
CompletionItem, CompletionItemKind,
40+
resolve_completion_edits, CallableSnippets, CompletionConfig, CompletionItem,
41+
CompletionItemKind,
4242
};
4343

4444
/// Lots of basic item definitions
@@ -84,7 +84,6 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
8484
prefer_absolute: false,
8585
snippets: Vec::new(),
8686
limit: None,
87-
fields_to_resolve: CompletionFieldsToResolve::empty(),
8887
};
8988

9089
pub(crate) fn completion_list(ra_fixture: &str) -> String {

src/tools/rust-analyzer/crates/ide/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ pub use ide_assists::{
119119
Assist, AssistConfig, AssistId, AssistKind, AssistResolveStrategy, SingleResolve,
120120
};
121121
pub use ide_completion::{
122-
CallableSnippets, CompletionConfig, CompletionFieldsToResolve, CompletionItem,
123-
CompletionItemKind, CompletionRelevance, Snippet, SnippetScope,
122+
CallableSnippets, CompletionConfig, CompletionItem, CompletionItemKind, CompletionRelevance,
123+
Snippet, SnippetScope,
124124
};
125125
pub use ide_db::{
126126
base_db::{Cancelled, CrateGraph, CrateId, FileChange, SourceRoot, SourceRootId},

src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use std::{
1212
use cfg::{CfgAtom, CfgDiff};
1313
use hir::Symbol;
1414
use ide::{
15-
AssistConfig, CallableSnippets, CompletionConfig, CompletionFieldsToResolve, DiagnosticsConfig,
16-
ExprFillDefaultMode, GenericParameterHints, HighlightConfig, HighlightRelatedConfig,
17-
HoverConfig, HoverDocFormat, InlayFieldsToResolve, InlayHintsConfig, JoinLinesConfig,
18-
MemoryLayoutHoverConfig, MemoryLayoutHoverRenderKind, Snippet, SnippetScope, SourceRootId,
15+
AssistConfig, CallableSnippets, CompletionConfig, DiagnosticsConfig, ExprFillDefaultMode,
16+
GenericParameterHints, HighlightConfig, HighlightRelatedConfig, HoverConfig, HoverDocFormat,
17+
InlayFieldsToResolve, InlayHintsConfig, JoinLinesConfig, MemoryLayoutHoverConfig,
18+
MemoryLayoutHoverRenderKind, Snippet, SnippetScope, SourceRootId,
1919
};
2020
use ide_db::{
2121
imports::insert_use::{ImportGranularity, InsertUseConfig, PrefixKind},
@@ -1393,7 +1393,6 @@ impl Config {
13931393
}
13941394

13951395
pub fn completion(&self, source_root: Option<SourceRootId>) -> CompletionConfig {
1396-
let client_capability_fields = self.completion_resolve_support_properties();
13971396
CompletionConfig {
13981397
enable_postfix_completions: self.completion_postfix_enable(source_root).to_owned(),
13991398
enable_imports_on_the_fly: self.completion_autoimport_enable(source_root).to_owned()
@@ -1418,16 +1417,6 @@ impl Config {
14181417
limit: self.completion_limit(source_root).to_owned(),
14191418
enable_term_search: self.completion_termSearch_enable(source_root).to_owned(),
14201419
term_search_fuel: self.completion_termSearch_fuel(source_root).to_owned() as u64,
1421-
fields_to_resolve: CompletionFieldsToResolve {
1422-
resolve_label_details: client_capability_fields.contains("labelDetails"),
1423-
resolve_tags: client_capability_fields.contains("tags"),
1424-
resolve_detail: client_capability_fields.contains("detail"),
1425-
resolve_documentation: client_capability_fields.contains("documentation"),
1426-
resolve_sort_text: client_capability_fields.contains("sortText"),
1427-
resolve_filter_text: client_capability_fields.contains("filterText"),
1428-
resolve_text_edit: client_capability_fields.contains("textEdit"),
1429-
resolve_command: client_capability_fields.contains("command"),
1430-
},
14311420
}
14321421
}
14331422

src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1019,11 +1019,9 @@ pub(crate) fn handle_completion(
10191019

10201020
let items = to_proto::completion_items(
10211021
&snap.config,
1022-
&completion_config.fields_to_resolve,
10231022
&line_index,
10241023
snap.file_version(position.file_id),
10251024
text_document_position,
1026-
completion_trigger_character,
10271025
items,
10281026
);
10291027

src/tools/rust-analyzer/crates/rust-analyzer/src/integrated_benchmarks.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
1313
use hir::ChangeWithProcMacros;
1414
use ide::{
15-
AnalysisHost, CallableSnippets, CompletionConfig, CompletionFieldsToResolve, DiagnosticsConfig,
16-
FilePosition, TextSize,
15+
AnalysisHost, CallableSnippets, CompletionConfig, DiagnosticsConfig, FilePosition, TextSize,
1716
};
1817
use ide_db::{
1918
imports::insert_use::{ImportGranularity, InsertUseConfig},
@@ -173,7 +172,6 @@ fn integrated_completion_benchmark() {
173172
snippets: Vec::new(),
174173
limit: None,
175174
add_semicolon_to_unit: true,
176-
fields_to_resolve: CompletionFieldsToResolve::empty(),
177175
};
178176
let position =
179177
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
@@ -221,7 +219,6 @@ fn integrated_completion_benchmark() {
221219
snippets: Vec::new(),
222220
limit: None,
223221
add_semicolon_to_unit: true,
224-
fields_to_resolve: CompletionFieldsToResolve::empty(),
225222
};
226223
let position =
227224
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
@@ -267,7 +264,6 @@ fn integrated_completion_benchmark() {
267264
snippets: Vec::new(),
268265
limit: None,
269266
add_semicolon_to_unit: true,
270-
fields_to_resolve: CompletionFieldsToResolve::empty(),
271267
};
272268
let position =
273269
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };

src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/capabilities.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,7 @@ impl ClientCapabilities {
458458
.into_iter()
459459
.flatten()
460460
.cloned()
461-
.collect()
462-
}
463-
464-
pub fn completion_resolve_support_properties(&self) -> FxHashSet<String> {
465-
self.0
466-
.text_document
467-
.as_ref()
468-
.and_then(|text| text.completion.as_ref())
469-
.and_then(|completion_caps| completion_caps.completion_item.as_ref())
470-
.and_then(|completion_item_caps| completion_item_caps.resolve_support.as_ref())
471-
.map(|resolve_support| resolve_support.properties.iter())
472-
.into_iter()
473-
.flatten()
474-
.cloned()
475-
.collect()
461+
.collect::<FxHashSet<_>>()
476462
}
477463

478464
pub fn hover_markdown_support(&self) -> bool {

src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs

-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ pub struct CompletionResolveData {
825825
pub position: lsp_types::TextDocumentPositionParams,
826826
pub imports: Vec<CompletionImport>,
827827
pub version: Option<i32>,
828-
pub completion_trigger_character: Option<char>,
829828
}
830829

831830
#[derive(Debug, Serialize, Deserialize)]

src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs

+5-25
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::{
66
};
77

88
use ide::{
9-
Annotation, AnnotationKind, Assist, AssistKind, Cancellable, CompletionFieldsToResolve,
10-
CompletionItem, CompletionItemKind, CompletionRelevance, Documentation, FileId, FileRange,
11-
FileSystemEdit, Fold, FoldKind, Highlight, HlMod, HlOperator, HlPunct, HlRange, HlTag, Indel,
9+
Annotation, AnnotationKind, Assist, AssistKind, Cancellable, CompletionItem,
10+
CompletionItemKind, CompletionRelevance, Documentation, FileId, FileRange, FileSystemEdit,
11+
Fold, FoldKind, Highlight, HlMod, HlOperator, HlPunct, HlRange, HlTag, Indel,
1212
InlayFieldsToResolve, InlayHint, InlayHintLabel, InlayHintLabelPart, InlayKind, Markup,
1313
NavigationTarget, ReferenceCategory, RenameError, Runnable, Severity, SignatureHelp,
1414
SnippetEdit, SourceChange, StructureNodeKind, SymbolKind, TextEdit, TextRange, TextSize,
@@ -227,11 +227,9 @@ pub(crate) fn snippet_text_edit_vec(
227227

228228
pub(crate) fn completion_items(
229229
config: &Config,
230-
fields_to_resolve: &CompletionFieldsToResolve,
231230
line_index: &LineIndex,
232231
version: Option<i32>,
233232
tdpp: lsp_types::TextDocumentPositionParams,
234-
completion_trigger_character: Option<char>,
235233
mut items: Vec<CompletionItem>,
236234
) -> Vec<lsp_types::CompletionItem> {
237235
if config.completion_hide_deprecated() {
@@ -241,17 +239,7 @@ pub(crate) fn completion_items(
241239
let max_relevance = items.iter().map(|it| it.relevance.score()).max().unwrap_or_default();
242240
let mut res = Vec::with_capacity(items.len());
243241
for item in items {
244-
completion_item(
245-
&mut res,
246-
config,
247-
fields_to_resolve,
248-
line_index,
249-
version,
250-
&tdpp,
251-
max_relevance,
252-
completion_trigger_character,
253-
item,
254-
);
242+
completion_item(&mut res, config, line_index, version, &tdpp, max_relevance, item);
255243
}
256244

257245
if let Some(limit) = config.completion(None).limit {
@@ -265,20 +253,17 @@ pub(crate) fn completion_items(
265253
fn completion_item(
266254
acc: &mut Vec<lsp_types::CompletionItem>,
267255
config: &Config,
268-
fields_to_resolve: &CompletionFieldsToResolve,
269256
line_index: &LineIndex,
270257
version: Option<i32>,
271258
tdpp: &lsp_types::TextDocumentPositionParams,
272259
max_relevance: u32,
273-
completion_trigger_character: Option<char>,
274260
item: CompletionItem,
275261
) {
276262
let insert_replace_support = config.insert_replace_support().then_some(tdpp.position);
277263
let ref_match = item.ref_match();
278264
let lookup = item.lookup().to_owned();
279265

280266
let mut additional_text_edits = Vec::new();
281-
let mut something_to_resolve = false;
282267

283268
// LSP does not allow arbitrary edits in completion, so we have to do a
284269
// non-trivial mapping here.
@@ -352,12 +337,7 @@ fn completion_item(
352337
})
353338
.collect::<Vec<_>>();
354339
if !imports.is_empty() {
355-
let data = lsp_ext::CompletionResolveData {
356-
position: tdpp.clone(),
357-
imports,
358-
version,
359-
completion_trigger_character,
360-
};
340+
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports, version };
361341
lsp_item.data = Some(to_value(data).unwrap());
362342
}
363343
}

0 commit comments

Comments
 (0)