Skip to content

Commit 8e10166

Browse files
committed
chore: Bump to 0.16.0 and upgrade analyzer to ^9.0.0
1 parent 4cf9f9d commit 8e10166

File tree

17 files changed

+119
-114
lines changed

17 files changed

+119
-114
lines changed

dpk.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
version: ^0.6.5
22

3+
workspace:
4+
- packages/*
5+
- packages/*/example
6+
37
catalog:
48
dependencies:
5-
analyzer: ^8.0.0
9+
luthor: ^0.16.0
10+
11+
analyzer: ^9.0.0
612
build: ^4.0.0
713
source_gen: ^4.0.0
814

@@ -27,6 +33,11 @@ scripts:
2733
runInPackages:
2834
- packages/luthor
2935

36+
build:
37+
command: dart run build_runner build
38+
runInPackages:
39+
- packages/luthor_generator/example
40+
3041
publish:luthor:
3142
command: dart pub publish -f
3243
runInPackages:

packages/luthor/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.16.0
2+
3+
- **FEAT**: Update version to match luthor_generator.
4+
15
# 0.15.0
26

37
- **FEAT**: Update version to match luthor_generator.

packages/luthor/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ environment:
88
sdk: '>=3.8.0 <4.0.0'
99

1010
dependencies:
11-
luthor:
11+
luthor: ^0.16.0 # Configured via catalog
1212

1313
dev_dependencies:
1414
lints: ^6.0.0

packages/luthor/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: luthor
22
description: |
33
A Dart validation library inspired by https://zod.dev
44
with support for code generation.
5-
version: 0.15.0
5+
version: 0.16.0
66
repository: https://github.com/exaby73/luthor/tree/main/packages/luthor
77
homepage: https://luthor.ex3.dev
88
resolution: workspace
99

1010
environment:
11-
sdk: '>=3.8.0 <4.0.0'
11+
sdk: ">=3.8.0 <4.0.0"
1212

1313
dependencies:
1414
meta: any

packages/luthor_generator/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.16.0
2+
3+
- **FEAT**: Update `analyzer` dependency to `^9.0.0`.
4+
15
# 0.15.0
26

37
- **FEAT**: Update `build` dependency to `^4.0.0`.

packages/luthor_generator/example/lib/without_freezed.mapper.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/luthor_generator/example/pubspec.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ dependencies:
1111
dart_mappable: ^4.3.0
1212
freezed_annotation: ^3.0.0
1313
json_annotation: ^4.9.0
14-
luthor: any
14+
luthor: ^0.16.0 # Configured via catalog
1515

1616
dev_dependencies:
17-
luthor_generator:
18-
path: ../
17+
luthor_generator: ^0.16.0 # Configured via catalog
1918
lints: ^6.0.0
2019
test: ^1.25.7
2120
build_runner: ^2.4.11

packages/luthor_generator/lib/generators/luthor_generator.dart

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// ignore_for_file: deprecated_member_use
2-
3-
import 'package:analyzer/dart/element/element2.dart';
1+
import 'package:analyzer/dart/element/element.dart';
42
import 'package:build/build.dart';
53
import 'package:luthor/luthor.dart';
64
import 'package:luthor_generator/checkers.dart';
@@ -10,33 +8,33 @@ import 'package:source_gen/source_gen.dart';
108
class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
119
@override
1210
String generateForAnnotatedElement(
13-
Element2 element,
11+
Element element,
1412
ConstantReader annotation,
1513
BuildStep buildStep,
1614
) {
1715
// Reset the generation context for each annotated element
1816
GenerationContext.reset();
19-
if (element is! ClassElement2) {
17+
if (element is! ClassElement) {
2018
throw InvalidGenerationSourceError(
2119
'Luthor can only be applied to classes.',
2220
element: element,
2321
);
2422
}
2523

26-
if (element.constructors2.isEmpty) {
24+
if (element.constructors.isEmpty) {
2725
throw InvalidGenerationSourceError(
2826
'Luthor can only be applied to classes with at least one constructor.',
2927
element: element,
3028
);
3129
}
3230

33-
final name = element.name3;
34-
final constructor = element.constructors2.first;
31+
final name = element.name;
32+
final constructor = element.constructors.first;
3533

3634
final isDartMappableClass =
3735
getAnnotation(dartMappableChecker, element) != null;
38-
final hasFromJsonCtor = element.constructors2.any(
39-
(element) => element.isFactory && element.name3 == 'fromJson',
36+
final hasFromJsonCtor = element.constructors.any(
37+
(element) => element.isFactory && element.name == 'fromJson',
4038
);
4139
if (!hasFromJsonCtor && !isDartMappableClass) {
4240
throw InvalidGenerationSourceError(
@@ -57,7 +55,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
5755
);
5856

5957
for (final param in params) {
60-
final fieldName = param.name3!;
58+
final fieldName = param.name;
6159
buffer.write(" ${name}SchemaKeys.$fieldName: ");
6260
buffer.write(getValidations(param, enclosingClass: element));
6361
buffer.write(',\n');
@@ -119,7 +117,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
119117
void _writeSchemaKeysRecord(
120118
StringBuffer buffer,
121119
String name,
122-
ConstructorElement2 constructor,
120+
ConstructorElement constructor,
123121
) {
124122
buffer.write('\n\n');
125123

@@ -128,7 +126,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
128126
buffer.write('const ${name}SchemaKeys = (\n');
129127

130128
for (final param in constructor.formalParameters) {
131-
final fieldName = _getRecordFieldName(param.name3!);
129+
final fieldName = _getRecordFieldName(param.name!);
132130
final jsonKeyName = _getJsonKeyName(param);
133131
buffer.write(' $fieldName: "$jsonKeyName",\n');
134132
}
@@ -139,7 +137,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
139137
void _writeErrorKeysRecord(
140138
StringBuffer buffer,
141139
String name,
142-
ConstructorElement2 constructor,
140+
ConstructorElement constructor,
143141
) {
144142
buffer.write('\n\n');
145143

@@ -165,15 +163,15 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
165163
Set<String> visitedTypes,
166164
) {
167165
for (final param in parameters) {
168-
final fieldName = _getRecordFieldName(param.name3!);
166+
final fieldName = _getRecordFieldName(param.name!);
169167
final jsonKeyName = _getJsonKeyName(param);
170168
final fullKey = prefix.isEmpty ? jsonKeyName : '$prefix.$jsonKeyName';
171169
final isNestedSchema = _isNestedSchema(param);
172170

173171
if (isNestedSchema) {
174172
final nestedClass = _getNestedClassElement(param);
175173
if (nestedClass != null) {
176-
final className = nestedClass.name3!;
174+
final className = nestedClass.name!;
177175

178176
// Check for circular reference
179177
if (visitedTypes.contains(className)) {
@@ -185,7 +183,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
185183
buffer.write('$indent$fieldName: (\n');
186184
_writeErrorKeysValues(
187185
buffer,
188-
nestedClass.constructors2.first.formalParameters,
186+
nestedClass.constructors.first.formalParameters,
189187
'$indent ',
190188
fullKey,
191189
visitedTypes,
@@ -210,26 +208,26 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
210208
.firstAnnotationOf(param)
211209
?.getField('name')
212210
?.toStringValue();
213-
return jsonKeyName ?? param.name3!;
211+
return jsonKeyName ?? param.name!;
214212
}
215213

216214
bool _isNestedSchema(FormalParameterElement param) {
217-
final element = param.type.element3;
215+
final element = param.type.element;
218216
if (element == null) return false;
219217

220218
final hasLuthorAnnotation = getAnnotation(luthorChecker, element) != null;
221219
if (hasLuthorAnnotation) return true;
222220

223-
if (element is ClassElement2 && isCompatibleForAutoGeneration(element)) {
221+
if (element is ClassElement && isCompatibleForAutoGeneration(element)) {
224222
return true;
225223
}
226224

227225
return false;
228226
}
229227

230-
ClassElement2? _getNestedClassElement(FormalParameterElement param) {
231-
final element = param.type.element3;
232-
if (element is ClassElement2) {
228+
ClassElement? _getNestedClassElement(FormalParameterElement param) {
229+
final element = param.type.element;
230+
if (element is ClassElement) {
233231
final hasLuthorAnnotation = getAnnotation(luthorChecker, element) != null;
234232
if (hasLuthorAnnotation || isCompatibleForAutoGeneration(element)) {
235233
return element;
@@ -239,8 +237,8 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
239237
}
240238

241239
/// Generates schema for a compatible class
242-
String _generateAutoSchema(ClassElement2 element, String className) {
243-
final constructor = element.constructors2.first;
240+
String _generateAutoSchema(ClassElement element, String className) {
241+
final constructor = element.constructors.first;
244242
final isDartMappableClass =
245243
getAnnotation(dartMappableChecker, element) != null;
246244

@@ -255,7 +253,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
255253
);
256254

257255
for (final param in constructor.formalParameters) {
258-
final fieldName = param.name3!;
256+
final fieldName = param.name!;
259257
buffer.write(" ${className}SchemaKeys.$fieldName: ");
260258
buffer.write(getValidations(param, enclosingClass: element));
261259
buffer.write(',\n');
@@ -285,7 +283,7 @@ class LuthorGenerator extends GeneratorForAnnotation<Luthor> {
285283
final currentClass = GenerationContext.discoveredClasses.first;
286284
GenerationContext.discoveredClasses.remove(currentClass);
287285

288-
final className = currentClass.name3!;
286+
final className = currentClass.name!;
289287

290288
// Skip if already processed
291289
if (processedClasses.contains(className)) {

0 commit comments

Comments
 (0)