Skip to content

Commit 54acb63

Browse files
authored
Use Dart 3.7.0, reformat. (#762)
1 parent 2a6be7e commit 54acb63

34 files changed

+809
-808
lines changed

.github/workflows/dart.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ jobs:
4040
- name: mono_repo self validate
4141
run: dart pub global run mono_repo generate --validate
4242
job_002:
43-
name: "analyze_format; linux; Dart 3.6.0; PKG: source_gen; `dart analyze`"
43+
name: "analyze_format; linux; Dart 3.7.0; PKG: source_gen; `dart analyze`"
4444
runs-on: ubuntu-latest
4545
steps:
4646
- name: Cache Pub hosted dependencies
4747
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
4848
with:
4949
path: "~/.pub-cache/hosted"
50-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:source_gen;commands:analyze_1"
50+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:source_gen;commands:analyze_1"
5151
restore-keys: |
52-
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:source_gen
53-
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
52+
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:source_gen
53+
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0
5454
os:ubuntu-latest;pub-cache-hosted
5555
os:ubuntu-latest
5656
- name: Setup Dart SDK
5757
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
5858
with:
59-
sdk: "3.6.0"
59+
sdk: "3.7.0"
6060
- id: checkout
6161
name: Checkout repository
6262
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -143,23 +143,23 @@ jobs:
143143
if: "always() && steps.source_gen_pub_upgrade.conclusion == 'success'"
144144
working-directory: source_gen
145145
job_004:
146-
name: "unit_test; linux; Dart 3.6.0; PKG: example_usage; `dart test --run-skipped`"
146+
name: "unit_test; linux; Dart 3.7.0; PKG: example_usage; `dart test --run-skipped`"
147147
runs-on: ubuntu-latest
148148
steps:
149149
- name: Cache Pub hosted dependencies
150150
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
151151
with:
152152
path: "~/.pub-cache/hosted"
153-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:example_usage;commands:test_0"
153+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:example_usage;commands:test_0"
154154
restore-keys: |
155-
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:example_usage
156-
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
155+
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:example_usage
156+
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0
157157
os:ubuntu-latest;pub-cache-hosted
158158
os:ubuntu-latest
159159
- name: Setup Dart SDK
160160
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
161161
with:
162-
sdk: "3.6.0"
162+
sdk: "3.7.0"
163163
- id: checkout
164164
name: Checkout repository
165165
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -177,23 +177,23 @@ jobs:
177177
- job_002
178178
- job_003
179179
job_005:
180-
name: "unit_test; linux; Dart 3.6.0; PKG: source_gen; `dart test`"
180+
name: "unit_test; linux; Dart 3.7.0; PKG: source_gen; `dart test`"
181181
runs-on: ubuntu-latest
182182
steps:
183183
- name: Cache Pub hosted dependencies
184184
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
185185
with:
186186
path: "~/.pub-cache/hosted"
187-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:source_gen;commands:test_1"
187+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:source_gen;commands:test_1"
188188
restore-keys: |
189-
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:source_gen
190-
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
189+
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0;packages:source_gen
190+
os:ubuntu-latest;pub-cache-hosted;sdk:3.7.0
191191
os:ubuntu-latest;pub-cache-hosted
192192
os:ubuntu-latest
193193
- name: Setup Dart SDK
194194
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
195195
with:
196-
sdk: "3.6.0"
196+
sdk: "3.7.0"
197197
- id: checkout
198198
name: Checkout repository
199199
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -279,13 +279,13 @@ jobs:
279279
- job_002
280280
- job_003
281281
job_008:
282-
name: "unit_test; windows; Dart 3.6.0; PKG: source_gen; `dart test`"
282+
name: "unit_test; windows; Dart 3.7.0; PKG: source_gen; `dart test`"
283283
runs-on: windows-latest
284284
steps:
285285
- name: Setup Dart SDK
286286
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
287287
with:
288-
sdk: "3.6.0"
288+
sdk: "3.7.0"
289289
- id: checkout
290290
name: Checkout repository
291291
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

_test_annotations/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ publish_to: none
33
resolution: workspace
44

55
environment:
6-
sdk: ^3.6.0
6+
sdk: ^3.7.0
77

88
dev_dependencies:
99
dart_flutter_team_lints: ^3.1.0

analysis_options.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ linter:
2929
- prefer_const_declarations
3030
- prefer_expression_function_bodies
3131
- prefer_final_locals
32-
- require_trailing_commas
3332
- sort_child_properties_last
3433
- unnecessary_await_in_return
3534
- use_full_hex_values_for_flutter_colors

example/lib/builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import 'src/property_product_generator.dart';
2121
import 'src/property_sum_generator.dart';
2222

2323
Builder metadataLibraryBuilder(BuilderOptions options) => LibraryBuilder(
24-
MemberCountLibraryGenerator(),
25-
generatedExtension: '.info.dart',
26-
);
24+
MemberCountLibraryGenerator(),
25+
generatedExtension: '.info.dart',
26+
);
2727

2828
Builder productBuilder(BuilderOptions options) =>
2929
SharedPartBuilder([PropertyProductGenerator()], 'product');

example/lib/src/property_product_generator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import 'utils.dart';
1010
class PropertyProductGenerator extends Generator {
1111
@override
1212
String generate(LibraryReader library, BuildStep buildStep) {
13-
final productNames = topLevelNumVariables(library)
14-
.map((element) => element.name)
15-
.join(' * ');
13+
final productNames = topLevelNumVariables(
14+
library,
15+
).map((element) => element.name).join(' * ');
1616

1717
return '''
1818
num allProduct() => $productNames;

example/lib/src/property_sum_generator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import 'utils.dart';
1010
class PropertySumGenerator extends Generator {
1111
@override
1212
String generate(LibraryReader library, BuildStep buildStep) {
13-
final sumNames = topLevelNumVariables(library)
14-
.map((element) => element.name)
15-
.join(' + ');
13+
final sumNames = topLevelNumVariables(
14+
library,
15+
).map((element) => element.name).join(' + ');
1616

1717
return '''
1818
num allSum() => $sumNames;

example/lib/src/utils.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'package:source_gen/source_gen.dart';
99
/// have a type of [num].
1010
Iterable<TopLevelVariableElement> topLevelNumVariables(LibraryReader reader) =>
1111
reader.allElements.whereType<TopLevelVariableElement>().where(
12-
(element) =>
13-
element.type.isDartCoreNum ||
14-
element.type.isDartCoreInt ||
15-
element.type.isDartCoreDouble,
16-
);
12+
(element) =>
13+
element.type.isDartCoreNum ||
14+
element.type.isDartCoreInt ||
15+
element.type.isDartCoreDouble,
16+
);

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ publish_to: none
33
resolution: workspace
44

55
environment:
6-
sdk: ^3.6.0
6+
sdk: ^3.7.0
77

88
dependencies:
99
analyzer: '>=6.9.0 <8.0.0'

example_usage/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ publish_to: none
33
resolution: workspace
44

55
environment:
6-
sdk: ^3.6.0
6+
sdk: ^3.7.0
77

88
dependencies:
99
source_gen_example:

source_gen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.1-wip
2+
3+
- Require Dart 3.7.0
4+
15
## 2.0.0
26

37
- **Breaking Change**: Change `formatOutput` function to accept a language

source_gen/lib/builder.dart

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ Builder combiningBuilder([BuilderOptions options = BuilderOptions.empty]) {
3333
optionsMap.remove('ignore_for_file') as List? ?? <String>[],
3434
);
3535
final preamble = optionsMap.remove('preamble') as String? ?? '';
36-
final buildExtensions =
37-
validatedBuildExtensionsFrom(optionsMap, _defaultExtensions);
36+
final buildExtensions = validatedBuildExtensionsFrom(
37+
optionsMap,
38+
_defaultExtensions,
39+
);
3840

3941
final builder = CombiningBuilder(
4042
includePartName: includePartName,
@@ -75,18 +77,19 @@ class CombiningBuilder implements Builder {
7577
Set<String>? ignoreForFile,
7678
String? preamble,
7779
this.buildExtensions = _defaultExtensions,
78-
}) : _includePartName = includePartName ?? false,
79-
_ignoreForFile = ignoreForFile ?? const <String>{},
80-
_preamble = preamble ?? '';
80+
}) : _includePartName = includePartName ?? false,
81+
_ignoreForFile = ignoreForFile ?? const <String>{},
82+
_preamble = preamble ?? '';
8183

8284
@override
8385
Future<void> build(BuildStep buildStep) async {
8486
// Pattern used for `findAssets`, which must be glob-compatible
8587
final assetPath = buildStep.inputId.path;
8688
final pattern = '${p.withoutExtension(Glob.quote(assetPath))}.*$_partFiles';
8789

88-
final inputBaseName =
89-
p.basenameWithoutExtension(buildStep.inputId.pathSegments.last);
90+
final inputBaseName = p.basenameWithoutExtension(
91+
buildStep.inputId.pathSegments.last,
92+
);
9093

9194
// Pattern used to ensure items are only considered if they match
9295
// [file name without extension].[valid part id].[part file extension]
@@ -101,11 +104,12 @@ class CombiningBuilder implements Builder {
101104
].join(),
102105
);
103106

104-
final assetIds = await buildStep
105-
.findAssets(Glob(pattern))
106-
.where((id) => restrictedPattern.hasMatch(id.pathSegments.last))
107-
.toList()
108-
..sort();
107+
final assetIds =
108+
await buildStep
109+
.findAssets(Glob(pattern))
110+
.where((id) => restrictedPattern.hasMatch(id.pathSegments.last))
111+
.toList()
112+
..sort();
109113

110114
final assets = await Stream.fromIterable(assetIds)
111115
.asyncMap((id) async {
@@ -124,8 +128,9 @@ class CombiningBuilder implements Builder {
124128
final partOfUri = uriOfPartial(inputLibrary, buildStep.inputId, outputId);
125129

126130
// Ensure that the input has a correct `part` statement.
127-
final libraryUnit =
128-
await buildStep.resolver.compilationUnitFor(buildStep.inputId);
131+
final libraryUnit = await buildStep.resolver.compilationUnitFor(
132+
buildStep.inputId,
133+
);
129134
final part = computePartUrl(buildStep.inputId, outputId);
130135
if (!hasExpectedPartDirective(libraryUnit, part)) {
131136
log.warning(
@@ -135,9 +140,10 @@ class CombiningBuilder implements Builder {
135140
return;
136141
}
137142

138-
final ignoreForFile = _ignoreForFile.isEmpty
139-
? ''
140-
: '\n// ignore_for_file: ${_ignoreForFile.join(', ')}\n';
143+
final ignoreForFile =
144+
_ignoreForFile.isEmpty
145+
? ''
146+
: '\n// ignore_for_file: ${_ignoreForFile.join(', ')}\n';
141147

142148
final preamble = _preamble.isEmpty ? '' : '\n$_preamble\n';
143149

source_gen/lib/src/builder.dart

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,15 @@ class _Builder extends Builder {
5757
bool? writeDescriptions,
5858
this.allowSyntaxErrors = false,
5959
BuilderOptions? options,
60-
}) : _generatedExtension = generatedExtension,
61-
buildExtensions = validatedBuildExtensionsFrom(
62-
options != null ? Map.of(options.config) : null, {
63-
'.dart': [
64-
generatedExtension,
65-
...additionalOutputExtensions,
66-
],
67-
}),
68-
_writeDescriptions = writeDescriptions ?? true,
69-
_header = (header ?? defaultFileHeader).trim() {
60+
}) : _generatedExtension = generatedExtension,
61+
buildExtensions = validatedBuildExtensionsFrom(
62+
options != null ? Map.of(options.config) : null,
63+
{
64+
'.dart': [generatedExtension, ...additionalOutputExtensions],
65+
},
66+
),
67+
_writeDescriptions = writeDescriptions ?? true,
68+
_header = (header ?? defaultFileHeader).trim() {
7069
if (_generatedExtension.isEmpty || !_generatedExtension.startsWith('.')) {
7170
throw ArgumentError.value(
7271
_generatedExtension,
@@ -102,8 +101,10 @@ class _Builder extends Builder {
102101
return;
103102
}
104103

105-
final lib = await buildStep.resolver
106-
.libraryFor(buildStep.inputId, allowSyntaxErrors: allowSyntaxErrors);
104+
final lib = await buildStep.resolver.libraryFor(
105+
buildStep.inputId,
106+
allowSyntaxErrors: allowSyntaxErrors,
107+
);
107108
await _generateForLibrary(lib, buildStep);
108109
}
109110

@@ -138,10 +139,13 @@ class _Builder extends Builder {
138139
..writeln('part of \'$partOfUri\';');
139140
final part = computePartUrl(buildStep.inputId, outputId);
140141

141-
final libraryUnit =
142-
await buildStep.resolver.compilationUnitFor(buildStep.inputId);
143-
final hasLibraryPartDirectiveWithOutputUri =
144-
hasExpectedPartDirective(libraryUnit, part);
142+
final libraryUnit = await buildStep.resolver.compilationUnitFor(
143+
buildStep.inputId,
144+
);
145+
final hasLibraryPartDirectiveWithOutputUri = hasExpectedPartDirective(
146+
libraryUnit,
147+
part,
148+
);
145149
if (!hasLibraryPartDirectiveWithOutputUri) {
146150
// TODO: Upgrade to error in a future breaking change?
147151
log.warning(
@@ -163,8 +167,9 @@ class _Builder extends Builder {
163167
..writeln()
164168
..writeln(_headerLine)
165169
..writeAll(
166-
LineSplitter.split(item.generatorDescription)
167-
.map((line) => '// $line\n'),
170+
LineSplitter.split(
171+
item.generatorDescription,
172+
).map((line) => '// $line\n'),
168173
)
169174
..writeln(_headerLine)
170175
..writeln();
@@ -176,8 +181,10 @@ class _Builder extends Builder {
176181
var genPartContent = contentBuffer.toString();
177182

178183
try {
179-
genPartContent =
180-
formatOutput(genPartContent, library.languageVersion.effective);
184+
genPartContent = formatOutput(
185+
genPartContent,
186+
library.languageVersion.effective,
187+
);
181188
} catch (e, stack) {
182189
log.severe(
183190
'''
@@ -240,10 +247,7 @@ class SharedPartBuilder extends _Builder {
240247
super.additionalOutputExtensions,
241248
super.allowSyntaxErrors,
242249
super.writeDescriptions,
243-
}) : super(
244-
generatedExtension: '.$partId.g.part',
245-
header: '',
246-
) {
250+
}) : super(generatedExtension: '.$partId.g.part', header: '') {
247251
if (!_partIdRegExp.hasMatch(partId)) {
248252
throw ArgumentError.value(
249253
partId,
@@ -304,9 +308,7 @@ class PartBuilder extends _Builder {
304308
super.header,
305309
super.allowSyntaxErrors,
306310
super.options,
307-
}) : super(
308-
generatedExtension: generatedExtension,
309-
);
311+
}) : super(generatedExtension: generatedExtension);
310312
}
311313

312314
/// A [Builder] which generates standalone Dart library files.

0 commit comments

Comments
 (0)