Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
10840352
Unverified
Commit
10840352
authored
Jun 10, 2021
by
Jonah Williams
Committed by
GitHub
Jun 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] switch flutter sdk to dart format (#84273)
parent
07921b56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
63 deletions
+35
-63
executable.dart
packages/flutter_tools/lib/executable.dart
+1
-1
format.dart
packages/flutter_tools/lib/src/commands/format.dart
+24
-44
create_test.dart
...tter_tools/test/commands.shard/permeable/create_test.dart
+6
-14
format_test.dart
...tter_tools/test/commands.shard/permeable/format_test.dart
+4
-4
No files found.
packages/flutter_tools/lib/executable.dart
View file @
10840352
...
...
@@ -160,7 +160,7 @@ List<FlutterCommand> generateCommands({
platform:
globals
.
platform
,
),
EmulatorsCommand
(),
FormatCommand
(),
FormatCommand
(
verboseHelp:
verboseHelp
),
GenerateCommand
(),
GenerateLocalizationsCommand
(
fileSystem:
globals
.
fs
,
...
...
packages/flutter_tools/lib/src/commands/format.dart
View file @
10840352
...
...
@@ -4,37 +4,21 @@
// @dart = 2.8
import
'package:args/args.dart'
;
import
'package:meta/meta.dart'
;
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
import
'../globals_null_migrated.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
class
FormatCommand
extends
FlutterCommand
{
FormatCommand
()
{
argParser
.
addFlag
(
'dry-run'
,
abbr:
'n'
,
help:
'Show which files would be modified but make no changes.'
,
defaultsTo:
false
,
negatable:
false
,
);
argParser
.
addFlag
(
'set-exit-if-changed'
,
help:
'Return exit code 1 if there are any formatting changes.'
,
defaultsTo:
false
,
negatable:
false
,
);
argParser
.
addFlag
(
'machine'
,
abbr:
'm'
,
help:
'Produce machine-readable JSON output.'
,
defaultsTo:
false
,
negatable:
false
,
);
argParser
.
addOption
(
'line-length'
,
abbr:
'l'
,
help:
'Wrap lines longer than this length.'
,
valueHelp:
'characters'
,
defaultsTo:
'80'
,
);
}
FormatCommand
({
@required
this
.
verboseHelp
});
@override
ArgParser
argParser
=
ArgParser
.
allowAnything
();
final
bool
verboseHelp
;
@override
final
String
name
=
'format'
;
...
...
@@ -50,29 +34,25 @@ class FormatCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
argResults
.
rest
.
isEmpty
)
{
throwToolExit
(
'No files specified to be formatted.
\n
'
'
\n
'
'To format all files in the current directory tree:
\n
'
'
${runner.executableName}
$name
.
\n
'
'
\n
'
'
$usage
'
);
}
final
String
dartSdk
=
globals
.
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartSdkPath
).
path
;
final
String
dartBinary
=
globals
.
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartBinary
).
path
;
final
List
<
String
>
command
=
<
String
>[
dartBinary
,
globals
.
fs
.
path
.
join
(
dartSdk
,
'bin'
,
'snapshots'
,
'dartfmt.dart.snapshot'
),
if
(
boolArg
(
'dry-run'
))
'-n'
,
if
(
boolArg
(
'machine'
))
'-m'
,
if
(
argResults
[
'line-length'
]
!=
null
)
'-l
${argResults['line-length']}
'
,
if
(!
boolArg
(
'dry-run'
)
&&
!
boolArg
(
'machine'
))
'-w'
,
if
(
boolArg
(
'set-exit-if-changed'
))
'--set-exit-if-changed'
,
...
argResults
.
rest
,
'format'
,
];
if
(
argResults
.
rest
.
isEmpty
)
{
globals
.
printError
(
'No files specified to be formatted.'
);
command
.
add
(
'-h'
);
}
else
{
command
.
addAll
(<
String
>[
for
(
String
arg
in
argResults
.
rest
)
if
(
arg
==
'--dry-run'
)
'--output=show'
else
arg
]);
}
final
int
result
=
await
globals
.
processUtils
.
stream
(
command
);
if
(
result
!=
0
)
{
...
...
packages/flutter_tools/test/commands.shard/permeable/create_test.dart
View file @
10840352
...
...
@@ -1099,17 +1099,13 @@ void main() {
final
String
original
=
file
.
readAsStringSync
();
final
Process
process
=
await
Process
.
start
(
globals
.
fs
.
path
.
join
(
globals
.
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartSdkPath
).
path
,
'bin'
,
globals
.
platform
.
isWindows
?
'dartfmt.bat'
:
'dartfmt'
,
),
<
String
>[
file
.
path
],
globals
.
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartBinary
).
path
,
<
String
>[
'format'
,
'--output=show'
,
file
.
path
],
workingDirectory:
projectDir
.
path
,
);
final
String
formatted
=
await
process
.
stdout
.
transform
(
utf8
.
decoder
).
join
();
expect
(
original
,
formatted
,
reason:
file
.
path
);
expect
(
formatted
,
contains
(
original
)
,
reason:
file
.
path
);
}
}
...
...
@@ -1205,17 +1201,13 @@ void main() {
final
String
original
=
file
.
readAsStringSync
();
final
Process
process
=
await
Process
.
start
(
globals
.
fs
.
path
.
join
(
globals
.
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartSdkPath
).
path
,
'bin'
,
globals
.
platform
.
isWindows
?
'dartfmt.bat'
:
'dartfmt'
,
),
<
String
>[
file
.
path
],
globals
.
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartBinary
).
path
,
<
String
>[
'format'
,
'--output=show'
,
file
.
path
],
workingDirectory:
projectDir
.
path
,
);
final
String
formatted
=
await
process
.
stdout
.
transform
(
utf8
.
decoder
).
join
();
expect
(
original
,
formatted
,
reason:
file
.
path
);
expect
(
formatted
,
contains
(
original
)
,
reason:
file
.
path
);
}
}
...
...
packages/flutter_tools/test/commands.shard/permeable/format_test.dart
View file @
10840352
...
...
@@ -34,7 +34,7 @@ void main() {
final
String
original
=
srcFile
.
readAsStringSync
();
srcFile
.
writeAsStringSync
(
original
.
replaceFirst
(
'main()'
,
'main( )'
));
final
FormatCommand
command
=
FormatCommand
();
final
FormatCommand
command
=
FormatCommand
(
verboseHelp:
false
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'format'
,
srcFile
.
path
]);
...
...
@@ -51,7 +51,7 @@ void main() {
'main()'
,
'main( )'
);
srcFile
.
writeAsStringSync
(
nonFormatted
);
final
FormatCommand
command
=
FormatCommand
();
final
FormatCommand
command
=
FormatCommand
(
verboseHelp:
false
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'format'
,
'--dry-run'
,
srcFile
.
path
]);
...
...
@@ -68,7 +68,7 @@ void main() {
'main()'
,
'main( )'
);
srcFile
.
writeAsStringSync
(
nonFormatted
);
final
FormatCommand
command
=
FormatCommand
();
final
FormatCommand
command
=
FormatCommand
(
verboseHelp:
false
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
expect
(
runner
.
run
(<
String
>[
...
...
@@ -92,7 +92,7 @@ void main() {
'main(anArgument1, anArgument2, anArgument3, anArgument4, anArgument5)'
));
final
String
nonFormattedWithLongLine
=
srcFile
.
readAsStringSync
();
final
FormatCommand
command
=
FormatCommand
();
final
FormatCommand
command
=
FormatCommand
(
verboseHelp:
false
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'format'
,
'--line-length'
,
'
$lineLengthLong
'
,
srcFile
.
path
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment