Skip to content

Commit 88bad10

Browse files
committed
refactor: rename code action
1 parent 277e032 commit 88bad10

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
@@ -15,13 +15,13 @@
1515
}
1616
1717
pub fn add_one(thing) {
18-
// ^ Triggering "Annotate all top level type definitions" code action here
18+
// ^ Triggering "Annotate all top level definitions" code action here
1919
let result = add(thing, 1)
2020
result
2121
}
2222
```
2323

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

2727
```gleam

compiler-core/src/language_server/code_action.rs

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

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

1373-
impl<'a> AnnotateTopLevelTypeDefinitions<'a> {
1373+
impl<'a> AnnotateTopLevelDefinitions<'a> {
13741374
pub fn new(
13751375
module: &'a Module,
13761376
line_numbers: &'a LineNumbers,
@@ -1397,7 +1397,7 @@ impl<'a> AnnotateTopLevelTypeDefinitions<'a> {
13971397
};
13981398

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

1409-
impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelTypeDefinitions<'_> {
1409+
impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelDefinitions<'_> {
14101410
fn visit_typed_module_constant(&mut self, constant: &'ast TypedModuleConstant) {
14111411
// Since type variable names are local to definitions, any type variables
14121412
// 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
@@ -44,7 +44,7 @@ use std::{collections::HashSet, sync::Arc};
4444
use super::{
4545
DownloadDependencies, MakeLocker,
4646
code_action::{
47-
AddAnnotations, AnnotateTopLevelTypeDefinitions, CodeActionBuilder, ConvertFromUse,
47+
AddAnnotations, AnnotateTopLevelDefinitions, CodeActionBuilder, ConvertFromUse,
4848
ConvertToFunctionCall, ConvertToPipe, ConvertToUse, ExpandFunctionCapture, ExtractConstant,
4949
ExtractVariable, FillInMissingLabelledArgs, FillUnusedFields, FixBinaryOperation,
5050
FixTruncatedBitArraySegment, GenerateDynamicDecoder, GenerateFunction, GenerateJsonEncoder,
@@ -461,9 +461,8 @@ where
461461
)
462462
.code_actions();
463463
AddAnnotations::new(module, &lines, &params).code_action(&mut actions);
464-
actions.extend(
465-
AnnotateTopLevelTypeDefinitions::new(module, &lines, &params).code_actions(),
466-
);
464+
actions
465+
.extend(AnnotateTopLevelDefinitions::new(module, &lines, &params).code_actions());
467466
Ok(if actions.is_empty() {
468467
None
469468
} 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";
@@ -10559,7 +10559,7 @@ pub fn main() {
1055910559
#[test]
1056010560
fn annotate_all_top_level_definitions_function() {
1056110561
assert_code_action!(
10562-
ANNOTATE_TOP_LEVEL_TYPE_DEFINITIONS,
10562+
ANNOTATE_TOP_LEVEL_DEFINITIONS,
1056310563
r#"
1056410564
pub fn add_two(thing) {
1056510565
thing + 2
@@ -10576,7 +10576,7 @@ pub fn add_one(thing) {
1057610576
#[test]
1057710577
fn annotate_all_top_level_definitions_constant() {
1057810578
assert_code_action!(
10579-
ANNOTATE_TOP_LEVEL_TYPE_DEFINITIONS,
10579+
ANNOTATE_TOP_LEVEL_DEFINITIONS,
1058010580
r#"
1058110581
pub const answer = 42
1058210582

0 commit comments

Comments
 (0)