From 3c43538148f387be845a9c4c078d05a537e9f78b Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Sun, 29 Sep 2024 04:28:12 +0000 Subject: [PATCH] Elements. Migrate ConvertIntoBlockBody. Change-Id: I49ca47fbb38902d31dd0995f9a6cdb771aa61034 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386737 Reviewed-by: Samuel Rawlins Commit-Queue: Konstantin Shcheglov --- pkg/analysis_server/analyzer_use_new_elements.txt | 1 + .../correction/dart/convert_into_block_body.dart | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/analysis_server/analyzer_use_new_elements.txt b/pkg/analysis_server/analyzer_use_new_elements.txt index 237df43b3e96..1ba8ccbba0b1 100644 --- a/pkg/analysis_server/analyzer_use_new_elements.txt +++ b/pkg/analysis_server/analyzer_use_new_elements.txt @@ -241,6 +241,7 @@ lib/src/services/correction/dart/convert_flutter_child.dart lib/src/services/correction/dart/convert_flutter_children.dart lib/src/services/correction/dart/convert_for_each_to_for_loop.dart lib/src/services/correction/dart/convert_into_async_body.dart +lib/src/services/correction/dart/convert_into_block_body.dart lib/src/services/correction/dart/convert_into_getter.dart lib/src/services/correction/dart/convert_into_is_not.dart lib/src/services/correction/dart/convert_quotes.dart diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_into_block_body.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_into_block_body.dart index 25762a276499..b9ef72b54a80 100644 --- a/pkg/analysis_server/lib/src/services/correction/dart/convert_into_block_body.dart +++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_into_block_body.dart @@ -6,7 +6,7 @@ import 'package:_fe_analyzer_shared/src/scanner/token.dart'; import 'package:analysis_server/src/services/correction/assist.dart'; import 'package:analysis_server_plugin/edit/dart/correction_producer.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/src/dart/ast/extensions.dart'; import 'package:analyzer_plugin/utilities/assist/assist.dart'; @@ -175,13 +175,13 @@ class ConvertIntoBlockBody extends ResolvedCorrectionProducer { return [returnCode]; } - ExecutableElement? _getFunctionElement(AstNode? node) { + ExecutableElement2? _getFunctionElement(AstNode? node) { if (node is MethodDeclaration) { - return node.declaredElement; + return node.declaredFragment?.element; } else if (node is ConstructorDeclaration) { - return node.declaredElement; + return node.declaredFragment?.element; } else if (node is FunctionExpression) { - return node.declaredElement; + return node.declaredFragment?.element ?? node.declaredElement2; } return null; }