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
45a34e83
Unverified
Commit
45a34e83
authored
Nov 23, 2021
by
Wizz.Xu
Committed by
GitHub
Nov 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Master analyze_base.dart to null-safety (#93954)
parent
77fca358
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
28 deletions
+36
-28
analyze_base.dart
packages/flutter_tools/lib/src/commands/analyze_base.dart
+36
-28
No files found.
packages/flutter_tools/lib/src/commands/analyze_base.dart
View file @
45a34e83
...
...
@@ -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:args/args.dart'
;
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -22,14 +20,14 @@ import '../globals.dart' as globals;
/// Common behavior for `flutter analyze` and `flutter analyze --watch`
abstract
class
AnalyzeBase
{
AnalyzeBase
(
this
.
argResults
,
{
@
required
this
.
repoRoots
,
@
required
this
.
repoPackages
,
@
required
this
.
fileSystem
,
@
required
this
.
logger
,
@
required
this
.
platform
,
@
required
this
.
processManager
,
@
required
this
.
terminal
,
@
required
this
.
artifacts
,
required
this
.
repoRoots
,
required
this
.
repoPackages
,
required
this
.
fileSystem
,
required
this
.
logger
,
required
this
.
platform
,
required
this
.
processManager
,
required
this
.
terminal
,
required
this
.
artifacts
,
});
/// The parsed argument results for execution.
...
...
@@ -81,16 +79,22 @@ abstract class AnalyzeBase {
}
bool
get
isFlutterRepo
=>
argResults
[
'flutter-repo'
]
as
bool
;
String
get
sdkPath
=>
argResults
[
'dart-sdk'
]
as
String
??
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartSdkPath
).
path
;
String
get
sdkPath
{
final
String
?
dartSdk
=
argResults
[
'dart-sdk'
]
as
String
?;
if
(
dartSdk
!=
null
)
{
return
dartSdk
;
}
return
artifacts
.
getHostArtifact
(
HostArtifact
.
engineDartSdkPath
).
path
;
}
bool
get
isBenchmarking
=>
argResults
[
'benchmark'
]
as
bool
;
String
get
protocolTrafficLog
=>
argResults
[
'protocol-traffic-log'
]
as
String
;
/// Generate an analysis summary for both [AnalyzeOnce], [AnalyzeContinuously].
static
String
generateErrorsMessage
({
@
required
int
issueCount
,
int
issueDiff
,
int
files
,
@
required
String
seconds
,
required
int
issueCount
,
int
?
issueDiff
,
int
?
files
,
required
String
seconds
,
})
{
final
StringBuffer
errorsMessage
=
StringBuffer
(
issueCount
>
0
?
'
$issueCount
${pluralize('issue', issueCount)}
found.'
...
...
@@ -118,7 +122,7 @@ class PackageDependency {
// This is a map from dependency targets (lib directories) to a list
// of places that ask for that target (.packages or pubspec.yaml files)
Map
<
String
,
List
<
String
>>
values
=
<
String
,
List
<
String
>>{};
String
canonicalSource
;
String
?
canonicalSource
;
void
addCanonicalCase
(
String
packagePath
,
String
pubSpecYamlPath
)
{
assert
(
canonicalSource
==
null
);
add
(
packagePath
,
pubSpecYamlPath
);
...
...
@@ -129,11 +133,12 @@ class PackageDependency {
}
bool
get
hasConflict
=>
values
.
length
>
1
;
bool
get
hasConflictAffectingFlutterRepo
{
assert
(
globals
.
fs
.
path
.
isAbsolute
(
Cache
.
flutterRoot
));
final
String
?
flutterRoot
=
Cache
.
flutterRoot
;
assert
(
flutterRoot
!=
null
&&
globals
.
fs
.
path
.
isAbsolute
(
flutterRoot
));
for
(
final
List
<
String
>
targetSources
in
values
.
values
)
{
for
(
final
String
source
in
targetSources
)
{
assert
(
globals
.
fs
.
path
.
isAbsolute
(
source
));
if
(
globals
.
fs
.
path
.
isWithin
(
Cache
.
flutterRoot
,
source
))
{
if
(
globals
.
fs
.
path
.
isWithin
(
flutterRoot
!
,
source
))
{
return
true
;
}
}
...
...
@@ -143,12 +148,13 @@ class PackageDependency {
void
describeConflict
(
StringBuffer
result
)
{
assert
(
hasConflict
);
final
List
<
String
>
targets
=
values
.
keys
.
toList
();
targets
.
sort
((
String
a
,
String
b
)
=>
values
[
b
]
.
length
.
compareTo
(
values
[
a
]
.
length
));
targets
.
sort
((
String
a
,
String
b
)
=>
values
[
b
]
!.
length
.
compareTo
(
values
[
a
]!
.
length
));
for
(
final
String
target
in
targets
)
{
final
int
count
=
values
[
target
].
length
;
final
List
<
String
>
targetList
=
values
[
target
]!;
final
int
count
=
targetList
.
length
;
result
.
writeln
(
'
$count
${count == 1 ? 'source wants' : 'sources want'}
"
$target
":'
);
bool
canonical
=
false
;
for
(
final
String
source
in
values
[
target
]
)
{
for
(
final
String
source
in
targetList
)
{
result
.
writeln
(
'
$source
'
);
if
(
source
==
canonicalSource
)
{
canonical
=
true
;
...
...
@@ -263,18 +269,20 @@ class PackageDependencyTracker {
String
generateConflictReport
()
{
assert
(
hasConflicts
);
final
StringBuffer
result
=
StringBuffer
();
for
(
final
String
package
in
packages
.
keys
.
where
((
String
package
)
=>
packages
[
package
].
hasConflict
))
{
result
.
writeln
(
'Package "
$package
" has conflicts:'
);
packages
[
package
].
describeConflict
(
result
);
}
packages
.
forEach
((
String
package
,
PackageDependency
dependency
)
{
if
(
dependency
.
hasConflict
)
{
result
.
writeln
(
'Package "
$package
" has conflicts:'
);
dependency
.
describeConflict
(
result
);
}
});
return
result
.
toString
();
}
Map
<
String
,
String
>
asPackageMap
()
{
final
Map
<
String
,
String
>
result
=
<
String
,
String
>{};
for
(
final
String
package
in
packages
.
keys
)
{
result
[
package
]
=
packages
[
package
]
.
target
;
}
packages
.
forEach
((
String
package
,
PackageDependency
dependency
)
{
result
[
package
]
=
dependency
.
target
;
}
);
return
result
;
}
}
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