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
af164fe5
Unverified
Commit
af164fe5
authored
Apr 05, 2021
by
Jenn Magder
Committed by
GitHub
Apr 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate vscode to null safety (#79805)
parent
30370c9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
41 deletions
+42
-41
vscode.dart
packages/flutter_tools/lib/src/vscode/vscode.dart
+41
-38
vscode_validator.dart
packages/flutter_tools/lib/src/vscode/vscode_validator.dart
+1
-3
No files found.
packages/flutter_tools/lib/src/vscode/vscode.dart
View file @
af164fe5
...
...
@@ -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/file_system.dart'
;
import
'../base/platform.dart'
;
import
'../base/utils.dart'
;
...
...
@@ -21,7 +17,7 @@ const String extensionMarketplaceUrl =
'https://marketplace.visualstudio.com/items?itemName=
$extensionIdentifier
'
;
class
VsCode
{
VsCode
.
_
(
this
.
directory
,
this
.
extensionDirectory
,
{
Version
version
,
this
.
edition
,
@
required
FileSystem
fileSystem
})
VsCode
.
_
(
this
.
directory
,
this
.
extensionDirectory
,
{
Version
?
version
,
this
.
edition
,
required
FileSystem
fileSystem
})
:
version
=
version
??
Version
.
unknown
{
if
(!
fileSystem
.
isDirectorySync
(
directory
))
{
...
...
@@ -64,13 +60,13 @@ class VsCode {
factory
VsCode
.
fromDirectory
(
String
installPath
,
String
extensionDirectory
,
{
String
edition
,
@
required
FileSystem
fileSystem
,
String
?
edition
,
required
FileSystem
fileSystem
,
})
{
final
String
packageJsonPath
=
fileSystem
.
path
.
join
(
installPath
,
'resources'
,
'app'
,
'package.json'
);
final
String
versionString
=
_getVersionFromPackageJson
(
packageJsonPath
,
fileSystem
);
Version
version
;
final
String
?
versionString
=
_getVersionFromPackageJson
(
packageJsonPath
,
fileSystem
);
Version
?
version
;
if
(
versionString
!=
null
)
{
version
=
Version
.
parse
(
versionString
);
}
...
...
@@ -80,9 +76,9 @@ class VsCode {
final
String
directory
;
final
String
extensionDirectory
;
final
Version
version
;
final
String
edition
;
final
String
?
edition
;
Version
_extensionVersion
;
Version
?
_extensionVersion
;
final
List
<
ValidationMessage
>
_validationMessages
=
<
ValidationMessage
>[];
String
get
productName
=>
'VS Code'
+
(
edition
!=
null
?
',
$edition
'
:
''
);
...
...
@@ -115,35 +111,38 @@ class VsCode {
// $HOME/.vscode/extensions
// $HOME/.vscode-insiders/extensions
static
List
<
VsCode
>
_installedMacOS
(
FileSystem
fileSystem
,
Platform
platform
)
{
final
String
?
homeDirPath
=
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
).
homeDirPath
;
return
_findInstalled
(<
_VsCodeInstallLocation
>[
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
'/Applications'
,
'Visual Studio Code.app'
,
'Contents'
),
'.vscode'
,
),
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
).
homeDirPath
,
'Applications'
,
'Visual Studio Code.app'
,
'Contents'
,
if
(
homeDirPath
!=
null
)
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
homeDirPath
,
'Applications'
,
'Visual Studio Code.app'
,
'Contents'
,
),
'.vscode'
,
),
'.vscode'
,
),
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
'/Applications'
,
'Visual Studio Code - Insiders.app'
,
'Contents'
),
'.vscode-insiders'
,
isInsiders:
true
,
),
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
).
homeDirPath
,
'Applications'
,
'Visual Studio Code - Insiders.app'
,
'Contents'
,
if
(
homeDirPath
!=
null
)
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
homeDirPath
,
'Applications'
,
'Visual Studio Code - Insiders.app'
,
'Contents'
,
),
'.vscode-insiders'
,
isInsiders:
true
,
),
'.vscode-insiders'
,
isInsiders:
true
,
),
],
fileSystem
,
platform
);
}
...
...
@@ -163,9 +162,9 @@ class VsCode {
FileSystem
fileSystem
,
Platform
platform
,
)
{
final
String
progFiles86
=
platform
.
environment
[
'programfiles(x86)'
];
final
String
progFiles
=
platform
.
environment
[
'programfiles'
];
final
String
localAppData
=
platform
.
environment
[
'localappdata'
];
final
String
?
progFiles86
=
platform
.
environment
[
'programfiles(x86)'
];
final
String
?
progFiles
=
platform
.
environment
[
'programfiles'
];
final
String
?
localAppData
=
platform
.
environment
[
'localappdata'
];
final
List
<
_VsCodeInstallLocation
>
searchLocations
=
<
_VsCodeInstallLocation
>[
if
(
localAppData
!=
null
)
...
...
@@ -241,9 +240,10 @@ class VsCode {
final
List
<
VsCode
>
results
=
<
VsCode
>[];
for
(
final
_VsCodeInstallLocation
searchLocation
in
searchLocations
)
{
if
(
fileSystem
.
isDirectorySync
(
searchLocation
.
installPath
))
{
final
String
?
homeDirPath
=
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
).
homeDirPath
;
if
(
homeDirPath
!=
null
&&
fileSystem
.
isDirectorySync
(
searchLocation
.
installPath
))
{
final
String
extensionDirectory
=
fileSystem
.
path
.
join
(
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
).
homeDirPath
,
homeDirPath
,
searchLocation
.
extensionsFolder
,
'extensions'
,
);
...
...
@@ -263,17 +263,20 @@ class VsCode {
String
toString
()
=>
'VS Code (
$version
)
${_extensionVersion != Version.unknown ? ', Flutter ($_extensionVersion)' : ''}
'
;
static
String
_getVersionFromPackageJson
(
String
packageJsonPath
,
FileSystem
fileSystem
)
{
static
String
?
_getVersionFromPackageJson
(
String
packageJsonPath
,
FileSystem
fileSystem
)
{
if
(!
fileSystem
.
isFileSync
(
packageJsonPath
))
{
return
null
;
}
final
String
jsonString
=
fileSystem
.
file
(
packageJsonPath
).
readAsStringSync
();
try
{
final
Map
<
String
,
dynamic
>
jsonObject
=
castStringKeyedMap
(
json
.
decode
(
jsonString
));
return
jsonObject
[
'version'
]
as
String
;
final
Map
<
String
,
dynamic
>?
jsonObject
=
castStringKeyedMap
(
json
.
decode
(
jsonString
));
if
(
jsonObject
?.
containsKey
(
'version'
)
==
true
)
{
return
jsonObject
![
'version'
]
as
String
;
}
}
on
FormatException
{
return
null
;
}
return
null
;
}
}
...
...
@@ -282,11 +285,11 @@ class _VsCodeInstallLocation {
this
.
installPath
,
this
.
extensionsFolder
,
{
this
.
edition
,
bool
isInsiders
bool
?
isInsiders
})
:
isInsiders
=
isInsiders
??
false
;
final
String
installPath
;
final
String
extensionsFolder
;
final
String
edition
;
final
String
?
edition
;
final
bool
isInsiders
;
}
packages/flutter_tools/lib/src/vscode/vscode_validator.dart
View file @
af164fe5
...
...
@@ -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
'../base/file_system.dart'
;
import
'../base/platform.dart'
;
import
'../base/user_messages.dart'
;
...
...
@@ -24,7 +22,7 @@ class VsCodeValidator extends DoctorValidator {
@override
Future
<
ValidationResult
>
validate
()
async
{
final
String
vsCodeVersionText
=
_vsCode
.
version
==
Version
.
unknown
final
String
?
vsCodeVersionText
=
_vsCode
.
version
==
Version
.
unknown
?
null
:
userMessages
.
vsCodeVersion
(
_vsCode
.
version
.
toString
());
...
...
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