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
bc4bda02
Unverified
Commit
bc4bda02
authored
Apr 02, 2021
by
Jenn Magder
Committed by
GitHub
Apr 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate analysis to null safety (#79525)
parent
06fa590c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
+35
-35
analysis.dart
packages/flutter_tools/lib/src/dart/analysis.dart
+35
-35
No files found.
packages/flutter_tools/lib/src/dart/analysis.dart
View file @
bc4bda02
...
...
@@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:math'
as
math
;
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'../base/common.dart'
;
...
...
@@ -24,12 +21,12 @@ class AnalysisServer {
AnalysisServer
(
this
.
sdkPath
,
this
.
directories
,
{
@
required
FileSystem
fileSystem
,
@
required
ProcessManager
processManager
,
@
required
Logger
logger
,
@
required
Platform
platform
,
@
required
Terminal
terminal
,
String
protocolTrafficLog
,
required
FileSystem
fileSystem
,
required
ProcessManager
processManager
,
required
Logger
logger
,
required
Platform
platform
,
required
Terminal
terminal
,
String
?
protocolTrafficLog
,
})
:
_fileSystem
=
fileSystem
,
_processManager
=
processManager
,
_logger
=
logger
,
...
...
@@ -44,9 +41,9 @@ class AnalysisServer {
final
Logger
_logger
;
final
Platform
_platform
;
final
Terminal
_terminal
;
final
String
_protocolTrafficLog
;
final
String
?
_protocolTrafficLog
;
Process
_process
;
Process
?
_process
;
final
StreamController
<
bool
>
_analyzingController
=
StreamController
<
bool
>.
broadcast
();
final
StreamController
<
FileAnalysisErrors
>
_errorsController
=
...
...
@@ -77,14 +74,14 @@ class AnalysisServer {
_logger
.
printTrace
(
'dart
${command.skip(1).join(' ')}
'
);
_process
=
await
_processManager
.
start
(
command
);
// This callback hookup can't throw.
unawaited
(
_process
.
exitCode
.
whenComplete
(()
=>
_process
=
null
));
unawaited
(
_process
!
.
exitCode
.
whenComplete
(()
=>
_process
=
null
));
final
Stream
<
String
>
errorStream
=
_process
.
stderr
final
Stream
<
String
>
errorStream
=
_process
!
.
stderr
.
transform
<
String
>(
utf8
.
decoder
)
.
transform
<
String
>(
const
LineSplitter
());
errorStream
.
listen
(
_logger
.
printError
);
final
Stream
<
String
>
inStream
=
_process
.
stdout
final
Stream
<
String
>
inStream
=
_process
!
.
stdout
.
transform
<
String
>(
utf8
.
decoder
)
.
transform
<
String
>(
const
LineSplitter
());
inStream
.
listen
(
_handleServerResponse
);
...
...
@@ -103,7 +100,7 @@ class AnalysisServer {
Stream
<
FileAnalysisErrors
>
get
onErrors
=>
_errorsController
.
stream
;
Future
<
int
>
get
onExit
=>
_process
.
exitCode
;
Future
<
int
?>
get
onExit
async
=>
_process
?
.
exitCode
;
void
_sendCommand
(
String
method
,
Map
<
String
,
dynamic
>
params
)
{
final
String
message
=
json
.
encode
(<
String
,
dynamic
>{
...
...
@@ -111,7 +108,7 @@ class AnalysisServer {
'method'
:
method
,
'params'
:
params
,
});
_process
.
stdin
.
writeln
(
message
);
_process
?
.
stdin
.
writeln
(
message
);
_logger
.
printTrace
(
'==>
$message
'
);
}
...
...
@@ -124,19 +121,23 @@ class AnalysisServer {
if
(
response
[
'event'
]
!=
null
)
{
final
String
event
=
response
[
'event'
]
as
String
;
final
dynamic
params
=
response
[
'params'
];
Map
<
String
,
dynamic
>?
paramsMap
;
if
(
params
is
Map
<
String
,
dynamic
>)
{
paramsMap
=
castStringKeyedMap
(
params
);
}
if
(
paramsMap
!=
null
)
{
if
(
event
==
'server.status'
)
{
_handleStatus
(
castStringKeyedMap
(
response
[
'params'
])
);
_handleStatus
(
paramsMap
);
}
else
if
(
event
==
'analysis.errors'
)
{
_handleAnalysisIssues
(
castStringKeyedMap
(
response
[
'params'
])
);
_handleAnalysisIssues
(
paramsMap
);
}
else
if
(
event
==
'server.error'
)
{
_handleServerError
(
castStringKeyedMap
(
response
[
'params'
])
);
_handleServerError
(
paramsMap
);
}
}
}
else
if
(
response
[
'error'
]
!=
null
)
{
// Fields are 'code', 'message', and 'stackTrace'.
final
Map
<
String
,
dynamic
>
error
=
castStringKeyedMap
(
response
[
'error'
]
)
;
final
Map
<
String
,
dynamic
>
error
=
castStringKeyedMap
(
response
[
'error'
]
!)!
;
_logger
.
printError
(
'Error response from the server:
${error['code']}
${error['message']}
'
);
if
(
error
[
'stackTrace'
]
!=
null
)
{
...
...
@@ -168,7 +169,7 @@ class AnalysisServer {
final
String
file
=
issueInfo
[
'file'
]
as
String
;
final
List
<
dynamic
>
errorsList
=
issueInfo
[
'errors'
]
as
List
<
dynamic
>;
final
List
<
AnalysisError
>
errors
=
errorsList
.
map
<
Map
<
String
,
dynamic
>>(
castStringKeyedMap
)
.
map
<
Map
<
String
,
dynamic
>>(
(
dynamic
e
)
=>
castStringKeyedMap
(
e
)
??
<
String
,
dynamic
>{}
)
.
map
<
AnalysisError
>((
Map
<
String
,
dynamic
>
json
)
{
return
AnalysisError
(
WrittenError
.
fromJson
(
json
),
fileSystem:
_fileSystem
,
...
...
@@ -182,7 +183,7 @@ class AnalysisServer {
}
}
Future
<
bool
>
dispose
()
async
{
Future
<
bool
?
>
dispose
()
async
{
await
_analyzingController
.
close
();
await
_errorsController
.
close
();
return
_process
?.
kill
();
...
...
@@ -200,9 +201,9 @@ enum AnalysisSeverity {
class
AnalysisError
implements
Comparable
<
AnalysisError
>
{
AnalysisError
(
this
.
writtenError
,
{
@
required
Platform
platform
,
@
required
Terminal
terminal
,
@
required
FileSystem
fileSystem
,
required
Platform
platform
,
required
Terminal
terminal
,
required
FileSystem
fileSystem
,
})
:
_platform
=
platform
,
_terminal
=
terminal
,
_fileSystem
=
fileSystem
;
...
...
@@ -224,7 +225,6 @@ class AnalysisError implements Comparable<AnalysisError> {
case
AnalysisSeverity
.
none
:
return
writtenError
.
severity
;
}
return
null
;
}
String
get
type
=>
writtenError
.
type
;
...
...
@@ -269,14 +269,14 @@ class AnalysisError implements Comparable<AnalysisError> {
/// [AnalysisError] in plain text content.
class
WrittenError
{
WrittenError
.
_
({
@
required
this
.
severity
,
@
required
this
.
type
,
@
required
this
.
message
,
@
required
this
.
code
,
@
required
this
.
file
,
@
required
this
.
startLine
,
@
required
this
.
startColumn
,
@
required
this
.
offset
,
required
this
.
severity
,
required
this
.
type
,
required
this
.
message
,
required
this
.
code
,
required
this
.
file
,
required
this
.
startLine
,
required
this
.
startColumn
,
required
this
.
offset
,
});
/// {
...
...
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