Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ea771bdc
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,发现更多精彩内容 >>
提交
ea771bdc
编写于
11月 19, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #63433
上级
a8dbfd29
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
40 deletion
+48
-40
src/vs/platform/configuration/node/configuration.ts
src/vs/platform/configuration/node/configuration.ts
+26
-16
src/vs/platform/configuration/node/configurationService.ts
src/vs/platform/configuration/node/configurationService.ts
+11
-14
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+11
-10
未找到文件。
src/vs/platform/configuration/node/configuration.ts
浏览文件 @
ea771bdc
...
...
@@ -12,32 +12,42 @@ import { Event, Emitter } from 'vs/base/common/event';
export
class
UserConfiguration
extends
Disposable
{
private
userConfigModelWatcher
:
ConfigWatcher
<
ConfigurationModelParser
>
;
private
initializePromise
:
Promise
<
void
>
;
private
readonly
_onDidChangeConfiguration
:
Emitter
<
ConfigurationModel
>
=
this
.
_register
(
new
Emitter
<
ConfigurationModel
>
());
readonly
onDidChangeConfiguration
:
Event
<
ConfigurationModel
>
=
this
.
_onDidChangeConfiguration
.
event
;
constructor
(
settingsPath
:
string
)
{
constructor
(
private
settingsPath
:
string
)
{
super
();
this
.
userConfigModelWatcher
=
new
ConfigWatcher
(
settingsPath
,
{
changeBufferDelay
:
300
,
onError
:
error
=>
onUnexpectedError
(
error
),
defaultConfig
:
new
ConfigurationModelParser
(
settingsPath
),
parse
:
(
content
:
string
,
parseErrors
:
any
[])
=>
{
const
userConfigModelParser
=
new
ConfigurationModelParser
(
settingsPath
);
userConfigModelParser
.
parse
(
content
);
parseErrors
=
[...
userConfigModelParser
.
errors
];
return
userConfigModelParser
;
}
});
this
.
_register
(
this
.
userConfigModelWatcher
);
// Listeners
this
.
_register
(
this
.
userConfigModelWatcher
.
onDidUpdateConfiguration
(()
=>
this
.
_onDidChangeConfiguration
.
fire
(
this
.
configurationModel
)));
}
get
configurationModel
():
ConfigurationModel
{
initialize
():
Promise
<
ConfigurationModel
>
{
if
(
!
this
.
initializePromise
)
{
this
.
initializePromise
=
new
Promise
<
void
>
((
c
,
e
)
=>
{
this
.
userConfigModelWatcher
=
new
ConfigWatcher
(
this
.
settingsPath
,
{
changeBufferDelay
:
300
,
onError
:
error
=>
onUnexpectedError
(
error
),
defaultConfig
:
new
ConfigurationModelParser
(
this
.
settingsPath
),
parse
:
(
content
:
string
,
parseErrors
:
any
[])
=>
{
const
userConfigModelParser
=
new
ConfigurationModelParser
(
this
.
settingsPath
);
userConfigModelParser
.
parse
(
content
);
parseErrors
=
[...
userConfigModelParser
.
errors
];
return
userConfigModelParser
;
},
initCallback
:
()
=>
c
(
null
)
});
this
.
_register
(
this
.
userConfigModelWatcher
);
// Listeners
this
.
_register
(
this
.
userConfigModelWatcher
.
onDidUpdateConfiguration
(()
=>
this
.
_onDidChangeConfiguration
.
fire
(
this
.
userConfigModelWatcher
.
getConfig
().
configurationModel
)));
});
}
return
this
.
initializePromise
.
then
(()
=>
this
.
userConfigModelWatcher
.
getConfig
().
configurationModel
);
}
initializeSync
():
ConfigurationModel
{
this
.
initialize
();
return
this
.
userConfigModelWatcher
.
getConfig
().
configurationModel
;
}
reload
():
Promise
<
void
>
{
return
new
Promise
<
void
>
(
c
=>
this
.
userConfigModelWatcher
.
reload
(()
=>
c
(
)));
reload
():
Promise
<
ConfigurationModel
>
{
return
this
.
initialize
().
then
(()
=>
new
Promise
<
ConfigurationModel
>
(
c
=>
this
.
userConfigModelWatcher
.
reload
(
userConfigModelParser
=>
c
(
userConfigModelParser
.
configurationModel
)
)));
}
}
\ No newline at end of file
src/vs/platform/configuration/node/configurationService.ts
浏览文件 @
ea771bdc
...
...
@@ -7,7 +7,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IConfigurationService
,
IConfigurationChangeEvent
,
IConfigurationOverrides
,
ConfigurationTarget
,
compare
,
isConfigurationOverrides
,
IConfigurationData
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
DefaultConfigurationModel
,
Configuration
,
ConfigurationChangeEvent
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
DefaultConfigurationModel
,
Configuration
,
ConfigurationChangeEvent
,
ConfigurationModel
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
equals
}
from
'
vs/base/common/objects
'
;
...
...
@@ -31,10 +31,13 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
this
.
userConfiguration
=
this
.
_register
(
new
UserConfiguration
(
environmentService
.
appSettingsPath
));
this
.
reset
();
// Initialize
const
defaults
=
new
DefaultConfigurationModel
();
const
user
=
this
.
userConfiguration
.
initializeSync
();
this
.
_configuration
=
new
Configuration
(
defaults
,
user
);
// Listeners
this
.
_register
(
this
.
userConfiguration
.
onDidChangeConfiguration
(
()
=>
this
.
onDidChangeUserConfiguration
(
)));
this
.
_register
(
this
.
userConfiguration
.
onDidChangeConfiguration
(
userConfigurationModel
=>
this
.
onDidChangeUserConfiguration
(
userConfigurationModel
)));
this
.
_register
(
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
onDidRegisterConfiguration
(
configurationProperties
=>
this
.
onDidRegisterConfiguration
(
configurationProperties
)));
}
...
...
@@ -85,16 +88,16 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
reloadConfiguration
(
folder
?:
IWorkspaceFolder
):
Promise
<
void
>
{
return
folder
?
Promise
.
resolve
(
null
)
:
this
.
userConfiguration
.
reload
().
then
(
()
=>
this
.
onDidChangeUserConfiguration
(
));
this
.
userConfiguration
.
reload
().
then
(
userConfigurationModel
=>
this
.
onDidChangeUserConfiguration
(
userConfigurationModel
));
}
private
onDidChangeUserConfiguration
():
void
{
private
onDidChangeUserConfiguration
(
userConfigurationModel
:
ConfigurationModel
):
void
{
let
changedKeys
:
string
[]
=
[];
const
{
added
,
updated
,
removed
}
=
compare
(
this
.
_configuration
.
user
,
this
.
userConfiguration
.
c
onfigurationModel
);
const
{
added
,
updated
,
removed
}
=
compare
(
this
.
_configuration
.
user
,
userC
onfigurationModel
);
changedKeys
=
[...
added
,
...
updated
,
...
removed
];
if
(
changedKeys
.
length
)
{
const
oldConfiguartion
=
this
.
_configuration
;
this
.
reset
(
);
this
.
_configuration
.
updateUserConfiguration
(
userConfigurationModel
);
changedKeys
=
changedKeys
.
filter
(
key
=>
!
equals
(
oldConfiguartion
.
getValue
(
key
,
{},
null
),
this
.
_configuration
.
getValue
(
key
,
{},
null
)));
if
(
changedKeys
.
length
)
{
this
.
trigger
(
changedKeys
,
ConfigurationTarget
.
USER
);
...
...
@@ -103,16 +106,10 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
}
private
onDidRegisterConfiguration
(
keys
:
string
[]):
void
{
this
.
reset
();
// reset our caches
this
.
_configuration
.
updateDefaultConfiguration
(
new
DefaultConfigurationModel
());
this
.
trigger
(
keys
,
ConfigurationTarget
.
DEFAULT
);
}
private
reset
():
void
{
const
defaults
=
new
DefaultConfigurationModel
();
const
user
=
this
.
userConfiguration
.
configurationModel
;
this
.
_configuration
=
new
Configuration
(
defaults
,
user
);
}
private
trigger
(
keys
:
string
[],
source
:
ConfigurationTarget
):
void
{
this
.
_onDidChangeConfiguration
.
fire
(
new
ConfigurationChangeEvent
().
change
(
keys
).
telemetryData
(
source
,
this
.
getTargetConfiguration
(
source
)));
}
...
...
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
ea771bdc
...
...
@@ -82,7 +82,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
this
.
defaultConfiguration
=
new
DefaultConfigurationModel
();
this
.
userConfiguration
=
this
.
_register
(
new
UserConfiguration
(
environmentService
.
appSettingsPath
));
this
.
workspaceConfiguration
=
this
.
_register
(
new
WorkspaceConfiguration
());
this
.
_register
(
this
.
userConfiguration
.
onDidChangeConfiguration
(
()
=>
this
.
onUserConfigurationChanged
(
)));
this
.
_register
(
this
.
userConfiguration
.
onDidChangeConfiguration
(
userConfiguration
=>
this
.
onUserConfigurationChanged
(
userConfiguration
)));
this
.
_register
(
this
.
workspaceConfiguration
.
onDidUpdateConfiguration
(()
=>
this
.
onWorkspaceConfigurationChanged
()));
this
.
_register
(
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
onDidSchemaChange
(
e
=>
this
.
registerConfigurationSchemas
()));
...
...
@@ -276,8 +276,8 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
return
this
.
reloadWorkspaceFolderConfiguration
(
folder
,
key
);
}
return
this
.
reloadUserConfiguration
()
.
then
(
()
=>
this
.
reloadWorkspaceConfiguration
()
)
.
then
(()
=>
this
.
loadConfiguration
(
));
.
then
(
userConfigurationModel
=>
this
.
reloadWorkspaceConfiguration
(
)
.
then
(()
=>
this
.
loadConfiguration
(
userConfigurationModel
)
));
}
inspect
<
T
>
(
key
:
string
,
overrides
?:
IConfigurationOverrides
):
{
...
...
@@ -425,10 +425,11 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
private
initializeConfiguration
():
Promise
<
void
>
{
this
.
registerConfigurationSchemas
();
return
this
.
loadConfiguration
();
return
this
.
userConfiguration
.
initialize
()
.
then
(
userConfigurationModel
=>
this
.
loadConfiguration
(
userConfigurationModel
));
}
private
reloadUserConfiguration
(
key
?:
string
):
Promise
<
void
>
{
private
reloadUserConfiguration
(
key
?:
string
):
Promise
<
ConfigurationModel
>
{
return
this
.
userConfiguration
.
reload
();
}
...
...
@@ -447,7 +448,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
return
this
.
onWorkspaceFolderConfigurationChanged
(
folder
,
key
);
}
private
loadConfiguration
():
Promise
<
void
>
{
private
loadConfiguration
(
userConfigurationModel
:
ConfigurationModel
):
Promise
<
void
>
{
// reset caches
this
.
cachedFolderConfigs
=
new
ResourceMap
<
FolderConfiguration
>
();
...
...
@@ -460,7 +461,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
folderConfigurations
.
forEach
((
folderConfiguration
,
index
)
=>
folderConfigurationModels
.
set
(
folders
[
index
].
uri
,
folderConfiguration
));
const
currentConfiguration
=
this
.
_configuration
;
this
.
_configuration
=
new
Configuration
(
this
.
defaultConfiguration
,
this
.
userConfiguration
.
c
onfigurationModel
,
workspaceConfiguration
,
folderConfigurationModels
,
new
ConfigurationModel
(),
new
ResourceMap
<
ConfigurationModel
>
(),
this
.
getWorkbenchState
()
!==
WorkbenchState
.
EMPTY
?
this
.
workspace
:
null
);
//TODO: Sandy Avoid passing null
this
.
_configuration
=
new
Configuration
(
this
.
defaultConfiguration
,
userC
onfigurationModel
,
workspaceConfiguration
,
folderConfigurationModels
,
new
ConfigurationModel
(),
new
ResourceMap
<
ConfigurationModel
>
(),
this
.
getWorkbenchState
()
!==
WorkbenchState
.
EMPTY
?
this
.
workspace
:
null
);
//TODO: Sandy Avoid passing null
if
(
currentConfiguration
)
{
const
changedKeys
=
this
.
_configuration
.
compare
(
currentConfiguration
);
...
...
@@ -527,8 +528,8 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
}
}
private
onUserConfigurationChanged
():
void
{
let
keys
=
this
.
_configuration
.
compareAndUpdateUserConfiguration
(
this
.
userConfiguration
.
configurationModel
);
private
onUserConfigurationChanged
(
userConfiguration
:
ConfigurationModel
):
void
{
let
keys
=
this
.
_configuration
.
compareAndUpdateUserConfiguration
(
userConfiguration
);
this
.
triggerConfigurationChange
(
keys
,
ConfigurationTarget
.
USER
);
}
...
...
@@ -623,7 +624,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
case
ConfigurationTarget
.
WORKSPACE_FOLDER
:
const
workspaceFolder
=
overrides
&&
overrides
.
resource
?
this
.
workspace
.
getFolder
(
overrides
.
resource
)
:
null
;
if
(
workspaceFolder
)
{
return
this
.
reloadWorkspaceFolderConfiguration
(
this
.
workspace
.
getFolder
(
overrides
.
resource
),
key
);
return
this
.
reloadWorkspaceFolderConfiguration
(
this
.
workspace
.
getFolder
(
overrides
.
resource
),
key
)
.
then
(()
=>
null
)
;
}
}
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录