Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0871300c
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,发现更多精彩内容 >>
提交
0871300c
编写于
8月 14, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract LazyPromise to its own file
上级
4d853d3f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
111 addition
and
103 deletion
+111
-103
src/vs/workbench/services/extensions/node/ipcRemoteCom.ts
src/vs/workbench/services/extensions/node/ipcRemoteCom.ts
+1
-103
src/vs/workbench/services/extensions/node/lazyPromise.ts
src/vs/workbench/services/extensions/node/lazyPromise.ts
+110
-0
未找到文件。
src/vs/workbench/services/extensions/node/ipcRemoteCom.ts
浏览文件 @
0871300c
...
...
@@ -8,6 +8,7 @@ import winjs = require('vs/base/common/winjs.base');
import
marshalling
=
require
(
'
vs/base/common/marshalling
'
);
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
LazyPromise
}
from
"
vs/workbench/services/extensions/node/lazyPromise
"
;
interface
IRPCFunc
{
(
rpcId
:
string
,
method
:
string
,
args
:
any
[]):
winjs
.
TPromise
<
any
>
;
...
...
@@ -40,109 +41,6 @@ class MessageFactory {
}
}
class
LazyPromise
{
private
_onCancel
:
()
=>
void
;
private
_actual
:
winjs
.
TPromise
<
any
>
;
private
_actualOk
:
winjs
.
ValueCallback
;
private
_actualErr
:
winjs
.
ErrorCallback
;
private
_hasValue
:
boolean
;
private
_value
:
any
;
private
_hasErr
:
boolean
;
private
_err
:
any
;
private
_isCanceled
:
boolean
;
constructor
(
onCancel
:
()
=>
void
)
{
this
.
_onCancel
=
onCancel
;
this
.
_actual
=
null
;
this
.
_actualOk
=
null
;
this
.
_actualErr
=
null
;
this
.
_hasValue
=
false
;
this
.
_value
=
null
;
this
.
_hasErr
=
false
;
this
.
_err
=
null
;
this
.
_isCanceled
=
false
;
}
private
_ensureActual
():
winjs
.
TPromise
<
any
>
{
if
(
!
this
.
_actual
)
{
this
.
_actual
=
new
winjs
.
TPromise
<
any
>
((
c
,
e
)
=>
{
this
.
_actualOk
=
c
;
this
.
_actualErr
=
e
;
},
this
.
_onCancel
);
if
(
this
.
_hasValue
)
{
this
.
_actualOk
(
this
.
_value
);
}
if
(
this
.
_hasErr
)
{
this
.
_actualErr
(
this
.
_err
);
}
}
return
this
.
_actual
;
}
public
resolveOk
(
value
:
any
):
void
{
if
(
this
.
_isCanceled
||
this
.
_hasErr
)
{
return
;
}
this
.
_hasValue
=
true
;
this
.
_value
=
value
;
if
(
this
.
_actual
)
{
this
.
_actualOk
(
value
);
}
}
public
resolveErr
(
err
:
any
):
void
{
if
(
this
.
_isCanceled
||
this
.
_hasValue
)
{
return
;
}
this
.
_hasErr
=
true
;
this
.
_err
=
err
;
if
(
this
.
_actual
)
{
this
.
_actualErr
(
err
);
}
}
public
then
(
success
:
any
,
error
:
any
):
any
{
if
(
this
.
_isCanceled
)
{
return
;
}
return
this
.
_ensureActual
().
then
(
success
,
error
);
}
public
done
(
success
:
any
,
error
:
any
):
void
{
if
(
this
.
_isCanceled
)
{
return
;
}
this
.
_ensureActual
().
done
(
success
,
error
);
}
public
cancel
():
void
{
if
(
this
.
_hasValue
||
this
.
_hasErr
)
{
return
;
}
this
.
_isCanceled
=
true
;
if
(
this
.
_actual
)
{
this
.
_actual
.
cancel
();
}
else
{
this
.
_onCancel
();
}
}
}
function
createRPC
(
serializeAndSend
:
(
value
:
string
)
=>
void
):
IRPCFunc
{
return
function
rpc
(
rpcId
:
string
,
method
:
string
,
args
:
any
[]):
winjs
.
TPromise
<
any
>
{
...
...
src/vs/workbench/services/extensions/node/lazyPromise.ts
0 → 100644
浏览文件 @
0871300c
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
,
ValueCallback
,
ErrorCallback
}
from
'
vs/base/common/winjs.base
'
;
export
class
LazyPromise
{
private
_onCancel
:
()
=>
void
;
private
_actual
:
TPromise
<
any
>
;
private
_actualOk
:
ValueCallback
;
private
_actualErr
:
ErrorCallback
;
private
_hasValue
:
boolean
;
private
_value
:
any
;
private
_hasErr
:
boolean
;
private
_err
:
any
;
private
_isCanceled
:
boolean
;
constructor
(
onCancel
:
()
=>
void
)
{
this
.
_onCancel
=
onCancel
;
this
.
_actual
=
null
;
this
.
_actualOk
=
null
;
this
.
_actualErr
=
null
;
this
.
_hasValue
=
false
;
this
.
_value
=
null
;
this
.
_hasErr
=
false
;
this
.
_err
=
null
;
this
.
_isCanceled
=
false
;
}
private
_ensureActual
():
TPromise
<
any
>
{
if
(
!
this
.
_actual
)
{
this
.
_actual
=
new
TPromise
<
any
>
((
c
,
e
)
=>
{
this
.
_actualOk
=
c
;
this
.
_actualErr
=
e
;
},
this
.
_onCancel
);
if
(
this
.
_hasValue
)
{
this
.
_actualOk
(
this
.
_value
);
}
if
(
this
.
_hasErr
)
{
this
.
_actualErr
(
this
.
_err
);
}
}
return
this
.
_actual
;
}
public
resolveOk
(
value
:
any
):
void
{
if
(
this
.
_isCanceled
||
this
.
_hasErr
)
{
return
;
}
this
.
_hasValue
=
true
;
this
.
_value
=
value
;
if
(
this
.
_actual
)
{
this
.
_actualOk
(
value
);
}
}
public
resolveErr
(
err
:
any
):
void
{
if
(
this
.
_isCanceled
||
this
.
_hasValue
)
{
return
;
}
this
.
_hasErr
=
true
;
this
.
_err
=
err
;
if
(
this
.
_actual
)
{
this
.
_actualErr
(
err
);
}
}
public
then
(
success
:
any
,
error
:
any
):
any
{
if
(
this
.
_isCanceled
)
{
return
;
}
return
this
.
_ensureActual
().
then
(
success
,
error
);
}
public
done
(
success
:
any
,
error
:
any
):
void
{
if
(
this
.
_isCanceled
)
{
return
;
}
this
.
_ensureActual
().
done
(
success
,
error
);
}
public
cancel
():
void
{
if
(
this
.
_hasValue
||
this
.
_hasErr
)
{
return
;
}
this
.
_isCanceled
=
true
;
if
(
this
.
_actual
)
{
this
.
_actual
.
cancel
();
}
else
{
this
.
_onCancel
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录