Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
1f30cbf6
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,发现更多精彩内容 >>
提交
1f30cbf6
编写于
4月 02, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract Configuration Cache
上级
1ca3959f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
206 addition
and
123 deletion
+206
-123
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+10
-3
src/vs/workbench/services/configuration/common/configuration.ts
.../workbench/services/configuration/common/configuration.ts
+11
-0
src/vs/workbench/services/configuration/node/configuration.ts
...vs/workbench/services/configuration/node/configuration.ts
+69
-94
src/vs/workbench/services/configuration/node/configurationCache.ts
...rkbench/services/configuration/node/configurationCache.ts
+82
-0
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+23
-14
src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts
...test/electron-browser/configurationEditingService.test.ts
+3
-2
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
...ration/test/electron-browser/configurationService.test.ts
+8
-6
src/vs/workbench/services/hash/node/hashService.ts
src/vs/workbench/services/hash/node/hashService.ts
+0
-3
src/vs/workbench/workbench.main.ts
src/vs/workbench/workbench.main.ts
+0
-1
未找到文件。
src/vs/workbench/electron-browser/main.ts
浏览文件 @
1f30cbf6
...
@@ -50,6 +50,9 @@ import { IChannel } from 'vs/base/parts/ipc/common/ipc';
...
@@ -50,6 +50,9 @@ import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import
{
REMOTE_FILE_SYSTEM_CHANNEL_NAME
,
RemoteExtensionsFileSystemProvider
}
from
'
vs/platform/remote/common/remoteAgentFileSystemChannel
'
;
import
{
REMOTE_FILE_SYSTEM_CHANNEL_NAME
,
RemoteExtensionsFileSystemProvider
}
from
'
vs/platform/remote/common/remoteAgentFileSystemChannel
'
;
import
{
REMOTE_HOST_SCHEME
}
from
'
vs/platform/remote/common/remoteHosts
'
;
import
{
REMOTE_HOST_SCHEME
}
from
'
vs/platform/remote/common/remoteHosts
'
;
import
{
DefaultConfigurationExportHelper
}
from
'
vs/workbench/services/configuration/node/configurationExportHelper
'
;
import
{
DefaultConfigurationExportHelper
}
from
'
vs/workbench/services/configuration/node/configurationExportHelper
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/node/hashService
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
class
CodeRendererMain
extends
Disposable
{
class
CodeRendererMain
extends
Disposable
{
...
@@ -198,8 +201,12 @@ class CodeRendererMain extends Disposable {
...
@@ -198,8 +201,12 @@ class CodeRendererMain extends Disposable {
fileService
.
registerProvider
(
REMOTE_HOST_SCHEME
,
new
RemoteExtensionsFileSystemProvider
(
channel
,
remoteAgentService
.
getEnvironment
()));
fileService
.
registerProvider
(
REMOTE_HOST_SCHEME
,
new
RemoteExtensionsFileSystemProvider
(
channel
,
remoteAgentService
.
getEnvironment
()));
}
}
// Hash Service
const
hashService
=
new
HashService
();
serviceCollection
.
set
(
IHashService
,
hashService
);
return
this
.
resolveWorkspaceInitializationPayload
(
environmentService
).
then
(
payload
=>
Promise
.
all
([
return
this
.
resolveWorkspaceInitializationPayload
(
environmentService
).
then
(
payload
=>
Promise
.
all
([
this
.
createWorkspaceService
(
payload
,
environmentService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
this
.
createWorkspaceService
(
payload
,
environmentService
,
hashService
,
remoteAgentService
,
logService
).
then
(
service
=>
{
// Workspace
// Workspace
serviceCollection
.
set
(
IWorkspaceContextService
,
service
);
serviceCollection
.
set
(
IWorkspaceContextService
,
service
);
...
@@ -290,8 +297,8 @@ class CodeRendererMain extends Disposable {
...
@@ -290,8 +297,8 @@ class CodeRendererMain extends Disposable {
},
error
=>
onUnexpectedError
(
error
));
},
error
=>
onUnexpectedError
(
error
));
}
}
private
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IEnvironmentService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
private
createWorkspaceService
(
payload
:
IWorkspaceInitializationPayload
,
environmentService
:
IEnvironmentService
,
hashService
:
IHashService
,
remoteAgentService
:
IRemoteAgentService
,
logService
:
ILogService
):
Promise
<
WorkspaceService
>
{
const
workspaceService
=
new
WorkspaceService
(
this
.
configuration
,
environment
Service
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
remoteAuthority
:
this
.
configuration
.
remoteAuthority
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
hash
Service
,
remoteAgentService
);
return
workspaceService
.
initialize
(
payload
).
then
(()
=>
workspaceService
,
error
=>
{
return
workspaceService
.
initialize
(
payload
).
then
(()
=>
workspaceService
,
error
=>
{
onUnexpectedError
(
error
);
onUnexpectedError
(
error
);
...
...
src/vs/workbench/services/configuration/common/configuration.ts
浏览文件 @
1f30cbf6
...
@@ -19,3 +19,14 @@ export const LAUNCH_CONFIGURATION_KEY = 'launch';
...
@@ -19,3 +19,14 @@ export const LAUNCH_CONFIGURATION_KEY = 'launch';
export
const
WORKSPACE_STANDALONE_CONFIGURATIONS
=
Object
.
create
(
null
);
export
const
WORKSPACE_STANDALONE_CONFIGURATIONS
=
Object
.
create
(
null
);
WORKSPACE_STANDALONE_CONFIGURATIONS
[
TASKS_CONFIGURATION_KEY
]
=
`
${
FOLDER_CONFIG_FOLDER_NAME
}
/
${
TASKS_CONFIGURATION_KEY
}
.json`
;
WORKSPACE_STANDALONE_CONFIGURATIONS
[
TASKS_CONFIGURATION_KEY
]
=
`
${
FOLDER_CONFIG_FOLDER_NAME
}
/
${
TASKS_CONFIGURATION_KEY
}
.json`
;
WORKSPACE_STANDALONE_CONFIGURATIONS
[
LAUNCH_CONFIGURATION_KEY
]
=
`
${
FOLDER_CONFIG_FOLDER_NAME
}
/
${
LAUNCH_CONFIGURATION_KEY
}
.json`
;
WORKSPACE_STANDALONE_CONFIGURATIONS
[
LAUNCH_CONFIGURATION_KEY
]
=
`
${
FOLDER_CONFIG_FOLDER_NAME
}
/
${
LAUNCH_CONFIGURATION_KEY
}
.json`
;
export
type
ConfigurationKey
=
{
type
:
'
user
'
|
'
workspaces
'
|
'
folder
'
,
key
:
string
};
export
interface
IConfigurationCache
{
read
(
key
:
ConfigurationKey
):
Promise
<
string
>
;
write
(
key
:
ConfigurationKey
,
content
:
string
):
Promise
<
void
>
;
remove
(
key
:
ConfigurationKey
):
Promise
<
void
>
;
}
src/vs/workbench/services/configuration/node/configuration.ts
浏览文件 @
1f30cbf6
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
createHash
}
from
'
crypto
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
...
@@ -15,7 +14,7 @@ import { RunOnceScheduler, Delayer } from 'vs/base/common/async';
...
@@ -15,7 +14,7 @@ import { RunOnceScheduler, Delayer } from 'vs/base/common/async';
import
{
FileChangeType
,
FileChangesEvent
,
IContent
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
FileChangeType
,
FileChangesEvent
,
IContent
,
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
ConfigurationModel
,
ConfigurationModelParser
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
ConfigurationModel
,
ConfigurationModelParser
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
WorkspaceConfigurationModelParser
,
FolderSettingsModelParser
,
StandaloneConfigurationModelParser
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
WorkspaceConfigurationModelParser
,
FolderSettingsModelParser
,
StandaloneConfigurationModelParser
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
FOLDER_SETTINGS_PATH
,
TASKS_CONFIGURATION_KEY
,
FOLDER_SETTINGS_NAME
,
LAUNCH_CONFIGURATION_KEY
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
FOLDER_SETTINGS_PATH
,
TASKS_CONFIGURATION_KEY
,
FOLDER_SETTINGS_NAME
,
LAUNCH_CONFIGURATION_KEY
,
IConfigurationCache
,
ConfigurationKey
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IStoredWorkspaceFolder
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IStoredWorkspaceFolder
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
JSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditingService
'
;
import
{
JSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditingService
'
;
import
{
WorkbenchState
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
WorkbenchState
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
...
@@ -23,9 +22,9 @@ import { ConfigurationScope } from 'vs/platform/configuration/common/configurati
...
@@ -23,9 +22,9 @@ import { ConfigurationScope } from 'vs/platform/configuration/common/configurati
import
{
extname
,
join
}
from
'
vs/base/common/path
'
;
import
{
extname
,
join
}
from
'
vs/base/common/path
'
;
import
{
equals
}
from
'
vs/base/common/objects
'
;
import
{
equals
}
from
'
vs/base/common/objects
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IConfigurationModel
,
compare
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationModel
,
compare
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
NodeBasedUserConfiguration
}
from
'
vs/platform/configuration/node/configuration
'
;
import
{
NodeBasedUserConfiguration
}
from
'
vs/platform/configuration/node/configuration
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
export
class
LocalUserConfiguration
extends
Disposable
{
export
class
LocalUserConfiguration
extends
Disposable
{
...
@@ -37,12 +36,11 @@ export class LocalUserConfiguration extends Disposable {
...
@@ -37,12 +36,11 @@ export class LocalUserConfiguration extends Disposable {
public
readonly
onDidChangeConfiguration
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChangeConfiguration
.
event
;
public
readonly
onDidChangeConfiguration
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChangeConfiguration
.
event
;
constructor
(
constructor
(
environmentService
:
IEnvironmentService
userSettingsPath
:
string
)
{
)
{
super
();
super
();
this
.
userConfigurationResource
=
URI
.
file
(
environmentService
.
appSettingsPath
);
this
.
userConfigurationResource
=
URI
.
file
(
userSettingsPath
);
this
.
userConfiguration
=
this
.
_register
(
new
NodeBasedUserConfiguration
(
environmentService
.
appSettingsPath
));
this
.
userConfiguration
=
this
.
_register
(
new
NodeBasedUserConfiguration
(
userSettingsPath
));
this
.
changeDisposable
=
this
.
_register
(
this
.
userConfiguration
.
onDidChangeConfiguration
(
configurationModel
=>
this
.
_onDidChangeConfiguration
.
fire
(
configurationModel
)));
}
}
initialize
():
Promise
<
ConfigurationModel
>
{
initialize
():
Promise
<
ConfigurationModel
>
{
...
@@ -74,10 +72,10 @@ export class RemoteUserConfiguration extends Disposable {
...
@@ -74,10 +72,10 @@ export class RemoteUserConfiguration extends Disposable {
constructor
(
constructor
(
remoteAuthority
:
string
,
remoteAuthority
:
string
,
environmentService
:
IEnvironmentServic
e
configurationCache
:
IConfigurationCach
e
)
{
)
{
super
();
super
();
this
.
_userConfiguration
=
this
.
_cachedConfiguration
=
new
CachedUserConfiguration
(
remoteAuthority
,
environmentServic
e
);
this
.
_userConfiguration
=
this
.
_cachedConfiguration
=
new
CachedUserConfiguration
(
remoteAuthority
,
configurationCach
e
);
}
}
initialize
():
Promise
<
ConfigurationModel
>
{
initialize
():
Promise
<
ConfigurationModel
>
{
...
@@ -236,17 +234,15 @@ class CachedUserConfiguration extends Disposable {
...
@@ -236,17 +234,15 @@ class CachedUserConfiguration extends Disposable {
private
readonly
_onDidChange
:
Emitter
<
ConfigurationModel
>
=
this
.
_register
(
new
Emitter
<
ConfigurationModel
>
());
private
readonly
_onDidChange
:
Emitter
<
ConfigurationModel
>
=
this
.
_register
(
new
Emitter
<
ConfigurationModel
>
());
readonly
onDidChange
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChange
.
event
;
readonly
onDidChange
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChange
.
event
;
private
readonly
cachedFolderPath
:
string
;
private
readonly
key
:
ConfigurationKey
;
private
readonly
cachedConfigurationPath
:
string
;
private
configurationModel
:
ConfigurationModel
;
private
configurationModel
:
ConfigurationModel
;
constructor
(
constructor
(
remoteAuthority
:
string
,
remoteAuthority
:
string
,
private
environmentService
:
IEnvironmentServic
e
private
readonly
configurationCache
:
IConfigurationCach
e
)
{
)
{
super
();
super
();
this
.
cachedFolderPath
=
join
(
this
.
environmentService
.
userDataPath
,
'
CachedConfigurations
'
,
'
user
'
,
remoteAuthority
);
this
.
key
=
{
type
:
'
user
'
,
key
:
remoteAuthority
};
this
.
cachedConfigurationPath
=
join
(
this
.
cachedFolderPath
,
'
configuration.json
'
);
this
.
configurationModel
=
new
ConfigurationModel
();
this
.
configurationModel
=
new
ConfigurationModel
();
}
}
...
@@ -258,33 +254,22 @@ class CachedUserConfiguration extends Disposable {
...
@@ -258,33 +254,22 @@ class CachedUserConfiguration extends Disposable {
return
this
.
reload
();
return
this
.
reload
();
}
}
reload
():
Promise
<
ConfigurationModel
>
{
async
reload
():
Promise
<
ConfigurationModel
>
{
return
pfs
.
readFile
(
this
.
cachedConfigurationPath
)
const
content
=
await
this
.
configurationCache
.
read
(
this
.
key
);
.
then
(
content
=>
content
.
toString
(),
()
=>
''
)
try
{
.
then
(
content
=>
{
const
parsed
:
IConfigurationModel
=
JSON
.
parse
(
content
);
try
{
this
.
configurationModel
=
new
ConfigurationModel
(
parsed
.
contents
,
parsed
.
keys
,
parsed
.
overrides
);
const
parsed
:
IConfigurationModel
=
JSON
.
parse
(
content
);
}
catch
(
e
)
{
this
.
configurationModel
=
new
ConfigurationModel
(
parsed
.
contents
,
parsed
.
keys
,
parsed
.
overrides
);
}
}
catch
(
e
)
{
return
this
.
configurationModel
;
}
return
this
.
configurationModel
;
});
}
}
updateConfiguration
(
configurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
updateConfiguration
(
configurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
const
raw
=
JSON
.
stringify
(
configurationModel
.
toJSON
());
if
(
configurationModel
.
keys
.
length
)
{
return
this
.
createCachedFolder
().
then
(
created
=>
{
return
this
.
configurationCache
.
write
(
this
.
key
,
JSON
.
stringify
(
configurationModel
.
toJSON
()));
if
(
created
)
{
}
else
{
return
configurationModel
.
keys
.
length
?
pfs
.
writeFile
(
this
.
cachedConfigurationPath
,
raw
)
:
pfs
.
rimraf
(
this
.
cachedFolderPath
);
return
this
.
configurationCache
.
remove
(
this
.
key
);
}
}
return
undefined
;
});
}
private
createCachedFolder
():
Promise
<
boolean
>
{
return
Promise
.
resolve
(
pfs
.
exists
(
this
.
cachedFolderPath
))
.
then
(
undefined
,
()
=>
false
)
.
then
(
exists
=>
exists
?
exists
:
pfs
.
mkdirp
(
this
.
cachedFolderPath
).
then
(()
=>
true
,
()
=>
false
));
}
}
}
}
...
@@ -304,10 +289,10 @@ export class WorkspaceConfiguration extends Disposable {
...
@@ -304,10 +289,10 @@ export class WorkspaceConfiguration extends Disposable {
public
readonly
onDidUpdateConfiguration
:
Event
<
void
>
=
this
.
_onDidUpdateConfiguration
.
event
;
public
readonly
onDidUpdateConfiguration
:
Event
<
void
>
=
this
.
_onDidUpdateConfiguration
.
event
;
constructor
(
constructor
(
environmentService
:
IEnvironmentServic
e
configurationCache
:
IConfigurationCach
e
)
{
)
{
super
();
super
();
this
.
_cachedConfiguration
=
new
CachedWorkspaceConfiguration
(
environmentServic
e
);
this
.
_cachedConfiguration
=
new
CachedWorkspaceConfiguration
(
configurationCach
e
);
this
.
_workspaceConfiguration
=
this
.
_cachedConfiguration
;
this
.
_workspaceConfiguration
=
this
.
_cachedConfiguration
;
}
}
...
@@ -537,25 +522,24 @@ class CachedWorkspaceConfiguration extends Disposable implements IWorkspaceConfi
...
@@ -537,25 +522,24 @@ class CachedWorkspaceConfiguration extends Disposable implements IWorkspaceConfi
private
readonly
_onDidChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
private
readonly
_onDidChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
readonly
onDidChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
private
cachedWorkspacePath
:
string
;
private
cachedConfigurationPath
:
string
;
workspaceConfigurationModelParser
:
WorkspaceConfigurationModelParser
;
workspaceConfigurationModelParser
:
WorkspaceConfigurationModelParser
;
workspaceSettings
:
ConfigurationModel
;
workspaceSettings
:
ConfigurationModel
;
constructor
(
private
environmentService
:
IEnvironmentServic
e
)
{
constructor
(
private
readonly
configurationCache
:
IConfigurationCach
e
)
{
super
();
super
();
this
.
workspaceConfigurationModelParser
=
new
WorkspaceConfigurationModelParser
(
''
);
this
.
workspaceConfigurationModelParser
=
new
WorkspaceConfigurationModelParser
(
''
);
this
.
workspaceSettings
=
new
ConfigurationModel
();
this
.
workspaceSettings
=
new
ConfigurationModel
();
}
}
load
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
Promise
<
void
>
{
async
load
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
Promise
<
void
>
{
this
.
createPaths
(
workspaceIdentifier
);
try
{
return
pfs
.
readFile
(
this
.
cachedConfigurationPath
)
const
key
=
this
.
getKey
(
workspaceIdentifier
);
.
then
(
contents
=>
{
const
contents
=
await
this
.
configurationCache
.
read
(
key
);
this
.
workspaceConfigurationModelParser
=
new
WorkspaceConfigurationModelParser
(
this
.
cachedConfigurationPath
);
this
.
workspaceConfigurationModelParser
=
new
WorkspaceConfigurationModelParser
(
key
.
key
);
this
.
workspaceConfigurationModelParser
.
parse
(
contents
.
toString
());
this
.
workspaceConfigurationModelParser
.
parse
(
contents
);
this
.
workspaceSettings
=
this
.
workspaceConfigurationModelParser
.
settingsModel
.
merge
(
this
.
workspaceConfigurationModelParser
.
launchModel
);
this
.
workspaceSettings
=
this
.
workspaceConfigurationModelParser
.
settingsModel
.
merge
(
this
.
workspaceConfigurationModelParser
.
launchModel
);
},
()
=>
{
});
}
catch
(
e
)
{
}
}
}
get
workspaceIdentifier
():
IWorkspaceIdentifier
|
null
{
get
workspaceIdentifier
():
IWorkspaceIdentifier
|
null
{
...
@@ -580,25 +564,21 @@ class CachedWorkspaceConfiguration extends Disposable implements IWorkspaceConfi
...
@@ -580,25 +564,21 @@ class CachedWorkspaceConfiguration extends Disposable implements IWorkspaceConfi
async
updateWorkspace
(
workspaceIdentifier
:
IWorkspaceIdentifier
,
configurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
async
updateWorkspace
(
workspaceIdentifier
:
IWorkspaceIdentifier
,
configurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
try
{
try
{
this
.
createPaths
(
workspaceIdentifier
);
const
key
=
this
.
getKey
(
workspaceIdentifier
);
if
(
configurationModel
.
keys
.
length
)
{
if
(
configurationModel
.
keys
.
length
)
{
const
exists
=
await
pfs
.
exists
(
this
.
cachedWorkspacePath
);
await
this
.
configurationCache
.
write
(
key
,
JSON
.
stringify
(
configurationModel
.
toJSON
().
contents
));
if
(
!
exists
)
{
await
pfs
.
mkdirp
(
this
.
cachedWorkspacePath
);
}
const
raw
=
JSON
.
stringify
(
configurationModel
.
toJSON
().
contents
);
await
pfs
.
writeFile
(
this
.
cachedConfigurationPath
,
raw
);
}
else
{
}
else
{
pfs
.
rimraf
(
this
.
cachedWorkspacePath
);
await
this
.
configurationCache
.
remove
(
key
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
errors
.
onUnexpectedError
(
error
);
}
}
}
}
private
createPaths
(
workspaceIdentifier
:
IWorkspaceIdentifier
)
{
private
getKey
(
workspaceIdentifier
:
IWorkspaceIdentifier
):
ConfigurationKey
{
this
.
cachedWorkspacePath
=
join
(
this
.
environmentService
.
userDataPath
,
'
CachedConfigurations
'
,
'
workspaces
'
,
workspaceIdentifier
.
id
);
return
{
this
.
cachedConfigurationPath
=
join
(
this
.
cachedWorkspacePath
,
'
workspace.json
'
);
type
:
'
workspaces
'
,
key
:
workspaceIdentifier
.
id
};
}
}
}
}
...
@@ -822,45 +802,45 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura
...
@@ -822,45 +802,45 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura
}
}
}
}
export
class
CachedFolderConfiguration
extends
Disposable
implements
IFolderConfiguration
{
class
CachedFolderConfiguration
extends
Disposable
implements
IFolderConfiguration
{
private
readonly
_onDidChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
private
readonly
_onDidChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
readonly
onDidChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
private
readonly
cachedFolderPath
:
string
;
private
readonly
cachedConfigurationPath
:
string
;
private
configurationModel
:
ConfigurationModel
;
private
configurationModel
:
ConfigurationModel
;
private
readonly
key
:
Thenable
<
ConfigurationKey
>
;
loaded
:
boolean
=
false
;
loaded
:
boolean
=
false
;
constructor
(
constructor
(
folder
:
URI
,
folder
:
URI
,
configFolderRelativePath
:
string
,
configFolderRelativePath
:
string
,
environmentService
:
IEnvironmentService
)
{
hashService
:
IHashService
,
private
readonly
configurationCache
:
IConfigurationCache
)
{
super
();
super
();
this
.
cachedFolderPath
=
join
(
environmentService
.
userDataPath
,
'
CachedConfigurations
'
,
'
folders
'
,
createHash
(
'
md5
'
).
update
(
join
(
folder
.
path
,
configFolderRelativePath
)).
digest
(
'
hex
'
));
this
.
key
=
hashService
.
createSHA1
(
join
(
folder
.
path
,
configFolderRelativePath
)).
then
(
key
=>
(
<
ConfigurationKey
>
{
type
:
'
folder
'
,
key
}));
this
.
cachedConfigurationPath
=
join
(
this
.
cachedFolderPath
,
'
configuration.json
'
);
this
.
configurationModel
=
new
ConfigurationModel
();
this
.
configurationModel
=
new
ConfigurationModel
();
}
}
loadConfiguration
():
Promise
<
ConfigurationModel
>
{
async
loadConfiguration
():
Promise
<
ConfigurationModel
>
{
return
pfs
.
readFile
(
this
.
cachedConfigurationPath
)
try
{
.
then
(
contents
=>
{
const
key
=
await
this
.
key
;
const
parsed
:
IConfigurationModel
=
JSON
.
parse
(
contents
.
toString
());
const
contents
=
await
this
.
configurationCache
.
read
(
key
);
this
.
configurationModel
=
new
ConfigurationModel
(
parsed
.
contents
,
parsed
.
keys
,
parsed
.
overrides
);
const
parsed
:
IConfigurationModel
=
JSON
.
parse
(
contents
.
toString
());
this
.
loaded
=
true
;
this
.
configurationModel
=
new
ConfigurationModel
(
parsed
.
contents
,
parsed
.
keys
,
parsed
.
overrides
);
return
this
.
configurationModel
;
this
.
loaded
=
true
;
},
()
=>
this
.
configurationModel
);
}
catch
(
e
)
{
}
return
this
.
configurationModel
;
}
}
updateConfiguration
(
configurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
async
updateConfiguration
(
configurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
const
raw
=
JSON
.
stringify
(
configurationModel
.
toJSON
());
const
key
=
await
this
.
key
;
return
this
.
createCachedFolder
().
then
(
created
=>
{
if
(
configurationModel
.
keys
.
length
)
{
if
(
created
)
{
await
this
.
configurationCache
.
write
(
key
,
JSON
.
stringify
(
configurationModel
.
toJSON
()));
return
configurationModel
.
keys
.
length
?
pfs
.
writeFile
(
this
.
cachedConfigurationPath
,
raw
)
:
pfs
.
rimraf
(
this
.
cachedFolderPath
);
}
else
{
}
await
this
.
configurationCache
.
remove
(
key
);
return
undefined
;
}
});
}
}
reprocess
():
ConfigurationModel
{
reprocess
():
ConfigurationModel
{
...
@@ -870,12 +850,6 @@ export class CachedFolderConfiguration extends Disposable implements IFolderConf
...
@@ -870,12 +850,6 @@ export class CachedFolderConfiguration extends Disposable implements IFolderConf
getUnsupportedKeys
():
string
[]
{
getUnsupportedKeys
():
string
[]
{
return
[];
return
[];
}
}
private
createCachedFolder
():
Promise
<
boolean
>
{
return
Promise
.
resolve
(
pfs
.
exists
(
this
.
cachedFolderPath
))
.
then
(
undefined
,
()
=>
false
)
.
then
(
exists
=>
exists
?
exists
:
pfs
.
mkdirp
(
this
.
cachedFolderPath
).
then
(()
=>
true
,
()
=>
false
));
}
}
}
export
class
FolderConfiguration
extends
Disposable
implements
IFolderConfiguration
{
export
class
FolderConfiguration
extends
Disposable
implements
IFolderConfiguration
{
...
@@ -891,12 +865,13 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
...
@@ -891,12 +865,13 @@ export class FolderConfiguration extends Disposable implements IFolderConfigurat
readonly
workspaceFolder
:
IWorkspaceFolder
,
readonly
workspaceFolder
:
IWorkspaceFolder
,
private
readonly
configFolderRelativePath
:
string
,
private
readonly
configFolderRelativePath
:
string
,
private
readonly
workbenchState
:
WorkbenchState
,
private
readonly
workbenchState
:
WorkbenchState
,
private
environmentService
:
IEnvironmentService
,
hashService
:
IHashService
,
configurationCache
:
IConfigurationCache
,
fileService
?:
IFileService
fileService
?:
IFileService
)
{
)
{
super
();
super
();
this
.
cachedFolderConfiguration
=
new
CachedFolderConfiguration
(
this
.
workspaceFolder
.
uri
,
this
.
configFolderRelativePath
,
this
.
environmentServic
e
);
this
.
cachedFolderConfiguration
=
new
CachedFolderConfiguration
(
this
.
workspaceFolder
.
uri
,
this
.
configFolderRelativePath
,
hashService
,
configurationCach
e
);
this
.
folderConfiguration
=
this
.
cachedFolderConfiguration
;
this
.
folderConfiguration
=
this
.
cachedFolderConfiguration
;
if
(
fileService
)
{
if
(
fileService
)
{
this
.
folderConfiguration
=
new
FileServiceBasedFolderConfiguration
(
this
.
workspaceFolder
.
uri
,
this
.
configFolderRelativePath
,
this
.
workbenchState
,
fileService
);
this
.
folderConfiguration
=
new
FileServiceBasedFolderConfiguration
(
this
.
workspaceFolder
.
uri
,
this
.
configFolderRelativePath
,
this
.
workbenchState
,
fileService
);
...
...
src/vs/workbench/services/configuration/node/configurationCache.ts
0 → 100644
浏览文件 @
1f30cbf6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
join
}
from
'
vs/base/common/path
'
;
import
{
IConfigurationCache
,
ConfigurationKey
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
export
class
ConfigurationCache
implements
IConfigurationCache
{
private
readonly
cachedConfigurations
:
Map
<
string
,
CachedConfiguration
>
=
new
Map
<
string
,
CachedConfiguration
>
();
constructor
(
private
readonly
environmentService
:
IEnvironmentService
)
{
}
read
(
key
:
ConfigurationKey
):
Promise
<
string
>
{
return
this
.
getCachedConfiguration
(
key
).
read
();
}
write
(
key
:
ConfigurationKey
,
content
:
string
):
Promise
<
void
>
{
return
this
.
getCachedConfiguration
(
key
).
save
(
content
);
}
remove
(
key
:
ConfigurationKey
):
Promise
<
void
>
{
return
this
.
getCachedConfiguration
(
key
).
remove
();
}
private
getCachedConfiguration
({
type
,
key
}:
ConfigurationKey
):
CachedConfiguration
{
const
k
=
`
${
type
}
:
${
key
}
`
;
let
cachedConfiguration
=
this
.
cachedConfigurations
.
get
(
k
);
if
(
!
cachedConfiguration
)
{
cachedConfiguration
=
new
CachedConfiguration
({
type
,
key
},
this
.
environmentService
);
this
.
cachedConfigurations
.
set
(
k
,
cachedConfiguration
);
}
return
cachedConfiguration
;
}
}
class
CachedConfiguration
{
private
cachedConfigurationFolderPath
:
string
;
private
cachedConfigurationFilePath
:
string
;
constructor
(
{
type
,
key
}:
ConfigurationKey
,
environmentService
:
IEnvironmentService
)
{
this
.
cachedConfigurationFolderPath
=
join
(
environmentService
.
userDataPath
,
'
CachedConfigurations
'
,
type
,
key
);
this
.
cachedConfigurationFilePath
=
join
(
this
.
cachedConfigurationFolderPath
,
type
===
'
workspaces
'
?
'
workspace.json
'
:
'
configuration.json
'
);
}
async
read
():
Promise
<
string
>
{
try
{
const
content
=
await
pfs
.
readFile
(
this
.
cachedConfigurationFilePath
);
return
content
.
toString
();
}
catch
(
e
)
{
return
''
;
}
}
async
save
(
content
:
string
):
Promise
<
void
>
{
const
created
=
await
this
.
createCachedFolder
();
if
(
created
)
{
await
pfs
.
writeFile
(
this
.
cachedConfigurationFilePath
,
content
);
}
}
remove
():
Promise
<
void
>
{
return
pfs
.
rimraf
(
this
.
cachedConfigurationFolderPath
);
}
private
createCachedFolder
():
Promise
<
boolean
>
{
return
Promise
.
resolve
(
pfs
.
exists
(
this
.
cachedConfigurationFolderPath
))
.
then
(
undefined
,
()
=>
false
)
.
then
(
exists
=>
exists
?
exists
:
pfs
.
mkdirp
(
this
.
cachedConfigurationFolderPath
).
then
(()
=>
true
,
()
=>
false
));
}
}
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
1f30cbf6
...
@@ -14,11 +14,10 @@ import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/plat
...
@@ -14,11 +14,10 @@ import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/plat
import
{
IWorkspaceContextService
,
Workspace
,
WorkbenchState
,
IWorkspaceFolder
,
toWorkspaceFolders
,
IWorkspaceFoldersChangeEvent
,
WorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
,
Workspace
,
WorkbenchState
,
IWorkspaceFolder
,
toWorkspaceFolders
,
IWorkspaceFoldersChangeEvent
,
WorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ConfigurationChangeEvent
,
ConfigurationModel
,
DefaultConfigurationModel
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
ConfigurationChangeEvent
,
ConfigurationModel
,
DefaultConfigurationModel
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
IConfigurationChangeEvent
,
ConfigurationTarget
,
IConfigurationOverrides
,
keyFromOverrideIdentifier
,
isConfigurationOverrides
,
IConfigurationData
,
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationChangeEvent
,
ConfigurationTarget
,
IConfigurationOverrides
,
keyFromOverrideIdentifier
,
isConfigurationOverrides
,
IConfigurationData
,
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
Configuration
,
WorkspaceConfigurationChangeEvent
,
AllKeysConfigurationChangeEvent
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
Configuration
,
WorkspaceConfigurationChangeEvent
,
AllKeysConfigurationChangeEvent
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
FOLDER_CONFIG_FOLDER_NAME
,
defaultSettingsSchemaId
,
userSettingsSchemaId
,
workspaceSettingsSchemaId
,
folderSettingsSchemaId
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
FOLDER_CONFIG_FOLDER_NAME
,
defaultSettingsSchemaId
,
userSettingsSchemaId
,
workspaceSettingsSchemaId
,
folderSettingsSchemaId
,
IConfigurationCache
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IConfigurationRegistry
,
Extensions
,
allSettings
,
windowSettings
,
resourceSettings
,
applicationSettings
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IConfigurationRegistry
,
Extensions
,
allSettings
,
windowSettings
,
resourceSettings
,
applicationSettings
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IWorkspaceIdentifier
,
isWorkspaceIdentifier
,
IStoredWorkspaceFolder
,
isStoredWorkspaceFolder
,
IWorkspaceFolderCreationData
,
ISingleFolderWorkspaceIdentifier
,
isSingleFolderWorkspaceIdentifier
,
IWorkspaceInitializationPayload
,
isSingleFolderWorkspaceInitializationPayload
,
ISingleFolderWorkspaceInitializationPayload
,
IEmptyWorkspaceInitializationPayload
,
useSlashForPath
,
getStoredWorkspaceFolder
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IWorkspaceIdentifier
,
isWorkspaceIdentifier
,
IStoredWorkspaceFolder
,
isStoredWorkspaceFolder
,
IWorkspaceFolderCreationData
,
ISingleFolderWorkspaceIdentifier
,
isSingleFolderWorkspaceIdentifier
,
IWorkspaceInitializationPayload
,
isSingleFolderWorkspaceInitializationPayload
,
ISingleFolderWorkspaceInitializationPayload
,
IEmptyWorkspaceInitializationPayload
,
useSlashForPath
,
getStoredWorkspaceFolder
}
from
'
vs/platform/workspaces/common/workspaces
'
;
...
@@ -32,7 +31,7 @@ import { isEqual, dirname } from 'vs/base/common/resources';
...
@@ -32,7 +31,7 @@ import { isEqual, dirname } from 'vs/base/common/resources';
import
{
mark
}
from
'
vs/base/common/performance
'
;
import
{
mark
}
from
'
vs/base/common/performance
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
I
WindowConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
import
{
I
HashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
export
class
WorkspaceService
extends
Disposable
implements
IConfigurationService
,
IWorkspaceContextService
{
export
class
WorkspaceService
extends
Disposable
implements
IConfigurationService
,
IWorkspaceContextService
{
...
@@ -40,9 +39,10 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
...
@@ -40,9 +39,10 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
private
workspace
:
Workspace
;
private
workspace
:
Workspace
;
private
completeWorkspaceBarrier
:
Barrier
;
private
completeWorkspaceBarrier
:
Barrier
;
private
readonly
configurationCache
:
IConfigurationCache
;
private
_configuration
:
Configuration
;
private
_configuration
:
Configuration
;
private
defaultConfiguration
:
DefaultConfigurationModel
;
private
defaultConfiguration
:
DefaultConfigurationModel
;
private
localUserConfiguration
:
LocalUserConfiguration
;
private
localUserConfiguration
:
LocalUserConfiguration
|
null
=
null
;
private
remoteUserConfiguration
:
RemoteUserConfiguration
|
null
=
null
;
private
remoteUserConfiguration
:
RemoteUserConfiguration
|
null
=
null
;
private
workspaceConfiguration
:
WorkspaceConfiguration
;
private
workspaceConfiguration
:
WorkspaceConfiguration
;
private
cachedFolderConfigs
:
ResourceMap
<
FolderConfiguration
>
;
private
cachedFolderConfigs
:
ResourceMap
<
FolderConfiguration
>
;
...
@@ -65,18 +65,25 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
...
@@ -65,18 +65,25 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
private
configurationEditingService
:
ConfigurationEditingService
;
private
configurationEditingService
:
ConfigurationEditingService
;
private
jsonEditingService
:
JSONEditingService
;
private
jsonEditingService
:
JSONEditingService
;
constructor
(
configuration
:
IWindowConfiguration
,
private
environmentService
:
IEnvironmentService
,
private
remoteAgentService
:
IRemoteAgentService
,
private
workspaceSettingsRootFolder
:
string
=
FOLDER_CONFIG_FOLDER_NAME
)
{
constructor
(
{
userSettingsPath
,
remoteAuthority
,
configurationCache
}:
{
userSettingsPath
?:
string
,
remoteAuthority
?:
string
,
configurationCache
:
IConfigurationCache
},
private
readonly
hashService
:
IHashService
,
private
readonly
remoteAgentService
:
IRemoteAgentService
,
)
{
super
();
super
();
this
.
completeWorkspaceBarrier
=
new
Barrier
();
this
.
completeWorkspaceBarrier
=
new
Barrier
();
this
.
defaultConfiguration
=
new
DefaultConfigurationModel
();
this
.
defaultConfiguration
=
new
DefaultConfigurationModel
();
this
.
localUserConfiguration
=
this
.
_register
(
new
LocalUserConfiguration
(
environmentService
));
this
.
configurationCache
=
configurationCache
;
this
.
_register
(
this
.
localUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onLocalUserConfigurationChanged
(
userConfiguration
)));
if
(
userSettingsPath
)
{
if
(
configuration
.
remoteAuthority
)
{
this
.
localUserConfiguration
=
this
.
_register
(
new
LocalUserConfiguration
(
userSettingsPath
));
this
.
remoteUserConfiguration
=
this
.
_register
(
new
RemoteUserConfiguration
(
configuration
.
remoteAuthority
,
environmentService
));
this
.
_register
(
this
.
localUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onLocalUserConfigurationChanged
(
userConfiguration
)));
}
if
(
remoteAuthority
)
{
this
.
remoteUserConfiguration
=
this
.
_register
(
new
RemoteUserConfiguration
(
remoteAuthority
,
configurationCache
));
this
.
_register
(
this
.
remoteUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onRemoteUserConfigurationChanged
(
userConfiguration
)));
this
.
_register
(
this
.
remoteUserConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onRemoteUserConfigurationChanged
(
userConfiguration
)));
}
}
this
.
workspaceConfiguration
=
this
.
_register
(
new
WorkspaceConfiguration
(
environmentServic
e
));
this
.
workspaceConfiguration
=
this
.
_register
(
new
WorkspaceConfiguration
(
configurationCach
e
));
this
.
_register
(
this
.
workspaceConfiguration
.
onDidUpdateConfiguration
(()
=>
this
.
onWorkspaceConfigurationChanged
()));
this
.
_register
(
this
.
workspaceConfiguration
.
onDidUpdateConfiguration
(()
=>
this
.
onWorkspaceConfigurationChanged
()));
this
.
_register
(
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
onDidSchemaChange
(
e
=>
this
.
registerConfigurationSchemas
()));
this
.
_register
(
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
onDidSchemaChange
(
e
=>
this
.
registerConfigurationSchemas
()));
...
@@ -291,7 +298,9 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
...
@@ -291,7 +298,9 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
acquireFileService
(
fileService
:
IFileService
):
void
{
acquireFileService
(
fileService
:
IFileService
):
void
{
this
.
fileService
=
fileService
;
this
.
fileService
=
fileService
;
const
changedWorkspaceFolders
:
IWorkspaceFolder
[]
=
[];
const
changedWorkspaceFolders
:
IWorkspaceFolder
[]
=
[];
this
.
localUserConfiguration
.
adopt
(
fileService
);
if
(
this
.
localUserConfiguration
)
{
this
.
localUserConfiguration
.
adopt
(
fileService
);
}
Promise
.
all
([
this
.
workspaceConfiguration
.
adopt
(
fileService
),
...
this
.
cachedFolderConfigs
.
values
()
Promise
.
all
([
this
.
workspaceConfiguration
.
adopt
(
fileService
),
...
this
.
cachedFolderConfigs
.
values
()
.
map
(
folderConfiguration
=>
folderConfiguration
.
adopt
(
fileService
)
.
map
(
folderConfiguration
=>
folderConfiguration
.
adopt
(
fileService
)
.
then
(
result
=>
{
.
then
(
result
=>
{
...
@@ -440,12 +449,12 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
...
@@ -440,12 +449,12 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
}
}
private
initializeUserConfiguration
():
Promise
<
{
local
:
ConfigurationModel
,
remote
:
ConfigurationModel
}
>
{
private
initializeUserConfiguration
():
Promise
<
{
local
:
ConfigurationModel
,
remote
:
ConfigurationModel
}
>
{
return
Promise
.
all
([
this
.
localUserConfiguration
.
initialize
(
),
this
.
remoteUserConfiguration
?
this
.
remoteUserConfiguration
.
initialize
()
:
Promise
.
resolve
(
new
ConfigurationModel
())])
return
Promise
.
all
([
this
.
localUserConfiguration
?
this
.
localUserConfiguration
.
initialize
()
:
Promise
.
resolve
(
new
ConfigurationModel
()
),
this
.
remoteUserConfiguration
?
this
.
remoteUserConfiguration
.
initialize
()
:
Promise
.
resolve
(
new
ConfigurationModel
())])
.
then
(([
local
,
remote
])
=>
({
local
,
remote
}));
.
then
(([
local
,
remote
])
=>
({
local
,
remote
}));
}
}
private
reloadUserConfiguration
(
key
?:
string
):
Promise
<
{
local
:
ConfigurationModel
,
remote
:
ConfigurationModel
}
>
{
private
reloadUserConfiguration
(
key
?:
string
):
Promise
<
{
local
:
ConfigurationModel
,
remote
:
ConfigurationModel
}
>
{
return
Promise
.
all
([
this
.
localUserConfiguration
.
reload
(
),
this
.
remoteUserConfiguration
?
this
.
remoteUserConfiguration
.
reload
()
:
Promise
.
resolve
(
new
ConfigurationModel
())])
return
Promise
.
all
([
this
.
localUserConfiguration
?
this
.
localUserConfiguration
.
reload
()
:
Promise
.
resolve
(
new
ConfigurationModel
()
),
this
.
remoteUserConfiguration
?
this
.
remoteUserConfiguration
.
reload
()
:
Promise
.
resolve
(
new
ConfigurationModel
())])
.
then
(([
local
,
remote
])
=>
({
local
,
remote
}));
.
then
(([
local
,
remote
])
=>
({
local
,
remote
}));
}
}
...
@@ -616,7 +625,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
...
@@ -616,7 +625,7 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
return
Promise
.
all
([...
folders
.
map
(
folder
=>
{
return
Promise
.
all
([...
folders
.
map
(
folder
=>
{
let
folderConfiguration
=
this
.
cachedFolderConfigs
.
get
(
folder
.
uri
);
let
folderConfiguration
=
this
.
cachedFolderConfigs
.
get
(
folder
.
uri
);
if
(
!
folderConfiguration
)
{
if
(
!
folderConfiguration
)
{
folderConfiguration
=
new
FolderConfiguration
(
folder
,
this
.
workspaceSettingsRootFolder
,
this
.
getWorkbenchState
(),
this
.
environmentServic
e
,
this
.
fileService
);
folderConfiguration
=
new
FolderConfiguration
(
folder
,
FOLDER_CONFIG_FOLDER_NAME
,
this
.
getWorkbenchState
(),
this
.
hashService
,
this
.
configurationCach
e
,
this
.
fileService
);
this
.
_register
(
folderConfiguration
.
onDidChange
(()
=>
this
.
onWorkspaceFolderConfigurationChanged
(
folder
)));
this
.
_register
(
folderConfiguration
.
onDidChange
(()
=>
this
.
onWorkspaceFolderConfigurationChanged
(
folder
)));
this
.
cachedFolderConfigs
.
set
(
folder
.
uri
,
this
.
_register
(
folderConfiguration
));
this
.
cachedFolderConfigs
.
set
(
folder
.
uri
,
this
.
_register
(
folderConfiguration
));
}
}
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationEditingService.test.ts
浏览文件 @
1f30cbf6
...
@@ -35,10 +35,11 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
...
@@ -35,10 +35,11 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import
{
CommandService
}
from
'
vs/workbench/services/commands/common/commandService
'
;
import
{
CommandService
}
from
'
vs/workbench/services/commands/common/commandService
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
createHash
}
from
'
crypto
'
;
import
{
createHash
}
from
'
crypto
'
;
import
{
IWindowConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
import
{
RemoteAgentService
}
from
'
vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl
'
;
import
{
RemoteAgentService
}
from
'
vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
setUnexpectedErrorHandler
}
from
'
vs/base/common/errors
'
;
import
{
setUnexpectedErrorHandler
}
from
'
vs/base/common/errors
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/node/hashService
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
...
@@ -105,7 +106,7 @@ suite('ConfigurationEditingService', () => {
...
@@ -105,7 +106,7 @@ suite('ConfigurationEditingService', () => {
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
return
workspaceService
.
initialize
(
noWorkspace
?
{
id
:
''
}
:
{
folder
:
URI
.
file
(
workspaceDir
),
id
:
createHash
(
'
md5
'
).
update
(
URI
.
file
(
workspaceDir
).
toString
()).
digest
(
'
hex
'
)
}).
then
(()
=>
{
return
workspaceService
.
initialize
(
noWorkspace
?
{
id
:
''
}
:
{
folder
:
URI
.
file
(
workspaceDir
),
id
:
createHash
(
'
md5
'
).
update
(
URI
.
file
(
workspaceDir
).
toString
()).
digest
(
'
hex
'
)
}).
then
(()
=>
{
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts
浏览文件 @
1f30cbf6
...
@@ -42,6 +42,8 @@ import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browse
...
@@ -42,6 +42,8 @@ import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browse
import
{
RemoteAuthorityResolverService
}
from
'
vs/platform/remote/electron-browser/remoteAuthorityResolverService
'
;
import
{
RemoteAuthorityResolverService
}
from
'
vs/platform/remote/electron-browser/remoteAuthorityResolverService
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
IRemoteAgentService
}
from
'
vs/workbench/services/remote/common/remoteAgentService
'
;
import
{
setUnexpectedErrorHandler
}
from
'
vs/base/common/errors
'
;
import
{
setUnexpectedErrorHandler
}
from
'
vs/base/common/errors
'
;
import
{
HashService
}
from
'
vs/workbench/services/hash/node/hashService
'
;
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/node/configurationCache
'
;
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
class
SettingsTestEnvironmentService
extends
EnvironmentService
{
...
@@ -100,7 +102,7 @@ suite('WorkspaceContextService - Folder', () => {
...
@@ -100,7 +102,7 @@ suite('WorkspaceContextService - Folder', () => {
workspaceResource
=
folderDir
;
workspaceResource
=
folderDir
;
const
globalSettingsFile
=
path
.
join
(
parentDir
,
'
settings.json
'
);
const
globalSettingsFile
=
path
.
join
(
parentDir
,
'
settings.json
'
);
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
workspaceContextService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAgentService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAuthorityResolverService
()));
workspaceContextService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
new
RemoteAgentService
(
<
IWindowConfiguration
>
{},
environmentService
,
new
RemoteAuthorityResolverService
()));
return
(
<
WorkspaceService
>
workspaceContextService
).
initialize
(
convertToWorkspacePayload
(
URI
.
file
(
folderDir
)));
return
(
<
WorkspaceService
>
workspaceContextService
).
initialize
(
convertToWorkspacePayload
(
URI
.
file
(
folderDir
)));
});
});
});
});
...
@@ -162,7 +164,7 @@ suite('WorkspaceContextService - Workspace', () => {
...
@@ -162,7 +164,7 @@ suite('WorkspaceContextService - Workspace', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
@@ -218,7 +220,7 @@ suite('WorkspaceContextService - Workspace Editing', () => {
...
@@ -218,7 +220,7 @@ suite('WorkspaceContextService - Workspace Editing', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
@@ -485,7 +487,7 @@ suite('WorkspaceService - Initialization', () => {
...
@@ -485,7 +487,7 @@ suite('WorkspaceService - Initialization', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
@@ -743,7 +745,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
...
@@ -743,7 +745,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
globalSettingsFile
);
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
instantiationService
.
stub
(
IEnvironmentService
,
environmentService
);
...
@@ -1034,7 +1036,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
...
@@ -1034,7 +1036,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
environmentService
=
new
SettingsTestEnvironmentService
(
parseArgs
(
process
.
argv
),
process
.
execPath
,
path
.
join
(
parentDir
,
'
settings.json
'
));
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
const
remoteAgentService
=
instantiationService
.
createInstance
(
RemoteAgentService
,
{});
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
instantiationService
.
stub
(
IRemoteAgentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
<
IWindowConfiguration
>
{},
environmentService
,
remoteAgentService
);
const
workspaceService
=
new
WorkspaceService
(
{
userSettingsPath
:
environmentService
.
appSettingsPath
,
configurationCache
:
new
ConfigurationCache
(
environmentService
)
},
new
HashService
()
,
remoteAgentService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IWorkspaceContextService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
instantiationService
.
stub
(
IConfigurationService
,
workspaceService
);
...
...
src/vs/workbench/services/hash/node/hashService.ts
浏览文件 @
1f30cbf6
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
import
{
createHash
}
from
'
crypto
'
;
import
{
createHash
}
from
'
crypto
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
IHashService
}
from
'
vs/workbench/services/hash/common/hashService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
export
class
HashService
implements
IHashService
{
export
class
HashService
implements
IHashService
{
...
@@ -15,5 +14,3 @@ export class HashService implements IHashService {
...
@@ -15,5 +14,3 @@ export class HashService implements IHashService {
return
Promise
.
resolve
(
createHash
(
'
sha1
'
).
update
(
content
).
digest
(
'
hex
'
));
return
Promise
.
resolve
(
createHash
(
'
sha1
'
).
update
(
content
).
digest
(
'
hex
'
));
}
}
}
}
registerSingleton
(
IHashService
,
HashService
,
true
);
\ No newline at end of file
src/vs/workbench/workbench.main.ts
浏览文件 @
1f30cbf6
...
@@ -94,7 +94,6 @@ import { RelayURLService } from 'vs/platform/url/electron-browser/urlService';
...
@@ -94,7 +94,6 @@ import { RelayURLService } from 'vs/platform/url/electron-browser/urlService';
import
'
vs/workbench/services/bulkEdit/browser/bulkEditService
'
;
import
'
vs/workbench/services/bulkEdit/browser/bulkEditService
'
;
import
'
vs/workbench/services/integrity/node/integrityService
'
;
import
'
vs/workbench/services/integrity/node/integrityService
'
;
import
'
vs/workbench/services/keybinding/common/keybindingEditing
'
;
import
'
vs/workbench/services/keybinding/common/keybindingEditing
'
;
import
'
vs/workbench/services/hash/node/hashService
'
;
import
'
vs/workbench/services/textMate/electron-browser/textMateService
'
;
import
'
vs/workbench/services/textMate/electron-browser/textMateService
'
;
import
'
vs/workbench/services/configurationResolver/browser/configurationResolverService
'
;
import
'
vs/workbench/services/configurationResolver/browser/configurationResolverService
'
;
import
'
vs/workbench/services/workspace/node/workspaceEditingService
'
;
import
'
vs/workbench/services/workspace/node/workspaceEditingService
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录