mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Do not add any new configuration parameters
This commit is contained in:
parent
3969c7c853
commit
4fb25ef43b
8 changed files with 12 additions and 57 deletions
|
@ -160,7 +160,7 @@ mod tests {
|
||||||
use crate::mock_analysis::single_file;
|
use crate::mock_analysis::single_file;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn default_generic_types_disabled() {
|
fn default_generic_types_should_not_be_displayed() {
|
||||||
let (analysis, file_id) = single_file(
|
let (analysis, file_id) = single_file(
|
||||||
r#"
|
r#"
|
||||||
struct Test<K, T = u8> {
|
struct Test<K, T = u8> {
|
||||||
|
@ -173,7 +173,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, false).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [69; 71),
|
range: [69; 71),
|
||||||
|
@ -185,32 +185,6 @@ fn main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn default_generic_types_enabled() {
|
|
||||||
let (analysis, file_id) = single_file(
|
|
||||||
r#"
|
|
||||||
struct Test<K, T = u8> {
|
|
||||||
k: K,
|
|
||||||
t: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let zz = Test { t: 23, k: 33 };
|
|
||||||
}"#,
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
|
||||||
[
|
|
||||||
InlayHint {
|
|
||||||
range: [69; 71),
|
|
||||||
kind: TypeHint,
|
|
||||||
label: "Test<i32, u8>",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
"###
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn let_statement() {
|
fn let_statement() {
|
||||||
let (analysis, file_id) = single_file(
|
let (analysis, file_id) = single_file(
|
||||||
|
@ -251,7 +225,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [193; 197),
|
range: [193; 197),
|
||||||
|
@ -325,7 +299,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [21; 30),
|
range: [21; 30),
|
||||||
|
@ -354,7 +328,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [21; 30),
|
range: [21; 30),
|
||||||
|
@ -402,7 +376,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [166; 170),
|
range: [166; 170),
|
||||||
|
@ -465,7 +439,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [166; 170),
|
range: [166; 170),
|
||||||
|
@ -528,7 +502,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, None, true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [311; 315),
|
range: [311; 315),
|
||||||
|
@ -570,7 +544,7 @@ fn main() {
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, Some(8), true).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, Some(8)).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [74; 75),
|
range: [74; 75),
|
||||||
|
|
|
@ -348,12 +348,9 @@ impl Analysis {
|
||||||
&self,
|
&self,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
max_inlay_hint_length: Option<usize>,
|
max_inlay_hint_length: Option<usize>,
|
||||||
show_default_types_in_inlay_hints: bool,
|
|
||||||
) -> Cancelable<Vec<InlayHint>> {
|
) -> Cancelable<Vec<InlayHint>> {
|
||||||
let truncate_options = hir::TruncateOptions {
|
let truncate_options =
|
||||||
max_length: max_inlay_hint_length,
|
hir::TruncateOptions { max_length: max_inlay_hint_length, show_default_types: false };
|
||||||
show_default_types: show_default_types_in_inlay_hints,
|
|
||||||
};
|
|
||||||
self.with_db(|db| {
|
self.with_db(|db| {
|
||||||
inlay_hints::inlay_hints(db, file_id, &db.parse(file_id).tree(), &truncate_options)
|
inlay_hints::inlay_hints(db, file_id, &db.parse(file_id).tree(), &truncate_options)
|
||||||
})
|
})
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub struct ServerConfig {
|
||||||
pub lru_capacity: Option<usize>,
|
pub lru_capacity: Option<usize>,
|
||||||
|
|
||||||
pub max_inlay_hint_length: Option<usize>,
|
pub max_inlay_hint_length: Option<usize>,
|
||||||
pub show_default_types_in_inlay_hints: bool,
|
|
||||||
|
|
||||||
/// For internal usage to make integrated tests faster.
|
/// For internal usage to make integrated tests faster.
|
||||||
#[serde(deserialize_with = "nullable_bool_true")]
|
#[serde(deserialize_with = "nullable_bool_true")]
|
||||||
|
@ -52,7 +51,6 @@ impl Default for ServerConfig {
|
||||||
use_client_watching: false,
|
use_client_watching: false,
|
||||||
lru_capacity: None,
|
lru_capacity: None,
|
||||||
max_inlay_hint_length: None,
|
max_inlay_hint_length: None,
|
||||||
show_default_types_in_inlay_hints: false,
|
|
||||||
with_sysroot: true,
|
with_sysroot: true,
|
||||||
feature_flags: FxHashMap::default(),
|
feature_flags: FxHashMap::default(),
|
||||||
cargo_features: Default::default(),
|
cargo_features: Default::default(),
|
||||||
|
|
|
@ -125,7 +125,6 @@ pub fn main_loop(
|
||||||
.and_then(|it| it.line_folding_only)
|
.and_then(|it| it.line_folding_only)
|
||||||
.unwrap_or(false),
|
.unwrap_or(false),
|
||||||
max_inlay_hint_length: config.max_inlay_hint_length,
|
max_inlay_hint_length: config.max_inlay_hint_length,
|
||||||
show_default_types_in_inlay_hints: config.show_default_types_in_inlay_hints,
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -895,11 +895,7 @@ pub fn handle_inlay_hints(
|
||||||
let analysis = world.analysis();
|
let analysis = world.analysis();
|
||||||
let line_index = analysis.file_line_index(file_id)?;
|
let line_index = analysis.file_line_index(file_id)?;
|
||||||
Ok(analysis
|
Ok(analysis
|
||||||
.inlay_hints(
|
.inlay_hints(file_id, world.options.max_inlay_hint_length)?
|
||||||
file_id,
|
|
||||||
world.options.max_inlay_hint_length,
|
|
||||||
world.options.show_default_types_in_inlay_hints,
|
|
||||||
)?
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|api_type| InlayHint {
|
.map(|api_type| InlayHint {
|
||||||
label: api_type.label.to_string(),
|
label: api_type.label.to_string(),
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub struct Options {
|
||||||
pub supports_location_link: bool,
|
pub supports_location_link: bool,
|
||||||
pub line_folding_only: bool,
|
pub line_folding_only: bool,
|
||||||
pub max_inlay_hint_length: Option<usize>,
|
pub max_inlay_hint_length: Option<usize>,
|
||||||
pub show_default_types_in_inlay_hints: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `WorldState` is the primary mutable state of the language server
|
/// `WorldState` is the primary mutable state of the language server
|
||||||
|
|
|
@ -30,7 +30,6 @@ export class Config {
|
||||||
public lruCapacity: null | number = null;
|
public lruCapacity: null | number = null;
|
||||||
public displayInlayHints = true;
|
public displayInlayHints = true;
|
||||||
public maxInlayHintLength: null | number = null;
|
public maxInlayHintLength: null | number = null;
|
||||||
public showDefaultTypesInInlayHints = false;
|
|
||||||
public excludeGlobs = [];
|
public excludeGlobs = [];
|
||||||
public useClientWatching = true;
|
public useClientWatching = true;
|
||||||
public featureFlags = {};
|
public featureFlags = {};
|
||||||
|
@ -154,11 +153,6 @@ export class Config {
|
||||||
'maxInlayHintLength',
|
'maxInlayHintLength',
|
||||||
) as number;
|
) as number;
|
||||||
}
|
}
|
||||||
if (config.has('showDefaultTypesInInlayHints')) {
|
|
||||||
this.showDefaultTypesInInlayHints = config.get(
|
|
||||||
'showDefaultTypesInInlayHints',
|
|
||||||
) as boolean;
|
|
||||||
}
|
|
||||||
if (config.has('excludeGlobs')) {
|
if (config.has('excludeGlobs')) {
|
||||||
this.excludeGlobs = config.get('excludeGlobs') || [];
|
this.excludeGlobs = config.get('excludeGlobs') || [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,6 @@ export class Server {
|
||||||
publishDecorations: true,
|
publishDecorations: true,
|
||||||
lruCapacity: Server.config.lruCapacity,
|
lruCapacity: Server.config.lruCapacity,
|
||||||
maxInlayHintLength: Server.config.maxInlayHintLength,
|
maxInlayHintLength: Server.config.maxInlayHintLength,
|
||||||
showDefaultTypesInInlayHints:
|
|
||||||
Server.config.showDefaultTypesInInlayHints,
|
|
||||||
excludeGlobs: Server.config.excludeGlobs,
|
excludeGlobs: Server.config.excludeGlobs,
|
||||||
useClientWatching: Server.config.useClientWatching,
|
useClientWatching: Server.config.useClientWatching,
|
||||||
featureFlags: Server.config.featureFlags,
|
featureFlags: Server.config.featureFlags,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue