Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6e127c97
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e127c97
编写于
5月 24, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement a better simple configuration service
上级
6b081a9f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
94 addition
and
4 deletion
+94
-4
src/vs/workbench/browser/web.simpleservices.ts
src/vs/workbench/browser/web.simpleservices.ts
+94
-4
未找到文件。
src/vs/workbench/browser/web.simpleservices.ts
浏览文件 @
6e127c97
...
...
@@ -9,11 +9,11 @@ import { ITextSnapshot } from 'vs/editor/common/model';
import
{
createTextBufferFactoryFromSnapshot
}
from
'
vs/editor/common/model/textModel
'
;
import
{
keys
,
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
// tslint:disable-next-line: import-patterns no-standalone-editor
import
{
S
impleConfigurationService
as
StandaloneEditorConfigurationService
,
S
tandaloneKeybindingService
,
SimpleResourcePropertiesService
}
from
'
vs/editor/standalone/browser/simpleServices
'
;
import
{
StandaloneKeybindingService
,
SimpleResourcePropertiesService
}
from
'
vs/editor/standalone/browser/simpleServices
'
;
import
{
IDownloadService
}
from
'
vs/platform/download/common/download
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IExtensionHostDebugParams
,
IDebugParams
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -51,7 +51,7 @@ import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common
import
{
IWorkspaceContextService
,
Workspace
,
toWorkspaceFolder
,
IWorkspaceFolder
,
WorkbenchState
,
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ITextResourcePropertiesService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
,
IConfigurationChangeEvent
,
IConfigurationData
,
IConfigurationOverrides
,
isConfigurationOverrides
,
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITunnelService
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -73,6 +73,9 @@ import { ICommentService, IResourceCommentThreadEvent, IWorkspaceCommentThreadsE
import
{
ICommentThreadChangedEvent
}
from
'
vs/workbench/contrib/comments/common/commentModel
'
;
import
{
CommentingRanges
}
from
'
vs/editor/common/modes
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Configuration
,
DefaultConfigurationModel
,
ConfigurationModel
,
ConfigurationChangeEvent
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
export
const
workspaceResource
=
URI
.
file
((
<
any
>
self
).
USER_HOME_DIR
||
'
/
'
).
with
({
scheme
:
Schemas
.
vscodeRemote
,
...
...
@@ -208,7 +211,94 @@ registerSingleton(IClipboardService, SimpleClipboardService, true);
//#region Configuration
export
class
SimpleConfigurationService
extends
StandaloneEditorConfigurationService
{
}
export
class
SimpleConfigurationService
extends
Disposable
implements
IConfigurationService
{
_serviceBrand
:
any
;
private
_configuration
:
Configuration
;
private
readonly
_onDidChangeConfiguration
:
Emitter
<
IConfigurationChangeEvent
>
=
this
.
_register
(
new
Emitter
<
IConfigurationChangeEvent
>
());
readonly
onDidChangeConfiguration
:
Event
<
IConfigurationChangeEvent
>
=
this
.
_onDidChangeConfiguration
.
event
;
constructor
()
{
super
();
// Initialize
const
defaults
=
new
DefaultConfigurationModel
();
this
.
_configuration
=
new
Configuration
(
defaults
,
new
ConfigurationModel
());
// Listeners
this
.
_register
(
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
onDidUpdateConfiguration
(
configurationProperties
=>
this
.
onDidDefaultConfigurationChange
(
configurationProperties
)));
}
get
configuration
():
Configuration
{
return
this
.
_configuration
;
}
getConfigurationData
():
IConfigurationData
{
return
this
.
configuration
.
toData
();
}
getValue
<
T
>
():
T
;
getValue
<
T
>
(
section
:
string
):
T
;
getValue
<
T
>
(
overrides
:
IConfigurationOverrides
):
T
;
getValue
<
T
>
(
section
:
string
,
overrides
:
IConfigurationOverrides
):
T
;
getValue
(
arg1
?:
any
,
arg2
?:
any
):
any
{
const
section
=
typeof
arg1
===
'
string
'
?
arg1
:
undefined
;
const
overrides
=
isConfigurationOverrides
(
arg1
)
?
arg1
:
isConfigurationOverrides
(
arg2
)
?
arg2
:
{};
return
this
.
configuration
.
getValue
(
section
,
overrides
,
undefined
);
}
updateValue
(
key
:
string
,
value
:
any
):
Promise
<
void
>
;
updateValue
(
key
:
string
,
value
:
any
,
overrides
:
IConfigurationOverrides
):
Promise
<
void
>
;
updateValue
(
key
:
string
,
value
:
any
,
target
:
ConfigurationTarget
):
Promise
<
void
>
;
updateValue
(
key
:
string
,
value
:
any
,
overrides
:
IConfigurationOverrides
,
target
:
ConfigurationTarget
):
Promise
<
void
>
;
updateValue
(
key
:
string
,
value
:
any
,
arg3
?:
any
,
arg4
?:
any
):
Promise
<
void
>
{
return
Promise
.
reject
(
new
Error
(
'
not supported
'
));
}
inspect
<
T
>
(
key
:
string
):
{
default
:
T
,
user
:
T
,
workspace
?:
T
,
workspaceFolder
?:
T
value
:
T
}
{
return
this
.
configuration
.
inspect
<
T
>
(
key
,
{},
undefined
);
}
keys
():
{
default
:
string
[];
user
:
string
[];
workspace
:
string
[];
workspaceFolder
:
string
[];
}
{
return
this
.
configuration
.
keys
(
undefined
);
}
reloadConfiguration
(
folder
?:
IWorkspaceFolder
):
Promise
<
void
>
{
return
Promise
.
resolve
(
undefined
);
}
private
onDidDefaultConfigurationChange
(
keys
:
string
[]):
void
{
this
.
_configuration
.
updateDefaultConfiguration
(
new
DefaultConfigurationModel
());
this
.
trigger
(
keys
,
ConfigurationTarget
.
DEFAULT
);
}
private
trigger
(
keys
:
string
[],
source
:
ConfigurationTarget
):
void
{
this
.
_onDidChangeConfiguration
.
fire
(
new
ConfigurationChangeEvent
().
change
(
keys
).
telemetryData
(
source
,
this
.
getTargetConfiguration
(
source
)));
}
private
getTargetConfiguration
(
target
:
ConfigurationTarget
):
any
{
switch
(
target
)
{
case
ConfigurationTarget
.
DEFAULT
:
return
this
.
_configuration
.
defaults
.
contents
;
case
ConfigurationTarget
.
USER
:
return
this
.
_configuration
.
localUserConfiguration
.
contents
;
}
return
{};
}
}
registerSingleton
(
IConfigurationService
,
SimpleConfigurationService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录