Skip to content

Commit 98ddc49

Browse files
committed
Remove deprecated API.
1 parent 957e4cb commit 98ddc49

File tree

10 files changed

+2
-216
lines changed

10 files changed

+2
-216
lines changed

source_gen/lib/source_gen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ export 'src/generator.dart'
1111
export 'src/generator_for_annotation.dart' show GeneratorForAnnotation;
1212
export 'src/library.dart'
1313
show AnnotatedDirective, AnnotatedElement, LibraryReader;
14-
export 'src/span_for_element.dart' show spanForElement, spanForElement2;
14+
export 'src/span_for_element.dart' show spanForElement;
1515
export 'src/type_checker.dart' show TypeChecker, UnresolvedAnnotationException;
1616
export 'src/utils.dart' show typeNameOf;

source_gen/lib/src/builder.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,6 @@ String languageOverrideForLibrary(LibraryElement2 library) {
431431
: '// @dart=${override.major}.${override.minor}\n';
432432
}
433433

434-
@Deprecated('Use languageOverrideForLibrary instead')
435-
String languageOverrideForLibrary2(LibraryElement2 library) =>
436-
languageOverrideForLibrary(library);
437-
438434
/// A comment configuring `dart_style` to use the default code width so no
439435
/// configuration discovery is required.
440436
const dartFormatWidth = '// dart format width=80';

source_gen/lib/src/constants/utils.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ void assertHasField(InterfaceElement2 root, String name) {
2828
);
2929
}
3030

31-
/// Throws a [FormatException] if [root] does not have a given field [name].
32-
///
33-
/// Super types [InterfaceElement2.supertype] are also checked before throwing.
34-
@Deprecated('Use assertHasField() instead')
35-
void assertHasField2(InterfaceElement2 root, String name) =>
36-
assertHasField(root, name);
37-
3831
/// Returns whether or not [object] is or represents a `null` value.
3932
bool isNullLike(DartObject? object) => object?.isNull != false;
4033

source_gen/lib/src/generator.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,6 @@ class InvalidGenerationSource implements Exception {
6464
this.node,
6565
});
6666

67-
@Deprecated('use the unnamed constructor instead')
68-
InvalidGenerationSource.v2(
69-
this.message, {
70-
this.todo = '',
71-
this.element,
72-
this.node,
73-
});
74-
75-
@Deprecated('use element instead')
76-
Element2? get element2 => element;
77-
7867
@override
7968
String toString() {
8069
final buffer = StringBuffer(message);

source_gen/lib/src/generator_for_annotation.dart

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ abstract class GeneratorForAnnotation<T> extends Generator {
7878
annotatedElement.annotation,
7979
buildStep,
8080
);
81-
generatedValue ??= generateForAnnotatedElement2(
82-
annotatedElement.element,
83-
annotatedElement.annotation,
84-
buildStep,
85-
);
8681
await for (var value in normalizeGeneratorOutput(generatedValue)) {
8782
assert(value.length == value.trim().length);
8883
values.add(value);
@@ -115,30 +110,6 @@ abstract class GeneratorForAnnotation<T> extends Generator {
115110
BuildStep buildStep,
116111
) {}
117112

118-
/// Implement to return source code to generate for [element].
119-
///
120-
/// This method is invoked based on finding elements annotated with an
121-
/// instance of [T]. The [annotation] is provided as a [ConstantReader].
122-
///
123-
/// Supported return values include a single [String] or multiple [String]
124-
/// instances within an [Iterable] or [Stream]. It is also valid to return a
125-
/// [Future] of [String], [Iterable], or [Stream]. When multiple values are
126-
/// returned through an iterable or stream they will be deduplicated.
127-
/// Typically each value will be an independent unit of code and the
128-
/// deduplication prevents re-defining the same member multiple times. For
129-
/// example if multiple annotated elements may need a specific utility method
130-
/// available it can be output for each one, and the single deduplicated
131-
/// definition can be shared.
132-
///
133-
/// Implementations should return `null` when no content is generated. Empty
134-
/// or whitespace-only [String] instances are also ignored.
135-
@Deprecated('use generateForAnnotatedElement instead')
136-
dynamic generateForAnnotatedElement2(
137-
Element2 element,
138-
ConstantReader annotation,
139-
BuildStep buildStep,
140-
) {}
141-
142113
/// Implement to return source code to generate for [directive]:
143114
/// - [LibraryImport]
144115
/// - [LibraryExport]

source_gen/lib/src/library.dart

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ class AnnotatedElement {
2727

2828
const AnnotatedElement(this.annotation, this.element);
2929

30-
@Deprecated('use element instead')
31-
Element2 get element2 => element;
32-
3330
Metadata? get metadata2 {
3431
if (element case final Annotatable annotatable) {
3532
return annotatable.metadata2;
@@ -44,33 +41,15 @@ class LibraryReader {
4441

4542
LibraryReader(this.element);
4643

47-
@Deprecated('use the default constructor instead')
48-
LibraryReader.v2(this.element);
49-
50-
@Deprecated('use element instead')
51-
LibraryElement2 get element2 => element;
52-
5344
/// All of the declarations in this library.
5445
Iterable<Element2> get allElements => [element, ...element.children2];
5546

56-
/// All of the declarations in this library.
57-
@Deprecated('use allElements instead')
58-
Iterable<Element2> get allElements2 => allElements;
59-
6047
/// All of the elements representing classes in this library.
6148
Iterable<ClassElement2> get classes => element.classes;
6249

63-
/// All of the elements representing classes in this library.
64-
@Deprecated('use classes instead')
65-
Iterable<ClassElement2> get classes2 => classes;
66-
6750
/// All of the elements representing enums in this library.
6851
Iterable<EnumElement2> get enums => element.enums;
6952

70-
/// All of the elements representing enums in this library.
71-
@Deprecated('use enums instead')
72-
Iterable<EnumElement2> get enums3 => enums;
73-
7453
/// All of the declarations in this library annotated with [checker].
7554
Iterable<AnnotatedElement> annotatedWith(
7655
TypeChecker checker, {
@@ -137,13 +116,6 @@ class LibraryReader {
137116
return type is ClassElement2 ? type : null;
138117
}
139118

140-
/// Returns a top-level [ClassElement2] publicly visible in by [name].
141-
///
142-
/// Unlike `LibraryElement2.getClass`, this also correctly traverses
143-
/// identifiers that are accessible via one or more `export` directives.
144-
@Deprecated('Use findType() instead')
145-
ClassElement2? findType2(String name) => findType(name);
146-
147119
/// Returns a [Uri] from the current library to the target [asset].
148120
///
149121
/// This is a typed convenience function for using [pathToUrl], and the same
@@ -157,13 +129,6 @@ class LibraryReader {
157129
Uri pathToElement(Element2 element) =>
158130
pathToUrl(element.firstFragment.libraryFragment!.source.uri);
159131

160-
/// Returns a [Uri] from the current library to the target [element].
161-
///
162-
/// This is a typed convenience function for using [pathToUrl], and the same
163-
/// API restrictions hold around supported schemes and relative paths.
164-
@Deprecated('use pathToElement instead')
165-
Uri pathToElement2(Element2 element) => pathToElement(element);
166-
167132
/// Returns a [Uri] from the current library to the one provided.
168133
///
169134
/// If possible, a `package:` or `dart:` URL scheme will be used to reference

source_gen/lib/src/span_for_element.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,6 @@ SourceSpan spanForElement(Element2 element, [SourceFile? file]) {
5454
);
5555
}
5656

57-
/// Returns a source span that spans the location where [element] is defined.
58-
///
59-
/// May be used to emit user-friendly warning and error messages:
60-
/// ```dart
61-
/// void invalidClass(ClassElement class) {
62-
/// log.warning(spanForElement.message('Cannot implement "Secret"'));
63-
/// }
64-
/// ```
65-
///
66-
/// Not all results from the analyzer API may return source information as part
67-
/// of the element, so [file] may need to be manually provided in those cases.
68-
@Deprecated('use spanForElement instead')
69-
SourceSpan spanForElement2(Element2 element, [SourceFile? file]) =>
70-
spanForElement(element, file);
71-
7257
/// Returns a source span that spans the location where [node] is written.
7358
SourceSpan spanForNode(AstNode node) {
7459
final unit = node.thisOrAncestorOfType<CompilationUnit>()!;

source_gen/lib/src/type_checker.dart

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,12 @@ abstract class TypeChecker {
7878
return results.isEmpty ? null : results.first;
7979
}
8080

81-
/// Returns the first constant annotating [element] assignable to this type.
82-
///
83-
/// Otherwise returns `null`.
84-
///
85-
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
86-
@Deprecated('use firstAnnotationOf instead')
87-
DartObject? firstAnnotationOf2(
88-
Object element, {
89-
bool throwOnUnresolved = true,
90-
}) =>
91-
firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved);
92-
9381
/// Returns if a constant annotating [element] is assignable to this type.
9482
///
9583
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
9684
bool hasAnnotationOf(Element2 element, {bool throwOnUnresolved = true}) =>
9785
firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved) != null;
9886

99-
/// Returns if a constant annotating [element] is assignable to this type.
100-
///
101-
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
102-
@Deprecated('use hasAnnotationOf instead')
103-
bool hasAnnotationOf2(Element2 element, {bool throwOnUnresolved = true}) =>
104-
hasAnnotationOf(element, throwOnUnresolved: throwOnUnresolved);
105-
10687
/// Returns the first constant annotating [element] that is exactly this type.
10788
///
10889
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
@@ -125,17 +106,6 @@ abstract class TypeChecker {
125106
return null;
126107
}
127108

128-
/// Returns the first constant annotating [element] that is exactly this type.
129-
///
130-
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
131-
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
132-
@Deprecated('use firstAnnotationOfExact instead')
133-
DartObject? firstAnnotationOfExact2(
134-
Element2 element, {
135-
bool throwOnUnresolved = true,
136-
}) =>
137-
firstAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved);
138-
139109
/// Returns if a constant annotating [element] is exactly this type.
140110
///
141111
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
@@ -147,17 +117,6 @@ abstract class TypeChecker {
147117
firstAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved) !=
148118
null;
149119

150-
/// Returns if a constant annotating [element] is exactly this type.
151-
///
152-
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
153-
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
154-
@Deprecated('use hasAnnotationOfExact instead')
155-
bool hasAnnotationOfExact2(
156-
Element2 element, {
157-
bool throwOnUnresolved = true,
158-
}) =>
159-
hasAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved);
160-
161120
DartObject? _computeConstantValue(
162121
Object element,
163122
ElementAnnotation annotation,
@@ -185,17 +144,6 @@ abstract class TypeChecker {
185144
throwOnUnresolved: throwOnUnresolved,
186145
);
187146

188-
/// Returns annotating constants on [element] assignable to this type.
189-
///
190-
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
191-
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
192-
@Deprecated('use annotationsOf instead')
193-
Iterable<DartObject> annotationsOf2(
194-
Object element, {
195-
bool throwOnUnresolved = true,
196-
}) =>
197-
annotationsOf(element, throwOnUnresolved: throwOnUnresolved);
198-
199147
Iterable<DartObject> _annotationsWhere(
200148
Object element,
201149
bool Function(DartType) predicate, {
@@ -231,27 +179,12 @@ abstract class TypeChecker {
231179
throwOnUnresolved: throwOnUnresolved,
232180
);
233181

234-
/// Returns annotating constants on [element] of exactly this type.
235-
///
236-
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
237-
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
238-
@Deprecated('use annotationsOfExact instead')
239-
Iterable<DartObject> annotationsOfExact2(
240-
Element2 element, {
241-
bool throwOnUnresolved = true,
242-
}) =>
243-
annotationsOfExact(element, throwOnUnresolved: throwOnUnresolved);
244-
245182
/// Returns `true` if the type of [element] can be assigned to this type.
246183
bool isAssignableFrom(Element2 element) =>
247184
isExactly(element) ||
248185
(element is InterfaceElement2 &&
249186
element.allSupertypes.any(isExactlyType));
250187

251-
/// Returns `true` if the type of [element] can be assigned to this type.
252-
@Deprecated('use isAssignableFrom instead')
253-
bool isAssignableFrom2(Element2 element) => isAssignableFrom(element);
254-
255188
/// Returns `true` if [staticType] can be assigned to this type.
256189
bool isAssignableFromType(DartType staticType) {
257190
final element = staticType.element3;
@@ -261,10 +194,6 @@ abstract class TypeChecker {
261194
/// Returns `true` if representing the exact same class as [element].
262195
bool isExactly(Element2 element);
263196

264-
/// Returns `true` if representing the exact same class as [element].
265-
@Deprecated('use isExactly instead')
266-
bool isExactly2(Element2 element) => isExactly(element);
267-
268197
/// Returns `true` if representing the exact same type as [staticType].
269198
///
270199
/// This will always return false for types without a backingclass such as
@@ -298,13 +227,6 @@ abstract class TypeChecker {
298227
return false;
299228
}
300229

301-
/// Returns `true` if representing a super class of [element].
302-
///
303-
/// This check only takes into account the *extends* hierarchy. If you wish
304-
/// to check mixins and interfaces, use [isAssignableFrom].
305-
@Deprecated('use isSuperOf instead')
306-
bool isSuperOf2(Element2 element) => isSuperOf(element);
307-
308230
/// Returns `true` if representing a super type of [staticType].
309231
///
310232
/// This only takes into account the *extends* hierarchy. If you wish
@@ -322,10 +244,6 @@ class _LibraryTypeChecker extends TypeChecker {
322244
bool isExactly(Element2 element) =>
323245
element is InterfaceElement2 && element == _type.element3;
324246

325-
@Deprecated('Use isExactly() instead')
326-
@override
327-
bool isExactly2(Element2 element) => isExactly(element);
328-
329247
@override
330248
String toString() => urlOfElement(_type.element3!);
331249
}
@@ -349,10 +267,6 @@ class _MirrorTypeChecker extends TypeChecker {
349267
@override
350268
bool isExactly(Element2 element) => _computed.isExactly(element);
351269

352-
@Deprecated('use isExactly instead')
353-
@override
354-
bool isExactly2(Element2 element) => isExactly(element);
355-
356270
@override
357271
String toString() => _computed.toString();
358272
}
@@ -385,10 +299,6 @@ class _UriTypeChecker extends TypeChecker {
385299
@override
386300
bool isExactly(Element2 element) => hasSameUrl(urlOfElement(element));
387301

388-
@Deprecated('use isExactly instead')
389-
@override
390-
bool isExactly2(Element2 element) => isExactly(element);
391-
392302
@override
393303
String toString() => '$uri';
394304
}
@@ -401,10 +311,6 @@ class _AnyChecker extends TypeChecker {
401311
@override
402312
bool isExactly(Element2 element) =>
403313
_checkers.any((c) => c.isExactly(element));
404-
405-
@Deprecated('use isExactly2 instead')
406-
@override
407-
bool isExactly2(Element2 element) => isExactly(element);
408314
}
409315

410316
/// Exception thrown when [TypeChecker] fails to resolve a metadata annotation.
@@ -422,9 +328,6 @@ class UnresolvedAnnotationException implements Exception {
422328
/// May be `null` if the import library was not found.
423329
final SourceSpan? annotationSource;
424330

425-
@Deprecated('use annotatedElement instead')
426-
Element2 get annotatedElement2 => annotatedElement;
427-
428331
static SourceSpan? _findSpan(Element2 annotatedElement, int annotationIndex) {
429332
try {
430333
final parsedLibrary =

0 commit comments

Comments
 (0)