diff --git a/pkg/analyzer/analyzer_use_new_elements.txt b/pkg/analyzer/analyzer_use_new_elements.txt index 9187e723c4fe..3449ba048e85 100644 --- a/pkg/analyzer/analyzer_use_new_elements.txt +++ b/pkg/analyzer/analyzer_use_new_elements.txt @@ -160,7 +160,6 @@ lib/src/summary2/types_builder.dart lib/src/summary2/variance_builder.dart lib/src/task/strong_mode.dart lib/src/test_utilities/find_element.dart -lib/src/test_utilities/find_element2.dart lib/src/test_utilities/find_node.dart lib/src/test_utilities/mock_sdk_elements.dart lib/src/util/ast_data_extractor.dart diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart index 589d6eb7208b..c298ef7f307a 100644 --- a/pkg/analyzer/lib/dart/element/element.dart +++ b/pkg/analyzer/lib/dart/element/element.dart @@ -546,6 +546,10 @@ abstract class DirectiveUriWithSource extends DirectiveUriWithRelativeUri { /// /// Clients may not extend, implement or mix-in this class. abstract class DirectiveUriWithUnit extends DirectiveUriWithSource { + /// The library fragment referenced by the [source]. + @experimental + LibraryFragment get libraryFragment; + /// The unit referenced by the [source]. CompilationUnitElement get unit; } diff --git a/pkg/analyzer/lib/dart/element/element2.dart b/pkg/analyzer/lib/dart/element/element2.dart index 231d0d767593..9fabfdecc83d 100644 --- a/pkg/analyzer/lib/dart/element/element2.dart +++ b/pkg/analyzer/lib/dart/element/element2.dart @@ -52,7 +52,6 @@ import 'package:analyzer/dart/constant/value.dart'; import 'package:analyzer/dart/element/element.dart' show DirectiveUri, - DirectiveUriWithUnit, ElementAnnotation, ElementKind, ElementLocation, @@ -2582,8 +2581,3 @@ abstract class VariableFragment implements Fragment { @override VariableFragment? get previousFragment; } - -extension DirectiveUriWithUnitExtension on DirectiveUriWithUnit { - /// The library fragment associated with this directive. - LibraryFragment get libraryFragment => unit as LibraryFragment; -} diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart index a14e61abc8e0..84cdbeb7ba81 100644 --- a/pkg/analyzer/lib/src/dart/element/element.dart +++ b/pkg/analyzer/lib/src/dart/element/element.dart @@ -1913,6 +1913,9 @@ class DirectiveUriWithUnitImpl extends DirectiveUriWithRelativeUriImpl required this.unit, }); + @override + LibraryFragment get libraryFragment => unit; + @override Source get source => unit.source; } diff --git a/pkg/linter/lib/src/rules/analyzer_use_new_elements.dart b/pkg/linter/lib/src/rules/analyzer_use_new_elements.dart index 93401dac79cd..8f5cf6d32053 100644 --- a/pkg/linter/lib/src/rules/analyzer_use_new_elements.dart +++ b/pkg/linter/lib/src/rules/analyzer_use_new_elements.dart @@ -35,6 +35,7 @@ bool _isOldModelElement(Element2? element) { 'DirectiveUriWithRelativeUri', 'DirectiveUriWithRelativeUriString', 'DirectiveUriWithSource', + 'DirectiveUriWithUnit', 'ElementAnnotation', 'ElementKind', 'ElementLocation',