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
9bfe50cb
Unverified
Commit
9bfe50cb
authored
May 06, 2020
by
Jonah Williams
Committed by
GitHub
May 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fix windows vscode lookup (#56491)
parent
dd54bbdc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
65 deletions
+100
-65
vscode.dart
packages/flutter_tools/lib/src/vscode/vscode.dart
+74
-62
vscode_validator.dart
packages/flutter_tools/lib/src/vscode/vscode_validator.dart
+2
-1
vscode_test.dart
.../flutter_tools/test/general.shard/vscode/vscode_test.dart
+2
-2
vscode_validator_test.dart
...ools/test/general.shard/vscode/vscode_validator_test.dart
+22
-0
No files found.
packages/flutter_tools/lib/src/vscode/vscode.dart
View file @
9bfe50cb
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'../base/file_system.dart'
;
import
'../base/platform.dart'
;
import
'../base/utils.dart'
;
import
'../base/version.dart'
;
import
'../convert.dart'
;
...
...
@@ -86,15 +87,18 @@ class VsCode {
Iterable
<
ValidationMessage
>
get
validationMessages
=>
_validationMessages
;
static
List
<
VsCode
>
allInstalled
()
{
if
(
globals
.
platform
.
isMacOS
)
{
return
_installedMacOS
();
static
List
<
VsCode
>
allInstalled
(
FileSystem
fileSystem
,
Platform
platform
,
)
{
if
(
platform
.
isMacOS
)
{
return
_installedMacOS
(
fileSystem
);
}
if
(
globals
.
platform
.
isWindows
)
{
return
_installedWindows
();
if
(
platform
.
isWindows
)
{
return
_installedWindows
(
fileSystem
,
platform
);
}
if
(
globals
.
platform
.
isLinux
)
{
return
_installedLinux
();
if
(
platform
.
isLinux
)
{
return
_installedLinux
(
fileSystem
);
}
// VS Code isn't supported on the other platforms.
return
<
VsCode
>[];
...
...
@@ -108,14 +112,14 @@ class VsCode {
// macOS Extensions:
// $HOME/.vscode/extensions
// $HOME/.vscode-insiders/extensions
static
List
<
VsCode
>
_installedMacOS
()
{
static
List
<
VsCode
>
_installedMacOS
(
FileSystem
fileSystem
)
{
return
_findInstalled
(<
_VsCodeInstallLocation
>[
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
'/Applications'
,
'Visual Studio Code.app'
,
'Contents'
),
fileSystem
.
path
.
join
(
'/Applications'
,
'Visual Studio Code.app'
,
'Contents'
),
'.vscode'
,
),
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
fileSystem
.
path
.
join
(
globals
.
fsUtils
.
homeDirPath
,
'Applications'
,
'Visual Studio Code.app'
,
...
...
@@ -124,12 +128,12 @@ class VsCode {
'.vscode'
,
),
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
'/Applications'
,
'Visual Studio Code - Insiders.app'
,
'Contents'
),
fileSystem
.
path
.
join
(
'/Applications'
,
'Visual Studio Code - Insiders.app'
,
'Contents'
),
'.vscode-insiders'
,
isInsiders:
true
,
),
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
fileSystem
.
path
.
join
(
globals
.
fsUtils
.
homeDirPath
,
'Applications'
,
'Visual Studio Code - Insiders.app'
,
...
...
@@ -138,7 +142,7 @@ class VsCode {
'.vscode-insiders'
,
isInsiders:
true
,
),
]);
]
,
fileSystem
);
}
// Windows:
...
...
@@ -153,51 +157,56 @@ class VsCode {
// Windows Extensions:
// $HOME/.vscode/extensions
// $HOME/.vscode-insiders/extensions
static
List
<
VsCode
>
_installedWindows
()
{
final
String
progFiles86
=
globals
.
platform
.
environment
[
'programfiles(x86)'
];
final
String
progFiles
=
globals
.
platform
.
environment
[
'programfiles'
];
final
String
localAppData
=
globals
.
platform
.
environment
[
'localappdata'
];
static
List
<
VsCode
>
_installedWindows
(
FileSystem
fileSystem
,
Platform
platform
,
)
{
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
)
{
searchLocations
.
add
(
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
localAppData
,
r'Programs\Microsoft VS Code'
),
'.vscode'
,
));
}
searchLocations
.
add
(
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
progFiles86
,
'Microsoft VS Code'
),
'.vscode'
,
edition:
'32-bit edition'
,
));
searchLocations
.
add
(
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
progFiles
,
'Microsoft VS Code'
),
'.vscode'
,
edition:
'64-bit edition'
,
));
if
(
localAppData
!=
null
)
{
searchLocations
.
add
(
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
localAppData
,
r'Programs\Microsoft VS Code Insiders'
),
'.vscode-insiders'
,
isInsiders:
true
,
));
}
searchLocations
.
add
(
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
progFiles86
,
'Microsoft VS Code Insiders'
),
'.vscode-insiders'
,
edition:
'32-bit edition'
,
isInsiders:
true
,
));
searchLocations
.
add
(
_VsCodeInstallLocation
(
globals
.
fs
.
path
.
join
(
progFiles
,
'Microsoft VS Code Insiders'
),
'.vscode-insiders'
,
edition:
'64-bit edition'
,
isInsiders:
true
,
));
return
_findInstalled
(
searchLocations
);
final
List
<
_VsCodeInstallLocation
>
searchLocations
=
<
_VsCodeInstallLocation
>[
if
(
localAppData
!=
null
)
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
localAppData
,
r'Programs\Microsoft VS Code'
),
'.vscode'
,
),
if
(
progFiles86
!=
null
)
...<
_VsCodeInstallLocation
>[
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
progFiles86
,
'Microsoft VS Code'
),
'.vscode'
,
edition:
'32-bit edition'
,
),
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
progFiles86
,
'Microsoft VS Code Insiders'
),
'.vscode-insiders'
,
edition:
'32-bit edition'
,
isInsiders:
true
,
),
],
if
(
progFiles
!=
null
)
...<
_VsCodeInstallLocation
>[
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
progFiles
,
'Microsoft VS Code'
),
'.vscode'
,
edition:
'64-bit edition'
,
),
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
progFiles
,
'Microsoft VS Code Insiders'
),
'.vscode-insiders'
,
edition:
'64-bit edition'
,
isInsiders:
true
,
),
],
if
(
localAppData
!=
null
)
_VsCodeInstallLocation
(
fileSystem
.
path
.
join
(
localAppData
,
r'Programs\Microsoft VS Code Insiders'
),
'.vscode-insiders'
,
isInsiders:
true
,
),
];
return
_findInstalled
(
searchLocations
,
fileSystem
);
}
// Linux:
...
...
@@ -206,7 +215,7 @@ class VsCode {
// Linux Extensions:
// $HOME/.vscode/extensions
// $HOME/.vscode-insiders/extensions
static
List
<
VsCode
>
_installedLinux
()
{
static
List
<
VsCode
>
_installedLinux
(
FileSystem
fileSystem
)
{
return
_findInstalled
(<
_VsCodeInstallLocation
>[
const
_VsCodeInstallLocation
(
'/usr/share/code'
,
'.vscode'
),
const
_VsCodeInstallLocation
(
...
...
@@ -214,10 +223,13 @@ class VsCode {
'.vscode-insiders'
,
isInsiders:
true
,
),
]);
]
,
fileSystem
);
}
static
List
<
VsCode
>
_findInstalled
(
List
<
_VsCodeInstallLocation
>
allLocations
)
{
static
List
<
VsCode
>
_findInstalled
(
List
<
_VsCodeInstallLocation
>
allLocations
,
FileSystem
fileSystem
,
)
{
final
Iterable
<
_VsCodeInstallLocation
>
searchLocations
=
_includeInsiders
?
allLocations
...
...
@@ -226,8 +238,8 @@ class VsCode {
final
List
<
VsCode
>
results
=
<
VsCode
>[];
for
(
final
_VsCodeInstallLocation
searchLocation
in
searchLocations
)
{
if
(
globals
.
fs
.
isDirectorySync
(
searchLocation
.
installPath
))
{
final
String
extensionDirectory
=
globals
.
fs
.
path
.
join
(
if
(
fileSystem
.
isDirectorySync
(
searchLocation
.
installPath
))
{
final
String
extensionDirectory
=
fileSystem
.
path
.
join
(
globals
.
fsUtils
.
homeDirPath
,
searchLocation
.
extensionsFolder
,
'extensions'
,
...
...
packages/flutter_tools/lib/src/vscode/vscode_validator.dart
View file @
9bfe50cb
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'../base/user_messages.dart'
;
import
'../base/version.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
import
'vscode.dart'
;
class
VsCodeValidator
extends
DoctorValidator
{
...
...
@@ -16,7 +17,7 @@ class VsCodeValidator extends DoctorValidator {
static
Iterable
<
DoctorValidator
>
get
installedValidators
{
return
VsCode
.
allInstalled
()
.
allInstalled
(
globals
.
fs
,
globals
.
platform
)
.
map
<
DoctorValidator
>((
VsCode
vsCode
)
=>
VsCodeValidator
(
vsCode
));
}
...
...
packages/flutter_tools/test/general.shard/vscode_test.dart
→
packages/flutter_tools/test/general.shard/vscode
/vscode
_test.dart
View file @
9bfe50cb
...
...
@@ -10,8 +10,8 @@ import 'package:flutter_tools/src/base/version.dart';
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/vscode/vscode.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../
../
src/common.dart'
;
import
'../
../
src/context.dart'
;
void
main
(
)
{
testUsingContext
(
'VsCode.fromDirectory does not crash when packages.json is malformed'
,
()
{
...
...
packages/flutter_tools/test/general.shard/vscode/vscode_validator_test.dart
0 → 100644
View file @
9bfe50cb
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/vscode/vscode.dart'
;
import
'../../src/common.dart'
;
void
main
(
)
{
testWithoutContext
(
'VsCode search locations on windows supports an empty environment'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
);
final
Platform
platform
=
FakePlatform
(
operatingSystem:
'windows'
,
environment:
<
String
,
String
>{},
);
expect
(
VsCode
.
allInstalled
(
fileSystem
,
platform
),
isEmpty
);
});
}
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