Skip to content

Commit 7ae8a00

Browse files
committed
use latest format
1 parent cd35335 commit 7ae8a00

24 files changed

Lines changed: 193 additions & 198 deletions

lib/src/core_config.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ library dart_dev.src.core_config;
66
import 'package:dart_dev/dart_dev.dart';
77

88
Map<String, DevTool> get coreConfig => {
9-
'analyze': AnalyzeTool(),
10-
'format': FormatTool(),
11-
'test': TestTool(),
12-
};
9+
'analyze': AnalyzeTool(),
10+
'format': FormatTool(),
11+
'test': TestTool(),
12+
};

lib/src/dart_dev_runner.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'utils/version.dart';
1111

1212
class DartDevRunner extends CommandRunner<int> {
1313
DartDevRunner(Map<String, DevTool> commands)
14-
: super('dart_dev', 'Dart tool runner.') {
14+
: super('dart_dev', 'Dart tool runner.') {
1515
// For backwards-compatibility, only add the `clean` command if it doesn't
1616
// conflict with any configured command.
1717
if (!commands.containsKey('clean')) {
@@ -79,6 +79,7 @@ class CommandNameMismatch implements Exception {
7979
CommandNameMismatch(this.actual, this.expected);
8080

8181
@override
82-
String toString() => 'CommandNameMismatch: '
82+
String toString() =>
83+
'CommandNameMismatch: '
8384
'Expected a "$expected" command but got one named "$actual".';
8485
}

lib/src/dart_dev_tool.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ abstract class DevTool {
1414
factory DevTool.fromFunction(
1515
FutureOr<int?> Function(DevToolExecutionContext context) function, {
1616
ArgParser? argParser,
17-
}) =>
18-
FunctionTool(function, argParser: argParser);
17+
}) => FunctionTool(function, argParser: argParser);
1918

2019
factory DevTool.fromProcess(
2120
String executable,
2221
List<String> args, {
2322
ProcessStartMode? mode,
2423
String? workingDirectory,
25-
}) =>
26-
ProcessTool(
27-
executable,
28-
args,
29-
mode: mode,
30-
workingDirectory: workingDirectory,
31-
);
24+
}) => ProcessTool(
25+
executable,
26+
args,
27+
mode: mode,
28+
workingDirectory: workingDirectory,
29+
);
3230

3331
/// The argument parser for this tool, if needed.
3432
///
@@ -122,13 +120,12 @@ class DevToolExecutionContext {
122120
String? commandName,
123121
void Function(String message)? usageException,
124122
bool? verbose,
125-
}) =>
126-
DevToolExecutionContext(
127-
argResults: argResults ?? this.argResults,
128-
commandName: commandName ?? this.commandName,
129-
usageException: usageException ?? this.usageException,
130-
verbose: verbose ?? this.verbose,
131-
);
123+
}) => DevToolExecutionContext(
124+
argResults: argResults ?? this.argResults,
125+
commandName: commandName ?? this.commandName,
126+
usageException: usageException ?? this.usageException,
127+
verbose: verbose ?? this.verbose,
128+
);
132129

133130
/// Calling this will throw a [UsageException] with [message] that should be
134131
/// caught by [CommandRunner] and used to set the exit code accordingly and

lib/src/executable.dart

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,10 @@ Future<void> run(List<String> args) async {
6262
}
6363

6464
final processArgs = generateRunScript();
65-
final process = await Process.start(
66-
processArgs.first,
67-
[
68-
if (processArgs.length > 1) ...processArgs.sublist(1),
69-
...args,
70-
],
71-
mode: ProcessStartMode.inheritStdio);
65+
final process = await Process.start(processArgs.first, [
66+
if (processArgs.length > 1) ...processArgs.sublist(1),
67+
...args,
68+
], mode: ProcessStartMode.inheritStdio);
7269
ensureProcessExit(process);
7370
exitCode = await process.exitCode;
7471
}
@@ -174,13 +171,14 @@ String? _computeRunScriptDigest() {
174171
if (packageConfig.existsSync()) ...packageConfig.readAsBytesSync(),
175172
if (configFile.existsSync()) ...configFile.readAsBytesSync(),
176173
if (configHasRelativeImports)
177-
for (final file in Glob('tool/**.dart', recursive: true)
178-
.listSync()
179-
.whereType<File>()
180-
.where(
181-
(f) => p.canonicalize(f.path) != p.canonicalize(_paths.config),
182-
)
183-
.sortedBy((f) => f.path))
174+
for (final file
175+
in Glob('tool/**.dart', recursive: true)
176+
.listSync()
177+
.whereType<File>()
178+
.where(
179+
(f) => p.canonicalize(f.path) != p.canonicalize(_paths.config),
180+
)
181+
.sortedBy((f) => f.path))
184182
...file.readAsBytesSync(),
185183
]);
186184
return base64.encode(digest.bytes);
@@ -328,7 +326,8 @@ Future<void> runWithConfig(
328326
DevTool chooseDefaultFormatTool({String? path}) {
329327
final pubspec = cachedPubspec(path: path);
330328
const orf = 'over_react_format';
331-
final hasOverReactFormat = pubspec.dependencies.containsKey(orf) ||
329+
final hasOverReactFormat =
330+
pubspec.dependencies.containsKey(orf) ||
332331
pubspec.devDependencies.containsKey(orf) ||
333332
pubspec.dependencyOverrides.containsKey(orf);
334333

lib/src/tools/analyze_tool.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class AnalyzeTool extends DevTool {
6868
final ArgParser argParser = ArgParser()
6969
..addOption(
7070
'analyzer-args',
71-
help: 'Args to pass to the "dartanalyzer" or "dart analyze" process.\n'
71+
help:
72+
'Args to pass to the "dartanalyzer" or "dart analyze" process.\n'
7273
'Run "dartanalyzer -h -v" or `dart analyze -h -v" to see all available options.',
7374
);
7475

@@ -82,8 +83,9 @@ class AnalyzeTool extends DevTool {
8283
context ?? DevToolExecutionContext(),
8384
configuredAnalyzerArgs: analyzerArgs,
8485
include: include,
85-
useDartAnalyze:
86-
!dartVersionHasDartanalyzer ? true : useDartAnalyze ?? false,
86+
useDartAnalyze: !dartVersionHasDartanalyzer
87+
? true
88+
: useDartAnalyze ?? false,
8789
),
8890
log: _log,
8991
);
@@ -179,7 +181,8 @@ ProcessDeclaration buildProcess(
179181
argResults,
180182
context.usageException,
181183
commandName: context.commandName,
182-
usageFooter: 'Arguments can be passed to the "$analyzerUsed" process via '
184+
usageFooter:
185+
'Arguments can be passed to the "$analyzerUsed" process via '
183186
'the --analyzer-args option.',
184187
);
185188
}
@@ -197,13 +200,10 @@ ProcessDeclaration buildProcess(
197200
verbose: context.verbose,
198201
useDartAnalyzer: useDartAnalyze,
199202
);
200-
return ProcessDeclaration(
201-
executable,
202-
[
203-
...args,
204-
...entrypoints,
205-
],
206-
mode: ProcessStartMode.inheritStdio);
203+
return ProcessDeclaration(executable, [
204+
...args,
205+
...entrypoints,
206+
], mode: ProcessStartMode.inheritStdio);
207207
}
208208

209209
/// Logs the `dartanalyzer` or `dart analyze` command that will be run by [AnalyzeTool] so that

lib/src/tools/compound_tool.dart

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ ArgResults takeOptionArgs(ArgParser parser, ArgResults results) =>
4343
/// ..addTool(TestTool(), argMapper: takeAllArgs)
4444
/// };
4545
ArgResults takeAllArgs(ArgParser parser, ArgResults results) => parser.parse([
46-
...optionArgsOnly(results, allowedOptions: parser.options.keys),
47-
...restArgsWithSeparator(results),
48-
]);
46+
...optionArgsOnly(results, allowedOptions: parser.options.keys),
47+
...restArgsWithSeparator(results),
48+
]);
4949

5050
class CompoundTool extends DevTool with CompoundToolMixin {}
5151

@@ -81,8 +81,8 @@ mixin CompoundToolMixin on DevTool {
8181
for (var i = 0; i < _specs.length; i++) {
8282
if (!shouldRunTool(_specs[i].when, code)) continue;
8383
final newCode = await _specs[i].tool.run(
84-
contextForTool(context, _specs[i]),
85-
);
84+
contextForTool(context, _specs[i]),
85+
);
8686
_log.fine('Step ${i + 1}/${_specs.length} done (code: $newCode)\n');
8787
if (code == 0) {
8888
code = newCode;
@@ -282,19 +282,18 @@ class CompoundArgParser implements ArgParser {
282282
bool hide = false,
283283
bool hideNegatedUsage = false,
284284
List<String> aliases = const [],
285-
}) =>
286-
_compoundParser.addFlag(
287-
name,
288-
abbr: abbr,
289-
help: help,
290-
defaultsTo: defaultsTo,
291-
negatable: negatable,
292-
// TODO once lower bound of args is 2.7.0 (requires Dart SDK 3.3.0), which adds hideNegatedUsage, forward this arg
293-
// hideNegatedUsage: hideNegatedUsage,
294-
callback: callback,
295-
hide: hide,
296-
aliases: aliases,
297-
);
285+
}) => _compoundParser.addFlag(
286+
name,
287+
abbr: abbr,
288+
help: help,
289+
defaultsTo: defaultsTo,
290+
negatable: negatable,
291+
// TODO once lower bound of args is 2.7.0 (requires Dart SDK 3.3.0), which adds hideNegatedUsage, forward this arg
292+
// hideNegatedUsage: hideNegatedUsage,
293+
callback: callback,
294+
hide: hide,
295+
aliases: aliases,
296+
);
298297

299298
@override
300299
void addMultiOption(
@@ -309,20 +308,19 @@ class CompoundArgParser implements ArgParser {
309308
bool splitCommas = true,
310309
bool hide = false,
311310
List<String> aliases = const [],
312-
}) =>
313-
_compoundParser.addMultiOption(
314-
name,
315-
abbr: abbr,
316-
help: help,
317-
valueHelp: valueHelp,
318-
allowed: allowed,
319-
allowedHelp: allowedHelp,
320-
defaultsTo: defaultsTo,
321-
callback: callback,
322-
splitCommas: splitCommas,
323-
hide: hide,
324-
aliases: aliases,
325-
);
311+
}) => _compoundParser.addMultiOption(
312+
name,
313+
abbr: abbr,
314+
help: help,
315+
valueHelp: valueHelp,
316+
allowed: allowed,
317+
allowedHelp: allowedHelp,
318+
defaultsTo: defaultsTo,
319+
callback: callback,
320+
splitCommas: splitCommas,
321+
hide: hide,
322+
aliases: aliases,
323+
);
326324

327325
@override
328326
void addOption(
@@ -337,18 +335,17 @@ class CompoundArgParser implements ArgParser {
337335
bool mandatory = false,
338336
bool hide = false,
339337
List<String> aliases = const [],
340-
}) =>
341-
_compoundParser.addOption(
342-
name,
343-
abbr: abbr,
344-
help: help,
345-
valueHelp: valueHelp,
346-
allowed: allowed,
347-
allowedHelp: allowedHelp,
348-
defaultsTo: defaultsTo,
349-
callback: callback,
350-
mandatory: mandatory,
351-
hide: hide,
352-
aliases: aliases,
353-
);
338+
}) => _compoundParser.addOption(
339+
name,
340+
abbr: abbr,
341+
help: help,
342+
valueHelp: valueHelp,
343+
allowed: allowed,
344+
allowedHelp: allowedHelp,
345+
defaultsTo: defaultsTo,
346+
callback: callback,
347+
mandatory: mandatory,
348+
hide: hide,
349+
aliases: aliases,
350+
);
354351
}

lib/src/tools/format_tool.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ class FormatTool extends DevTool {
108108
'check',
109109
abbr: 'c',
110110
negatable: false,
111-
help: 'Check if changes need to be made and set the exit code '
111+
help:
112+
'Check if changes need to be made and set the exit code '
112113
'accordingly.\nImplies "--dry-run" and "--set-exit-if-changed".',
113114
)
114115
..addSeparator('======== Other Options')
115116
..addOption(
116117
'formatter-args',
117-
help: 'Args to pass to the "dartfmt" or "dart format" process.\n'
118+
help:
119+
'Args to pass to the "dartfmt" or "dart format" process.\n'
118120
'Run "dartfmt -h -v" or "dart format -h -v" to see all available options.',
119121
);
120122

@@ -281,11 +283,11 @@ class FormatterInputs {
281283
/// output of step 1 (an instance of this class) with very simple unit tests.
282284
class FormatExecution {
283285
FormatExecution.exitEarly(this.exitCode)
284-
: formatProcess = null,
285-
directiveOrganization = null;
286+
: formatProcess = null,
287+
directiveOrganization = null;
286288

287289
FormatExecution.process(this.formatProcess, [this.directiveOrganization])
288-
: exitCode = null;
290+
: exitCode = null;
289291

290292
/// If non-null, the execution is already complete and the [FormatTool] should
291293
/// exit with this code.
@@ -455,7 +457,8 @@ FormatExecution buildExecution(
455457
}) {
456458
FormatMode? mode;
457459

458-
final useRestForInputs = (context.argResults?.rest.isNotEmpty ?? false) &&
460+
final useRestForInputs =
461+
(context.argResults?.rest.isNotEmpty ?? false) &&
459462
context.commandName == 'hackFastFormat';
460463

461464
final argResults = context.argResults;
@@ -512,7 +515,8 @@ FormatExecution buildExecution(
512515

513516
final dartFormatter = buildFormatProcess(formatter);
514517
Iterable<String> args;
515-
final dartStyleSupportsWriteArg = formatter != Formatter.dartStyle ||
518+
final dartStyleSupportsWriteArg =
519+
formatter != Formatter.dartStyle ||
516520
_dartStyleVersionSupportsWriteArg(path: path);
517521
final formatterLanguageVersion = _formatterLanguageVersion(
518522
formatter,
@@ -544,13 +548,10 @@ FormatExecution buildExecution(
544548
verbose: context.verbose,
545549
);
546550

547-
final formatProcess = ProcessDeclaration(
548-
dartFormatter.executable,
549-
[
550-
...args,
551-
...inputs.includedFiles,
552-
],
553-
mode: ProcessStartMode.inheritStdio);
551+
final formatProcess = ProcessDeclaration(dartFormatter.executable, [
552+
...args,
553+
...inputs.includedFiles,
554+
], mode: ProcessStartMode.inheritStdio);
554555
DirectiveOrganization? directiveOrganization;
555556
if (organizeDirectives) {
556557
directiveOrganization = DirectiveOrganization(

lib/src/tools/function_tool.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class FunctionTool extends DevTool {
1515
FunctionTool(
1616
FutureOr<int?> Function(DevToolExecutionContext context) function, {
1717
ArgParser? argParser,
18-
}) : _argParser = argParser,
19-
_function = function;
18+
}) : _argParser = argParser,
19+
_function = function;
2020

2121
final FutureOr<int?> Function(DevToolExecutionContext context) _function;
2222

0 commit comments

Comments
 (0)