Skip to content

Commit

Permalink
Revert "Revive to the object's variableElement if available (#713)" (
Browse files Browse the repository at this point in the history
…#719)

This reverts commit ac1837f.
  • Loading branch information
jakemac53 authored Sep 11, 2024
1 parent 76475e3 commit ae17dde
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 27 deletions.
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');
});
});
}

0 comments on commit ae17dde

Please sign in to comment.