|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a
|
3 | 3 | // BSD-style license that can be found in the LICENSE file.
|
4 | 4 |
|
5 |
| -import 'dart:mirrors' hide SourceLocation; |
| 5 | +// ignore_for_file: deprecated_member_use until analyzer 7 support is dropped. |
6 | 6 |
|
7 | 7 | import 'package:analyzer/dart/analysis/results.dart';
|
8 | 8 | import 'package:analyzer/dart/ast/ast.dart';
|
@@ -32,20 +32,6 @@ abstract class TypeChecker {
|
32 | 32 | /// ```
|
33 | 33 | const factory TypeChecker.any(Iterable<TypeChecker> checkers) = _AnyChecker;
|
34 | 34 |
|
35 |
| - /// Create a new [TypeChecker] backed by a runtime [type]. |
36 |
| - /// |
37 |
| - /// This implementation uses `dart:mirrors` (runtime reflection). |
38 |
| - @Deprecated(''' |
39 |
| -Will be removed in 4.0.0 to drop `dart:mirrors` dependency. |
40 |
| -
|
41 |
| -Recommended: replace `fromRuntime(Foo)` with |
42 |
| -`typeNamed(Foo, inPackage: 'foo_package')`. This is a slighly weaker check than |
43 |
| -`fromRuntime(Foo)` as it matches any annotation named `Foo` in |
44 |
| -`package:foo_package`. |
45 |
| -
|
46 |
| -If you need an exact match, use `fromUrl`.''') |
47 |
| - const factory TypeChecker.fromRuntime(Type type) = _MirrorTypeChecker; |
48 |
| - |
49 | 35 | /// Create a new [TypeChecker] for types matching the name of [type].
|
50 | 36 | ///
|
51 | 37 | /// Optionally, also pass [inPackage] to restrict to a specific package by
|
@@ -252,29 +238,6 @@ class _LibraryTypeChecker extends TypeChecker {
|
252 | 238 | String toString() => urlOfElement(_type.element!);
|
253 | 239 | }
|
254 | 240 |
|
255 |
| -// Checks a runtime type against a static type. |
256 |
| -class _MirrorTypeChecker extends TypeChecker { |
257 |
| - static Uri _uriOf(ClassMirror mirror) => normalizeUrl( |
258 |
| - (mirror.owner as LibraryMirror).uri, |
259 |
| - ).replace(fragment: MirrorSystem.getName(mirror.simpleName)); |
260 |
| - |
261 |
| - // Precomputed type checker for types that already have been used. |
262 |
| - static final _cache = Expando<TypeChecker>(); |
263 |
| - |
264 |
| - final Type _type; |
265 |
| - |
266 |
| - const _MirrorTypeChecker(this._type) : super._(); |
267 |
| - |
268 |
| - TypeChecker get _computed => |
269 |
| - _cache[this] ??= TypeChecker.fromUrl(_uriOf(reflectClass(_type))); |
270 |
| - |
271 |
| - @override |
272 |
| - bool isExactly(Element element) => _computed.isExactly(element); |
273 |
| - |
274 |
| - @override |
275 |
| - String toString() => _computed.toString(); |
276 |
| -} |
277 |
| - |
278 | 241 | // Checks a runtime type name and optional package against a static type.
|
279 | 242 | class _NameTypeChecker extends TypeChecker {
|
280 | 243 | final Type _type;
|
|
0 commit comments