Skip to content

Commit 6723eab

Browse files
ankddevlpil
authored andcommitted
refactor: don't visit expr_fn's in code action
They're not top level definitions, I added them by mistake, so removing
1 parent d2e404d commit 6723eab

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

compiler-core/src/language_server/code_action.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,62 +1476,6 @@ impl<'ast> ast::visit::Visit<'ast> for AnnotateTopLevelTypeDefinitions<'_> {
14761476
);
14771477
}
14781478
}
1479-
1480-
fn visit_typed_expr_fn(
1481-
&mut self,
1482-
location: &'ast SrcSpan,
1483-
type_: &'ast Arc<Type>,
1484-
kind: &'ast FunctionLiteralKind,
1485-
arguments: &'ast [TypedArg],
1486-
body: &'ast Vec1<TypedStatement>,
1487-
return_annotation: &'ast Option<ast::TypeAst>,
1488-
) {
1489-
ast::visit::visit_typed_expr_fn(
1490-
self,
1491-
location,
1492-
type_,
1493-
kind,
1494-
arguments,
1495-
body,
1496-
return_annotation,
1497-
);
1498-
1499-
// If the function doesn't have a head, we can't annotate it
1500-
let location = match kind {
1501-
// Function captures don't need any type annotations
1502-
FunctionLiteralKind::Capture { .. } => return,
1503-
FunctionLiteralKind::Anonymous { head } => head,
1504-
FunctionLiteralKind::Use { location } => location,
1505-
};
1506-
1507-
let code_action_range = self.edits.src_span_to_lsp_range(*location);
1508-
1509-
if overlaps(code_action_range, self.params.range) {
1510-
self.is_hovering_definition = true;
1511-
}
1512-
1513-
// Annotate each argument separately
1514-
for argument in arguments.iter() {
1515-
// Don't annotate the argument if it's already annotated
1516-
if argument.annotation.is_some() {
1517-
continue;
1518-
}
1519-
1520-
self.edits.insert(
1521-
argument.location.end,
1522-
format!(": {}", self.printer.print_type(&argument.type_)),
1523-
);
1524-
}
1525-
1526-
// Annotate the return type if it isn't already annotated, and this is
1527-
// an anonymous function.
1528-
if return_annotation.is_none() && matches!(kind, FunctionLiteralKind::Anonymous { .. }) {
1529-
let return_type = &type_.return_type().expect("Type must be a function");
1530-
let pretty_type = self.printer.print_type(return_type);
1531-
self.edits
1532-
.insert(location.end, format!(" -> {pretty_type}"));
1533-
}
1534-
}
15351479
}
15361480

15371481
struct TypeVariableCollector<'a, 'b> {

0 commit comments

Comments
 (0)