[analyzer] Start using IndexError.check in library_element.

Reverses https://dart-review.googlesource.com/c/sdk/+/269141.
Now that the pubspec specifies 2.19 as the minimum version, we can
swap to IndexError.check instead of checkValidIndex.

Change-Id: I0dab64b4c8408a29b8bea35920e3f5e69e6e92d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294124
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
Kallen Tu
2023-04-06 23:12:58 +00:00
committed by Commit Queue
parent e945ac6051
commit 7906ccf7ea
@@ -21,9 +21,7 @@ extension _ElementExtension on Element {
/// is a match up to [thisIndex].
Element? _locateElement(ElementLocation location, int thisIndex) {
final components = location.components;
// TODO(paulberry): once the analyzer's pubspec specifies a minimum SDK
// version that supports [IndexError.check], switch to using that instead.
RangeError.checkValidIndex(thisIndex, components);
IndexError.check(thisIndex, components.length, indexable: components);
final nextIndex = thisIndex + 1;
if (nextIndex == components.length) {