[element model] migrate `prefer_constructors_over_static_methods`

Bug: https://github.com/dart-lang/linter/issues/5099
Change-Id: I8b165b87ac6159d3df2a7cd7f0a804b619c7eeb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390022
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/linter/lib/src/rules/prefer_constructors_over_static_methods.dart b/pkg/linter/lib/src/rules/prefer_constructors_over_static_methods.dart
index 642a3340..85c0008 100644
--- a/pkg/linter/lib/src/rules/prefer_constructors_over_static_methods.dart
+++ b/pkg/linter/lib/src/rules/prefer_constructors_over_static_methods.dart
@@ -80,10 +80,12 @@
 
 extension on AstNode? {
   InterfaceType? typeToCheckOrNull() => switch (this) {
-        ExtensionTypeDeclaration e =>
-          e.typeParameters == null ? e.declaredElement?.thisType : null,
-        ClassDeclaration c =>
-          c.typeParameters == null ? c.declaredElement?.thisType : null,
+        ExtensionTypeDeclaration e => e.typeParameters == null
+            ? e.declaredFragment?.element.thisType
+            : null,
+        ClassDeclaration c => c.typeParameters == null
+            ? c.declaredFragment?.element.thisType
+            : null,
         _ => null
       };
 }