Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
69e95938
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,发现更多精彩内容 >>
提交
69e95938
编写于
6月 28, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #29633
上级
53e3e9e2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
210 addition
and
12 deletion
+210
-12
src/vs/platform/configuration/common/configuration.ts
src/vs/platform/configuration/common/configuration.ts
+16
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/node/extHostConfiguration.ts
src/vs/workbench/api/node/extHostConfiguration.ts
+25
-6
src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts
...ch/test/electron-browser/api/extHostConfiguration.test.ts
+168
-5
未找到文件。
src/vs/platform/configuration/common/configuration.ts
浏览文件 @
69e95938
...
...
@@ -207,6 +207,7 @@ export class Configuration<T> {
private
_globalConfiguration
:
ConfigurationModel
<
T
>
;
private
_workspaceConsolidatedConfiguration
:
ConfigurationModel
<
T
>
;
private
_legacyWorkspaceConsolidatedConfiguration
:
ConfigurationModel
<
T
>
;
protected
_foldersConsolidatedConfigurations
:
StrictResourceMap
<
ConfigurationModel
<
T
>>
;
constructor
(
protected
_defaults
:
ConfigurationModel
<
T
>
,
protected
_user
:
ConfigurationModel
<
T
>
,
protected
_workspaceConfiguration
:
ConfigurationModel
<
T
>
=
new
ConfigurationModel
<
T
>
(),
protected
folders
:
StrictResourceMap
<
ConfigurationModel
<
T
>>
=
new
StrictResourceMap
<
ConfigurationModel
<
T
>>
(),
protected
_workspace
?:
Workspace
)
{
...
...
@@ -224,6 +225,7 @@ export class Configuration<T> {
protected
merge
():
void
{
this
.
_globalConfiguration
=
new
ConfigurationModel
<
T
>
().
merge
(
this
.
_defaults
).
merge
(
this
.
_user
);
this
.
_workspaceConsolidatedConfiguration
=
new
ConfigurationModel
<
T
>
().
merge
(
this
.
_globalConfiguration
).
merge
(
this
.
_workspaceConfiguration
);
this
.
_legacyWorkspaceConsolidatedConfiguration
=
null
;
this
.
_foldersConsolidatedConfigurations
=
new
StrictResourceMap
<
ConfigurationModel
<
T
>>
();
for
(
const
folder
of
this
.
folders
.
keys
())
{
this
.
mergeFolder
(
folder
);
...
...
@@ -252,6 +254,20 @@ export class Configuration<T> {
};
}
lookupLegacy
<
C
>
(
key
:
string
):
IConfigurationValue
<
C
>
{
if
(
!
this
.
_legacyWorkspaceConsolidatedConfiguration
)
{
this
.
_legacyWorkspaceConsolidatedConfiguration
=
this
.
_workspace
?
new
ConfigurationModel
<
any
>
().
merge
(
this
.
_workspaceConfiguration
).
merge
(
this
.
folders
.
get
(
this
.
_workspace
.
roots
[
0
]))
:
null
;
}
const
consolidateConfigurationModel
=
this
.
getConsolidateConfigurationModel
({});
return
{
default
:
objects
.
clone
(
getConfigurationValue
<
C
>
(
this
.
_defaults
.
contents
,
key
)),
user
:
objects
.
clone
(
getConfigurationValue
<
C
>
(
this
.
_user
.
contents
,
key
)),
workspace
:
objects
.
clone
(
this
.
_legacyWorkspaceConsolidatedConfiguration
?
getConfigurationValue
<
C
>
(
this
.
_legacyWorkspaceConsolidatedConfiguration
.
contents
,
key
)
:
void
0
),
folder
:
void
0
,
value
:
objects
.
clone
(
getConfigurationValue
<
C
>
(
consolidateConfigurationModel
.
contents
,
key
))
};
}
keys
():
IConfigurationKeys
{
return
{
default
:
this
.
_defaults
.
keys
,
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
69e95938
...
...
@@ -430,7 +430,7 @@ export function createApiFactory(
return
extHostConfiguration
.
getConfiguration
(
section
);
},
getConfiguration2
:
proposedApiFunction
(
extension
,
(
section
?:
string
,
resource
?:
vscode
.
Uri
):
vscode
.
WorkspaceConfiguration
=>
{
return
extHostConfiguration
.
getConfiguration
(
section
,
<
URI
>
resource
);
return
extHostConfiguration
.
getConfiguration
2
(
section
,
<
URI
>
resource
);
}),
registerTaskProvider
:
proposedApiFunction
(
extension
,
(
type
:
string
,
provider
:
vscode
.
TaskProvider
)
=>
{
return
extHostTask
.
registerTaskProvider
(
extension
,
provider
);
...
...
src/vs/workbench/api/node/extHostConfiguration.ts
浏览文件 @
69e95938
...
...
@@ -7,7 +7,7 @@
import
{
mixin
}
from
'
vs/base/common/objects
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
WorkspaceConfiguration
}
from
'
vscode
'
;
import
{
WorkspaceConfiguration
,
WorkspaceConfiguration2
}
from
'
vscode
'
;
import
{
ExtHostWorkspace
}
from
'
vs/workbench/api/node/extHostWorkspace
'
;
import
{
ExtHostConfigurationShape
,
MainThreadConfigurationShape
}
from
'
./extHost.protocol
'
;
import
{
IConfigurationData
,
Configuration
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -24,6 +24,14 @@ function lookUp(tree: any, key: string) {
}
}
type
ConfigurationInspect
<
T
>
=
{
key
:
string
;
defaultValue
?:
T
;
globalValue
?:
T
;
workspaceValue
?:
T
;
folderValue
?:
T
;
};
export
class
ExtHostConfiguration
extends
ExtHostConfigurationShape
{
private
readonly
_onDidChangeConfiguration
=
new
Emitter
<
void
>
();
...
...
@@ -47,7 +55,15 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
this
.
_onDidChangeConfiguration
.
fire
(
undefined
);
}
getConfiguration
(
section
?:
string
,
resource
?:
URI
):
WorkspaceConfiguration
{
getConfiguration
(
section
?:
string
):
WorkspaceConfiguration
{
return
this
.
_getConfiguration
(
section
,
null
,
true
);
}
getConfiguration2
(
section
?:
string
,
resource
?:
URI
):
WorkspaceConfiguration2
{
return
this
.
_getConfiguration
(
section
,
resource
,
false
);
}
private
_getConfiguration
(
section
:
string
,
resource
:
URI
,
legacy
:
boolean
):
WorkspaceConfiguration
{
const
config
=
section
?
lookUp
(
this
.
_configuration
.
getValue
(
null
,
{
resource
}),
section
)
...
...
@@ -73,17 +89,20 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
return
this
.
_proxy
.
$removeConfigurationOption
(
target
,
key
);
}
},
inspect
:
<
T
>
(
key
:
string
):
{
key
:
string
;
defaultValue
?:
T
;
globalValue
?:
T
;
workspaceValue
?:
T
,
folderValue
?:
T
}
=>
{
inspect
:
<
T
>
(
key
:
string
):
ConfigurationInspect
<
T
>
=>
{
key
=
section
?
`
${
section
}
.
${
key
}
`
:
key
;
const
config
=
this
.
_configuration
.
values
()[
key
]
;
const
config
=
legacy
?
this
.
_configuration
.
lookupLegacy
<
T
>
(
key
)
:
this
.
_configuration
.
lookup
<
T
>
(
key
,
{
resource
})
;
if
(
config
)
{
return
{
const
inspect
:
ConfigurationInspect
<
T
>
=
{
key
,
defaultValue
:
config
.
default
,
globalValue
:
config
.
user
,
workspaceValue
:
config
.
workspace
,
folderValue
:
config
.
folder
};
if
(
!
legacy
)
{
inspect
.
folderValue
=
config
.
folder
;
}
return
inspect
;
}
return
undefined
;
}
...
...
src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts
浏览文件 @
69e95938
...
...
@@ -84,7 +84,40 @@ suite('ExtHostConfiguration', function () {
assert
.
deepEqual
(
config
.
get
(
'
nested
'
),
{
config1
:
42
,
config2
:
'
Das Pferd frisst kein Reis.
'
});
});
test
(
'
inspect
'
,
function
()
{
test
(
'
inspect in no workspace context
'
,
function
()
{
const
testObject
=
new
ExtHostConfiguration
(
new
class
extends
MainThreadConfigurationShape
{
},
new
ExtHostWorkspace
(
new
TestThreadService
(),
null
),
{
defaults
:
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
off
'
}
},
[
'
editor.wordWrap
'
]),
user
:
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
on
'
}
},
[
'
editor.wordWrap
'
]),
workspace
:
new
ConfigurationModel
({},
[]),
folders
:
Object
.
create
(
null
)
}
);
let
actual
=
testObject
.
getConfiguration
().
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual
.
workspaceValue
,
undefined
);
assert
.
ok
(
Object
.
keys
(
actual
).
indexOf
(
'
folderValue
'
)
===
-
1
);
actual
=
testObject
.
getConfiguration
(
'
editor
'
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual
.
workspaceValue
,
undefined
);
assert
.
ok
(
Object
.
keys
(
actual
).
indexOf
(
'
folderValue
'
)
===
-
1
);
});
test
(
'
inspect in single root context
'
,
function
()
{
const
workspaceUri
=
URI
.
file
(
'
foo
'
);
const
folders
=
Object
.
create
(
null
);
const
workspace
=
new
ConfigurationModel
({
...
...
@@ -116,10 +149,140 @@ suite('ExtHostConfiguration', function () {
}
);
const
actual
=
testObject
.
getConfiguration
().
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual
.
workspaceValue
,
'
bounded
'
);
let
actual1
=
testObject
.
getConfiguration
().
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual1
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual1
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual1
.
workspaceValue
,
'
bounded
'
);
assert
.
ok
(
Object
.
keys
(
actual1
).
indexOf
(
'
folderValue
'
)
===
-
1
);
actual1
=
testObject
.
getConfiguration
(
'
editor
'
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual1
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual1
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual1
.
workspaceValue
,
'
bounded
'
);
assert
.
ok
(
Object
.
keys
(
actual1
).
indexOf
(
'
folderValue
'
)
===
-
1
);
let
actual2
=
testObject
.
getConfiguration2
(
null
,
workspaceUri
).
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
equal
(
actual2
.
folderValue
,
'
bounded
'
);
actual2
=
testObject
.
getConfiguration2
(
'
editor
'
,
workspaceUri
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
equal
(
actual2
.
folderValue
,
'
bounded
'
);
});
test
(
'
inspect in multi root context
'
,
function
()
{
const
workspace
=
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
bounded
'
}
},
[
'
editor.wordWrap
'
]);
const
firstRoot
=
URI
.
file
(
'
foo1
'
);
const
secondRoot
=
URI
.
file
(
'
foo2
'
);
const
thirdRoot
=
URI
.
file
(
'
foo3
'
);
const
folders
=
Object
.
create
(
null
);
folders
[
firstRoot
.
toString
()]
=
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
off
'
,
'
lineNumbers
'
:
'
relative
'
}
},
[
'
editor.wordWrap
'
]);
folders
[
secondRoot
.
toString
()]
=
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
on
'
}
},
[
'
editor.wordWrap
'
]);
folders
[
thirdRoot
.
toString
()]
=
new
ConfigurationModel
({},
[]);
const
testObject
=
new
ExtHostConfiguration
(
new
class
extends
MainThreadConfigurationShape
{
},
new
ExtHostWorkspace
(
new
TestThreadService
(),
{
'
id
'
:
'
foo
'
,
'
roots
'
:
[
firstRoot
,
secondRoot
],
'
name
'
:
'
foo
'
}),
{
defaults
:
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
off
'
,
'
lineNumbers
'
:
'
on
'
}
},
[
'
editor.wordWrap
'
]),
user
:
new
ConfigurationModel
({
'
editor
'
:
{
'
wordWrap
'
:
'
on
'
}
},
[
'
editor.wordWrap
'
]),
workspace
,
folders
}
);
let
actual1
=
testObject
.
getConfiguration
().
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual1
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual1
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual1
.
workspaceValue
,
'
off
'
);
assert
.
ok
(
Object
.
keys
(
actual1
).
indexOf
(
'
folderValue
'
)
===
-
1
);
actual1
=
testObject
.
getConfiguration
(
'
editor
'
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual1
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual1
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual1
.
workspaceValue
,
'
off
'
);
assert
.
ok
(
Object
.
keys
(
actual1
).
indexOf
(
'
folderValue
'
)
===
-
1
);
actual1
=
testObject
.
getConfiguration
(
'
editor
'
).
inspect
(
'
lineNumbers
'
);
assert
.
equal
(
actual1
.
defaultValue
,
'
on
'
);
assert
.
equal
(
actual1
.
globalValue
,
undefined
);
assert
.
equal
(
actual1
.
workspaceValue
,
'
relative
'
);
assert
.
ok
(
Object
.
keys
(
actual1
).
indexOf
(
'
folderValue
'
)
===
-
1
);
let
actual2
=
testObject
.
getConfiguration2
(
null
,
firstRoot
).
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
equal
(
actual2
.
folderValue
,
'
off
'
);
actual2
=
testObject
.
getConfiguration2
(
'
editor
'
,
firstRoot
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
equal
(
actual2
.
folderValue
,
'
off
'
);
actual2
=
testObject
.
getConfiguration2
(
'
editor
'
,
firstRoot
).
inspect
(
'
lineNumbers
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
on
'
);
assert
.
equal
(
actual2
.
globalValue
,
undefined
);
assert
.
equal
(
actual2
.
workspaceValue
,
undefined
);
assert
.
equal
(
actual2
.
folderValue
,
'
relative
'
);
actual2
=
testObject
.
getConfiguration2
(
null
,
secondRoot
).
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
equal
(
actual2
.
folderValue
,
'
on
'
);
actual2
=
testObject
.
getConfiguration2
(
'
editor
'
,
secondRoot
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
equal
(
actual2
.
folderValue
,
'
on
'
);
actual2
=
testObject
.
getConfiguration2
(
null
,
thirdRoot
).
inspect
(
'
editor.wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
ok
(
Object
.
keys
(
actual2
).
indexOf
(
'
folderValue
'
)
!==
-
1
);
assert
.
equal
(
actual2
.
folderValue
,
undefined
);
actual2
=
testObject
.
getConfiguration2
(
'
editor
'
,
thirdRoot
).
inspect
(
'
wordWrap
'
);
assert
.
equal
(
actual2
.
defaultValue
,
'
off
'
);
assert
.
equal
(
actual2
.
globalValue
,
'
on
'
);
assert
.
equal
(
actual2
.
workspaceValue
,
'
bounded
'
);
assert
.
ok
(
Object
.
keys
(
actual2
).
indexOf
(
'
folderValue
'
)
!==
-
1
);
assert
.
equal
(
actual2
.
folderValue
,
undefined
);
});
test
(
'
getConfiguration vs get
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录