Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revive to the object's variableElement if available (#713)" #719

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion source_gen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- Document deduplication behavior for the output of
`GeneratorForAnnotation.generateForAnnotatedElement`.
- Support all the glob quotes.
- Revive to the object's `variableElement` if available
- Require `analyzer: ^6.9.0`
- Require Dart 3.5.0

Expand Down
15 changes: 0 additions & 15 deletions source_gen/lib/src/constants/revive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@ import '../utils.dart';
/// Dart source code (such as referencing private constructors). It is up to the
/// build tool(s) using this library to surface error messages to the user.
Revivable reviveInstance(DartObject object, [LibraryElement? origin]) {
final variableElement = object.variable;
if (variableElement != null &&
variableElement.isConst &&
variableElement.isPublic) {
final url = Uri.parse(urlOfElement(variableElement)).removeFragment();
if (variableElement.enclosingElement
case final TypeDefiningElement enclosingElement?) {
return Revivable._(
source: url,
accessor: '${enclosingElement.name}.${variableElement.name}',
);
}
return Revivable._(source: url, accessor: variableElement.name);
}

final objectType = object.type;
Element? element = objectType!.alias?.element;
if (element == null) {
Expand Down
11 changes: 0 additions & 11 deletions source_gen/test/constants_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ void main() {
@_privateField
@Wrapper(_privateFunction)
@ProcessStartMode.normal
@ExtensionTypeWithStaticField.staticField
class Example {}

class Int64Like implements Int64LikeBase{
Expand Down Expand Up @@ -297,10 +296,6 @@ void main() {
}

void _privateFunction() {}

extension type const ExtensionTypeWithStaticField._(int _) {
static const staticField = ExtensionTypeWithStaticField._(1);
}
''',
(resolver) async => (await resolver.findLibraryByName('test_lib'))!,
);
Expand Down Expand Up @@ -398,11 +393,5 @@ void main() {
expect(staticFieldWithPrivateImpl.isPrivate, isFalse);
expect(staticFieldWithPrivateImpl.source.fragment, isEmpty);
});

test('should decode static fields on extension types', () {
final fieldOnly = constants[14].revive();
expect(fieldOnly.source.fragment, isEmpty);
expect(fieldOnly.accessor, 'ExtensionTypeWithStaticField.staticField');
});
});
}