Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1800eaf8
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,发现更多精彩内容 >>
提交
1800eaf8
编写于
3月 29, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
restart worker when defaults change
上级
a80db720
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
28 deletion
+36
-28
src/vs/languages/typescript/common/typescript.ts
src/vs/languages/typescript/common/typescript.ts
+8
-18
src/vs/languages/typescript/common/worker/worker.ts
src/vs/languages/typescript/common/worker/worker.ts
+4
-0
src/vs/languages/typescript/common/worker/workerManager.ts
src/vs/languages/typescript/common/worker/workerManager.ts
+24
-10
未找到文件。
src/vs/languages/typescript/common/typescript.ts
浏览文件 @
1800eaf8
...
...
@@ -10,21 +10,15 @@ import * as ts from 'vs/languages/typescript/common/lib/typescriptServices';
export
class
LanguageServiceDefaults
{
private
_onDidChange
=
new
Emitter
<
LanguageServiceDefaults
>
();
private
_compilerOptions
:
ts
.
CompilerOptions
=
{
allowNonTsExtensions
:
true
,
target
:
ts
.
ScriptTarget
.
Latest
};
private
_onDidChangeCompilerOptions
=
new
Emitter
<
ts
.
CompilerOptions
>
();
private
_extraLibs
:
{
[
path
:
string
]:
string
}
=
Object
.
create
(
null
);
private
_onDidAddExtraLib
=
new
Emitter
<
string
>
();
private
_onDidRemoveExtraLib
=
new
Emitter
<
string
>
();
get
onDid
AddExtraLibs
():
Event
<
string
>
{
return
this
.
_onDid
AddExtraLib
.
event
;
get
onDid
Change
():
Event
<
LanguageServiceDefaults
>
{
return
this
.
_onDid
Change
.
event
;
}
get
onDidRemoveExtraLib
():
Event
<
string
>
{
return
this
.
_onDidRemoveExtraLib
.
event
;
}
getExtraLibs
():
{
[
path
:
string
]:
string
}
{
get
extraLibs
():
{
[
path
:
string
]:
string
}
{
return
Object
.
freeze
(
this
.
_extraLibs
);
}
...
...
@@ -38,28 +32,24 @@ export class LanguageServiceDefaults {
}
this
.
_extraLibs
[
filePath
]
=
content
;
this
.
_onDid
AddExtraLib
.
fire
(
filePath
);
this
.
_onDid
Change
.
fire
(
this
);
return
{
dispose
:
()
=>
{
if
(
delete
this
.
_extraLibs
[
filePath
])
{
this
.
_onDid
RemoveExtraLib
.
fire
(
filePath
);
this
.
_onDid
Change
.
fire
(
this
);
}
}
};
}
get
onDidChangeCompilerOptions
():
Event
<
ts
.
CompilerOptions
>
{
return
this
.
_onDidChangeCompilerOptions
.
event
;
}
getCompilerOptions
():
ts
.
CompilerOptions
{
get
compilerOptions
():
ts
.
CompilerOptions
{
return
this
.
_compilerOptions
;
}
setCompilerOptions
(
options
:
ts
.
CompilerOptions
):
void
{
this
.
_compilerOptions
=
options
||
Object
.
create
(
null
);
this
.
_onDidChange
CompilerOptions
.
fire
(
this
.
_compilerOption
s
);
this
.
_onDidChange
.
fire
(
thi
s
);
}
}
...
...
src/vs/languages/typescript/common/worker/worker.ts
浏览文件 @
1800eaf8
...
...
@@ -39,6 +39,10 @@ abstract class AbstractWorker implements IRequestHandler {
throw
notImplemented
();
}
acceptExtraLib
(
fileName
:
string
,
content
:
string
):
TPromise
<
void
>
{
throw
notImplemented
();
}
// --- language features
getCompletionsAtPosition
(
uri
:
string
,
offset
:
number
):
TPromise
<
ts
.
CompletionInfo
>
{
...
...
src/vs/languages/typescript/common/worker/workerManager.ts
浏览文件 @
1800eaf8
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
forEach
}
from
'
vs/base/common/collections
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
,
disposeAll
}
from
'
vs/base/common/lifecycle
'
;
import
{
DefaultWorkerFactory
}
from
'
vs/base/worker/defaultWorkerFactory
'
;
...
...
@@ -26,28 +27,41 @@ class Client {
}
private
_createClient
():
TPromise
<
AbstractWorker
>
{
let
client
=
new
SimpleWorkerClient
<
AbstractWorker
>
(
this
.
_factory
,
this
.
_clientDispose
=
[];
let
client
=
new
SimpleWorkerClient
<
AbstractWorker
>
(
this
.
_factory
,
'
vs/languages/typescript/common/worker/workerImpl
'
,
AbstractWorker
);
this
.
_clientDispose
.
push
(
client
);
this
.
_clientDispose
=
[];
const
stopWorker
=
()
=>
{
this
.
_clientDispose
=
disposeAll
(
this
.
_clientDispose
);
this
.
_client
=
null
;
client
=
null
;
};
// stop worker after being idle
const
handle
=
setInterval
(()
=>
{
if
(
Date
.
now
()
-
client
.
getLastRequestTimestamp
()
>
1000
*
60
)
{
this
.
_clientDispose
=
disposeAll
(
this
.
_clientDispose
);
this
.
_client
=
null
;
client
=
null
;
stopWorker
();
}
},
1000
*
60
);
this
.
_clientDispose
.
push
({
dispose
()
{
clearInterval
(
handle
);
}
});
this
.
_clientDispose
.
push
(
client
);
// stop worker when defaults change
this
.
_clientDispose
.
push
(
Defaults
.
onDidChange
(()
=>
stopWorker
()));
// send default to worker right away
const
worker
=
client
.
get
();
this
.
_clientDispose
.
push
(
Defaults
.
onDidChangeCompilerOptions
(
options
=>
worker
.
acceptCompilerOptions
(
options
)));
const
promises
:
TPromise
<
any
>
[]
=
[];
promises
.
push
(
worker
.
acceptCompilerOptions
(
Defaults
.
compilerOptions
));
forEach
(
Defaults
.
extraLibs
,
entry
=>
promises
.
push
(
worker
.
acceptExtraLib
(
entry
.
key
,
entry
.
value
)));
return
worker
.
acceptCompilerOptions
(
Defaults
.
getCompilerOptions
()).
then
(()
=>
worker
);
return
TPromise
.
join
(
promises
).
then
(()
=>
{
promises
.
length
=
0
;
return
worker
;
});
}
dispose
():
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录