Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source_gen/lib/source_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export 'src/generator.dart'
export 'src/generator_for_annotation.dart' show GeneratorForAnnotation;
export 'src/library.dart'
show AnnotatedDirective, AnnotatedElement, LibraryReader;
export 'src/span_for_element.dart' show spanForElement, spanForElement2;
export 'src/span_for_element.dart' show spanForElement;
export 'src/type_checker.dart' show TypeChecker, UnresolvedAnnotationException;
export 'src/utils.dart' show typeNameOf;
4 changes: 0 additions & 4 deletions source_gen/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,6 @@ String languageOverrideForLibrary(LibraryElement2 library) {
: '// @dart=${override.major}.${override.minor}\n';
}

@Deprecated('Use languageOverrideForLibrary instead')
String languageOverrideForLibrary2(LibraryElement2 library) =>
languageOverrideForLibrary(library);

/// A comment configuring `dart_style` to use the default code width so no
/// configuration discovery is required.
const dartFormatWidth = '// dart format width=80';
7 changes: 0 additions & 7 deletions source_gen/lib/src/constants/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ void assertHasField(InterfaceElement2 root, String name) {
);
}

/// Throws a [FormatException] if [root] does not have a given field [name].
///
/// Super types [InterfaceElement2.supertype] are also checked before throwing.
@Deprecated('Use assertHasField() instead')
void assertHasField2(InterfaceElement2 root, String name) =>
assertHasField(root, name);

/// Returns whether or not [object] is or represents a `null` value.
bool isNullLike(DartObject? object) => object?.isNull != false;

Expand Down
11 changes: 0 additions & 11 deletions source_gen/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,6 @@ class InvalidGenerationSource implements Exception {
this.node,
});

@Deprecated('use the unnamed constructor instead')
InvalidGenerationSource.v2(
this.message, {
this.todo = '',
this.element,
this.node,
});

@Deprecated('use element instead')
Element2? get element2 => element;

@override
String toString() {
final buffer = StringBuffer(message);
Expand Down
29 changes: 0 additions & 29 deletions source_gen/lib/src/generator_for_annotation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ abstract class GeneratorForAnnotation<T> extends Generator {
annotatedElement.annotation,
buildStep,
);
generatedValue ??= generateForAnnotatedElement2(
annotatedElement.element,
annotatedElement.annotation,
buildStep,
);
await for (var value in normalizeGeneratorOutput(generatedValue)) {
assert(value.length == value.trim().length);
values.add(value);
Expand Down Expand Up @@ -115,30 +110,6 @@ abstract class GeneratorForAnnotation<T> extends Generator {
BuildStep buildStep,
) {}

/// Implement to return source code to generate for [element].
///
/// This method is invoked based on finding elements annotated with an
/// instance of [T]. The [annotation] is provided as a [ConstantReader].
///
/// Supported return values include a single [String] or multiple [String]
/// instances within an [Iterable] or [Stream]. It is also valid to return a
/// [Future] of [String], [Iterable], or [Stream]. When multiple values are
/// returned through an iterable or stream they will be deduplicated.
/// Typically each value will be an independent unit of code and the
/// deduplication prevents re-defining the same member multiple times. For
/// example if multiple annotated elements may need a specific utility method
/// available it can be output for each one, and the single deduplicated
/// definition can be shared.
///
/// Implementations should return `null` when no content is generated. Empty
/// or whitespace-only [String] instances are also ignored.
@Deprecated('use generateForAnnotatedElement instead')
dynamic generateForAnnotatedElement2(
Element2 element,
ConstantReader annotation,
BuildStep buildStep,
) {}

/// Implement to return source code to generate for [directive]:
/// - [LibraryImport]
/// - [LibraryExport]
Expand Down
35 changes: 0 additions & 35 deletions source_gen/lib/src/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class AnnotatedElement {

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

@Deprecated('use element instead')
Element2 get element2 => element;

Metadata? get metadata2 {
if (element case final Annotatable annotatable) {
return annotatable.metadata2;
Expand All @@ -44,33 +41,15 @@ class LibraryReader {

LibraryReader(this.element);

@Deprecated('use the default constructor instead')
LibraryReader.v2(this.element);

@Deprecated('use element instead')
LibraryElement2 get element2 => element;

/// All of the declarations in this library.
Iterable<Element2> get allElements => [element, ...element.children2];

/// All of the declarations in this library.
@Deprecated('use allElements instead')
Iterable<Element2> get allElements2 => allElements;

/// All of the elements representing classes in this library.
Iterable<ClassElement2> get classes => element.classes;

/// All of the elements representing classes in this library.
@Deprecated('use classes instead')
Iterable<ClassElement2> get classes2 => classes;

/// All of the elements representing enums in this library.
Iterable<EnumElement2> get enums => element.enums;

/// All of the elements representing enums in this library.
@Deprecated('use enums instead')
Iterable<EnumElement2> get enums3 => enums;

/// All of the declarations in this library annotated with [checker].
Iterable<AnnotatedElement> annotatedWith(
TypeChecker checker, {
Expand Down Expand Up @@ -137,13 +116,6 @@ class LibraryReader {
return type is ClassElement2 ? type : null;
}

/// Returns a top-level [ClassElement2] publicly visible in by [name].
///
/// Unlike `LibraryElement2.getClass`, this also correctly traverses
/// identifiers that are accessible via one or more `export` directives.
@Deprecated('Use findType() instead')
ClassElement2? findType2(String name) => findType(name);

/// Returns a [Uri] from the current library to the target [asset].
///
/// This is a typed convenience function for using [pathToUrl], and the same
Expand All @@ -157,13 +129,6 @@ class LibraryReader {
Uri pathToElement(Element2 element) =>
pathToUrl(element.firstFragment.libraryFragment!.source.uri);

/// Returns a [Uri] from the current library to the target [element].
///
/// This is a typed convenience function for using [pathToUrl], and the same
/// API restrictions hold around supported schemes and relative paths.
@Deprecated('use pathToElement instead')
Uri pathToElement2(Element2 element) => pathToElement(element);

/// Returns a [Uri] from the current library to the one provided.
///
/// If possible, a `package:` or `dart:` URL scheme will be used to reference
Expand Down
15 changes: 0 additions & 15 deletions source_gen/lib/src/span_for_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,6 @@ SourceSpan spanForElement(Element2 element, [SourceFile? file]) {
);
}

/// Returns a source span that spans the location where [element] is defined.
///
/// May be used to emit user-friendly warning and error messages:
/// ```dart
/// void invalidClass(ClassElement class) {
/// log.warning(spanForElement.message('Cannot implement "Secret"'));
/// }
/// ```
///
/// Not all results from the analyzer API may return source information as part
/// of the element, so [file] may need to be manually provided in those cases.
@Deprecated('use spanForElement instead')
SourceSpan spanForElement2(Element2 element, [SourceFile? file]) =>
spanForElement(element, file);

/// Returns a source span that spans the location where [node] is written.
SourceSpan spanForNode(AstNode node) {
final unit = node.thisOrAncestorOfType<CompilationUnit>()!;
Expand Down
97 changes: 0 additions & 97 deletions source_gen/lib/src/type_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,12 @@ abstract class TypeChecker {
return results.isEmpty ? null : results.first;
}

/// Returns the first constant annotating [element] assignable to this type.
///
/// Otherwise returns `null`.
///
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
@Deprecated('use firstAnnotationOf instead')
DartObject? firstAnnotationOf2(
Object element, {
bool throwOnUnresolved = true,
}) =>
firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved);

/// Returns if a constant annotating [element] is assignable to this type.
///
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
bool hasAnnotationOf(Element2 element, {bool throwOnUnresolved = true}) =>
firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved) != null;

/// Returns if a constant annotating [element] is assignable to this type.
///
/// Throws on unresolved annotations unless [throwOnUnresolved] is `false`.
@Deprecated('use hasAnnotationOf instead')
bool hasAnnotationOf2(Element2 element, {bool throwOnUnresolved = true}) =>
hasAnnotationOf(element, throwOnUnresolved: throwOnUnresolved);

/// Returns the first constant annotating [element] that is exactly this type.
///
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
Expand All @@ -125,17 +106,6 @@ abstract class TypeChecker {
return null;
}

/// Returns the first constant annotating [element] that is exactly this type.
///
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
@Deprecated('use firstAnnotationOfExact instead')
DartObject? firstAnnotationOfExact2(
Element2 element, {
bool throwOnUnresolved = true,
}) =>
firstAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved);

/// Returns if a constant annotating [element] is exactly this type.
///
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
Expand All @@ -147,17 +117,6 @@ abstract class TypeChecker {
firstAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved) !=
null;

/// Returns if a constant annotating [element] is exactly this type.
///
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
@Deprecated('use hasAnnotationOfExact instead')
bool hasAnnotationOfExact2(
Element2 element, {
bool throwOnUnresolved = true,
}) =>
hasAnnotationOfExact(element, throwOnUnresolved: throwOnUnresolved);

DartObject? _computeConstantValue(
Object element,
ElementAnnotation annotation,
Expand Down Expand Up @@ -185,17 +144,6 @@ abstract class TypeChecker {
throwOnUnresolved: throwOnUnresolved,
);

/// Returns annotating constants on [element] assignable to this type.
///
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
@Deprecated('use annotationsOf instead')
Iterable<DartObject> annotationsOf2(
Object element, {
bool throwOnUnresolved = true,
}) =>
annotationsOf(element, throwOnUnresolved: throwOnUnresolved);

Iterable<DartObject> _annotationsWhere(
Object element,
bool Function(DartType) predicate, {
Expand Down Expand Up @@ -231,27 +179,12 @@ abstract class TypeChecker {
throwOnUnresolved: throwOnUnresolved,
);

/// Returns annotating constants on [element] of exactly this type.
///
/// Throws [UnresolvedAnnotationException] on unresolved annotations unless
/// [throwOnUnresolved] is explicitly set to `false` (default is `true`).
@Deprecated('use annotationsOfExact instead')
Iterable<DartObject> annotationsOfExact2(
Element2 element, {
bool throwOnUnresolved = true,
}) =>
annotationsOfExact(element, throwOnUnresolved: throwOnUnresolved);

/// Returns `true` if the type of [element] can be assigned to this type.
bool isAssignableFrom(Element2 element) =>
isExactly(element) ||
(element is InterfaceElement2 &&
element.allSupertypes.any(isExactlyType));

/// Returns `true` if the type of [element] can be assigned to this type.
@Deprecated('use isAssignableFrom instead')
bool isAssignableFrom2(Element2 element) => isAssignableFrom(element);

/// Returns `true` if [staticType] can be assigned to this type.
bool isAssignableFromType(DartType staticType) {
final element = staticType.element3;
Expand All @@ -261,10 +194,6 @@ abstract class TypeChecker {
/// Returns `true` if representing the exact same class as [element].
bool isExactly(Element2 element);

/// Returns `true` if representing the exact same class as [element].
@Deprecated('use isExactly instead')
bool isExactly2(Element2 element) => isExactly(element);

/// Returns `true` if representing the exact same type as [staticType].
///
/// This will always return false for types without a backingclass such as
Expand Down Expand Up @@ -298,13 +227,6 @@ abstract class TypeChecker {
return false;
}

/// Returns `true` if representing a super class of [element].
///
/// This check only takes into account the *extends* hierarchy. If you wish
/// to check mixins and interfaces, use [isAssignableFrom].
@Deprecated('use isSuperOf instead')
bool isSuperOf2(Element2 element) => isSuperOf(element);

/// Returns `true` if representing a super type of [staticType].
///
/// This only takes into account the *extends* hierarchy. If you wish
Expand All @@ -322,10 +244,6 @@ class _LibraryTypeChecker extends TypeChecker {
bool isExactly(Element2 element) =>
element is InterfaceElement2 && element == _type.element3;

@Deprecated('Use isExactly() instead')
@override
bool isExactly2(Element2 element) => isExactly(element);

@override
String toString() => urlOfElement(_type.element3!);
}
Expand All @@ -349,10 +267,6 @@ class _MirrorTypeChecker extends TypeChecker {
@override
bool isExactly(Element2 element) => _computed.isExactly(element);

@Deprecated('use isExactly instead')
@override
bool isExactly2(Element2 element) => isExactly(element);

@override
String toString() => _computed.toString();
}
Expand Down Expand Up @@ -385,10 +299,6 @@ class _UriTypeChecker extends TypeChecker {
@override
bool isExactly(Element2 element) => hasSameUrl(urlOfElement(element));

@Deprecated('use isExactly instead')
@override
bool isExactly2(Element2 element) => isExactly(element);

@override
String toString() => '$uri';
}
Expand All @@ -401,10 +311,6 @@ class _AnyChecker extends TypeChecker {
@override
bool isExactly(Element2 element) =>
_checkers.any((c) => c.isExactly(element));

@Deprecated('use isExactly2 instead')
@override
bool isExactly2(Element2 element) => isExactly(element);
}

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

@Deprecated('use annotatedElement instead')
Element2 get annotatedElement2 => annotatedElement;

static SourceSpan? _findSpan(Element2 annotatedElement, int annotationIndex) {
try {
final parsedLibrary =
Expand Down
Loading
Loading