Skip to content

Commit

Permalink
rename use-related actions
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri authored and lpil committed Feb 12, 2025
1 parent 67edda0 commit eb3dbaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
17 changes: 9 additions & 8 deletions compiler-core/src/language_server/code_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2190,16 +2190,17 @@ pub fn code_action_convert_unqualified_constructor_to_qualified(
actions.extend(new_actions);
}

/// Builder for code action to apply the desugar use expression.
/// Builder for code action to apply the convert from use action, turning a use
/// expression into a regular function call.
///
pub struct DesugarUse<'a> {
pub struct ConvertFromUse<'a> {
module: &'a Module,
params: &'a CodeActionParams,
edits: TextEdits<'a>,
selected_use: Option<&'a TypedUse>,
}

impl<'a> DesugarUse<'a> {
impl<'a> ConvertFromUse<'a> {
pub fn new(
module: &'a Module,
line_numbers: &'a LineNumbers,
Expand Down Expand Up @@ -2381,7 +2382,7 @@ impl<'a> DesugarUse<'a> {
}
}

impl<'ast> ast::visit::Visit<'ast> for DesugarUse<'ast> {
impl<'ast> ast::visit::Visit<'ast> for ConvertFromUse<'ast> {
fn visit_typed_use(&mut self, use_: &'ast TypedUse) {
// We only want to take into account the innermost use we find ourselves
// into, so we can't stop at the first use we find (the outermost one)
Expand Down Expand Up @@ -2414,9 +2415,9 @@ impl<'ast> ast::visit::Visit<'ast> for DesugarUse<'ast> {
}
}

/// Builder for code action to apply the turn into use expression.
/// Builder for code action to apply the convert to use action.
///
pub struct TurnIntoUse<'a> {
pub struct ConvertToUse<'a> {
module: &'a Module,
params: &'a CodeActionParams,
edits: TextEdits<'a>,
Expand All @@ -2434,7 +2435,7 @@ struct CallLocations {
callback_body_span: SrcSpan,
}

impl<'a> TurnIntoUse<'a> {
impl<'a> ConvertToUse<'a> {
pub fn new(
module: &'a Module,
line_numbers: &'a LineNumbers,
Expand Down Expand Up @@ -2533,7 +2534,7 @@ impl<'a> TurnIntoUse<'a> {
}
}

impl<'ast> ast::visit::Visit<'ast> for TurnIntoUse<'ast> {
impl<'ast> ast::visit::Visit<'ast> for ConvertToUse<'ast> {
fn visit_typed_function(&mut self, fun: &'ast ast::TypedFunction) {
// The cursor has to be inside the last statement of the function to
// offer the code action.
Expand Down
11 changes: 5 additions & 6 deletions compiler-core/src/language_server/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ use super::{
code_action::{
code_action_add_missing_patterns, code_action_convert_qualified_constructor_to_unqualified,
code_action_convert_unqualified_constructor_to_qualified, code_action_import_module,
code_action_inexhaustive_let_to_case, AddAnnotations, CodeActionBuilder,
ConvertToFunctionCall, DesugarUse, ExpandFunctionCapture, ExtractVariable,
code_action_inexhaustive_let_to_case, AddAnnotations, CodeActionBuilder, ConvertFromUse,
ConvertToFunctionCall, ConvertToUse, ExpandFunctionCapture, ExtractVariable,
FillInMissingLabelledArgs, GenerateDynamicDecoder, GenerateFunction, GenerateJsonEncoder,
LetAssertToCase, PatternMatchOnValue, RedundantTupleInCaseSubject, TurnIntoUse,
UseLabelShorthandSyntax,
LetAssertToCase, PatternMatchOnValue, RedundantTupleInCaseSubject, UseLabelShorthandSyntax,
},
completer::Completer,
rename::{rename_local_variable, VariableRenameKind},
Expand Down Expand Up @@ -334,8 +333,8 @@ where
.extend(RedundantTupleInCaseSubject::new(module, &lines, &params).code_actions());
actions.extend(UseLabelShorthandSyntax::new(module, &lines, &params).code_actions());
actions.extend(FillInMissingLabelledArgs::new(module, &lines, &params).code_actions());
actions.extend(DesugarUse::new(module, &lines, &params).code_actions());
actions.extend(TurnIntoUse::new(module, &lines, &params).code_actions());
actions.extend(ConvertFromUse::new(module, &lines, &params).code_actions());
actions.extend(ConvertToUse::new(module, &lines, &params).code_actions());
actions.extend(ExpandFunctionCapture::new(module, &lines, &params).code_actions());
actions.extend(ExtractVariable::new(module, &lines, &params).code_actions());
actions.extend(GenerateFunction::new(module, &lines, &params).code_actions());
Expand Down

0 comments on commit eb3dbaf

Please sign in to comment.