mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Reorder CompletionContext fields
This commit is contained in:
parent
8b6c3eaaeb
commit
aa29364f83
2 changed files with 15 additions and 18 deletions
|
@ -67,14 +67,13 @@ pub(crate) struct CompletionContext<'a> {
|
||||||
pub(super) krate: Option<hir::Crate>,
|
pub(super) krate: Option<hir::Crate>,
|
||||||
pub(super) expected_name: Option<NameOrNameRef>,
|
pub(super) expected_name: Option<NameOrNameRef>,
|
||||||
pub(super) expected_type: Option<Type>,
|
pub(super) expected_type: Option<Type>,
|
||||||
pub(super) name_ref_syntax: Option<ast::NameRef>,
|
|
||||||
|
|
||||||
pub(super) use_item_syntax: Option<ast::Use>,
|
|
||||||
|
|
||||||
/// The parent function of the cursor position if it exists.
|
/// The parent function of the cursor position if it exists.
|
||||||
pub(super) function_def: Option<ast::Fn>,
|
pub(super) function_def: Option<ast::Fn>,
|
||||||
/// The parent impl of the cursor position if it exists.
|
/// The parent impl of the cursor position if it exists.
|
||||||
pub(super) impl_def: Option<ast::Impl>,
|
pub(super) impl_def: Option<ast::Impl>,
|
||||||
|
pub(super) name_ref_syntax: Option<ast::NameRef>,
|
||||||
|
pub(super) use_item_syntax: Option<ast::Use>,
|
||||||
|
|
||||||
// potentially set if we are completing a lifetime
|
// potentially set if we are completing a lifetime
|
||||||
pub(super) lifetime_syntax: Option<ast::Lifetime>,
|
pub(super) lifetime_syntax: Option<ast::Lifetime>,
|
||||||
|
@ -89,13 +88,12 @@ pub(crate) struct CompletionContext<'a> {
|
||||||
pub(super) completion_location: Option<ImmediateLocation>,
|
pub(super) completion_location: Option<ImmediateLocation>,
|
||||||
pub(super) prev_sibling: Option<ImmediatePrevSibling>,
|
pub(super) prev_sibling: Option<ImmediatePrevSibling>,
|
||||||
pub(super) attribute_under_caret: Option<ast::Attr>,
|
pub(super) attribute_under_caret: Option<ast::Attr>,
|
||||||
|
pub(super) previous_token: Option<SyntaxToken>,
|
||||||
|
|
||||||
pub(super) path_context: Option<PathCompletionContext>,
|
pub(super) path_context: Option<PathCompletionContext>,
|
||||||
/// FIXME: `ActiveParameter` is string-based, which is very very wrong
|
|
||||||
pub(super) active_parameter: Option<ActiveParameter>,
|
pub(super) active_parameter: Option<ActiveParameter>,
|
||||||
pub(super) locals: Vec<(String, Local)>,
|
pub(super) locals: Vec<(String, Local)>,
|
||||||
|
|
||||||
pub(super) previous_token: Option<SyntaxToken>,
|
|
||||||
pub(super) in_loop_body: bool,
|
pub(super) in_loop_body: bool,
|
||||||
pub(super) incomplete_let: bool,
|
pub(super) incomplete_let: bool,
|
||||||
|
|
||||||
|
@ -143,28 +141,28 @@ impl<'a> CompletionContext<'a> {
|
||||||
original_token,
|
original_token,
|
||||||
token,
|
token,
|
||||||
krate,
|
krate,
|
||||||
lifetime_allowed: false,
|
|
||||||
expected_name: None,
|
expected_name: None,
|
||||||
expected_type: None,
|
expected_type: None,
|
||||||
|
function_def: None,
|
||||||
|
impl_def: None,
|
||||||
name_ref_syntax: None,
|
name_ref_syntax: None,
|
||||||
|
use_item_syntax: None,
|
||||||
lifetime_syntax: None,
|
lifetime_syntax: None,
|
||||||
lifetime_param_syntax: None,
|
lifetime_param_syntax: None,
|
||||||
function_def: None,
|
lifetime_allowed: false,
|
||||||
use_item_syntax: None,
|
|
||||||
impl_def: None,
|
|
||||||
active_parameter: ActiveParameter::at(db, position),
|
|
||||||
is_label_ref: false,
|
is_label_ref: false,
|
||||||
is_param: false,
|
|
||||||
is_pat_or_const: None,
|
is_pat_or_const: None,
|
||||||
path_context: None,
|
is_param: false,
|
||||||
previous_token: None,
|
|
||||||
in_loop_body: false,
|
|
||||||
completion_location: None,
|
completion_location: None,
|
||||||
prev_sibling: None,
|
prev_sibling: None,
|
||||||
no_completion_required: false,
|
|
||||||
incomplete_let: false,
|
|
||||||
attribute_under_caret: None,
|
attribute_under_caret: None,
|
||||||
|
previous_token: None,
|
||||||
|
path_context: None,
|
||||||
|
active_parameter: ActiveParameter::at(db, position),
|
||||||
locals,
|
locals,
|
||||||
|
in_loop_body: false,
|
||||||
|
incomplete_let: false,
|
||||||
|
no_completion_required: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut original_file = original_file.syntax().clone();
|
let mut original_file = original_file.syntax().clone();
|
||||||
|
|
|
@ -223,9 +223,8 @@ impl FnCallNode {
|
||||||
ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?,
|
ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
FnCallNode::MethodCallExpr(call_expr) => {
|
FnCallNode::MethodCallExpr(call_expr) => {
|
||||||
call_expr.syntax().children().filter_map(ast::NameRef::cast).next()
|
call_expr.syntax().children().find_map(ast::NameRef::cast)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue