Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
0779716a
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0779716a
编写于
6月 20, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use user data service for reading settings
上级
0c890df5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
97 addition
and
39 deletion
+97
-39
src/vs/workbench/browser/web.main.ts
src/vs/workbench/browser/web.main.ts
+9
-3
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+9
-3
src/vs/workbench/services/configuration/browser/configuration.ts
...workbench/services/configuration/browser/configuration.ts
+47
-8
src/vs/workbench/services/configuration/browser/configurationService.ts
...ch/services/configuration/browser/configurationService.ts
+9
-9
src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts
...test/electron-browser/configurationEditingService.test.ts
+3
-1
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+20
-15
未找到文件。
src/vs/workbench/browser/web.main.ts
浏览文件 @
0779716a
...
...
@@ -35,6 +35,8 @@ import { SignService } from 'vs/platform/sign/browser/signService';
import
{
hash
}
from
'
vs/base/common/hash
'
;
import
{
IWorkbenchConstructionOptions
}
from
'
vs/workbench/workbench.web.api
'
;
import
{
ProductService
}
from
'
vs/platform/product/browser/productService
'
;
import
{
FileUserDataService
}
from
'
../services/userData/common/fileUserDataService
'
;
import
{
IUserDataService
}
from
'
../services/userData/common/userDataService
'
;
class
CodeRendererMain
extends
Disposable
{
...
...
@@ -117,10 +119,14 @@ class CodeRendererMain extends Disposable {
fileService
.
registerProvider
(
Schemas
.
vscodeRemote
,
remoteFileSystemProvider
);
}
// User Data Service
const
userDataService
=
this
.
_register
(
new
FileUserDataService
(
environmentService
,
fileService
));
serviceCollection
.
set
(
IUserDataService
,
userDataService
);
const
payload
=
await
this
.
resolveWorkspaceInitializationPayload
();
await
Promise
.
all
([
this
.
createWorkspaceService
(
payload
,
environmentService
,
fileService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
this
.
createWorkspaceService
(
payload
,
environmentService
,
fileService
,
userDataService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
// Workspace
serviceCollection
.
set
(
IWorkspaceContextService
,
service
);
...
...
@@ -135,8 +141,8 @@ class CodeRendererMain extends Disposable {
return
{
serviceCollection
,
logService
};
}
private
async
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IWorkbenchEnvironmentService
,
fileService
:
FileService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
()
},
file
Service
,
remoteAgentService
);
private
async
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IWorkbenchEnvironmentService
,
fileService
:
FileService
,
userDataService
:
IUserDataService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
({
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
()
},
fileService
,
userData
Service
,
remoteAgentService
);
try
{
await
workspaceService
.
initialize
(
payload
);
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
0779716a
...
...
@@ -50,6 +50,8 @@ import { ConfigurationCache } from 'vs/workbench/services/configuration/node/con
import
{
SpdLogService
}
from
'
vs/platform/log/node/spdlogService
'
;
import
{
SignService
}
from
'
vs/platform/sign/node/signService
'
;
import
{
ISignService
}
from
'
vs/platform/sign/common/sign
'
;
import
{
IUserDataService
}
from
'
../services/userData/common/userDataService
'
;
import
{
FileUserDataService
}
from
'
../services/userData/common/fileUserDataService
'
;
class
CodeRendererMain
extends
Disposable
{
...
...
@@ -205,10 +207,14 @@ class CodeRendererMain extends Disposable {
fileService
.
registerProvider
(
Schemas
.
vscodeRemote
,
remoteFileSystemProvider
);
}
// User Data Service
const
userDataService
=
this
.
_register
(
new
FileUserDataService
(
environmentService
,
fileService
));
serviceCollection
.
set
(
IUserDataService
,
userDataService
);
const
payload
=
await
this
.
resolveWorkspaceInitializationPayload
(
environmentService
);
const
services
=
await
Promise
.
all
([
this
.
createWorkspaceService
(
payload
,
environmentService
,
fileService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
this
.
createWorkspaceService
(
payload
,
environmentService
,
fileService
,
userDataService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
// Workspace
serviceCollection
.
set
(
IWorkspaceContextService
,
service
);
...
...
@@ -304,8 +310,8 @@ class CodeRendererMain extends Disposable {
return
;
}
private
async
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IWorkbenchEnvironmentService
,
fileService
:
FileService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
file
Service
,
remoteAgentService
);
private
async
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IWorkbenchEnvironmentService
,
fileService
:
FileService
,
userDataService
:
IUserDataService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
({
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userData
Service
,
remoteAgentService
);
try
{
await
workspaceService
.
initialize
(
payload
);
...
...
src/vs/workbench/services/configuration/browser/configuration.ts
浏览文件 @
0779716a
...
...
@@ -12,7 +12,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import
{
FileChangeType
,
FileChangesEvent
}
from
'
vs/platform/files/common/files
'
;
import
{
ConfigurationModel
,
ConfigurationModelParser
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
WorkspaceConfigurationModelParser
,
StandaloneConfigurationModelParser
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
FOLDER_SETTINGS_PATH
,
TASKS_CONFIGURATION_KEY
,
FOLDER_SETTINGS_NAME
,
LAUNCH_CONFIGURATION_KEY
,
IConfigurationCache
,
ConfigurationKey
,
REMOTE_MACHINE_SCOPES
,
FOLDER_SCOPES
,
WORKSPACE_SCOPES
,
ConfigurationFileService
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
FOLDER_SETTINGS_PATH
,
TASKS_CONFIGURATION_KEY
,
FOLDER_SETTINGS_NAME
,
LAUNCH_CONFIGURATION_KEY
,
IConfigurationCache
,
ConfigurationKey
,
REMOTE_MACHINE_SCOPES
,
FOLDER_SCOPES
,
WORKSPACE_SCOPES
,
USER_CONFIGURATION_KEY
,
ConfigurationFileService
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IStoredWorkspaceFolder
,
IWorkspaceIdentifier
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
JSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditingService
'
;
import
{
WorkbenchState
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -23,12 +23,51 @@ import { Schemas } from 'vs/base/common/network';
import
{
IConfigurationModel
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
hash
}
from
'
vs/base/common/hash
'
;
import
{
IUserDataService
}
from
'
../../userData/common/userDataService
'
;
export
class
UserConfiguration
extends
Disposable
{
private
readonly
parser
:
ConfigurationModelParser
;
private
readonly
reloadConfigurationScheduler
:
RunOnceScheduler
;
protected
readonly
_onDidChangeConfiguration
:
Emitter
<
ConfigurationModel
>
=
this
.
_register
(
new
Emitter
<
ConfigurationModel
>
());
readonly
onDidChangeConfiguration
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChangeConfiguration
.
event
;
constructor
(
private
readonly
scopes
:
ConfigurationScope
[]
|
undefined
,
private
readonly
userDataService
:
IUserDataService
)
{
super
();
this
.
parser
=
new
ConfigurationModelParser
(
USER_CONFIGURATION_KEY
,
this
.
scopes
);
this
.
reloadConfigurationScheduler
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
reload
().
then
(
configurationModel
=>
this
.
_onDidChangeConfiguration
.
fire
(
configurationModel
)),
50
));
this
.
_register
(
Event
.
filter
(
this
.
userDataService
.
onDidChange
,
e
=>
e
.
contains
(
USER_CONFIGURATION_KEY
))(()
=>
this
.
reloadConfigurationScheduler
.
schedule
()));
}
async
initialize
():
Promise
<
ConfigurationModel
>
{
return
this
.
reload
();
}
async
reload
():
Promise
<
ConfigurationModel
>
{
try
{
const
content
=
await
this
.
userDataService
.
read
(
USER_CONFIGURATION_KEY
);
this
.
parser
.
parseContent
(
content
);
return
this
.
parser
.
configurationModel
;
}
catch
(
e
)
{
return
new
ConfigurationModel
();
}
}
reprocess
():
ConfigurationModel
{
this
.
parser
.
parse
();
return
this
.
parser
.
configurationModel
;
}
}
export
class
RemoteUserConfiguration
extends
Disposable
{
private
readonly
_cachedConfiguration
:
CachedUserConfiguration
;
private
readonly
_cachedConfiguration
:
Cached
Remote
UserConfiguration
;
private
readonly
_configurationFileService
:
ConfigurationFileService
;
private
_userConfiguration
:
UserConfiguration
|
Cached
UserConfiguration
;
private
_userConfiguration
:
FileServiceBasedRemoteUserConfiguration
|
CachedRemote
UserConfiguration
;
private
_userConfigurationInitializationPromise
:
Promise
<
ConfigurationModel
>
|
null
=
null
;
private
readonly
_onDidChangeConfiguration
:
Emitter
<
ConfigurationModel
>
=
this
.
_register
(
new
Emitter
<
ConfigurationModel
>
());
...
...
@@ -42,10 +81,10 @@ export class RemoteUserConfiguration extends Disposable {
)
{
super
();
this
.
_configurationFileService
=
configurationFileService
;
this
.
_userConfiguration
=
this
.
_cachedConfiguration
=
new
CachedUserConfiguration
(
remoteAuthority
,
configurationCache
);
this
.
_userConfiguration
=
this
.
_cachedConfiguration
=
new
Cached
Remote
UserConfiguration
(
remoteAuthority
,
configurationCache
);
remoteAgentService
.
getEnvironment
().
then
(
async
environment
=>
{
if
(
environment
)
{
const
userConfiguration
=
this
.
_register
(
new
UserConfiguration
(
environment
.
settingsPath
,
REMOTE_MACHINE_SCOPES
,
this
.
_configurationFileService
));
const
userConfiguration
=
this
.
_register
(
new
FileServiceBasedRemote
UserConfiguration
(
environment
.
settingsPath
,
REMOTE_MACHINE_SCOPES
,
this
.
_configurationFileService
));
this
.
_register
(
userConfiguration
.
onDidChangeConfiguration
(
configurationModel
=>
this
.
onDidUserConfigurationChange
(
configurationModel
)));
this
.
_userConfigurationInitializationPromise
=
userConfiguration
.
initialize
();
const
configurationModel
=
await
this
.
_userConfigurationInitializationPromise
;
...
...
@@ -57,7 +96,7 @@ export class RemoteUserConfiguration extends Disposable {
}
async
initialize
():
Promise
<
ConfigurationModel
>
{
if
(
this
.
_userConfiguration
instanceof
UserConfiguration
)
{
if
(
this
.
_userConfiguration
instanceof
FileServiceBasedRemote
UserConfiguration
)
{
return
this
.
_userConfiguration
.
initialize
();
}
...
...
@@ -90,7 +129,7 @@ export class RemoteUserConfiguration extends Disposable {
}
}
export
class
UserConfiguration
extends
Disposable
{
class
FileServiceBasedRemote
UserConfiguration
extends
Disposable
{
private
readonly
parser
:
ConfigurationModelParser
;
private
readonly
reloadConfigurationScheduler
:
RunOnceScheduler
;
...
...
@@ -190,7 +229,7 @@ export class UserConfiguration extends Disposable {
}
}
class
CachedUserConfiguration
extends
Disposable
{
class
Cached
Remote
UserConfiguration
extends
Disposable
{
private
readonly
_onDidChange
:
Emitter
<
ConfigurationModel
>
=
this
.
_register
(
new
Emitter
<
ConfigurationModel
>
());
readonly
onDidChange
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChange
.
event
;
...
...
src/vs/workbench/services/configuration/browser/configurationService.ts
浏览文件 @
0779716a
...
...
@@ -29,6 +29,7 @@ import { isEqual, dirname } from 'vs/base/common/resources';
import
{
mark
}
from
'
vs/base/common/performance
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IUserDataService
}
from
'
../../userData/common/userDataService
'
;
export
class
WorkspaceService
extends
Disposable
implements
IConfigurationService
,
IWorkspaceContextService
{
...
...
@@ -40,7 +41,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
private
_configuration
:
Configuration
;
private
initialized
:
boolean
=
false
;
private
defaultConfiguration
:
DefaultConfigurationModel
;
private
localUserConfiguration
:
UserConfiguration
|
null
=
null
;
private
localUserConfiguration
:
UserConfiguration
;
private
remoteUserConfiguration
:
RemoteUserConfiguration
|
null
=
null
;
private
workspaceConfiguration
:
WorkspaceConfiguration
;
private
cachedFolderConfigs
:
ResourceMap
<
FolderConfiguration
>
;
...
...
@@ -67,9 +68,10 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
private
cyclicDependency
=
new
Promise
<
void
>
(
resolve
=>
this
.
cyclicDependencyReady
=
resolve
);
constructor
(
{
userSettingsResource
,
remoteAuthority
,
configurationCache
}:
{
userSettingsResource
?:
URI
,
remoteAuthority
?:
string
,
configurationCache
:
IConfigurationCache
},
{
remoteAuthority
,
configurationCache
}:
{
remoteAuthority
?:
string
,
configurationCache
:
IConfigurationCache
},
fileService
:
IFileService
,
remoteAgentService
:
IRemoteAgentService
,
userDataService
:
IUserDataService
,
remoteAgentService
:
IRemoteAgentService
)
{
super
();
...
...
@@ -79,10 +81,8 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
this
.
configurationFileService
=
new
ConfigurationFileService
(
fileService
);
this
.
_configuration
=
new
Configuration
(
this
.
defaultConfiguration
,
new
ConfigurationModel
(),
new
ConfigurationModel
(),
new
ConfigurationModel
(),
new
ResourceMap
(),
new
ConfigurationModel
(),
new
ResourceMap
<
ConfigurationModel
>
(),
this
.
workspace
);
this
.
cachedFolderConfigs
=
new
ResourceMap
<
FolderConfiguration
>
();
if
(
userSettingsResource
)
{
this
.
localUserConfiguration
=
this
.
_register
(
new
UserConfiguration
(
userSettingsResource
,
remoteAuthority
?
LOCAL_MACHINE_SCOPES
:
undefined
,
this
.
configurationFileService
));
this
.
_register
(
this
.
localUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onLocalUserConfigurationChanged
(
userConfiguration
)));
}
this
.
localUserConfiguration
=
this
.
_register
(
new
UserConfiguration
(
remoteAuthority
?
LOCAL_MACHINE_SCOPES
:
undefined
,
userDataService
));
this
.
_register
(
this
.
localUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onLocalUserConfigurationChanged
(
userConfiguration
)));
if
(
remoteAuthority
)
{
this
.
remoteUserConfiguration
=
this
.
_register
(
new
RemoteUserConfiguration
(
remoteAuthority
,
configurationCache
,
this
.
configurationFileService
,
remoteAgentService
));
this
.
_register
(
this
.
remoteUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onRemoteUserConfigurationChanged
(
userConfiguration
)));
...
...
@@ -426,7 +426,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
}
private
initializeUserConfiguration
():
Promise
<
{
local
:
ConfigurationModel
,
remote
:
ConfigurationModel
}
>
{
return
Promise
.
all
([
this
.
localUserConfiguration
?
this
.
localUserConfiguration
.
initialize
()
:
Promise
.
resolve
(
new
ConfigurationModel
()
),
this
.
remoteUserConfiguration
?
this
.
remoteUserConfiguration
.
initialize
()
:
Promise
.
resolve
(
new
ConfigurationModel
())])
return
Promise
.
all
([
this
.
localUserConfiguration
.
initialize
(
),
this
.
remoteUserConfiguration
?
this
.
remoteUserConfiguration
.
initialize
()
:
Promise
.
resolve
(
new
ConfigurationModel
())])
.
then
(([
local
,
remote
])
=>
({
local
,
remote
}));
}
...
...
@@ -435,7 +435,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
}
private
reloadLocalUserConfiguration
(
key
?:
string
):
Promise
<
ConfigurationModel
>
{
return
this
.
localUserConfiguration
?
this
.
localUserConfiguration
.
reload
()
:
Promise
.
resolve
(
new
ConfigurationModel
()
);
return
this
.
localUserConfiguration
.
reload
(
);
}
private
reloadRemoeUserConfiguration
(
key
?:
string
):
Promise
<
ConfigurationModel
>
{
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts
浏览文件 @
0779716a
...
...
@@ -39,6 +39,7 @@ import { Schemas } from 'vs/base/common/network';
import
{
DiskFileSystemProvider
}
from
'
vs/workbench/services/files/node/diskFileSystemProvider
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
import
{
FileUserDataService
}
from
'
vs/workbench/services/userData/common/fileUserDataService
'
;
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
...
...
@@ -107,7 +108,8 @@ suite('ConfigurationEditingService', () => {
fileService
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
new
NullLogService
()));
instantiationService
.
stub
(
IFileService
,
fileService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
);
const
workspaceService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userDataService
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
return
workspaceService
.
initialize
(
noWorkspace
?
{
id
:
''
}
:
{
folder
:
URI
.
file
(
workspaceDir
),
id
:
createHash
(
'
md5
'
).
update
(
URI
.
file
(
workspaceDir
).
toString
()).
digest
(
'
hex
'
)
}).
then
(()
=>
{
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
0779716a
...
...
@@ -31,7 +31,7 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
import
{
JSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditingService
'
;
import
{
createHash
}
from
'
crypto
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
originalFSPath
}
from
'
vs/base/common/resources
'
;
import
{
originalFSPath
,
dirname
}
from
'
vs/base/common/resources
'
;
import
{
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
IWindowConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
import
{
RemoteAgentService
}
from
'
vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl
'
;
...
...
@@ -45,14 +45,16 @@ import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEn
import
{
IConfigurationCache
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
import
{
SignService
}
from
'
vs/platform/sign/browser/signService
'
;
import
{
FileUserDataService
}
from
'
vs/workbench/services/userData/common/fileUserDataService
'
;
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
constructor
(
args
:
ParsedArgs
,
_execPath
:
string
,
private
customAppSettingsHome
:
string
)
{
constructor
(
args
:
ParsedArgs
,
_execPath
:
string
,
private
_settingsPath
:
string
)
{
super
(
args
,
_execPath
);
}
get
settingsResource
():
URI
{
return
URI
.
file
(
this
.
customAppSettingsHome
);
}
get
appSettingsHome
():
URI
{
return
dirname
(
this
.
settingsResource
);
}
get
settingsResource
():
URI
{
return
URI
.
file
(
this
.
_settingsPath
);
}
}
function
setUpFolderWorkspace
(
folderName
:
string
):
Promise
<
{
parentDir
:
string
,
folderDir
:
string
}
>
{
...
...
@@ -103,7 +105,9 @@ suite('WorkspaceContextService - Folder', () => {
workspaceResource
=
folderDir
;
const
globalSettingsFile
=
path
.
join
(
parentDir
,
'
settings.json
'
);
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
workspaceContextService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
FileService
(
new
NullLogService
()),
new
RemoteAgentService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAuthorityResolverService
(),
new
SignService
()));
const
fileService
=
new
FileService
(
new
NullLogService
());
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
);
workspaceContextService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userDataService
,
new
RemoteAgentService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAuthorityResolverService
(),
new
SignService
()));
return
(
<
WorkspaceService
>
workspaceContextService
).
initialize
(
convertToWorkspacePayload
(
URI
.
file
(
folderDir
)));
});
});
...
...
@@ -167,7 +171,8 @@ suite('WorkspaceContextService - Workspace', () => {
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
new
NullLogService
()));
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
);
const
workspaceService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userDataService
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
@@ -225,8 +230,8 @@ suite('WorkspaceContextService - Workspace Editing', () => {
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
new
NullLogService
()));
const
configurationFileService
=
fileService
;
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
configurationFile
Service
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
)
;
const
workspaceService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userData
Service
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
@@ -485,8 +490,8 @@ suite('WorkspaceService - Initialization', () => {
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
new
NullLogService
()));
const
configurationFileService
=
fileService
;
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
configurationFile
Service
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
)
;
const
workspaceService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userData
Service
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
...
@@ -748,8 +753,8 @@ suite('WorkspaceConfigurationService - Folder', () => {
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
new
NullLogService
()));
const
configurationFileService
=
fileService
;
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
configurationFile
Service
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
)
;
const
workspaceService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userData
Service
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
...
@@ -1075,8 +1080,8 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
new
DiskFileSystemProvider
(
new
NullLogService
()));
const
configurationFileService
=
fileService
;
const
workspaceService
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
configurationFile
Service
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
)
;
const
workspaceService
=
new
WorkspaceService
({
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
fileService
,
userData
Service
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
@@ -1476,9 +1481,9 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
const
remoteAgentService
=
instantiationService
.
stub
(
IRemoteAgentService
,
<
Partial
<
IRemoteAgentService
>>
{
getEnvironment
:
()
=>
remoteEnvironmentPromise
});
const
fileService
=
new
FileService
(
new
NullLogService
());
fileService
.
registerProvider
(
Schemas
.
file
,
diskFileSystemProvider
);
const
configurationFileService
=
fileService
;
const
configurationCache
:
IConfigurationCache
=
{
read
:
()
=>
Promise
.
resolve
(
''
),
write
:
()
=>
Promise
.
resolve
(),
remove
:
()
=>
Promise
.
resolve
()
};
testObject
=
new
WorkspaceService
({
userSettingsResource
:
environmentService
.
settingsResource
,
configurationCache
,
remoteAuthority
},
configurationFileService
,
remoteAgentService
);
const
userDataService
=
new
FileUserDataService
(
environmentService
,
fileService
);
testObject
=
new
WorkspaceService
({
configurationCache
,
remoteAuthority
},
fileService
,
userDataService
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
testObject
);
instantiationService
.
stub
(
IConfigurationService
,
testObject
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录