Skip to content

Commit 5d22ff4

Browse files
ankddevlpil
authored andcommitted
refactor: rename code action
1 parent 6723eab commit 5d22ff4

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,13 @@
307307
}
308308
309309
pub fn add_one(thing) {
310-
// ^ Triggering "Annotate all top level type definitions" code action here
310+
// ^ Triggering "Annotate all top level definitions" code action here
311311
let result = add(thing, 1)
312312
result
313313
}
314314
```
315315

316-
Triggering the "Annotate all top level type definitions" code action over
316+
Triggering the "Annotate all top level definitions" code action over
317317
the name of function `add_one` would result in following code:
318318

319319
```gleam

compiler-core/src/language_server/code_action.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,15 +1363,15 @@ impl<'a> AddAnnotations<'a> {
13631363

13641364
/// Code action to add type annotations to all top level definitions
13651365
///
1366-
pub struct AnnotateTopLevelTypeDefinitions<'a> {
1366+
pub struct AnnotateTopLevelDefinitions<'a> {
13671367
module: &'a Module,
13681368
params: &'a CodeActionParams,
13691369
edits: TextEdits<'a>,
13701370
printer: Printer<'a>,
13711371
is_hovering_definition: bool,
13721372
}
13731373

1374-
impl<'a> AnnotateTopLevelTypeDefinitions<'a> {
1374+
impl<'a> AnnotateTopLevelDefinitions<'a> {
13751375
pub fn new(
13761376
module: &'a Module,
13771377
line_numbers: &'a LineNumbers,
@@ -1398,7 +1398,7 @@ impl<'a> AnnotateTopLevelTypeDefinitions<'a> {
13981398
};
13991399

14001400
let mut action = Vec::with_capacity(1);
1401-
CodeActionBuilder::new("Annotate all top level type definitions")
1401+
CodeActionBuilder::new("Annotate all top level definitions")
14021402
.kind(CodeActionKind::REFACTOR_REWRITE)
14031403
.changes(self.params.text_document.uri.clone(), self.edits.edits)
14041404
.preferred(false)
@@ -1407,7 +1407,7 @@ impl<'a> AnnotateTopLevelTypeDefinitions<'a> {
14071407
}
14081408
}
14091409

1410-
impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelTypeDefinitions<'_> {
1410+
impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelDefinitions<'_> {
14111411
fn visit_typed_module_constant(&mut self, constant: &'ast TypedModuleConstant) {
14121412
// Since type variable names are local to definitions, any type variables
14131413
// in other parts of the module shouldn't affect what we print for the

compiler-core/src/language_server/engine.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use std::{collections::HashSet, sync::Arc};
4545
use super::{
4646
DownloadDependencies, MakeLocker,
4747
code_action::{
48-
AddAnnotations, AnnotateTopLevelTypeDefinitions, CodeActionBuilder, ConvertFromUse,
48+
AddAnnotations, AnnotateTopLevelDefinitions, CodeActionBuilder, ConvertFromUse,
4949
ConvertToFunctionCall, ConvertToPipe, ConvertToUse, ExpandFunctionCapture, ExtractConstant,
5050
ExtractVariable, FillInMissingLabelledArgs, FillUnusedFields, FixBinaryOperation,
5151
FixTruncatedBitArraySegment, GenerateDynamicDecoder, GenerateFunction, GenerateJsonEncoder,
@@ -467,9 +467,8 @@ where
467467
)
468468
.code_actions();
469469
AddAnnotations::new(module, &lines, &params).code_action(&mut actions);
470-
actions.extend(
471-
AnnotateTopLevelTypeDefinitions::new(module, &lines, &params).code_actions(),
472-
);
470+
actions
471+
.extend(AnnotateTopLevelDefinitions::new(module, &lines, &params).code_actions());
473472
Ok(if actions.is_empty() {
474473
None
475474
} else {

compiler-core/src/language_server/tests/action.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const ASSIGN_UNUSED_RESULT: &str = "Assign unused Result value to `_`";
112112
const ADD_MISSING_PATTERNS: &str = "Add missing patterns";
113113
const ADD_ANNOTATION: &str = "Add type annotation";
114114
const ADD_ANNOTATIONS: &str = "Add type annotations";
115-
const ANNOTATE_TOP_LEVEL_TYPE_DEFINITIONS: &str = "Annotate all top level type definitions";
115+
const ANNOTATE_TOP_LEVEL_DEFINITIONS: &str = "Annotate all top level definitions";
116116
const CONVERT_FROM_USE: &str = "Convert from `use`";
117117
const CONVERT_TO_USE: &str = "Convert to `use`";
118118
const EXTRACT_VARIABLE: &str = "Extract variable";
@@ -11171,7 +11171,7 @@ fn merge_case_branch_does_not_merge_branches_with_variables_with_same_name_and_d
1117111171

1117211172
fn annotate_all_top_level_definitions_dont_affect_local_vars() {
1117311173
assert_code_action!(
11174-
ANNOTATE_TOP_LEVEL_TYPE_DEFINITIONS,
11174+
ANNOTATE_TOP_LEVEL_DEFINITIONS,
1117511175
r#"
1117611176
pub const answer = 42
1117711177
@@ -11189,7 +11189,7 @@ pub fn add_one(thing) {
1118911189
#[test]
1119011190
fn annotate_all_top_level_definitions_constant() {
1119111191
assert_code_action!(
11192-
ANNOTATE_TOP_LEVEL_TYPE_DEFINITIONS,
11192+
ANNOTATE_TOP_LEVEL_DEFINITIONS,
1119311193
r#"
1119411194
pub const answer = 42
1119511195

0 commit comments

Comments
 (0)