Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
802be774
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,发现更多精彩内容 >>
提交
802be774
编写于
1月 23, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#36967 - Support reading workspace launches in mulit root workspace
上级
486ad5ee
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
40 deletion
+105
-40
src/vs/workbench/services/configuration/common/configurationModels.ts
...ench/services/configuration/common/configurationModels.ts
+31
-12
src/vs/workbench/services/configuration/node/configuration.ts
...vs/workbench/services/configuration/node/configuration.ts
+23
-18
src/vs/workbench/services/configuration/node/configurationService.ts
...bench/services/configuration/node/configurationService.ts
+1
-1
src/vs/workbench/services/configuration/test/node/configurationService.test.ts
...ices/configuration/test/node/configurationService.test.ts
+50
-9
未找到文件。
src/vs/workbench/services/configuration/common/configurationModels.ts
浏览文件 @
802be774
...
...
@@ -14,7 +14,7 @@ import { Workspace } from 'vs/platform/workspace/common/workspace';
import
{
StrictResourceMap
}
from
'
vs/base/common/map
'
;
import
URI
from
'
vs/base/common/uri
'
;
export
class
Workspace
SettingsModel
extends
ConfigurationModel
{
export
class
SettingsModel
extends
ConfigurationModel
{
private
_unsupportedKeys
:
string
[];
...
...
@@ -32,30 +32,49 @@ export class WorkspaceSettingsModel extends ConfigurationModel {
export
class
WorkspaceConfigurationModelParser
extends
ConfigurationModelParser
{
private
_folders
:
IStoredWorkspaceFolder
[]
=
[];
private
_workspaceSettingsModelParser
:
FolderSettingsModelParser
;
private
_settingsModelParser
:
FolderSettingsModelParser
;
private
_launchModel
:
ConfigurationModel
;
constructor
(
name
:
string
)
{
super
(
name
);
this
.
_workspaceSettingsModelParser
=
new
FolderSettingsModelParser
(
name
);
this
.
_settingsModelParser
=
new
FolderSettingsModelParser
(
name
);
this
.
_launchModel
=
new
ConfigurationModel
();
}
get
folders
():
IStoredWorkspaceFolder
[]
{
return
this
.
_folders
;
}
get
workspaceSettingsModel
():
WorkspaceSettingsModel
{
return
this
.
_workspaceSettingsModelParser
.
folderSettingsModel
;
get
settingsModel
():
SettingsModel
{
return
this
.
_settingsModelParser
.
settingsModel
;
}
get
launchModel
():
ConfigurationModel
{
return
this
.
_launchModel
;
}
reprocessWorkspaceSettings
():
void
{
this
.
_
workspaceS
ettingsModelParser
.
reprocess
();
this
.
_
s
ettingsModelParser
.
reprocess
();
}
protected
parseRaw
(
raw
:
any
):
IConfigurationModel
{
this
.
_folders
=
(
raw
[
'
folders
'
]
||
[])
as
IStoredWorkspaceFolder
[];
this
.
_workspaceSettingsModelParser
.
parse
(
raw
[
'
settings
'
]);
this
.
_settingsModelParser
.
parse
(
raw
[
'
settings
'
]);
this
.
_launchModel
=
this
.
createConfigurationModelFrom
(
raw
,
'
launch
'
);
return
super
.
parseRaw
(
raw
);
}
private
createConfigurationModelFrom
(
raw
:
any
,
key
:
string
):
ConfigurationModel
{
const
data
=
raw
[
key
];
if
(
data
)
{
const
contents
=
toValuesTree
(
data
,
message
=>
console
.
error
(
`Conflict in settings file
${
this
.
_name
}
:
${
message
}
`
));
const
scopedContents
=
Object
.
create
(
null
);
scopedContents
[
key
]
=
contents
;
const
keys
=
Object
.
keys
(
data
).
map
(
k
=>
`
${
key
}
.
${
k
}
`
);
return
new
ConfigurationModel
(
scopedContents
,
keys
,
[]);
}
return
new
ConfigurationModel
();
}
}
export
class
StandaloneConfigurationModelParser
extends
ConfigurationModelParser
{
...
...
@@ -77,7 +96,7 @@ export class StandaloneConfigurationModelParser extends ConfigurationModelParser
export
class
FolderSettingsModelParser
extends
ConfigurationModelParser
{
private
_raw
:
any
;
private
_
workspaceSettingsModel
:
Workspace
SettingsModel
;
private
_
settingsModel
:
SettingsModel
;
constructor
(
name
:
string
,
private
configurationScope
?:
ConfigurationScope
)
{
super
(
name
);
...
...
@@ -89,11 +108,11 @@ export class FolderSettingsModelParser extends ConfigurationModelParser {
}
get
configurationModel
():
ConfigurationModel
{
return
this
.
_
workspaceSettingsModel
||
new
Workspace
SettingsModel
({},
[],
[],
[]);
return
this
.
_
settingsModel
||
new
SettingsModel
({},
[],
[],
[]);
}
get
folderSettingsModel
():
Workspace
SettingsModel
{
return
<
Workspace
SettingsModel
>
this
.
configurationModel
;
get
settingsModel
():
SettingsModel
{
return
<
SettingsModel
>
this
.
configurationModel
;
}
reprocess
():
void
{
...
...
@@ -114,7 +133,7 @@ export class FolderSettingsModelParser extends ConfigurationModelParser {
}
}
const
configurationModel
=
this
.
parseRaw
(
rawWorkspaceSettings
);
this
.
_
workspaceSettingsModel
=
new
Workspace
SettingsModel
(
configurationModel
.
contents
,
configurationModel
.
keys
,
configurationModel
.
overrides
,
unsupportedKeys
);
this
.
_
settingsModel
=
new
SettingsModel
(
configurationModel
.
contents
,
configurationModel
.
keys
,
configurationModel
.
overrides
,
unsupportedKeys
);
}
private
getScope
(
key
:
string
,
configurationProperties
:
{
[
qualifiedKey
:
string
]:
IConfigurationPropertySchema
}):
ConfigurationScope
{
...
...
src/vs/workbench/services/configuration/node/configuration.ts
浏览文件 @
802be774
...
...
@@ -16,7 +16,7 @@ import { FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files
import
{
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
ConfigWatcher
}
from
'
vs/base/node/config
'
;
import
{
ConfigurationModel
,
ConfigurationModelParser
}
from
'
vs/platform/configuration/common/configurationModels
'
;
import
{
WorkspaceConfigurationModelParser
,
FolderSettingsModelParser
,
StandaloneConfigurationModelParser
,
WorkspaceSettingsModel
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
WorkspaceConfigurationModelParser
,
FolderSettingsModelParser
,
StandaloneConfigurationModelParser
}
from
'
vs/workbench/services/configuration/common/configurationModels
'
;
import
{
WORKSPACE_STANDALONE_CONFIGURATIONS
,
FOLDER_SETTINGS_PATH
,
TASKS_CONFIGURATION_KEY
,
LAUNCH_CONFIGURATION_KEY
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
IStoredWorkspace
,
IStoredWorkspaceFolder
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
...
...
@@ -82,6 +82,9 @@ export class WorkspaceConfiguration extends Disposable {
private
_onDidUpdateConfiguration
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidUpdateConfiguration
:
Event
<
void
>
=
this
.
_onDidUpdateConfiguration
.
event
;
private
_workspaceConfigurationModelParser
:
WorkspaceConfigurationModelParser
=
new
WorkspaceConfigurationModelParser
(
this
.
_workspaceConfigPath
?
this
.
_workspaceConfigPath
.
fsPath
:
''
);
private
_cache
:
ConfigurationModel
=
new
ConfigurationModel
();
load
(
workspaceConfigPath
:
URI
):
TPromise
<
void
>
{
if
(
this
.
_workspaceConfigPath
&&
this
.
_workspaceConfigPath
.
fsPath
===
workspaceConfigPath
.
fsPath
)
{
return
this
.
reload
();
...
...
@@ -98,20 +101,17 @@ export class WorkspaceConfiguration extends Disposable {
onError
:
error
=>
errors
.
onUnexpectedError
(
error
),
defaultConfig
,
parse
:
(
content
:
string
,
parseErrors
:
any
[])
=>
{
const
workspaceConfigurationModel
=
new
WorkspaceConfigurationModelParser
(
this
.
_workspaceConfigPath
.
fsPath
);
workspaceConfigurationModel
.
parse
(
content
);
parseErrors
=
[...
workspaceConfigurationModel
.
errors
];
return
workspaceConfigurationModel
;
this
.
_workspaceConfigurationModelParser
=
new
WorkspaceConfigurationModelParser
(
this
.
_workspaceConfigPath
.
fsPath
);
this
.
_workspaceConfigurationModelParser
.
parse
(
content
);
parseErrors
=
[...
this
.
_workspaceConfigurationModelParser
.
errors
];
this
.
consolidate
();
return
this
.
_workspaceConfigurationModelParser
;
},
initCallback
:
()
=>
c
(
null
)
});
this
.
listenToWatcher
();
});
}
private
get
workspaceConfigurationModelParser
():
WorkspaceConfigurationModelParser
{
return
this
.
_workspaceConfigurationWatcher
?
this
.
_workspaceConfigurationWatcher
.
getConfig
()
:
new
WorkspaceConfigurationModelParser
(
this
.
_workspaceConfigPath
?
this
.
_workspaceConfigPath
.
fsPath
:
''
);
}
reload
():
TPromise
<
void
>
{
this
.
stopListeningToWatcher
();
return
new
TPromise
<
void
>
(
c
=>
this
.
_workspaceConfigurationWatcher
.
reload
(()
=>
{
...
...
@@ -121,7 +121,7 @@ export class WorkspaceConfiguration extends Disposable {
}
getFolders
():
IStoredWorkspaceFolder
[]
{
return
this
.
workspaceConfigurationModelParser
.
folders
;
return
this
.
_
workspaceConfigurationModelParser
.
folders
;
}
setFolders
(
folders
:
IStoredWorkspaceFolder
[],
jsonEditingService
:
JSONEditingService
):
TPromise
<
void
>
{
...
...
@@ -130,15 +130,16 @@ export class WorkspaceConfiguration extends Disposable {
}
getConfiguration
():
ConfigurationModel
{
return
this
.
workspaceConfigurationModelParser
.
workspaceSettingsModel
;
return
this
.
_cache
;
}
get
WorkspaceSettings
():
WorkspaceSettingsModel
{
return
this
.
workspaceConfigurationModelParser
.
workspaceSettingsModel
;
get
UnsupportedKeys
():
string
[]
{
return
this
.
_workspaceConfigurationModelParser
.
settingsModel
.
unsupportedKeys
;
}
reprocessWorkspaceSettings
():
ConfigurationModel
{
this
.
workspaceConfigurationModelParser
.
reprocessWorkspaceSettings
();
this
.
_workspaceConfigurationModelParser
.
reprocessWorkspaceSettings
();
this
.
consolidate
();
return
this
.
getConfiguration
();
}
...
...
@@ -151,6 +152,10 @@ export class WorkspaceConfiguration extends Disposable {
this
.
_workspaceConfigurationWatcherDisposables
=
dispose
(
this
.
_workspaceConfigurationWatcherDisposables
);
}
private
consolidate
():
void
{
this
.
_cache
=
this
.
_workspaceConfigurationModelParser
.
settingsModel
.
merge
(
this
.
_workspaceConfigurationModelParser
.
launchModel
);
}
dispose
():
void
{
dispose
(
this
.
_workspaceConfigurationWatcherDisposables
);
super
.
dispose
();
...
...
@@ -190,20 +195,20 @@ export class FolderConfiguration extends Disposable {
}
reprocess
():
ConfigurationModel
{
const
oldContents
=
this
.
_folderSettingsModelParser
.
folderS
ettingsModel
.
contents
;
const
oldContents
=
this
.
_folderSettingsModelParser
.
s
ettingsModel
.
contents
;
this
.
_folderSettingsModelParser
.
reprocess
();
if
(
!
equals
(
oldContents
,
this
.
_folderSettingsModelParser
.
folderS
ettingsModel
.
contents
))
{
if
(
!
equals
(
oldContents
,
this
.
_folderSettingsModelParser
.
s
ettingsModel
.
contents
))
{
this
.
consolidate
();
}
return
this
.
_cache
;
}
getUnsupportedKeys
():
string
[]
{
return
this
.
_folderSettingsModelParser
.
folderS
ettingsModel
.
unsupportedKeys
;
return
this
.
_folderSettingsModelParser
.
s
ettingsModel
.
unsupportedKeys
;
}
private
consolidate
():
void
{
this
.
_cache
=
this
.
_folderSettingsModelParser
.
folderS
ettingsModel
.
merge
(...
this
.
_standAloneConfigurations
);
this
.
_cache
=
this
.
_folderSettingsModelParser
.
s
ettingsModel
.
merge
(...
this
.
_standAloneConfigurations
);
}
private
loadWorkspaceConfigFiles
():
TPromise
<
{
[
relativeWorkspacePath
:
string
]:
ConfigurationModelParser
}
>
{
...
...
src/vs/workbench/services/configuration/node/configurationService.ts
浏览文件 @
802be774
...
...
@@ -279,7 +279,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
}
getUnsupportedWorkspaceKeys
():
string
[]
{
const
unsupportedWorkspaceKeys
=
[...
this
.
workspaceConfiguration
.
get
WorkspaceSettings
().
unsupportedKeys
];
const
unsupportedWorkspaceKeys
=
[...
this
.
workspaceConfiguration
.
get
UnsupportedKeys
()
];
for
(
const
folder
of
this
.
workspace
.
folders
)
{
unsupportedWorkspaceKeys
.
push
(...
this
.
cachedFolderConfigs
.
get
(
folder
.
uri
).
getUnsupportedKeys
());
}
...
...
src/vs/workbench/services/configuration/test/node/configurationService.test.ts
浏览文件 @
802be774
...
...
@@ -1038,6 +1038,56 @@ suite('WorkspaceConfigurationService - Multiroot', () => {
});
});
test
(
'
get launch configuration
'
,
()
=>
{
const
expectedLaunchConfiguration
=
{
'
version
'
:
'
0.1.0
'
,
'
configurations
'
:
[
{
'
type
'
:
'
node
'
,
'
request
'
:
'
launch
'
,
'
name
'
:
'
Gulp Build
'
,
'
program
'
:
'
${workspaceFolder}/node_modules/gulp/bin/gulp.js
'
,
'
stopOnEntry
'
:
true
,
'
args
'
:
[
'
watch-extension:json-client
'
],
'
cwd
'
:
'
${workspaceFolder}
'
}
]
};
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
,
{
key
:
'
launch
'
,
value
:
expectedLaunchConfiguration
},
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
const
actual
=
testObject
.
getValue
(
'
launch
'
);
assert
.
deepEqual
(
actual
,
expectedLaunchConfiguration
);
});
});
test
(
'
inspect launch configuration
'
,
()
=>
{
const
expectedLaunchConfiguration
=
{
'
version
'
:
'
0.1.0
'
,
'
configurations
'
:
[
{
'
type
'
:
'
node
'
,
'
request
'
:
'
launch
'
,
'
name
'
:
'
Gulp Build
'
,
'
program
'
:
'
${workspaceFolder}/node_modules/gulp/bin/gulp.js
'
,
'
stopOnEntry
'
:
true
,
'
args
'
:
[
'
watch-extension:json-client
'
],
'
cwd
'
:
'
${workspaceFolder}
'
}
]
};
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
,
{
key
:
'
launch
'
,
value
:
expectedLaunchConfiguration
},
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
const
actual
=
testObject
.
inspect
(
'
launch
'
).
workspace
;
assert
.
deepEqual
(
actual
,
expectedLaunchConfiguration
);
});
});
test
(
'
update user configuration
'
,
()
=>
{
return
testObject
.
updateValue
(
'
configurationService.workspace.testSetting
'
,
'
userValue
'
,
ConfigurationTarget
.
USER
)
.
then
(()
=>
assert
.
equal
(
testObject
.
getValue
(
'
configurationService.workspace.testSetting
'
),
'
userValue
'
));
...
...
@@ -1102,13 +1152,4 @@ suite('WorkspaceConfigurationService - Multiroot', () => {
assert
.
equal
(
actual
.
workspace
,
void
0
);
});
});
test
(
'
launch configurations are not read from workspace
'
,
()
=>
{
return
jsonEditingServce
.
write
(
workspaceContextService
.
getWorkspace
().
configuration
,
{
key
:
'
launch
'
,
value
:
{
'
version
'
:
'
1.0
'
}
},
true
)
.
then
(()
=>
testObject
.
reloadConfiguration
())
.
then
(()
=>
{
const
actual
=
testObject
.
inspect
(
'
launch.version
'
);
assert
.
equal
(
actual
.
workspace
,
void
0
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录