Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
67549490
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,发现更多精彩内容 >>
提交
67549490
编写于
9月 21, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
configuration resolver service first steps
上级
59cf7a96
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
186 addition
and
0 deletion
+186
-0
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+6
-0
src/vs/workbench/services/configurationResolver/common/configurationResolver.ts
...ces/configurationResolver/common/configurationResolver.ts
+20
-0
src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts
...onfigurationResolver/node/configurationResolverService.ts
+148
-0
src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts
...onResolver/test/node/configurationResolverService.test.ts
+12
-0
未找到文件。
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
67549490
...
...
@@ -53,6 +53,8 @@ import {IActivityService} from 'vs/workbench/services/activity/common/activitySe
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/common/viewletService
'
;
import
{
FileService
}
from
'
vs/workbench/services/files/electron-browser/fileService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
import
{
ConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/node/configurationResolverService
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
WorkbenchMessageService
}
from
'
vs/workbench/services/message/browser/messageService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -388,6 +390,10 @@ export class Workbench implements IPartService {
// Configuration Editing
serviceCollection
.
set
(
IConfigurationEditingService
,
this
.
instantiationService
.
createInstance
(
ConfigurationEditingService
));
// Configuration Resolver
const
configurationResolverService
=
this
.
instantiationService
.
createInstance
(
ConfigurationResolverService
);
serviceCollection
.
set
(
IConfigurationResolverService
,
configurationResolverService
);
// Quick open service (quick open controller)
this
.
quickOpen
=
this
.
instantiationService
.
createInstance
(
QuickOpenController
);
this
.
toDispose
.
push
(
this
.
quickOpen
);
...
...
src/vs/workbench/services/configurationResolver/common/configurationResolver.ts
0 → 100644
浏览文件 @
67549490
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
const
IConfigurationResolverService
=
createDecorator
<
IConfigurationResolverService
>
(
'
configurationResolverService
'
);
export
interface
IConfigurationResolverService
{
_serviceBrand
:
any
;
resolve
(
value
:
string
):
string
;
resolve
(
value
:
string
[]):
string
[];
resolve
(
value
:
IStringDictionary
<
string
>
):
IStringDictionary
<
string
>
;
resolve
(
value
:
IStringDictionary
<
string
[]
>
):
IStringDictionary
<
string
[]
>
;
resolve
(
value
:
IStringDictionary
<
IStringDictionary
<
string
>>
):
IStringDictionary
<
IStringDictionary
<
string
>>
;
resolveAny
<
T
>
(
value
:
T
):
T
;
}
src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts
0 → 100644
浏览文件 @
67549490
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
IConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
asFileEditorInput
}
from
'
vs/workbench/common/editor
'
;
export
class
ConfigurationResolverService
implements
IConfigurationResolverService
{
_serviceBrand
:
any
;
private
_workspaceRoot
:
string
;
private
_execPath
:
string
;
constructor
(
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
)
{
const
workspace
=
contextService
.
getWorkspace
();
const
fsPath
=
workspace
?
workspace
.
resource
.
fsPath
:
''
;
this
.
_workspaceRoot
=
paths
.
normalize
(
fsPath
,
true
);
this
.
_execPath
=
environmentService
.
execPath
;
Object
.
keys
(
process
.
env
).
forEach
(
key
=>
{
this
[
`env.
${
key
}
`
]
=
process
.
env
[
key
];
});
}
private
get
execPath
():
string
{
return
this
.
_execPath
;
}
private
get
cwd
():
string
{
return
this
.
workspaceRoot
;
}
private
get
workspaceRoot
():
string
{
return
this
.
_workspaceRoot
;
}
private
get
file
():
string
{
return
this
.
getFilePath
();
}
private
get
relativeFile
():
string
{
return
(
this
.
workspaceRoot
)
?
paths
.
relative
(
this
.
workspaceRoot
,
this
.
file
)
:
this
.
file
;
}
private
get
fileBasename
():
string
{
return
paths
.
basename
(
this
.
getFilePath
());
}
private
get
fileDirname
():
string
{
return
paths
.
dirname
(
this
.
getFilePath
());
}
private
get
fileExtname
():
string
{
return
paths
.
extname
(
this
.
getFilePath
());
}
private
getFilePath
():
string
{
let
input
=
this
.
editorService
.
getActiveEditorInput
();
if
(
!
input
)
{
return
''
;
}
let
fileEditorInput
=
asFileEditorInput
(
input
);
if
(
!
fileEditorInput
)
{
return
''
;
}
let
resource
=
fileEditorInput
.
getResource
();
return
paths
.
normalize
(
resource
.
fsPath
,
true
);
}
public
resolve
(
value
:
string
):
string
;
public
resolve
(
value
:
string
[]):
string
[];
public
resolve
(
value
:
IStringDictionary
<
string
>
):
IStringDictionary
<
string
>
;
public
resolve
(
value
:
IStringDictionary
<
string
[]
>
):
IStringDictionary
<
string
[]
>
;
public
resolve
(
value
:
IStringDictionary
<
IStringDictionary
<
string
>>
):
IStringDictionary
<
IStringDictionary
<
string
>>
;
public
resolve
(
value
:
any
):
any
{
if
(
types
.
isString
(
value
))
{
return
this
.
resolveString
(
value
);
}
else
if
(
types
.
isArray
(
value
))
{
return
this
.
__resolveArray
(
value
);
}
else
if
(
types
.
isObject
(
value
))
{
return
this
.
__resolveLiteral
(
value
);
}
return
value
;
}
public
resolveAny
<
T
>
(
value
:
T
):
T
;
public
resolveAny
<
T
>
(
value
:
any
):
any
{
if
(
types
.
isString
(
value
))
{
return
this
.
resolveString
(
value
);
}
else
if
(
types
.
isArray
(
value
))
{
return
this
.
__resolveAnyArray
(
value
);
}
else
if
(
types
.
isObject
(
value
))
{
return
this
.
__resolveAnyLiteral
(
value
);
}
return
value
;
}
protected
resolveString
(
value
:
string
):
string
{
let
regexp
=
/
\$\{(
.*
?)\}
/g
;
return
value
.
replace
(
regexp
,
(
match
:
string
,
name
:
string
)
=>
{
let
newValue
=
(
<
any
>
this
)[
name
];
if
(
types
.
isString
(
newValue
))
{
return
newValue
;
}
else
{
return
match
&&
match
.
indexOf
(
'
env.
'
)
>
0
?
''
:
match
;
}
});
}
private
__resolveLiteral
(
values
:
IStringDictionary
<
string
|
IStringDictionary
<
string
>
|
string
[]
>
):
IStringDictionary
<
string
|
IStringDictionary
<
string
>
|
string
[]
>
{
let
result
:
IStringDictionary
<
string
|
IStringDictionary
<
string
>
|
string
[]
>
=
Object
.
create
(
null
);
Object
.
keys
(
values
).
forEach
(
key
=>
{
let
value
=
values
[
key
];
result
[
key
]
=
<
any
>
this
.
resolve
(
<
any
>
value
);
});
return
result
;
}
private
__resolveAnyLiteral
<
T
>
(
values
:
T
):
T
;
private
__resolveAnyLiteral
<
T
>
(
values
:
any
):
any
{
let
result
:
IStringDictionary
<
string
|
IStringDictionary
<
string
>
|
string
[]
>
=
Object
.
create
(
null
);
Object
.
keys
(
values
).
forEach
(
key
=>
{
let
value
=
values
[
key
];
result
[
key
]
=
<
any
>
this
.
resolveAny
(
<
any
>
value
);
});
return
result
;
}
private
__resolveArray
(
value
:
string
[]):
string
[]
{
return
value
.
map
(
s
=>
this
.
resolveString
(
s
));
}
private
__resolveAnyArray
<
T
>
(
value
:
T
[]):
T
[];
private
__resolveAnyArray
(
value
:
any
[]):
any
[]
{
return
value
.
map
(
s
=>
this
.
resolveAny
(
s
));
}
}
src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts
0 → 100644
浏览文件 @
67549490
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
assert
=
require
(
'
assert
'
);
suite
(
'
Configuration Resolver Service
'
,
()
=>
{
test
(
'
fake
'
,
()
=>
{
assert
.
equal
(
true
,
true
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录