Skip to content

Commit

Permalink
Elements. Migrate FindElement2.
Browse files Browse the repository at this point in the history
Change-Id: Ia5b901fbe8a7666a829628dcf9056c35e99f20bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396460
Reviewed-by: Phil Quitslund <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Nov 19, 2024
1 parent dcee4f2 commit 156ff66
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion pkg/analyzer/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/analyzer/lib/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/analyzer/lib/dart/element/element2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element.dart'
show
DirectiveUri,
DirectiveUriWithUnit,
ElementAnnotation,
ElementKind,
ElementLocation,
Expand Down Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,9 @@ class DirectiveUriWithUnitImpl extends DirectiveUriWithRelativeUriImpl
required this.unit,
});

@override
LibraryFragment get libraryFragment => unit;

@override
Source get source => unit.source;
}
Expand Down
1 change: 1 addition & 0 deletions pkg/linter/lib/src/rules/analyzer_use_new_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bool _isOldModelElement(Element2? element) {
'DirectiveUriWithRelativeUri',
'DirectiveUriWithRelativeUriString',
'DirectiveUriWithSource',
'DirectiveUriWithUnit',
'ElementAnnotation',
'ElementKind',
'ElementLocation',
Expand Down

0 comments on commit 156ff66

Please sign in to comment.