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
Show 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 {
outputPreferences:
globals
.
outputPreferences
,
);
await
context
.
run
<
bool
>(
body:
()
=>
doctor
.
diagnose
(
verbose:
true
,
showColor:
false
),
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
logger
,
},
);
final
Doctor
doctor
=
Doctor
(
logger:
logger
);
await
doctor
.
diagnose
(
verbose:
true
,
showColor:
false
);
return
logger
.
statusText
;
}
on
Exception
catch
(
error
,
trace
)
{
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
457972b7
...
...
@@ -19,7 +19,6 @@ import '../base/utils.dart';
import
'../cache.dart'
;
import
'../convert.dart'
;
import
'../dart/pub.dart'
;
import
'../doctor.dart'
;
import
'../features.dart'
;
import
'../flutter_project_metadata.dart'
;
import
'../globals.dart'
as
globals
;
...
...
@@ -417,9 +416,9 @@ class CreateCommand extends FlutterCommand {
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
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.
await
doctor
.
summary
();
await
globals
.
doctor
.
summary
();
globals
.
printStatus
(
'''
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
globals
.
printStatus
(
''
);
// Give the user more detailed analysis.
await
doctor
.
diagnose
();
await
globals
.
doctor
.
diagnose
();
globals
.
printStatus
(
''
);
globals
.
printStatus
(
"After installing components, run 'flutter doctor' in order to "
're-validate your setup.'
);
...
...
packages/flutter_tools/lib/src/commands/devices.dart
View file @
457972b7
...
...
@@ -8,7 +8,6 @@ import '../base/common.dart';
import
'../base/utils.dart'
;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -52,7 +51,7 @@ class DevicesCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(!
doctor
.
canListAnything
)
{
if
(!
globals
.
doctor
.
canListAnything
)
{
throwToolExit
(
"Unable to locate a development device; please run 'flutter doctor' for "
'information about installing additional components.'
,
...
...
packages/flutter_tools/lib/src/commands/doctor.dart
View file @
457972b7
...
...
@@ -5,7 +5,6 @@
import
'dart:async'
;
import
'../base/common.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -47,7 +46,7 @@ class DoctorCommand extends FlutterCommand {
if
(
argResults
.
wasParsed
(
'check-for-remote-artifacts'
))
{
final
String
engineRevision
=
stringArg
(
'check-for-remote-artifacts'
);
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
)
{
throwToolExit
(
'Artifacts for engine
$engineRevision
are missing or are '
'not yet available.'
,
exitCode:
1
);
...
...
@@ -57,7 +56,7 @@ class DoctorCommand extends FlutterCommand {
'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
);
}
}
packages/flutter_tools/lib/src/commands/emulators.dart
View file @
457972b7
...
...
@@ -33,7 +33,7 @@ class EmulatorsCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
doctor
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
))
{
if
(
globals
.
doctor
.
workflows
.
every
((
Workflow
w
)
=>
!
w
.
canListEmulators
))
{
throwToolExit
(
'Unable to find any emulator sources. Please ensure you have some
\n
'
'Android AVD images '
+
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
457972b7
...
...
@@ -126,7 +126,7 @@ Future<T> runInContext<T>(
),
DevFSConfig:
()
=>
DevFSConfig
(),
DeviceManager:
()
=>
DeviceManager
(),
Doctor:
()
=>
const
Doctor
(
),
Doctor:
()
=>
Doctor
(
logger:
globals
.
logger
),
DoctorValidatorsProvider:
()
=>
DoctorValidatorsProvider
.
defaultInstance
,
EmulatorManager:
()
=>
EmulatorManager
(),
FeatureFlags:
()
=>
const
FeatureFlags
(),
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
457972b7
...
...
@@ -40,8 +40,6 @@ import 'web/workflow.dart';
import
'windows/visual_studio_validator.dart'
;
import
'windows/windows_workflow.dart'
;
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
abstract
class
DoctorValidatorsProvider
{
/// The singleton instance, pulled from the [AppContext].
static
DoctorValidatorsProvider
get
instance
=>
context
.
get
<
DoctorValidatorsProvider
>();
...
...
@@ -153,7 +151,11 @@ class ValidatorTask {
}
class
Doctor
{
const
Doctor
();
Doctor
({
@required
Logger
logger
,
})
:
_logger
=
logger
;
final
Logger
_logger
;
List
<
DoctorValidator
>
get
validators
{
return
DoctorValidatorsProvider
.
instance
.
validators
;
...
...
@@ -184,7 +186,7 @@ class Doctor {
/// Print a summary of the state of the tooling, as well as how to get more info.
Future
<
void
>
summary
()
async
{
globals
.
printStatus
(
await
_summaryText
());
_logger
.
printStatus
(
await
_summaryText
());
}
Future
<
String
>
_summaryText
()
async
{
...
...
@@ -263,7 +265,7 @@ class Doctor {
}
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
;
int
issues
=
0
;
...
...
@@ -307,10 +309,10 @@ class Doctor {
final
String
leadingBox
=
showColor
?
result
.
coloredLeadingBox
:
result
.
leadingBox
;
if
(
result
.
statusInfo
!=
null
)
{
globals
.
printStatus
(
'
$leadingBox
${validator.title}
(
${result.statusInfo}
)'
,
_logger
.
printStatus
(
'
$leadingBox
${validator.title}
(
${result.statusInfo}
)'
,
hangingIndent:
result
.
leadingBox
.
length
+
1
);
}
else
{
globals
.
printStatus
(
'
$leadingBox
${validator.title}
'
,
_logger
.
printStatus
(
'
$leadingBox
${validator.title}
'
,
hangingIndent:
result
.
leadingBox
.
length
+
1
);
}
...
...
@@ -320,7 +322,7 @@ class Doctor {
int
indent
=
4
;
final
String
indicator
=
showColor
?
message
.
coloredIndicator
:
message
.
indicator
;
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.
hangingIndent
=
0
;
indent
=
6
;
...
...
@@ -328,20 +330,20 @@ class Doctor {
}
}
if
(
verbose
)
{
globals
.
printStatus
(
''
);
_logger
.
printStatus
(
''
);
}
}
// Make sure there's always one line before the summary even when not verbose.
if
(!
verbose
)
{
globals
.
printStatus
(
''
);
_logger
.
printStatus
(
''
);
}
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
);
}
else
{
globals
.
printStatus
(
'
${showColor ? globals.terminal.color('•', TerminalColor.green) : '•'}
'
_logger
.
printStatus
(
'
${showColor ? globals.terminal.color('•', TerminalColor.green) : '•'}
'
' No issues found!'
,
hangingIndent:
2
);
}
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
457972b7
...
...
@@ -22,6 +22,7 @@ import 'base/terminal.dart';
import
'base/user_messages.dart'
;
import
'build_system/build_system.dart'
;
import
'cache.dart'
;
import
'doctor.dart'
;
import
'fuchsia/fuchsia_sdk.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/plist_parser.dart'
;
...
...
@@ -39,6 +40,7 @@ Artifacts get artifacts => context.get<Artifacts>();
BuildSystem
get
buildSystem
=>
context
.
get
<
BuildSystem
>();
Cache
get
cache
=>
context
.
get
<
Cache
>();
Config
get
config
=>
context
.
get
<
Config
>();
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
Logger
get
logger
=>
context
.
get
<
Logger
>();
OperatingSystemUtils
get
os
=>
context
.
get
<
OperatingSystemUtils
>();
PersistentToolState
get
persistentToolState
=>
PersistentToolState
.
instance
;
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
457972b7
...
...
@@ -25,7 +25,6 @@ import '../cache.dart';
import
'../dart/package_map.dart'
;
import
'../dart/pub.dart'
;
import
'../device.dart'
;
import
'../doctor.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
import
'../project.dart'
;
...
...
@@ -762,7 +761,7 @@ abstract class FlutterCommand extends Command<void> {
/// If no device can be found that meets specified criteria,
/// then print an error message and return null.
Future
<
List
<
Device
>>
findAllTargetDevices
()
async
{
if
(!
doctor
.
canLaunchAnything
)
{
if
(!
globals
.
doctor
.
canLaunchAnything
)
{
globals
.
printError
(
userMessages
.
flutterNoDevelopmentDevice
);
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(
AnsiTerminal:
()
=>
AnsiTerminal
(
platform:
globals
.
platform
,
stdio:
globals
.
stdio
),
Config:
()
=>
buildConfig
(
globals
.
fs
),
DeviceManager:
()
=>
FakeDeviceManager
(),
Doctor:
()
=>
FakeDoctor
(),
Doctor:
()
=>
FakeDoctor
(
globals
.
logger
),
FlutterVersion:
()
=>
MockFlutterVersion
(),
HttpClient:
()
=>
MockHttpClient
(),
IOSSimulatorUtils:
()
{
...
...
@@ -261,6 +261,8 @@ class FakeAndroidLicenseValidator extends AndroidLicenseValidator {
}
class
FakeDoctor
extends
Doctor
{
FakeDoctor
(
Logger
logger
)
:
super
(
logger:
logger
);
// True for testing.
@override
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