Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6d8e64ee
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,发现更多精彩内容 >>
提交
6d8e64ee
编写于
5月 18, 2017
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add error handler for reader
上级
288968f8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
31 deletion
+39
-31
extensions/typescript/src/typescriptServiceClient.ts
extensions/typescript/src/typescriptServiceClient.ts
+19
-19
extensions/typescript/src/utils/wireProtocol.ts
extensions/typescript/src/utils/wireProtocol.ts
+20
-12
未找到文件。
extensions/typescript/src/typescriptServiceClient.ts
浏览文件 @
6d8e64ee
...
...
@@ -328,7 +328,9 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
private
logTrace
(
message
:
string
,
data
?:
any
):
void
{
this
.
logger
.
logLevel
(
'
Trace
'
,
message
,
data
);
if
(
this
.
trace
!==
Trace
.
Off
)
{
this
.
logger
.
logLevel
(
'
Trace
'
,
message
,
data
);
}
}
public
logTelemetry
(
eventName
:
string
,
properties
?:
{
[
prop
:
string
]:
string
})
{
...
...
@@ -464,13 +466,14 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
let
value
=
process
.
env
.
TSS_DEBUG
;
if
(
value
)
{
le
t
port
=
parseInt
(
value
);
cons
t
port
=
parseInt
(
value
);
if
(
!
isNaN
(
port
))
{
this
.
info
(
`TSServer started in debug mode using port
${
port
}
`
);
options
.
execArgv
=
[
`--debug=
${
port
}
`
];
}
}
let
args
:
string
[]
=
[];
const
args
:
string
[]
=
[];
if
(
this
.
apiVersion
.
has206Features
())
{
args
.
push
(
'
--useSingleInferredProject
'
);
if
(
workspace
.
getConfiguration
().
get
<
boolean
>
(
'
typescript.disableAutomaticTypeAcquisition
'
,
false
))
{
...
...
@@ -540,9 +543,12 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
this
.
serviceExited
(
true
);
});
this
.
reader
=
new
Reader
<
Proto
.
Response
>
(
childProcess
.
stdout
,
(
msg
)
=>
{
this
.
dispatchMessage
(
msg
);
});
this
.
reader
=
new
Reader
<
Proto
.
Response
>
(
childProcess
.
stdout
,
(
msg
)
=>
{
this
.
dispatchMessage
(
msg
);
},
error
=>
{
this
.
error
(
'
ReaderError
'
,
error
);
});
this
.
_onReady
.
resolve
();
resolve
(
childProcess
);
this
.
serviceStarted
(
resendModels
);
...
...
@@ -759,7 +765,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
});
this
.
callbacks
=
Object
.
create
(
null
);
if
(
restart
)
{
le
t
diff
=
Date
.
now
()
-
this
.
lastStart
;
cons
t
diff
=
Date
.
now
()
-
this
.
lastStart
;
this
.
numberRestarts
++
;
let
startService
=
true
;
if
(
this
.
numberRestarts
>
5
)
{
...
...
@@ -902,17 +908,13 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
for
(
let
i
=
0
;
i
<
this
.
requestQueue
.
length
;
i
++
)
{
if
(
this
.
requestQueue
[
i
].
request
.
seq
===
seq
)
{
this
.
requestQueue
.
splice
(
i
,
1
);
if
(
this
.
trace
!==
Trace
.
Off
)
{
this
.
logTrace
(
`TypeScript Service: canceled request with sequence number
${
seq
}
`
);
}
this
.
logTrace
(
`TypeScript Service: canceled request with sequence number
${
seq
}
`
);
return
true
;
}
}
if
(
this
.
apiVersion
.
has222Features
()
&&
this
.
cancellationPipeName
)
{
if
(
this
.
trace
!==
Trace
.
Off
)
{
this
.
logTrace
(
`TypeScript Service: trying to cancel ongoing request with sequence number
${
seq
}
`
);
}
this
.
logTrace
(
`TypeScript Service: trying to cancel ongoing request with sequence number
${
seq
}
`
);
try
{
fs
.
writeFileSync
(
this
.
cancellationPipeName
+
seq
,
''
);
return
true
;
...
...
@@ -921,17 +923,15 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
}
if
(
this
.
trace
!==
Trace
.
Off
)
{
this
.
logTrace
(
`TypeScript Service: tried to cancel request with sequence number
${
seq
}
. But request got already delivered.`
);
}
this
.
logTrace
(
`TypeScript Service: tried to cancel request with sequence number
${
seq
}
. But request got already delivered.`
);
return
false
;
}
private
dispatchMessage
(
message
:
Proto
.
Message
):
void
{
try
{
if
(
message
.
type
===
'
response
'
)
{
let
response
:
Proto
.
Response
=
<
Proto
.
Response
>
messag
e
;
le
t
p
=
this
.
callbacks
[
response
.
request_seq
];
const
response
:
Proto
.
Response
=
message
as
Proto
.
Respons
e
;
cons
t
p
=
this
.
callbacks
[
response
.
request_seq
];
if
(
p
)
{
this
.
traceResponse
(
response
,
p
.
start
);
delete
this
.
callbacks
[
response
.
request_seq
];
...
...
@@ -943,7 +943,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
}
}
else
if
(
message
.
type
===
'
event
'
)
{
le
t
event
:
Proto
.
Event
=
<
Proto
.
Event
>
message
;
cons
t
event
:
Proto
.
Event
=
<
Proto
.
Event
>
message
;
this
.
traceEvent
(
event
);
if
(
event
.
event
===
'
syntaxDiag
'
)
{
this
.
host
.
syntaxDiagnosticsReceived
(
event
as
Proto
.
DiagnosticEvent
);
...
...
extensions/typescript/src/utils/wireProtocol.ts
浏览文件 @
6d8e64ee
...
...
@@ -96,7 +96,11 @@ export class Reader<T> {
private
readonly
buffer
:
ProtocolBuffer
;
private
nextMessageLength
:
number
;
public
constructor
(
readable
:
stream
.
Readable
,
callback
:
ICallback
<
T
>
)
{
public
constructor
(
readable
:
stream
.
Readable
,
callback
:
ICallback
<
T
>
,
private
readonly
onError
:
(
error
:
any
)
=>
void
=
()
=>
({})
)
{
this
.
readable
=
readable
;
this
.
buffer
=
new
ProtocolBuffer
();
this
.
callback
=
callback
;
...
...
@@ -107,21 +111,25 @@ export class Reader<T> {
}
private
onLengthData
(
data
:
Buffer
):
void
{
this
.
buffer
.
append
(
data
);
while
(
true
)
{
if
(
this
.
nextMessageLength
===
-
1
)
{
this
.
nextMessageLength
=
this
.
buffer
.
tryReadContentLength
();
try
{
this
.
buffer
.
append
(
data
);
while
(
true
)
{
if
(
this
.
nextMessageLength
===
-
1
)
{
this
.
nextMessageLength
=
this
.
buffer
.
tryReadContentLength
();
if
(
this
.
nextMessageLength
===
-
1
)
{
return
;
}
}
const
msg
=
this
.
buffer
.
tryReadContent
(
this
.
nextMessageLength
);
if
(
msg
===
null
)
{
return
;
}
this
.
nextMessageLength
=
-
1
;
const
json
=
JSON
.
parse
(
msg
);
this
.
callback
(
json
);
}
const
msg
=
this
.
buffer
.
tryReadContent
(
this
.
nextMessageLength
);
if
(
msg
===
null
)
{
return
;
}
this
.
nextMessageLength
=
-
1
;
let
json
=
JSON
.
parse
(
msg
);
this
.
callback
(
json
);
}
catch
(
e
)
{
this
.
onError
(
e
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录