Skip to content

Commit

Permalink
Elements. Migrate ShadowField.
Browse files Browse the repository at this point in the history
Change-Id: Id073dbba830e0f3b0acd0ac8630910a478443c26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387415
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and Commit Queue committed Sep 30, 2024
1 parent 38bc539 commit 9b6c7e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/analysis_server/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ lib/src/services/correction/dart/replace_with_tear_off.dart
lib/src/services/correction/dart/replace_with_unicode_escape.dart
lib/src/services/correction/dart/replace_with_var.dart
lib/src/services/correction/dart/replace_with_wildcard.dart
lib/src/services/correction/dart/shadow_field.dart
lib/src/services/correction/dart/sort_child_property_last.dart
lib/src/services/correction/dart/sort_combinators.dart
lib/src/services/correction/dart/sort_constructor_first.dart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:analysis_server_plugin/edit/dart/correction_producer.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer_plugin/utilities/assist/assist.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
Expand All @@ -30,12 +30,12 @@ class ShadowField extends ResolvedCorrectionProducer {
return;
}

var accessor = node.writeOrReadElement;
if (accessor is! PropertyAccessorElement) {
var accessor = node.writeOrReadElement2;
if (accessor is! GetterElement) {
return;
}

if (!accessor.isGetter || accessor.enclosingElement3 is! InterfaceElement) {
if (accessor.enclosingElement2 is! InterfaceElement2) {
// TODO(brianwilkerson): Should we also require that the getter be synthetic?
return;
}
Expand All @@ -53,7 +53,7 @@ class ShadowField extends ResolvedCorrectionProducer {
return;
}

var correspondingSetter = accessor.correspondingSetter;
var correspondingSetter = accessor.correspondingSetter2;
if (correspondingSetter == null) {
return;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ class ShadowField extends ResolvedCorrectionProducer {
/// A utility that will find any references to a setter within an AST structure.
class _ReferenceFinder extends RecursiveAstVisitor<void> {
/// The setter being searched for.
final PropertyAccessorElement setter;
final SetterElement setter;

/// A flag indicating whether a reference to the [setter] has been found.
bool hasSetterReference = false;
Expand All @@ -135,7 +135,7 @@ class _ReferenceFinder extends RecursiveAstVisitor<void> {

@override
void visitSimpleIdentifier(SimpleIdentifier node) {
if (node.writeOrReadElement == setter) {
if (node.writeOrReadElement2 == setter) {
hasSetterReference = true;
}
}
Expand Down

0 comments on commit 9b6c7e6

Please sign in to comment.