Skip to content

Commit a9a7c30

Browse files
committed
Resolve conflicts
1 parent 3258b1a commit a9a7c30

16 files changed

+307
-244
lines changed

packages/go_router_builder/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
## 3.1.0
1+
## 3.2.0
22

33
- Adds support for `TypedRelativeGoRoute`.
4+
5+
## 3.1.0
6+
47
- Restricts `build` to versions less than 2.5.0.
8+
- Updates dependencies to use the latest `analyzer`, `build`, and `source_gen`.
9+
- Updates dev dependencies to use the latest `build_test`.
10+
- Migrates to the `element2` API.
11+
- Improves test code formatting consistency.
12+
- Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
513

614
## 3.0.1
715

packages/go_router_builder/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ To use `go_router_builder`, you need to have the following dependencies in
88
```yaml
99
dependencies:
1010
# ...along with your other dependencies
11-
go_router: ^9.0.3
11+
go_router: ^16.1.1
1212

1313
dev_dependencies:
1414
# ...along with your other dev-dependencies
15-
build_runner: ^2.0.0
16-
go_router_builder: ^2.3.0
15+
build_runner: ^2.6.0
16+
go_router_builder: ^3.2.0
1717
```
1818
1919
### Source code

packages/go_router_builder/lib/go_router_builder.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ import 'src/go_router_generator.dart';
2121
/// `go_router`.
2222
///
2323
/// Not meant to be invoked by hand-authored code.
24-
Builder goRouterBuilder(BuilderOptions options) => SharedPartBuilder(
25-
const <Generator>[GoRouterGenerator()],
26-
'go_router',
27-
);
24+
Builder goRouterBuilder(BuilderOptions options) =>
25+
SharedPartBuilder(const <Generator>[GoRouterGenerator()], 'go_router');

packages/go_router_builder/lib/src/go_router_generator.dart

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'dart:async';
66

7-
import 'package:analyzer/dart/element/element.dart';
7+
import 'package:analyzer/dart/element/element2.dart';
88
import 'package:analyzer/dart/element/type.dart';
99
import 'package:build/build.dart';
1010
import 'package:source_gen/source_gen.dart';
@@ -28,9 +28,10 @@ class GoRouterGenerator extends Generator {
2828
const GoRouterGenerator();
2929

3030
TypeChecker get _typeChecker => TypeChecker.any(
31-
_annotations.keys.map((String annotation) =>
32-
TypeChecker.fromUrl('$_routeDataUrl#$annotation')),
33-
);
31+
_annotations.keys.map(
32+
(String annotation) => TypeChecker.fromUrl('$_routeDataUrl#$annotation'),
33+
),
34+
);
3435

3536
@override
3637
FutureOr<String> generate(LibraryReader library, BuildStep buildStep) async {
@@ -62,48 +63,53 @@ ${getters.map((String e) => "$e,").join('\n')}
6263
Set<String> values,
6364
Set<String> getters,
6465
) {
65-
for (final AnnotatedElement annotatedElement
66-
in library.annotatedWith(_typeChecker)) {
66+
for (final AnnotatedElement annotatedElement in library.annotatedWith(
67+
_typeChecker,
68+
)) {
6769
final InfoIterable generatedValue = _generateForAnnotatedElement(
6870
annotatedElement.element,
6971
annotatedElement.annotation,
7072
);
7173
getters.add(generatedValue.routeGetterName);
72-
for (final String value in generatedValue) {
73-
assert(value.length == value.trim().length);
74-
values.add(value);
75-
}
74+
values.addAll(generatedValue.members);
7675
}
7776
}
7877

7978
InfoIterable _generateForAnnotatedElement(
80-
Element element,
79+
Element2 element,
8180
ConstantReader annotation,
8281
) {
83-
final String typedAnnotation =
84-
withoutNullability(annotation.objectValue.type!.getDisplayString());
85-
final String type =
86-
typedAnnotation.substring(0, typedAnnotation.indexOf('<'));
82+
final String typedAnnotation = withoutNullability(
83+
annotation.objectValue.type!.getDisplayString(),
84+
);
85+
final String type = typedAnnotation.substring(
86+
0,
87+
typedAnnotation.indexOf('<'),
88+
);
8789
final String routeData = _annotations[type]!;
88-
if (element is! ClassElement) {
90+
if (element is! ClassElement2) {
8991
throw InvalidGenerationSourceError(
9092
'The @$type annotation can only be applied to classes.',
9193
element: element,
9294
);
9395
}
9496

95-
final TypeChecker dataChecker =
96-
TypeChecker.fromUrl('$_routeDataUrl#$routeData');
97-
if (!element.allSupertypes
98-
.any((InterfaceType element) => dataChecker.isExactlyType(element))) {
97+
final TypeChecker dataChecker = TypeChecker.fromUrl(
98+
'$_routeDataUrl#$routeData',
99+
);
100+
if (!element.allSupertypes.any(
101+
(InterfaceType element) => dataChecker.isExactlyType(element),
102+
)) {
99103
throw InvalidGenerationSourceError(
100104
'The @$type annotation can only be applied to classes that '
101105
'extend or implement `$routeData`.',
102106
element: element,
103107
);
104108
}
105109

106-
return RouteBaseConfig.fromAnnotation(annotation, element)
107-
.generateMembers();
110+
return RouteBaseConfig.fromAnnotation(
111+
annotation,
112+
element,
113+
).generateMembers();
108114
}
109115
}

packages/go_router_builder/lib/src/path_utils.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ final RegExp _parameterRegExp = RegExp(r':(\w+)(\((?:\\.|[^\\()])+\))?');
1515
/// final pathParameters = pathParametersFromPattern(pattern); // {'id', 'bookId'}
1616
/// ```
1717
Set<String> pathParametersFromPattern(String pattern) => <String>{
18-
for (final RegExpMatch match in _parameterRegExp.allMatches(pattern))
19-
match[1]!,
20-
};
18+
for (final RegExpMatch match in _parameterRegExp.allMatches(pattern))
19+
match[1]!,
20+
};
2121

2222
/// Reconstructs the full path from a [pattern] and path parameters.
2323
///

0 commit comments

Comments
 (0)