Elements. Remove FragmentImpl.source

Change-Id: I1949f0bb87fc18078c94100b5f9a658e3525e84a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441380
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 75966a6..5fbb3da 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -3688,12 +3688,6 @@
     return asElement2?.sinceSdkVersion;
   }
 
-  /// Return the source associated with this target, or `null` if this target is
-  /// not associated with a source.
-  Source? get source {
-    return enclosingFragment?.source;
-  }
-
   /// Whether to include the [nameOffset] in [identifier] to disambiguate
   /// elements that might otherwise have the same identifier.
   bool get _includeNameOffsetInIdentifier {
@@ -6127,7 +6121,6 @@
 class LibraryFragmentImpl extends _ExistingFragmentImpl
     with DeferredResolutionReadingMixin
     implements LibraryFragment {
-  /// The source that corresponds to this compilation unit.
   @override
   final Source source;
 
@@ -8218,9 +8211,6 @@
   set hasInitializer(bool hasInitializer) {
     setModifier(Modifier.HAS_INITIALIZER, hasInitializer);
   }
-
-  @override
-  Source get source => enclosingFragment.source!;
 }
 
 class PartIncludeImpl extends ElementDirectiveImpl implements PartInclude {
@@ -10371,9 +10361,6 @@
 
 abstract class _ExistingFragmentImpl extends FragmentImpl {
   _ExistingFragmentImpl({required super.firstTokenOffset});
-
-  @override
-  Source get source => enclosingFragment!.source!;
 }
 
 /// Instances of [List]s that are used as "not yet computed" values, they
diff --git a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
index 31d3b80..2563f0b 100644
--- a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
+++ b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
@@ -670,7 +670,7 @@
       if (accessor.isStatic) {
         continue;
       }
-      if (accessor.source != _currentUnit.source) {
+      if (accessor.libraryFragment.source != _currentUnit.source) {
         continue;
       }
       var baseName = accessor.displayName;
@@ -692,7 +692,7 @@
       if (method.isStatic) {
         continue;
       }
-      if (method.source != _currentUnit.source) {
+      if (method.libraryFragment.source != _currentUnit.source) {
         continue;
       }
       var baseName = method.displayName;
@@ -720,7 +720,7 @@
     }
 
     for (var accessor in fragment.accessors) {
-      if (accessor.source != _currentUnit.source) {
+      if (accessor.libraryFragment.source != _currentUnit.source) {
         continue;
       }
       var baseName = accessor.displayName;
@@ -737,7 +737,7 @@
     }
 
     for (var method in fragment.methods) {
-      if (method.source != _currentUnit.source) {
+      if (method.libraryFragment.source != _currentUnit.source) {
         continue;
       }
       var baseName = method.displayName;
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index ddd6f63..6a8856a 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -2247,7 +2247,7 @@
 
     // method declared in the enclosing class vs. inherited getter/setter
     for (var method in fragment.methods) {
-      if (method.source != _currentUnit.source) {
+      if (method.libraryFragment.source != _currentUnit.source) {
         continue;
       }