mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Make naming more uniform
This commit is contained in:
parent
d98a5fab46
commit
fd3ece2b73
@ -75,9 +75,9 @@ impl Default for CompletionOptions {
|
|||||||
pub(crate) fn completions(
|
pub(crate) fn completions(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
opts: &CompletionOptions,
|
options: &CompletionOptions,
|
||||||
) -> Option<Completions> {
|
) -> Option<Completions> {
|
||||||
let ctx = CompletionContext::new(db, position, opts)?;
|
let ctx = CompletionContext::new(db, position, options)?;
|
||||||
|
|
||||||
let mut acc = Completions::default();
|
let mut acc = Completions::default();
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ use ra_syntax::{
|
|||||||
use crate::{FileId, FunctionSignature};
|
use crate::{FileId, FunctionSignature};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct InlayConfig {
|
pub struct InlayHintsOptions {
|
||||||
pub type_hints: bool,
|
pub type_hints: bool,
|
||||||
pub parameter_hints: bool,
|
pub parameter_hints: bool,
|
||||||
pub max_length: Option<usize>,
|
pub max_length: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for InlayConfig {
|
impl Default for InlayHintsOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { type_hints: true, parameter_hints: true, max_length: None }
|
Self { type_hints: true, parameter_hints: true, max_length: None }
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ pub struct InlayHint {
|
|||||||
pub(crate) fn inlay_hints(
|
pub(crate) fn inlay_hints(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
inlay_hint_opts: &InlayConfig,
|
options: &InlayHintsOptions,
|
||||||
) -> Vec<InlayHint> {
|
) -> Vec<InlayHint> {
|
||||||
let _p = profile("inlay_hints");
|
let _p = profile("inlay_hints");
|
||||||
let sema = Semantics::new(db);
|
let sema = Semantics::new(db);
|
||||||
@ -49,9 +49,9 @@ pub(crate) fn inlay_hints(
|
|||||||
for node in file.syntax().descendants() {
|
for node in file.syntax().descendants() {
|
||||||
match_ast! {
|
match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, inlay_hint_opts, ast::Expr::from(it)); },
|
ast::CallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); },
|
||||||
ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, inlay_hint_opts, ast::Expr::from(it)); },
|
ast::MethodCallExpr(it) => { get_param_name_hints(&mut res, &sema, options, ast::Expr::from(it)); },
|
||||||
ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, inlay_hint_opts, it); },
|
ast::BindPat(it) => { get_bind_pat_hints(&mut res, &sema, options, it); },
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,10 +62,10 @@ pub(crate) fn inlay_hints(
|
|||||||
fn get_param_name_hints(
|
fn get_param_name_hints(
|
||||||
acc: &mut Vec<InlayHint>,
|
acc: &mut Vec<InlayHint>,
|
||||||
sema: &Semantics<RootDatabase>,
|
sema: &Semantics<RootDatabase>,
|
||||||
inlay_hint_opts: &InlayConfig,
|
options: &InlayHintsOptions,
|
||||||
expr: ast::Expr,
|
expr: ast::Expr,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
if !inlay_hint_opts.parameter_hints {
|
if !options.parameter_hints {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +102,10 @@ fn get_param_name_hints(
|
|||||||
fn get_bind_pat_hints(
|
fn get_bind_pat_hints(
|
||||||
acc: &mut Vec<InlayHint>,
|
acc: &mut Vec<InlayHint>,
|
||||||
sema: &Semantics<RootDatabase>,
|
sema: &Semantics<RootDatabase>,
|
||||||
inlay_hint_opts: &InlayConfig,
|
options: &InlayHintsOptions,
|
||||||
pat: ast::BindPat,
|
pat: ast::BindPat,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
if !inlay_hint_opts.type_hints {
|
if !options.type_hints {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ fn get_bind_pat_hints(
|
|||||||
acc.push(InlayHint {
|
acc.push(InlayHint {
|
||||||
range: pat.syntax().text_range(),
|
range: pat.syntax().text_range(),
|
||||||
kind: InlayKind::TypeHint,
|
kind: InlayKind::TypeHint,
|
||||||
label: ty.display_truncated(sema.db, inlay_hint_opts.max_length).to_string().into(),
|
label: ty.display_truncated(sema.db, options.max_length).to_string().into(),
|
||||||
});
|
});
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ fn get_fn_signature(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::inlay_hints::InlayConfig;
|
use crate::inlay_hints::InlayHintsOptions;
|
||||||
use insta::assert_debug_snapshot;
|
use insta::assert_debug_snapshot;
|
||||||
|
|
||||||
use crate::mock_analysis::single_file;
|
use crate::mock_analysis::single_file;
|
||||||
@ -238,7 +238,7 @@ mod tests {
|
|||||||
let _x = foo(4, 4);
|
let _x = foo(4, 4);
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ parameter_hints: true, type_hints: false, max_length: None}).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: true, type_hints: false, max_length: None}).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [106; 107),
|
range: [106; 107),
|
||||||
@ -262,7 +262,7 @@ mod tests {
|
|||||||
let _x = foo(4, 4);
|
let _x = foo(4, 4);
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ type_hints: false, parameter_hints: false, max_length: None}).unwrap(), @r###"[]"###);
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: false, parameter_hints: false, max_length: None}).unwrap(), @r###"[]"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -274,7 +274,7 @@ mod tests {
|
|||||||
let _x = foo(4, 4);
|
let _x = foo(4, 4);
|
||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig{ type_hints: true, parameter_hints: false, max_length: None}).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ type_hints: true, parameter_hints: false, max_length: None}).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [97; 99),
|
range: [97; 99),
|
||||||
@ -298,7 +298,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [69; 71),
|
range: [69; 71),
|
||||||
@ -355,7 +355,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [193; 197),
|
range: [193; 197),
|
||||||
@ -435,7 +435,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [21; 30),
|
range: [21; 30),
|
||||||
@ -499,7 +499,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [21; 30),
|
range: [21; 30),
|
||||||
@ -549,7 +549,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [188; 192),
|
range: [188; 192),
|
||||||
@ -644,7 +644,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [188; 192),
|
range: [188; 192),
|
||||||
@ -739,7 +739,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [252; 256),
|
range: [252; 256),
|
||||||
@ -811,7 +811,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [74; 75),
|
range: [74; 75),
|
||||||
@ -899,7 +899,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig::default()).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions::default()).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [798; 809),
|
range: [798; 809),
|
||||||
@ -1021,7 +1021,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
|
||||||
[]
|
[]
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
@ -1047,7 +1047,7 @@ fn main() {
|
|||||||
}"#,
|
}"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions { max_length: Some(8), ..Default::default() }).unwrap(), @r###"
|
||||||
[]
|
[]
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
@ -68,7 +68,7 @@ pub use crate::{
|
|||||||
expand_macro::ExpandedMacro,
|
expand_macro::ExpandedMacro,
|
||||||
folding_ranges::{Fold, FoldKind},
|
folding_ranges::{Fold, FoldKind},
|
||||||
hover::HoverResult,
|
hover::HoverResult,
|
||||||
inlay_hints::{InlayConfig, InlayHint, InlayKind},
|
inlay_hints::{InlayHint, InlayHintsOptions, InlayKind},
|
||||||
references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult},
|
references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult},
|
||||||
runnables::{Runnable, RunnableKind, TestId},
|
runnables::{Runnable, RunnableKind, TestId},
|
||||||
source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
|
source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
|
||||||
@ -319,7 +319,7 @@ impl Analysis {
|
|||||||
pub fn inlay_hints(
|
pub fn inlay_hints(
|
||||||
&self,
|
&self,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
inlay_hint_opts: &InlayConfig,
|
inlay_hint_opts: &InlayHintsOptions,
|
||||||
) -> Cancelable<Vec<InlayHint>> {
|
) -> Cancelable<Vec<InlayHint>> {
|
||||||
self.with_db(|db| inlay_hints::inlay_hints(db, file_id, inlay_hint_opts))
|
self.with_db(|db| inlay_hints::inlay_hints(db, file_id, inlay_hint_opts))
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//! tweak things like automatic insertion of `()` in completions.
|
//! tweak things like automatic insertion of `()` in completions.
|
||||||
|
|
||||||
use crate::req::InlayConfigDef;
|
use crate::req::InlayConfigDef;
|
||||||
use ra_ide::InlayConfig;
|
use ra_ide::InlayHintsOptions;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ra_project_model::CargoFeatures;
|
use ra_project_model::CargoFeatures;
|
||||||
@ -33,7 +33,7 @@ pub struct ServerConfig {
|
|||||||
pub lru_capacity: Option<usize>,
|
pub lru_capacity: Option<usize>,
|
||||||
|
|
||||||
#[serde(with = "InlayConfigDef")]
|
#[serde(with = "InlayConfigDef")]
|
||||||
pub inlay_hints: InlayConfig,
|
pub inlay_hints: InlayHintsOptions,
|
||||||
|
|
||||||
pub cargo_watch_enable: bool,
|
pub cargo_watch_enable: bool,
|
||||||
pub cargo_watch_args: Vec<String>,
|
pub cargo_watch_args: Vec<String>,
|
||||||
|
@ -4,7 +4,7 @@ use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
|
|||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use ra_ide::{InlayConfig, InlayKind};
|
use ra_ide::{InlayHintsOptions, InlayKind};
|
||||||
|
|
||||||
pub use lsp_types::{
|
pub use lsp_types::{
|
||||||
notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
|
notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
|
||||||
|
@ -13,7 +13,7 @@ use lsp_types::Url;
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckWatcher};
|
use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckWatcher};
|
||||||
use ra_ide::{
|
use ra_ide::{
|
||||||
Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayConfig, LibraryData,
|
Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayHintsOptions, LibraryData,
|
||||||
SourceRootId,
|
SourceRootId,
|
||||||
};
|
};
|
||||||
use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace};
|
use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace};
|
||||||
@ -35,7 +35,7 @@ pub struct Options {
|
|||||||
pub publish_decorations: bool,
|
pub publish_decorations: bool,
|
||||||
pub supports_location_link: bool,
|
pub supports_location_link: bool,
|
||||||
pub line_folding_only: bool,
|
pub line_folding_only: bool,
|
||||||
pub inlay_hints: InlayConfig,
|
pub inlay_hints: InlayHintsOptions,
|
||||||
pub rustfmt_args: Vec<String>,
|
pub rustfmt_args: Vec<String>,
|
||||||
pub cargo_watch: CheckOptions,
|
pub cargo_watch: CheckOptions,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user