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
d79b1668
Unverified
Commit
d79b1668
authored
Mar 24, 2021
by
Jenn Magder
Committed by
GitHub
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate error_handling_io to null safety (#78932)
parent
2c413842
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
84 deletions
+62
-84
config.dart
packages/flutter_tools/lib/src/base/config.dart
+6
-8
error_handling_io.dart
packages/flutter_tools/lib/src/base/error_handling_io.dart
+50
-55
depfile.dart
packages/flutter_tools/lib/src/build_system/depfile.dart
+4
-8
error_handling_io_test.dart
...tools/test/general.shard/base/error_handling_io_test.dart
+2
-13
No files found.
packages/flutter_tools/lib/src/base/config.dart
View file @
d79b1668
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:meta/meta.dart'
;
...
...
@@ -27,9 +25,9 @@ class Config {
/// home directory.
factory
Config
(
String
name
,
{
@
required
FileSystem
fileSystem
,
@
required
Logger
logger
,
@
required
Platform
platform
,
required
FileSystem
fileSystem
,
required
Logger
logger
,
required
Platform
platform
,
})
{
final
String
filePath
=
_configPath
(
platform
,
fileSystem
,
name
);
final
File
file
=
fileSystem
.
file
(
filePath
);
...
...
@@ -43,8 +41,8 @@ class Config {
/// Defaults to [BufferLogger], [MemoryFileSystem], and [name]=test.
factory
Config
.
test
({
String
name
=
'test'
,
Directory
directory
,
Logger
logger
,
Directory
?
directory
,
Logger
?
logger
,
})
{
directory
??=
MemoryFileSystem
.
test
().
directory
(
'/'
);
return
Config
.
createForTesting
(
directory
.
childFile
(
'.
${kConfigDir}
_
$name
'
),
logger
??
BufferLogger
.
test
());
...
...
@@ -58,7 +56,7 @@ class Config {
}
try
{
ErrorHandlingFileSystem
.
noExitOnFailure
(()
{
_values
=
castStringKeyedMap
(
json
.
decode
(
_file
.
readAsStringSync
()));
_values
=
castStringKeyedMap
(
json
.
decode
(
_file
.
readAsStringSync
()))
??
<
String
,
dynamic
>{}
;
});
}
on
FormatException
{
_logger
...
...
packages/flutter_tools/lib/src/base/error_handling_io.dart
View file @
d79b1668
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/build_system/depfile.dart
View file @
d79b1668
...
...
@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'../base/error_handling_io.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logger.dart'
;
...
...
@@ -13,8 +9,8 @@ import '../base/logger.dart';
/// A service for creating and parsing [Depfile]s.
class
DepfileService
{
DepfileService
({
@
required
Logger
logger
,
@
required
FileSystem
fileSystem
,
required
Logger
logger
,
required
FileSystem
fileSystem
,
})
:
_logger
=
logger
,
_fileSystem
=
fileSystem
;
...
...
@@ -67,7 +63,7 @@ class DepfileService {
if
(
rawUri
.
trim
().
isEmpty
)
{
continue
;
}
final
Uri
fileUri
=
Uri
.
tryParse
(
rawUri
);
final
Uri
?
fileUri
=
Uri
.
tryParse
(
rawUri
);
if
(
fileUri
==
null
)
{
continue
;
}
...
...
@@ -102,7 +98,7 @@ class DepfileService {
.
replaceAllMapped
(
_separatorExpr
,
(
Match
match
)
=>
'
${match.group(1)}
\n
'
)
.
split
(
'
\n
'
)
// Expand escape sequences, so that '\ ', for example,ß becomes ' '
.
map
<
String
>((
String
path
)
=>
path
.
replaceAllMapped
(
_escapeExpr
,
(
Match
match
)
=>
match
.
group
(
1
)).
trim
())
.
map
<
String
>((
String
path
)
=>
path
.
replaceAllMapped
(
_escapeExpr
,
(
Match
match
)
=>
match
.
group
(
1
)
!
).
trim
())
.
where
((
String
path
)
=>
path
.
isNotEmpty
)
// The tool doesn't write duplicates to these lists. This call is an attempt to
// be resilient to the outputs of other tools which write or user edits to depfiles.
...
...
packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
View file @
d79b1668
...
...
@@ -14,8 +14,6 @@ import 'package:flutter_tools/src/base/error_handling_io.dart';
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
show
flutterUsage
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:path/path.dart'
as
path
;
// flutter_ignore: package_path_import
import
'package:process/process.dart'
;
...
...
@@ -955,8 +953,7 @@ void main() {
verify
(
source
.
copySync
(
'dest'
)).
called
(
1
);
});
// Uses context for analytics.
testUsingContext
(
'copySync can directly copy bytes if both files can be opened but copySync fails'
,
()
{
testWithoutContext
(
'copySync can directly copy bytes if both files can be opened but copySync fails'
,
()
{
final
MemoryFileSystem
memoryFileSystem
=
MemoryFileSystem
.
test
();
final
MockFile
source
=
MockFile
();
final
MockFile
dest
=
MockFile
();
...
...
@@ -978,15 +975,9 @@ void main() {
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
);
expect
(
memoryDest
.
readAsBytesSync
(),
expectedBytes
);
expect
((
globals
.
flutterUsage
as
TestUsage
).
events
,
contains
(
const
TestUsageEvent
(
'error-handling'
,
'copy-fallback'
),
));
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
});
// Uses context for analytics.
testUsingContext
(
'copySync deletes the result file if the fallback fails'
,
()
{
testWithoutContext
(
'copySync deletes the result file if the fallback fails'
,
()
{
final
MemoryFileSystem
memoryFileSystem
=
MemoryFileSystem
.
test
();
final
MockFile
source
=
MockFile
();
final
MockFile
dest
=
MockFile
();
...
...
@@ -1015,8 +1006,6 @@ void main() {
expect
(()
=>
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
),
throwsToolExit
());
verify
(
dest
.
deleteSync
(
recursive:
true
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
});
});
}
...
...
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