Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a8216d42
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,发现更多精彩内容 >>
提交
a8216d42
编写于
2月 11, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the typescript plugins contribution point dynamic
Part of #67575
上级
ebff3af5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
16 deletion
+59
-16
extensions/typescript-language-features/src/typescriptServiceClient.ts
...pescript-language-features/src/typescriptServiceClient.ts
+4
-0
extensions/typescript-language-features/src/utils/plugins.ts
extensions/typescript-language-features/src/utils/plugins.ts
+55
-16
未找到文件。
extensions/typescript-language-features/src/typescriptServiceClient.ts
浏览文件 @
a8216d42
...
...
@@ -166,6 +166,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this
.
_register
(
this
.
pluginManager
.
onDidUpdateConfig
(
update
=>
{
this
.
configurePlugin
(
update
.
pluginId
,
update
.
config
);
}));
this
.
_register
(
this
.
pluginManager
.
onDidChangePlugins
(()
=>
{
this
.
restartTsServer
();
}));
}
public
get
configuration
()
{
...
...
extensions/typescript-language-features/src/utils/plugins.ts
浏览文件 @
a8216d42
...
...
@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
vscode
from
'
vscode
'
;
import
*
as
arrays
from
'
./arrays
'
;
import
{
Disposable
}
from
'
./dispose
'
;
import
{
memoize
}
from
'
./memoize
'
;
export
interface
TypeScriptServerPlugin
{
readonly
path
:
string
;
...
...
@@ -14,28 +14,45 @@ export interface TypeScriptServerPlugin {
readonly
languages
:
ReadonlyArray
<
string
>
;
}
namespace
TypeScriptServerPlugin
{
export
function
equals
(
a
:
TypeScriptServerPlugin
,
b
:
TypeScriptServerPlugin
):
boolean
{
return
a
.
path
===
b
.
path
&&
a
.
name
===
b
.
name
&&
a
.
enableForWorkspaceTypeScriptVersions
===
b
.
enableForWorkspaceTypeScriptVersions
&&
arrays
.
equals
(
a
.
languages
,
b
.
languages
);
}
}
export
class
PluginManager
extends
Disposable
{
private
readonly
_pluginConfigurations
=
new
Map
<
string
,
{}
>
();
@
memoize
public
get
plugins
():
ReadonlyArray
<
TypeScriptServerPlugin
>
{
const
plugins
:
TypeScriptServerPlugin
[]
=
[];
for
(
const
extension
of
vscode
.
extensions
.
all
)
{
const
pack
=
extension
.
packageJSON
;
if
(
pack
.
contributes
&&
Array
.
isArray
(
pack
.
contributes
.
typescriptServerPlugins
))
{
for
(
const
plugin
of
pack
.
contributes
.
typescriptServerPlugins
)
{
plugins
.
push
({
name
:
plugin
.
name
,
enableForWorkspaceTypeScriptVersions
:
!!
plugin
.
enableForWorkspaceTypeScriptVersions
,
path
:
extension
.
extensionPath
,
languages
:
Array
.
isArray
(
plugin
.
languages
)
?
plugin
.
languages
:
[],
});
}
private
_plugins
:
Map
<
string
,
ReadonlyArray
<
TypeScriptServerPlugin
>>
|
undefined
;
constructor
()
{
super
();
vscode
.
extensions
.
onDidChange
(()
=>
{
if
(
!
this
.
_plugins
)
{
return
;
}
const
newPlugins
=
this
.
readPlugins
();
if
(
!
arrays
.
equals
(
arrays
.
flatten
(
Array
.
from
(
this
.
_plugins
.
values
())),
arrays
.
flatten
(
Array
.
from
(
newPlugins
.
values
())),
TypeScriptServerPlugin
.
equals
))
{
this
.
_plugins
=
newPlugins
;
this
.
_onDidUpdatePlugins
.
fire
(
this
);
}
},
undefined
,
this
.
_disposables
);
}
public
get
plugins
():
ReadonlyArray
<
TypeScriptServerPlugin
>
{
if
(
!
this
.
_plugins
)
{
this
.
_plugins
=
this
.
readPlugins
();
}
return
plugins
;
return
arrays
.
flatten
(
Array
.
from
(
this
.
_plugins
.
values
()))
;
}
private
readonly
_onDidUpdatePlugins
=
this
.
_register
(
new
vscode
.
EventEmitter
<
this
>
());
public
readonly
onDidChangePlugins
=
this
.
_onDidUpdatePlugins
.
event
;
private
readonly
_onDidUpdateConfig
=
this
.
_register
(
new
vscode
.
EventEmitter
<
{
pluginId
:
string
,
config
:
{}
}
>
());
public
readonly
onDidUpdateConfig
=
this
.
_onDidUpdateConfig
.
event
;
...
...
@@ -47,4 +64,26 @@ export class PluginManager extends Disposable {
public
configurations
():
IterableIterator
<
[
string
,
{}]
>
{
return
this
.
_pluginConfigurations
.
entries
();
}
private
readPlugins
()
{
const
pluginMap
=
new
Map
<
string
,
ReadonlyArray
<
TypeScriptServerPlugin
>>
();
for
(
const
extension
of
vscode
.
extensions
.
all
)
{
const
pack
=
extension
.
packageJSON
;
if
(
pack
.
contributes
&&
Array
.
isArray
(
pack
.
contributes
.
typescriptServerPlugins
))
{
const
plugins
:
TypeScriptServerPlugin
[]
=
[];
for
(
const
plugin
of
pack
.
contributes
.
typescriptServerPlugins
)
{
plugins
.
push
({
name
:
plugin
.
name
,
enableForWorkspaceTypeScriptVersions
:
!!
plugin
.
enableForWorkspaceTypeScriptVersions
,
path
:
extension
.
extensionPath
,
languages
:
Array
.
isArray
(
plugin
.
languages
)
?
plugin
.
languages
:
[],
});
}
if
(
plugins
.
length
)
{
pluginMap
.
set
(
extension
.
id
,
plugins
);
}
}
}
return
pluginMap
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录