Skip to content

Commit 7f9eb05

Browse files
committed
Fix analysis errors.
1 parent f051bcc commit 7f9eb05

File tree

10 files changed

+42
-36
lines changed

10 files changed

+42
-36
lines changed

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ analyzer:
55
strict-casts: true
66
strict-inference: true
77
strict-raw-types: true
8+
errors:
9+
deprecated_member_use_from_same_package: ignore
810

911
linter:
1012
rules:

source_gen/lib/src/builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ const partIdRegExpLiteral = r'[A-Za-z_\d-]+';
425425

426426
final _partIdRegExp = RegExp('^$partIdRegExpLiteral\$');
427427

428-
@deprecated
428+
@Deprecated('Use languageOverrideForLibrary2 instead')
429429
String languageOverrideForLibrary(LibraryElement library) {
430430
final override = library.languageVersion.override;
431431
return override == null

source_gen/lib/src/constants/revive.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import '../utils.dart';
2222
/// **NOTE**: Some returned [Revivable] instances are not representable as valid
2323
/// Dart source code (such as referencing private constructors). It is up to the
2424
/// build tool(s) using this library to surface error messages to the user.
25-
@deprecated
25+
@Deprecated('use reviveInstance2 instead')
2626
Revivable reviveInstance(DartObject object, [LibraryElement? origin]) {
2727
final objectType = object.type;
2828
Element? element = objectType!.alias?.element;

source_gen/lib/src/generator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class InvalidGenerationSource implements Exception {
6060
/// code, or if the location was passed with [element].
6161
final AstNode? node;
6262

63-
@deprecated
63+
@Deprecated('use v2 instead')
6464
InvalidGenerationSource(
6565
this.message, {
6666
this.todo = '',
@@ -75,7 +75,7 @@ class InvalidGenerationSource implements Exception {
7575
this.node,
7676
}) : element2 = element;
7777

78-
@deprecated
78+
@Deprecated('use element2 instead')
7979
Element? get element => element2?.asElement;
8080

8181
@override

source_gen/lib/src/generator_for_annotation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ abstract class GeneratorForAnnotation<T> extends Generator {
112112
///
113113
/// Implementations should return `null` when no content is generated. Empty
114114
/// or whitespace-only [String] instances are also ignored.
115-
@deprecated
115+
@Deprecated('use generateForAnnotatedElement2 instead')
116116
dynamic generateForAnnotatedElement(
117117
Element element,
118118
ConstantReader annotation,

source_gen/lib/src/library.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AnnotatedElement {
3030

3131
const AnnotatedElement(this.annotation, this.element2);
3232

33-
@deprecated
33+
@Deprecated('use element2 instead')
3434
Element get element => element2.asElement!;
3535

3636
Metadata? get metadata2 {
@@ -45,16 +45,16 @@ class AnnotatedElement {
4545
class LibraryReader {
4646
final LibraryElement2 element2;
4747

48-
@deprecated
48+
@Deprecated('use v2 instead')
4949
LibraryReader(LibraryElement element) : this.v2(element.asElement2);
5050

5151
LibraryReader.v2(this.element2);
5252

53-
@deprecated
53+
@Deprecated('use element2 instead')
5454
LibraryElement get element => element2.asElement;
5555

5656
/// All of the declarations in this library.
57-
@deprecated
57+
@Deprecated('use allElements2 instead')
5858
Iterable<Element> get allElements => [
5959
element,
6060
...element.topLevelElements,
@@ -67,15 +67,15 @@ class LibraryReader {
6767
Iterable<Element2> get allElements2 => [element2, ...element2.children2];
6868

6969
/// All of the elements representing classes in this library.
70-
@deprecated
70+
@Deprecated('use classes2 instead')
7171
Iterable<ClassElement> get classes =>
7272
element.units.expand((cu) => cu.classes);
7373

7474
/// All of the elements representing classes in this library.
7575
Iterable<ClassElement2> get classes2 => element2.classes;
7676

7777
/// All of the elements representing enums in this library.
78-
@deprecated
78+
@Deprecated('use enums2 instead')
7979
Iterable<EnumElement> get enums => element.units.expand((cu) => cu.enums);
8080

8181
/// All of the elements representing enums in this library.
@@ -150,7 +150,7 @@ class LibraryReader {
150150

151151
/// Returns a top-level [ClassElement2] publicly visible in by [name].
152152
///
153-
/// Unlike [LibraryElement2.getClass], this also correctly traverses
153+
/// Unlike `LibraryElement2.getClass`, this also correctly traverses
154154
/// identifiers that are accessible via one or more `export` directives.
155155
ClassElement2? findType2(String name) {
156156
final type = element2.exportNamespace.get2(name);
@@ -167,7 +167,7 @@ class LibraryReader {
167167
///
168168
/// This is a typed convenience function for using [pathToUrl], and the same
169169
/// API restrictions hold around supported schemes and relative paths.
170-
@deprecated
170+
@Deprecated('use pathToElement2 instead')
171171
Uri pathToElement(Element element) => pathToUrl(element.source!.uri);
172172

173173
/// Returns a [Uri] from the current library to the target [element].

source_gen/lib/src/span_for_element.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import 'utils.dart';
2020
///
2121
/// Not all results from the analyzer API may return source information as part
2222
/// of the element, so [file] may need to be manually provided in those cases.
23-
@deprecated
23+
@Deprecated('use spanForElement2 instead')
2424
SourceSpan spanForElement(Element element, [SourceFile? file]) {
2525
final url = assetToPackageUrl(element.source!.uri);
2626
if (file == null) {

source_gen/lib/src/type_checker.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ abstract class TypeChecker {
6464
/// Otherwise returns `null`.
6565
///
6666
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
67-
@deprecated
67+
@Deprecated('use firstAnnotationOf2 instead')
6868
DartObject? firstAnnotationOf(
6969
Element element, {
7070
bool throwOnUnresolved = true,
@@ -104,7 +104,7 @@ abstract class TypeChecker {
104104
/// Returns if a constant annotating [element] is assignable to this type.
105105
///
106106
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
107-
@deprecated
107+
@Deprecated('use hasAnnotationOf2 instead')
108108
bool hasAnnotationOf(Element element, {bool throwOnUnresolved = true}) =>
109109
firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved) != null;
110110

@@ -118,7 +118,7 @@ abstract class TypeChecker {
118118
///
119119
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
120120
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
121-
@deprecated
121+
@Deprecated('use firstAnnotationOfExact2 instead')
122122
DartObject? firstAnnotationOfExact(
123123
Element element, {
124124
bool throwOnUnresolved = true,
@@ -159,7 +159,7 @@ abstract class TypeChecker {
159159
///
160160
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
161161
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
162-
@deprecated
162+
@Deprecated('use hasAnnotationOfExact2 instead')
163163
bool hasAnnotationOfExact(Element element, {bool throwOnUnresolved = true}) =>
164164
firstAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved) !=
165165
null;
@@ -175,7 +175,7 @@ abstract class TypeChecker {
175175
firstAnnotationOfExact2(element, throwOnUnresolved: throwOnUnresolved) !=
176176
null;
177177

178-
@deprecated
178+
@Deprecated('use _computeConstantValue2 instead')
179179
DartObject? _computeConstantValue(
180180
Element element,
181181
int annotationIndex, {
@@ -209,7 +209,7 @@ abstract class TypeChecker {
209209
///
210210
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
211211
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
212-
@deprecated
212+
@Deprecated('use annotationsOf2 instead')
213213
Iterable<DartObject> annotationsOf(
214214
Element element, {
215215
bool throwOnUnresolved = true,
@@ -234,7 +234,7 @@ abstract class TypeChecker {
234234
throwOnUnresolved: throwOnUnresolved,
235235
);
236236

237-
@deprecated
237+
@Deprecated('use _annotationsWhere2 instead')
238238
Iterable<DartObject> _annotationsWhere(
239239
Element element,
240240
bool Function(DartType) predicate, {
@@ -277,7 +277,7 @@ abstract class TypeChecker {
277277
///
278278
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
279279
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
280-
@deprecated
280+
@Deprecated('use annotationsOfExact2 instead')
281281
Iterable<DartObject> annotationsOfExact(
282282
Element element, {
283283
bool throwOnUnresolved = true,
@@ -303,7 +303,7 @@ abstract class TypeChecker {
303303
);
304304

305305
/// Returns `true` if the type of [element] can be assigned to this type.
306-
@deprecated
306+
@Deprecated('use isAssignableFrom2 instead')
307307
bool isAssignableFrom(Element element) =>
308308
isExactly(element) ||
309309
(element is InterfaceElement && element.allSupertypes.any(isExactlyType));
@@ -321,7 +321,7 @@ abstract class TypeChecker {
321321
}
322322

323323
/// Returns `true` if representing the exact same class as [element].
324-
@deprecated
324+
@Deprecated('use isExactly2 instead')
325325
bool isExactly(Element element);
326326

327327
/// Returns `true` if representing the exact same class as [element].
@@ -344,7 +344,7 @@ abstract class TypeChecker {
344344
///
345345
/// This check only takes into account the *extends* hierarchy. If you wish
346346
/// to check mixins and interfaces, use [isAssignableFrom].
347-
@deprecated
347+
@Deprecated('use isSuperOf2 instead')
348348
bool isSuperOf(Element element) {
349349
if (element is InterfaceElement) {
350350
var theSuper = element.supertype;
@@ -423,7 +423,7 @@ class _MirrorTypeChecker extends TypeChecker {
423423
TypeChecker get _computed =>
424424
_cache[this] ??= TypeChecker.fromUrl(_uriOf(reflectClass(_type)));
425425

426-
@deprecated
426+
@Deprecated('use isExactly2 instead')
427427
@override
428428
bool isExactly(Element element) => _computed.isExactly(element);
429429

@@ -459,7 +459,7 @@ class _UriTypeChecker extends TypeChecker {
459459
uri.toString() ==
460460
(url is String ? url : normalizeUrl(url as Uri).toString());
461461

462-
@deprecated
462+
@Deprecated('use isExactly2 instead')
463463
@override
464464
bool isExactly(Element element) => hasSameUrl(urlOfElement(element));
465465

@@ -475,7 +475,7 @@ class _AnyChecker extends TypeChecker {
475475

476476
const _AnyChecker(this._checkers) : super._();
477477

478-
@deprecated
478+
@Deprecated('use isExactly2 instead')
479479
@override
480480
bool isExactly(Element element) => _checkers.any((c) => c.isExactly(element));
481481

@@ -499,7 +499,7 @@ class UnresolvedAnnotationException implements Exception {
499499
/// May be `null` if the import library was not found.
500500
final SourceSpan? annotationSource;
501501

502-
@deprecated
502+
@Deprecated('use annotatedElement2 instead')
503503
Element get annotatedElement => annotatedElement2.asElement!;
504504

505505
static SourceSpan? _findSpan(Element2 annotatedElement, int annotationIndex) {
@@ -552,7 +552,7 @@ the version of `package:source_gen`, `package:analyzer` from `pubspec.lock`.
552552
}
553553

554554
/// Creates an exception from an annotation ([annotationIndex]) that was not
555-
/// resolvable while traversing [Element2.metadata] on [annotatedElement].
555+
/// resolvable while traversing `Element2.metadata` on [annotatedElement].
556556
factory UnresolvedAnnotationException._from(
557557
Element2 annotatedElement,
558558
int annotationIndex,

source_gen/lib/src/utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool hasExpectedPartDirective(CompilationUnit unit, String part) =>
4545
.any((e) => e.uri.stringValue == part);
4646

4747
/// Returns a uri suitable for `part of "..."` when pointing to [element].
48-
@deprecated
48+
@Deprecated('use uriOfPartial2 instead')
4949
String uriOfPartial(LibraryElement element, AssetId source, AssetId output) {
5050
assert(source.package == output.package);
5151
return p.url.relative(source.path, from: p.url.dirname(output.path));
@@ -65,7 +65,7 @@ String computePartUrl(AssetId input, AssetId output) => p.url.joinAll(
6565
);
6666

6767
/// Returns a URL representing [element].
68-
@deprecated
68+
@Deprecated('use urlOfElement2 instead')
6969
String urlOfElement(Element element) => element.kind == ElementKind.DYNAMIC
7070
? 'dart:core#dynamic'
7171
// using librarySource.uri – in case the element is in a part

source_gen/test/type_checker_test.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,14 @@ void main() {
200200
group(
201201
'(MapMixin',
202202
() {
203-
test('should equal MapMixin class', () {
204-
expect(checkMapMixin().isExactlyType(staticMapMixin), isTrue);
205-
expect(checkMapMixin().isExactly2(staticMapMixin.element3), isTrue);
206-
}, skip: 'Google3 test gives google3:// URI for the test mirror');
203+
test(
204+
'should equal MapMixin class',
205+
() {
206+
expect(checkMapMixin().isExactlyType(staticMapMixin), isTrue);
207+
expect(checkMapMixin().isExactly2(staticMapMixin.element3), isTrue);
208+
},
209+
skip: 'Google3 test gives google3:// URI for the test mirror',
210+
);
207211
},
208212
onPlatform: const {
209213
'windows': Skip('https://github.com/dart-lang/source_gen/issues/573'),

0 commit comments

Comments
 (0)