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
457972b7
Unverified
Commit
457972b7
authored
Apr 16, 2020
by
Jenn Magder
Committed by
GitHub
Apr 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move doctor into globals (#54912)
* Move doctor into globals * Fix tests
parent
6f9ee13e
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
111 additions
and
88 deletions
+111
-88
runner.dart
packages/flutter_tools/lib/runner.dart
+2
-6
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+3
-4
devices.dart
packages/flutter_tools/lib/src/commands/devices.dart
+1
-2
doctor.dart
packages/flutter_tools/lib/src/commands/doctor.dart
+2
-3
emulators.dart
packages/flutter_tools/lib/src/commands/emulators.dart
+1
-1
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-1
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+14
-12
globals.dart
packages/flutter_tools/lib/src/globals.dart
+2
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+1
-2
doctor_test.dart
...utter_tools/test/commands.shard/hermetic/doctor_test.dart
+81
-56
context.dart
packages/flutter_tools/test/src/context.dart
+3
-1
No files found.
packages/flutter_tools/lib/runner.dart
View file @
457972b7
...
@@ -242,12 +242,8 @@ Future<String> _doctorText() async {
...
@@ -242,12 +242,8 @@ Future<String> _doctorText() async {
outputPreferences:
globals
.
outputPreferences
,
outputPreferences:
globals
.
outputPreferences
,
);
);
await
context
.
run
<
bool
>(
final
Doctor
doctor
=
Doctor
(
logger:
logger
);
body:
()
=>
doctor
.
diagnose
(
verbose:
true
,
showColor:
false
),
await
doctor
.
diagnose
(
verbose:
true
,
showColor:
false
);
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
logger
,
},
);
return
logger
.
statusText
;
return
logger
.
statusText
;
}
on
Exception
catch
(
error
,
trace
)
{
}
on
Exception
catch
(
error
,
trace
)
{
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
457972b7
...
@@ -19,7 +19,6 @@ import '../base/utils.dart';
...
@@ -19,7 +19,6 @@ import '../base/utils.dart';
import
'../cache.dart'
;
import
'../cache.dart'
;
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../dart/pub.dart'
;
import
'../dart/pub.dart'
;
import
'../doctor.dart'
;
import
'../features.dart'
;
import
'../features.dart'
;
import
'../flutter_project_metadata.dart'
;
import
'../flutter_project_metadata.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
...
@@ -417,9 +416,9 @@ class CreateCommand extends FlutterCommand {
...
@@ -417,9 +416,9 @@ class CreateCommand extends FlutterCommand {
final
String
relativeAppMain
=
globals
.
fs
.
path
.
join
(
relativeAppPath
,
'lib'
,
'main.dart'
);
final
String
relativeAppMain
=
globals
.
fs
.
path
.
join
(
relativeAppPath
,
'lib'
,
'main.dart'
);
final
String
relativePluginPath
=
globals
.
fs
.
path
.
normalize
(
globals
.
fs
.
path
.
relative
(
projectDirPath
));
final
String
relativePluginPath
=
globals
.
fs
.
path
.
normalize
(
globals
.
fs
.
path
.
relative
(
projectDirPath
));
final
String
relativePluginMain
=
globals
.
fs
.
path
.
join
(
relativePluginPath
,
'lib'
,
'
$projectName
.dart'
);
final
String
relativePluginMain
=
globals
.
fs
.
path
.
join
(
relativePluginPath
,
'lib'
,
'
$projectName
.dart'
);
if
(
doctor
.
canLaunchAnything
)
{
if
(
globals
.
doctor
.
canLaunchAnything
)
{
// Let them know a summary of the state of their tooling.
// Let them know a summary of the state of their tooling.
await
doctor
.
summary
();
await
globals
.
doctor
.
summary
();
globals
.
printStatus
(
'''
globals
.
printStatus
(
'''
In order to run your
$application
, type:
In order to run your
$application
, type:
...
@@ -443,7 +442,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
...
@@ -443,7 +442,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
globals
.
printStatus
(
''
);
globals
.
printStatus
(
''
);
// Give the user more detailed analysis.
// Give the user more detailed analysis.
await
doctor
.
diagnose
();
await
globals
.
doctor
.
diagnose
();
globals
.
printStatus
(
''
);
globals
.
printStatus
(
''
);
globals
.
printStatus
(
"After installing components, run 'flutter doctor' in order to "
globals
.
printStatus
(
"After installing components, run 'flutter doctor' in order to "
're-validate your setup.'
);
're-validate your setup.'
);
...
...
packages/flutter_tools/lib/src/commands/devices.dart
View file @
457972b7
...
@@ -8,7 +8,6 @@ import '../base/common.dart';
...
@@ -8,7 +8,6 @@ import '../base/common.dart';
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command.dart'
;
...
@@ -52,7 +51,7 @@ class DevicesCommand extends FlutterCommand {
...
@@ -52,7 +51,7 @@ class DevicesCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(!
doctor
.
canListAnything
)
{
if
(!
globals
.
doctor
.
canListAnything
)
{
throwToolExit
(
throwToolExit
(
"Unable to locate a development device; please run 'flutter doctor' for "
"Unable to locate a development device; please run 'flutter doctor' for "
'information about installing additional components.'
,
'information about installing additional components.'
,
...
...
packages/flutter_tools/lib/src/commands/doctor.dart
View file @
457972b7
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
import
'dart:async'
;
import
'dart:async'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command.dart'
;
...
@@ -47,7 +46,7 @@ class DoctorCommand extends FlutterCommand {
...
@@ -47,7 +46,7 @@ class DoctorCommand extends FlutterCommand {
if
(
argResults
.
wasParsed
(
'check-for-remote-artifacts'
))
{
if
(
argResults
.
wasParsed
(
'check-for-remote-artifacts'
))
{
final
String
engineRevision
=
stringArg
(
'check-for-remote-artifacts'
);
final
String
engineRevision
=
stringArg
(
'check-for-remote-artifacts'
);
if
(
engineRevision
.
startsWith
(
RegExp
(
r'[a-f0-9]{1,40}'
)))
{
if
(
engineRevision
.
startsWith
(
RegExp
(
r'[a-f0-9]{1,40}'
)))
{
final
bool
success
=
await
doctor
.
checkRemoteArtifacts
(
engineRevision
);
final
bool
success
=
await
globals
.
doctor
.
checkRemoteArtifacts
(
engineRevision
);
if
(!
success
)
{
if
(!
success
)
{
throwToolExit
(
'Artifacts for engine
$engineRevision
are missing or are '
throwToolExit
(
'Artifacts for engine
$engineRevision
are missing or are '
'not yet available.'
,
exitCode:
1
);
'not yet available.'
,
exitCode:
1
);
...
@@ -57,7 +56,7 @@ class DoctorCommand extends FlutterCommand {
...
@@ -57,7 +56,7 @@ class DoctorCommand extends FlutterCommand {
'git hash.'
);
'git hash.'
);
}
}
}
}
final
bool
success
=
await
doctor
.
diagnose
(
androidLicenses:
boolArg
(
'android-licenses'
),
verbose:
verbose
);
final
bool
success
=
await
globals
.
doctor
.
diagnose
(
androidLicenses:
boolArg
(
'android-licenses'
),
verbose:
verbose
);
return
FlutterCommandResult
(
success
?
ExitStatus
.
success
:
ExitStatus
.
warning
);
return
FlutterCommandResult
(
success
?
ExitStatus
.
success
:
ExitStatus
.
warning
);
}
}
}
}
packages/flutter_tools/lib/src/commands/emulators.dart
View file @
457972b7
...
@@ -33,7 +33,7 @@ class EmulatorsCommand extends FlutterCommand {
...
@@ -33,7 +33,7 @@ class EmulatorsCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
doctor
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
))
{
if
(
globals
.
doctor
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
))
{
throwToolExit
(
throwToolExit
(
'Unable to find any emulator sources. Please ensure you have some
\n
'
'Unable to find any emulator sources. Please ensure you have some
\n
'
'Android AVD images '
+
'Android AVD images '
+
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
457972b7
...
@@ -126,7 +126,7 @@ Future<T> runInContext<T>(
...
@@ -126,7 +126,7 @@ Future<T> runInContext<T>(
),
),
DevFSConfig:
()
=>
DevFSConfig
(),
DevFSConfig:
()
=>
DevFSConfig
(),
DeviceManager:
()
=>
DeviceManager
(),
DeviceManager:
()
=>
DeviceManager
(),
Doctor:
()
=>
const
Doctor
(
),
Doctor:
()
=>
Doctor
(
logger:
globals
.
logger
),
DoctorValidatorsProvider:
()
=>
DoctorValidatorsProvider
.
defaultInstance
,
DoctorValidatorsProvider:
()
=>
DoctorValidatorsProvider
.
defaultInstance
,
EmulatorManager:
()
=>
EmulatorManager
(),
EmulatorManager:
()
=>
EmulatorManager
(),
FeatureFlags:
()
=>
const
FeatureFlags
(),
FeatureFlags:
()
=>
const
FeatureFlags
(),
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
457972b7
...
@@ -40,8 +40,6 @@ import 'web/workflow.dart';
...
@@ -40,8 +40,6 @@ import 'web/workflow.dart';
import
'windows/visual_studio_validator.dart'
;
import
'windows/visual_studio_validator.dart'
;
import
'windows/windows_workflow.dart'
;
import
'windows/windows_workflow.dart'
;
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
abstract
class
DoctorValidatorsProvider
{
abstract
class
DoctorValidatorsProvider
{
/// The singleton instance, pulled from the [AppContext].
/// The singleton instance, pulled from the [AppContext].
static
DoctorValidatorsProvider
get
instance
=>
context
.
get
<
DoctorValidatorsProvider
>();
static
DoctorValidatorsProvider
get
instance
=>
context
.
get
<
DoctorValidatorsProvider
>();
...
@@ -153,7 +151,11 @@ class ValidatorTask {
...
@@ -153,7 +151,11 @@ class ValidatorTask {
}
}
class
Doctor
{
class
Doctor
{
const
Doctor
();
Doctor
({
@required
Logger
logger
,
})
:
_logger
=
logger
;
final
Logger
_logger
;
List
<
DoctorValidator
>
get
validators
{
List
<
DoctorValidator
>
get
validators
{
return
DoctorValidatorsProvider
.
instance
.
validators
;
return
DoctorValidatorsProvider
.
instance
.
validators
;
...
@@ -184,7 +186,7 @@ class Doctor {
...
@@ -184,7 +186,7 @@ class Doctor {
/// Print a summary of the state of the tooling, as well as how to get more info.
/// Print a summary of the state of the tooling, as well as how to get more info.
Future
<
void
>
summary
()
async
{
Future
<
void
>
summary
()
async
{
globals
.
printStatus
(
await
_summaryText
());
_logger
.
printStatus
(
await
_summaryText
());
}
}
Future
<
String
>
_summaryText
()
async
{
Future
<
String
>
_summaryText
()
async
{
...
@@ -263,7 +265,7 @@ class Doctor {
...
@@ -263,7 +265,7 @@ class Doctor {
}
}
if
(!
verbose
)
{
if
(!
verbose
)
{
globals
.
printStatus
(
'Doctor summary (to see all details, run flutter doctor -v):'
);
_logger
.
printStatus
(
'Doctor summary (to see all details, run flutter doctor -v):'
);
}
}
bool
doctorResult
=
true
;
bool
doctorResult
=
true
;
int
issues
=
0
;
int
issues
=
0
;
...
@@ -307,10 +309,10 @@ class Doctor {
...
@@ -307,10 +309,10 @@ class Doctor {
final
String
leadingBox
=
showColor
?
result
.
coloredLeadingBox
:
result
.
leadingBox
;
final
String
leadingBox
=
showColor
?
result
.
coloredLeadingBox
:
result
.
leadingBox
;
if
(
result
.
statusInfo
!=
null
)
{
if
(
result
.
statusInfo
!=
null
)
{
globals
.
printStatus
(
'
$leadingBox
${validator.title}
(
${result.statusInfo}
)'
,
_logger
.
printStatus
(
'
$leadingBox
${validator.title}
(
${result.statusInfo}
)'
,
hangingIndent:
result
.
leadingBox
.
length
+
1
);
hangingIndent:
result
.
leadingBox
.
length
+
1
);
}
else
{
}
else
{
globals
.
printStatus
(
'
$leadingBox
${validator.title}
'
,
_logger
.
printStatus
(
'
$leadingBox
${validator.title}
'
,
hangingIndent:
result
.
leadingBox
.
length
+
1
);
hangingIndent:
result
.
leadingBox
.
length
+
1
);
}
}
...
@@ -320,7 +322,7 @@ class Doctor {
...
@@ -320,7 +322,7 @@ class Doctor {
int
indent
=
4
;
int
indent
=
4
;
final
String
indicator
=
showColor
?
message
.
coloredIndicator
:
message
.
indicator
;
final
String
indicator
=
showColor
?
message
.
coloredIndicator
:
message
.
indicator
;
for
(
final
String
line
in
'
$indicator
${message.message}
'
.
split
(
'
\n
'
))
{
for
(
final
String
line
in
'
$indicator
${message.message}
'
.
split
(
'
\n
'
))
{
globals
.
printStatus
(
line
,
hangingIndent:
hangingIndent
,
indent:
indent
,
emphasis:
true
);
_logger
.
printStatus
(
line
,
hangingIndent:
hangingIndent
,
indent:
indent
,
emphasis:
true
);
// Only do hanging indent for the first line.
// Only do hanging indent for the first line.
hangingIndent
=
0
;
hangingIndent
=
0
;
indent
=
6
;
indent
=
6
;
...
@@ -328,20 +330,20 @@ class Doctor {
...
@@ -328,20 +330,20 @@ class Doctor {
}
}
}
}
if
(
verbose
)
{
if
(
verbose
)
{
globals
.
printStatus
(
''
);
_logger
.
printStatus
(
''
);
}
}
}
}
// Make sure there's always one line before the summary even when not verbose.
// Make sure there's always one line before the summary even when not verbose.
if
(!
verbose
)
{
if
(!
verbose
)
{
globals
.
printStatus
(
''
);
_logger
.
printStatus
(
''
);
}
}
if
(
issues
>
0
)
{
if
(
issues
>
0
)
{
globals
.
printStatus
(
'
${showColor ? globals.terminal.color('!', TerminalColor.yellow) : '!'}
'
_logger
.
printStatus
(
'
${showColor ? globals.terminal.color('!', TerminalColor.yellow) : '!'}
'
' Doctor found issues in
$issues
categor
${issues > 1 ? "ies" : "y"}
.'
,
hangingIndent:
2
);
' Doctor found issues in
$issues
categor
${issues > 1 ? "ies" : "y"}
.'
,
hangingIndent:
2
);
}
else
{
}
else
{
globals
.
printStatus
(
'
${showColor ? globals.terminal.color('•', TerminalColor.green) : '•'}
'
_logger
.
printStatus
(
'
${showColor ? globals.terminal.color('•', TerminalColor.green) : '•'}
'
' No issues found!'
,
hangingIndent:
2
);
' No issues found!'
,
hangingIndent:
2
);
}
}
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
457972b7
...
@@ -22,6 +22,7 @@ import 'base/terminal.dart';
...
@@ -22,6 +22,7 @@ import 'base/terminal.dart';
import
'base/user_messages.dart'
;
import
'base/user_messages.dart'
;
import
'build_system/build_system.dart'
;
import
'build_system/build_system.dart'
;
import
'cache.dart'
;
import
'cache.dart'
;
import
'doctor.dart'
;
import
'fuchsia/fuchsia_sdk.dart'
;
import
'fuchsia/fuchsia_sdk.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/plist_parser.dart'
;
import
'ios/plist_parser.dart'
;
...
@@ -39,6 +40,7 @@ Artifacts get artifacts => context.get<Artifacts>();
...
@@ -39,6 +40,7 @@ Artifacts get artifacts => context.get<Artifacts>();
BuildSystem
get
buildSystem
=>
context
.
get
<
BuildSystem
>();
BuildSystem
get
buildSystem
=>
context
.
get
<
BuildSystem
>();
Cache
get
cache
=>
context
.
get
<
Cache
>();
Cache
get
cache
=>
context
.
get
<
Cache
>();
Config
get
config
=>
context
.
get
<
Config
>();
Config
get
config
=>
context
.
get
<
Config
>();
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
Logger
get
logger
=>
context
.
get
<
Logger
>();
Logger
get
logger
=>
context
.
get
<
Logger
>();
OperatingSystemUtils
get
os
=>
context
.
get
<
OperatingSystemUtils
>();
OperatingSystemUtils
get
os
=>
context
.
get
<
OperatingSystemUtils
>();
PersistentToolState
get
persistentToolState
=>
PersistentToolState
.
instance
;
PersistentToolState
get
persistentToolState
=>
PersistentToolState
.
instance
;
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
457972b7
...
@@ -25,7 +25,6 @@ import '../cache.dart';
...
@@ -25,7 +25,6 @@ import '../cache.dart';
import
'../dart/package_map.dart'
;
import
'../dart/package_map.dart'
;
import
'../dart/pub.dart'
;
import
'../dart/pub.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
import
'../doctor.dart'
;
import
'../features.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../project.dart'
;
import
'../project.dart'
;
...
@@ -762,7 +761,7 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -762,7 +761,7 @@ abstract class FlutterCommand extends Command<void> {
/// If no device can be found that meets specified criteria,
/// If no device can be found that meets specified criteria,
/// then print an error message and return null.
/// then print an error message and return null.
Future
<
List
<
Device
>>
findAllTargetDevices
()
async
{
Future
<
List
<
Device
>>
findAllTargetDevices
()
async
{
if
(!
doctor
.
canLaunchAnything
)
{
if
(!
globals
.
doctor
.
canLaunchAnything
)
{
globals
.
printError
(
userMessages
.
flutterNoDevelopmentDevice
);
globals
.
printError
(
userMessages
.
flutterNoDevelopmentDevice
);
return
null
;
return
null
;
}
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
View file @
457972b7
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/src/context.dart
View file @
457972b7
...
@@ -109,7 +109,7 @@ void testUsingContext(
...
@@ -109,7 +109,7 @@ void testUsingContext(
AnsiTerminal:
()
=>
AnsiTerminal
(
platform:
globals
.
platform
,
stdio:
globals
.
stdio
),
AnsiTerminal:
()
=>
AnsiTerminal
(
platform:
globals
.
platform
,
stdio:
globals
.
stdio
),
Config:
()
=>
buildConfig
(
globals
.
fs
),
Config:
()
=>
buildConfig
(
globals
.
fs
),
DeviceManager:
()
=>
FakeDeviceManager
(),
DeviceManager:
()
=>
FakeDeviceManager
(),
Doctor:
()
=>
FakeDoctor
(),
Doctor:
()
=>
FakeDoctor
(
globals
.
logger
),
FlutterVersion:
()
=>
MockFlutterVersion
(),
FlutterVersion:
()
=>
MockFlutterVersion
(),
HttpClient:
()
=>
MockHttpClient
(),
HttpClient:
()
=>
MockHttpClient
(),
IOSSimulatorUtils:
()
{
IOSSimulatorUtils:
()
{
...
@@ -261,6 +261,8 @@ class FakeAndroidLicenseValidator extends AndroidLicenseValidator {
...
@@ -261,6 +261,8 @@ class FakeAndroidLicenseValidator extends AndroidLicenseValidator {
}
}
class
FakeDoctor
extends
Doctor
{
class
FakeDoctor
extends
Doctor
{
FakeDoctor
(
Logger
logger
)
:
super
(
logger:
logger
);
// True for testing.
// True for testing.
@override
@override
bool
get
canListAnything
=>
true
;
bool
get
canListAnything
=>
true
;
...
...
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