Skip to content

Commit

Permalink
Revert "Update analyzer and dart_style dependencies to allow uppe…
Browse files Browse the repository at this point in the history
…r versio…"

This reverts commit dccfb6c.
  • Loading branch information
trevorwang authored Dec 30, 2024
1 parent dccfb6c commit 9e936ea
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 501 deletions.
4 changes: 1 addition & 3 deletions generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
## 9.1.6

- Update `analyzer`, `dart_style` and `source_gen` dependencies to allow upper versions
# Changelog

## 9.1.5

Expand Down
24 changes: 8 additions & 16 deletions generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class RetrofitGenerator extends GeneratorForAnnotation<retrofit.RestApi> {
});

final emitter = DartEmitter(useNullSafetySyntax: true);
return DartFormatter(languageVersion: DartFormatter.latestLanguageVersion)
return DartFormatter()
.format([_analyzerIgnores, classBuilder.accept(emitter)].join('\n\n'));
}

Expand Down Expand Up @@ -1727,7 +1727,7 @@ if (T != dynamic &&
.assign(refer(bodyName.displayName))
.statement,
);
} else if (_missingSerialize(ele.enclosingElement3, bodyName.type)) {
} else if (_missingSerialize(ele.enclosingElement, bodyName.type)) {
log.warning(
'${_displayString(bodyName.type)} must provide a `serialize${_displayString(bodyName.type)}()` method which returns a Map.\n'
"It is programmer's responsibility to make sure the ${_displayString(bodyName.type)} is properly serialized");
Expand Down Expand Up @@ -1911,7 +1911,7 @@ ${bodyName.displayName} == null
blocks.add(returnCode);
}
if (p.type.isNullable) {
blocks.add(const Code('}'));
blocks.add(Code('}'));
}
} else if (_displayString(p.type) == 'List<int>') {
final optionalFile = m.parameters
Expand Down Expand Up @@ -2278,18 +2278,10 @@ ${bodyName.displayName} == null
}

Object? _getFieldValue(ConstantReader? value) {
if (value?.isBool ?? false) {
return value?.boolValue;
}
if (value?.isDouble ?? false) {
return value?.doubleValue;
}
if (value?.isInt ?? false) {
return value?.intValue;
}
if (value?.isString ?? false) {
return value?.stringValue;
}
if (value?.isBool ?? false) return value?.boolValue;
if (value?.isDouble ?? false) return value?.doubleValue;
if (value?.isInt ?? false) return value?.intValue;
if (value?.isString ?? false) return value?.stringValue;
if (value?.objectValue.isEnum ?? false) {
return value?.objectValue.variable?.displayName;
}
Expand All @@ -2316,7 +2308,7 @@ ${bodyName.displayName} == null
final fields = <String, Object?>{};
final type = value!.objectValue.type;
if (type is InterfaceType) {
for (final field in type.element.fields) {
for (var field in type.element.fields) {
if (!field.isStatic) {
final fieldValue = value.peek(field.name);
fields[field.name] = _getFieldValue(fieldValue);
Expand Down
12 changes: 6 additions & 6 deletions generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ topics:
- rest
- retrofit
- codegen
version: 9.1.6
version: 9.1.5
environment:
sdk: '>=3.3.0 <4.0.0'

dependencies:
analyzer: '>=6.9.0 <8.0.0'
analyzer: ^6.5.0
build: ^2.4.1
built_collection: ^5.1.1
code_builder: ^4.10.0
dart_style: '>=2.3.7 <4.0.0'
dart_style: ^2.3.0
dio: ^5.0.0
protobuf: ^3.1.0
retrofit: ^4.4.1
source_gen: '>=1.5.0 <3.0.0'
retrofit: ^4.4.0
source_gen: ^1.5.0

dev_dependencies:
lints: any
lints: ^4.0.0
source_gen_test: ^1.0.6
test: ^1.25.0
2 changes: 1 addition & 1 deletion generator/test/generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Future<void> main() async {
RetrofitGenerator(RetrofitOptions()),
defaultConfiguration: ['default'],
additionalGenerators: {
'use_result': RetrofitGenerator(RetrofitOptions(useResult: true)),
'use_result': RetrofitGenerator(RetrofitOptions(useResult: true))
},
);
}
Loading

0 comments on commit 9e936ea

Please sign in to comment.