Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a50ca56b
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,发现更多精彩内容 >>
提交
a50ca56b
编写于
6月 16, 2017
作者:
S
Sandeep Somavarapu
提交者:
GitHub
6月 16, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #28858 from Microsoft/sandy081/adoptExtHostConfiguration
Adopt ext host to use configuration tree data
上级
f02a1ace
81b98b88
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
86 addition
and
81 deletion
+86
-81
src/vs/workbench/api/electron-browser/mainThreadConfiguration.ts
...workbench/api/electron-browser/mainThreadConfiguration.ts
+1
-1
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+3
-3
src/vs/workbench/api/node/extHostConfiguration.ts
src/vs/workbench/api/node/extHostConfiguration.ts
+18
-29
src/vs/workbench/electron-browser/extensionHost.ts
src/vs/workbench/electron-browser/extensionHost.ts
+1
-1
src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts
...ch/test/electron-browser/api/extHostConfiguration.test.ts
+63
-47
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadConfiguration.ts
浏览文件 @
a50ca56b
...
...
@@ -26,7 +26,7 @@ export class MainThreadConfiguration extends MainThreadConfigurationShape {
const
proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostConfiguration
);
this
.
_toDispose
=
configurationService
.
onDidUpdateConfiguration
(()
=>
{
proxy
.
$acceptConfigurationChanged
(
configurationService
.
values
());
proxy
.
$acceptConfigurationChanged
(
configurationService
.
getConfigurationData
());
});
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
a50ca56b
...
...
@@ -30,7 +30,7 @@ import { IResourceEdit } from 'vs/editor/common/services/bulkEdit';
import
{
ITextSource
}
from
'
vs/editor/common/model/textSource
'
;
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IConfiguration
Values
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfiguration
Data
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IPickOpenEntry
,
IPickOptions
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
SaveReason
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
...
...
@@ -67,7 +67,7 @@ export interface IInitData {
environment
:
IEnvironment
;
workspace
:
IWorkspaceData
;
extensions
:
IExtensionDescription
[];
configuration
:
IConfiguration
Values
;
configuration
:
IConfiguration
Data
<
any
>
;
telemetryInfo
:
ITelemetryInfo
;
}
...
...
@@ -349,7 +349,7 @@ export abstract class ExtHostCommandsShape {
}
export
abstract
class
ExtHostConfigurationShape
{
$acceptConfigurationChanged
(
values
:
IConfigurationValues
)
{
throw
ni
();
}
$acceptConfigurationChanged
(
data
:
IConfigurationData
<
any
>
)
{
throw
ni
();
}
}
export
abstract
class
ExtHostDiagnosticsShape
{
...
...
src/vs/workbench/api/node/extHostConfiguration.ts
浏览文件 @
a50ca56b
...
...
@@ -8,9 +8,8 @@ import { mixin } from 'vs/base/common/objects';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
WorkspaceConfiguration
}
from
'
vscode
'
;
import
{
ExtHostConfigurationShape
,
MainThreadConfigurationShape
}
from
'
./extHost.protocol
'
;
import
{
IConfiguration
Values
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfiguration
Data
,
Configuration
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
toValuesTree
}
from
'
vs/platform/configuration/common/model
'
;
function
lookUp
(
tree
:
any
,
key
:
string
)
{
if
(
key
)
{
...
...
@@ -23,51 +22,41 @@ function lookUp(tree: any, key: string) {
}
}
interface
UsefulConfiguration
{
data
:
IConfigurationValues
;
valueTree
:
any
;
}
function
createUsefulConfiguration
(
data
:
IConfigurationValues
):
{
data
:
IConfigurationValues
,
valueTree
:
any
}
{
const
valueMap
:
{
[
key
:
string
]:
any
}
=
Object
.
create
(
null
);
for
(
let
key
in
data
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
data
,
key
))
{
valueMap
[
key
]
=
data
[
key
].
value
;
}
}
const
valueTree
=
toValuesTree
(
valueMap
,
message
=>
console
.
error
(
`Conflict in configuration settings:
${
message
}
`
));
return
{
data
,
valueTree
};
}
export
class
ExtHostConfiguration
extends
ExtHostConfigurationShape
{
private
_onDidChangeConfiguration
=
new
Emitter
<
void
>
();
private
_proxy
:
MainThreadConfigurationShape
;
private
_configuration
:
UsefulConfiguration
;
private
_data
:
IConfigurationData
<
any
>
;
private
_configuration
:
Configuration
<
any
>
;
constructor
(
proxy
:
MainThreadConfigurationShape
,
data
:
IConfiguration
Values
)
{
constructor
(
proxy
:
MainThreadConfigurationShape
,
data
:
IConfiguration
Data
<
any
>
)
{
super
();
this
.
_proxy
=
proxy
;
this
.
_
configuration
=
createUsefulConfiguration
(
data
)
;
this
.
_
data
=
data
;
}
get
onDidChangeConfiguration
():
Event
<
void
>
{
return
this
.
_onDidChangeConfiguration
&&
this
.
_onDidChangeConfiguration
.
event
;
}
public
$acceptConfigurationChanged
(
data
:
IConfigurationValues
)
{
this
.
_configuration
=
createUsefulConfiguration
(
data
);
public
$acceptConfigurationChanged
(
data
:
IConfigurationData
<
any
>
)
{
this
.
_configuration
=
null
;
this
.
_data
=
data
;
this
.
_onDidChangeConfiguration
.
fire
(
undefined
);
}
private
get
configuration
():
Configuration
<
any
>
{
if
(
!
this
.
_configuration
)
{
this
.
_configuration
=
Configuration
.
parse
(
this
.
_data
);
}
return
this
.
_configuration
;
}
public
getConfiguration
(
section
?:
string
):
WorkspaceConfiguration
{
const
config
=
section
?
lookUp
(
this
.
_configuration
.
valueTree
,
section
)
:
this
.
_configuration
.
valueTree
;
?
lookUp
(
this
.
configuration
.
getValue
()
,
section
)
:
this
.
configuration
.
getValue
()
;
const
result
:
WorkspaceConfiguration
=
{
has
(
key
:
string
):
boolean
{
...
...
@@ -91,7 +80,7 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
},
inspect
:
<
T
>
(
key
:
string
):
{
key
:
string
;
defaultValue
?:
T
;
globalValue
?:
T
;
workspaceValue
?:
T
}
=>
{
key
=
section
?
`
${
section
}
.
${
key
}
`
:
key
;
const
config
=
this
.
_configuration
.
data
[
key
];
const
config
=
this
.
configuration
.
values
()
[
key
];
if
(
config
)
{
return
{
key
,
...
...
src/vs/workbench/electron-browser/extensionHost.ts
浏览文件 @
a50ca56b
...
...
@@ -290,7 +290,7 @@ export class ExtensionHostProcessWorker {
},
workspace
:
<
IWorkspaceData
>
this
.
contextService
.
getWorkspace2
(),
extensions
:
extensionDescriptions
,
configuration
:
this
.
configurationService
.
values
(),
configuration
:
this
.
configurationService
.
getConfigurationData
(),
telemetryInfo
};
});
...
...
src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts
浏览文件 @
a50ca56b
...
...
@@ -10,7 +10,7 @@ import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration
import
{
MainThreadConfigurationShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ConfigurationTarget
,
ConfigurationEditingErrorCode
,
IConfigurationEditingError
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IConfigurationValues
,
IConfigurationValue
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ConfigurationModel
}
from
'
vs/platform/configuration/common/configuration
'
;
suite
(
'
ExtHostConfiguration
'
,
function
()
{
...
...
@@ -22,25 +22,25 @@ suite('ExtHostConfiguration', function () {
}
};
function
createExtHostConfiguration
(
data
:
IConfigurationValues
=
Object
.
create
(
null
),
shape
?:
MainThreadConfigurationShape
)
{
function
createExtHostConfiguration
(
contents
:
any
=
Object
.
create
(
null
),
shape
?:
MainThreadConfigurationShape
)
{
if
(
!
shape
)
{
shape
=
new
class
extends
MainThreadConfigurationShape
{
};
}
return
new
ExtHostConfiguration
(
shape
,
data
);
}
function
createConfigurationValue
<
T
>
(
value
:
T
):
IConfigurationValue
<
T
>
{
return
{
value
,
default
:
value
,
user
:
undefined
,
workspace
:
undefined
};
return
new
ExtHostConfiguration
(
shape
,
{
defaults
:
new
ConfigurationModel
(
contents
),
user
:
new
ConfigurationModel
(
contents
),
folders
:
Object
.
create
(
null
),
workspaceUri
:
void
0
});
}
test
(
'
getConfiguration fails regression test 1.7.1 -> 1.8 #15552
'
,
function
()
{
const
extHostConfig
=
createExtHostConfiguration
({
[
'
search.exclude
'
]:
createConfigurationValue
({
'
**/node_modules
'
:
true
})
'
search
'
:
{
'
exclude
'
:
{
'
**/node_modules
'
:
true
}
}
});
assert
.
equal
(
extHostConfig
.
getConfiguration
(
'
search.exclude
'
)[
'
**/node_modules
'
],
true
);
...
...
@@ -54,10 +54,14 @@ suite('ExtHostConfiguration', function () {
test
(
'
has/get
'
,
function
()
{
const
all
=
createExtHostConfiguration
({
[
'
farboo.config0
'
]:
createConfigurationValue
(
true
),
[
'
farboo.nested.config1
'
]:
createConfigurationValue
(
42
),
[
'
farboo.nested.config2
'
]:
createConfigurationValue
(
'
Das Pferd frisst kein Reis.
'
),
[
'
farboo.config4
'
]:
createConfigurationValue
(
''
)
'
farboo
'
:
{
'
config0
'
:
true
,
'
nested
'
:
{
'
config1
'
:
42
,
'
config2
'
:
'
Das Pferd frisst kein Reis.
'
},
'
config4
'
:
''
}
});
const
config
=
all
.
getConfiguration
(
'
farboo
'
);
...
...
@@ -80,8 +84,10 @@ suite('ExtHostConfiguration', function () {
test
(
'
getConfiguration vs get
'
,
function
()
{
const
all
=
createExtHostConfiguration
({
[
'
farboo.config0
'
]:
createConfigurationValue
(
true
),
[
'
farboo.config4
'
]:
createConfigurationValue
(
38
)
'
farboo
'
:
{
'
config0
'
:
true
,
'
config4
'
:
38
}
});
let
config
=
all
.
getConfiguration
(
'
farboo.config0
'
);
...
...
@@ -96,8 +102,10 @@ suite('ExtHostConfiguration', function () {
test
(
'
getConfiguration vs get
'
,
function
()
{
const
all
=
createExtHostConfiguration
({
[
'
farboo.config0
'
]:
createConfigurationValue
(
true
),
[
'
farboo.config4
'
]:
createConfigurationValue
(
38
)
'
farboo
'
:
{
'
config0
'
:
true
,
'
config4
'
:
38
}
});
let
config
=
all
.
getConfiguration
(
'
farboo.config0
'
);
...
...
@@ -111,7 +119,9 @@ suite('ExtHostConfiguration', function () {
test
(
'
name vs property
'
,
function
()
{
const
all
=
createExtHostConfiguration
({
[
'
farboo.get
'
]:
createConfigurationValue
(
'
get-prop
'
)
'
farboo
'
:
{
'
get
'
:
'
get-prop
'
}
});
const
config
=
all
.
getConfiguration
(
'
farboo
'
);
...
...
@@ -125,8 +135,10 @@ suite('ExtHostConfiguration', function () {
const
shape
=
new
RecordingShape
();
const
allConfig
=
createExtHostConfiguration
({
[
'
foo.bar
'
]:
createConfigurationValue
(
1
),
[
'
foo.far
'
]:
createConfigurationValue
(
1
)
'
foo
'
:
{
'
bar
'
:
1
,
'
far
'
:
1
}
},
shape
);
let
config
=
allConfig
.
getConfiguration
(
'
foo
'
);
...
...
@@ -146,7 +158,9 @@ suite('ExtHostConfiguration', function () {
test
(
'
update, what is #15834
'
,
function
()
{
const
shape
=
new
RecordingShape
();
const
allConfig
=
createExtHostConfiguration
({
[
'
editor.formatOnSave
'
]:
createConfigurationValue
(
true
)
'
editor
'
:
{
'
formatOnSave
'
:
true
}
},
shape
);
allConfig
.
getConfiguration
(
'
editor
'
).
update
(
'
formatOnSave
'
,
{
extensions
:
[
'
ts
'
]
});
...
...
@@ -154,28 +168,30 @@ suite('ExtHostConfiguration', function () {
assert
.
deepEqual
(
shape
.
lastArgs
[
2
],
{
extensions
:
[
'
ts
'
]
});
});
test
(
'
bogous data, #15834
'
,
function
()
{
let
oldLogger
=
console
.
error
;
let
errorLogged
=
false
;
// workaround until we have a proper logging story
console
.
error
=
(
message
,
args
)
=>
{
errorLogged
=
true
;
};
let
allConfig
;
try
{
const
shape
=
new
RecordingShape
();
allConfig
=
createExtHostConfiguration
({
[
'
editor.formatOnSave
'
]:
createConfigurationValue
(
true
),
[
'
editor.formatOnSave.extensions
'
]:
createConfigurationValue
([
'
ts
'
])
},
shape
);
}
finally
{
console
.
error
=
oldLogger
;
}
assert
.
ok
(
errorLogged
);
assert
.
ok
(
allConfig
.
getConfiguration
(
''
).
has
(
'
editor.formatOnSave
'
));
assert
.
ok
(
!
allConfig
.
getConfiguration
(
''
).
has
(
'
editor.formatOnSave.extensions
'
));
});
/*
test('bogous data, #15834', function () {
let oldLogger = console.error;
let errorLogged = false;
// workaround until we have a proper logging story
console.error = (message, args) => {
errorLogged = true;
};
let allConfig;
try {
const shape = new RecordingShape();
allConfig = createExtHostConfiguration({
['editor.formatOnSave']: createConfigurationValue(true),
['editor.formatOnSave.extensions']: createConfigurationValue(['ts'])
}, shape);
} finally {
console.error = oldLogger;
}
assert.ok(errorLogged);
assert.ok(allConfig.getConfiguration('').has('editor.formatOnSave'));
assert.ok(!allConfig.getConfiguration('').has('editor.formatOnSave.extensions'));
});
*/
test
(
'
update/error-state not OK
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录