Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4d29f5d2
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,发现更多精彩内容 >>
提交
4d29f5d2
编写于
1月 08, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use const enum and namespace
上级
c723a054
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
47 deletion
+53
-47
src/vs/workbench/services/progress/browser/progressService.ts
...vs/workbench/services/progress/browser/progressService.ts
+53
-47
未找到文件。
src/vs/workbench/services/progress/browser/progressService.ts
浏览文件 @
4d29f5d2
...
...
@@ -11,38 +11,44 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import
{
IProgressService
,
IProgressRunner
}
from
'
vs/platform/progress/common/progress
'
;
const
NoneProgressState
=
new
class
{
readonly
type
=
'
none
'
;
};
const
DoneProgressState
=
new
class
{
readonly
type
=
'
done
'
;
};
const
InfiniteProgressState
=
new
class
{
readonly
type
=
'
infinite
'
;
};
class
WhileProgressState
{
static
readonly
type
=
'
while
'
;
public
readonly
type
=
WhileProgressState
.
type
;
namespace
ProgressState
{
export
const
enum
Type
{
None
,
Done
,
Infinite
,
While
,
Work
}
constructor
(
public
readonly
whilePromise
:
Promise
<
any
>
,
public
readonly
whileStart
:
number
,
public
readonly
whileDelay
:
number
,
)
{
}
}
export
const
None
=
new
class
{
readonly
type
=
Type
.
None
;
};
export
const
Done
=
new
class
{
readonly
type
=
Type
.
Done
;
};
export
const
Infinite
=
new
class
{
readonly
type
=
Type
.
Infinite
;
};
export
class
While
{
public
readonly
type
=
Type
.
While
;
constructor
(
public
readonly
whilePromise
:
Promise
<
any
>
,
public
readonly
whileStart
:
number
,
public
readonly
whileDelay
:
number
,
)
{
}
}
class
WorkProgressState
{
static
readonly
type
=
'
work
'
;
public
readonly
type
=
WorkProgressState
.
type
;
export
class
Work
{
public
readonly
type
=
Type
.
Work
;
constructor
(
public
readonly
total
:
number
|
undefined
,
public
readonly
worked
:
number
|
undefined
)
{
}
}
constructor
(
public
readonly
total
:
number
|
undefined
,
public
readonly
worked
:
number
|
undefined
)
{
}
export
type
State
=
typeof
None
|
typeof
Done
|
typeof
Infinite
|
While
|
Work
;
}
type
ProgressState
=
typeof
NoneProgressState
|
typeof
DoneProgressState
|
typeof
InfiniteProgressState
|
WhileProgressState
|
WorkProgressState
;
export
abstract
class
ScopedService
extends
Disposable
{
constructor
(
private
viewletService
:
IViewletService
,
private
panelService
:
IPanelService
,
private
scopeId
:
string
)
{
...
...
@@ -80,7 +86,7 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
_serviceBrand
:
any
;
private
isActive
:
boolean
;
private
progressbar
:
ProgressBar
;
private
progressState
:
ProgressState
=
NoneProgressStat
e
;
private
progressState
:
ProgressState
.
State
=
ProgressState
.
Non
e
;
constructor
(
progressbar
:
ProgressBar
,
...
...
@@ -103,12 +109,12 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
this
.
isActive
=
true
;
// Return early if progress state indicates that progress is done
if
(
this
.
progressState
.
type
===
DoneProgressStat
e
.
type
)
{
if
(
this
.
progressState
.
type
===
ProgressState
.
Don
e
.
type
)
{
return
;
}
// Replay Infinite Progress from Promise
if
(
this
.
progressState
.
type
===
WhileProgressState
.
typ
e
)
{
if
(
this
.
progressState
.
type
===
ProgressState
.
Type
.
Whil
e
)
{
let
delay
:
number
|
undefined
;
if
(
this
.
progressState
.
whileDelay
>
0
)
{
const
remainingDelay
=
this
.
progressState
.
whileDelay
-
(
Date
.
now
()
-
this
.
progressState
.
whileStart
);
...
...
@@ -121,12 +127,12 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
}
// Replay Infinite Progress
else
if
(
this
.
progressState
.
type
===
InfiniteProgressSta
te
.
type
)
{
else
if
(
this
.
progressState
.
type
===
ProgressState
.
Infini
te
.
type
)
{
this
.
progressbar
.
infinite
().
show
();
}
// Replay Finite Progress (Total & Worked)
else
if
(
this
.
progressState
.
type
===
WorkProgressState
.
type
)
{
else
if
(
this
.
progressState
.
type
===
ProgressState
.
Type
.
Work
)
{
if
(
this
.
progressState
.
total
)
{
this
.
progressbar
.
total
(
this
.
progressState
.
total
).
show
();
}
...
...
@@ -142,30 +148,30 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
show
(
infiniteOrTotal
:
boolean
|
number
,
delay
?:
number
):
IProgressRunner
{
// Sort out Arguments
if
(
typeof
infiniteOrTotal
===
'
boolean
'
)
{
this
.
progressState
=
InfiniteProgressSta
te
;
this
.
progressState
=
ProgressState
.
Infini
te
;
}
else
{
this
.
progressState
=
new
WorkProgressState
(
infiniteOrTotal
,
undefined
);
this
.
progressState
=
new
ProgressState
.
Work
(
infiniteOrTotal
,
undefined
);
}
// Active: Show Progress
if
(
this
.
isActive
)
{
// Infinite: Start Progressbar and Show after Delay
if
(
this
.
progressState
.
type
===
InfiniteProgressSta
te
.
type
)
{
if
(
this
.
progressState
.
type
===
ProgressState
.
Infini
te
.
type
)
{
this
.
progressbar
.
infinite
().
show
(
delay
);
}
// Finite: Start Progressbar and Show after Delay
else
if
(
this
.
progressState
.
type
===
WorkProgressState
.
type
&&
typeof
this
.
progressState
.
total
===
'
number
'
)
{
else
if
(
this
.
progressState
.
type
===
ProgressState
.
Type
.
Work
&&
typeof
this
.
progressState
.
total
===
'
number
'
)
{
this
.
progressbar
.
total
(
this
.
progressState
.
total
).
show
(
delay
);
}
}
return
{
total
:
(
total
:
number
)
=>
{
this
.
progressState
=
new
WorkProgressState
(
this
.
progressState
=
new
ProgressState
.
Work
(
total
,
this
.
progressState
.
type
===
WorkProgressState
.
type
?
this
.
progressState
.
worked
:
undefined
);
this
.
progressState
.
type
===
ProgressState
.
Type
.
Work
?
this
.
progressState
.
worked
:
undefined
);
if
(
this
.
isActive
)
{
this
.
progressbar
.
total
(
total
);
...
...
@@ -176,9 +182,9 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
// Verify first that we are either not active or the progressbar has a total set
if
(
!
this
.
isActive
||
this
.
progressbar
.
hasTotal
())
{
this
.
progressState
=
new
WorkProgressState
(
this
.
progressState
.
type
===
WorkProgressState
.
type
?
this
.
progressState
.
total
:
undefined
,
this
.
progressState
.
type
===
WorkProgressState
.
type
&&
typeof
this
.
progressState
.
worked
===
'
number
'
?
this
.
progressState
.
worked
+
worked
:
worked
);
this
.
progressState
=
new
ProgressState
.
Work
(
this
.
progressState
.
type
===
ProgressState
.
Type
.
Work
?
this
.
progressState
.
total
:
undefined
,
this
.
progressState
.
type
===
ProgressState
.
Type
.
Work
&&
typeof
this
.
progressState
.
worked
===
'
number
'
?
this
.
progressState
.
worked
+
worked
:
worked
);
if
(
this
.
isActive
)
{
this
.
progressbar
.
worked
(
worked
);
...
...
@@ -187,13 +193,13 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
// Otherwise the progress bar does not support worked(), we fallback to infinite() progress
else
{
this
.
progressState
=
InfiniteProgressSta
te
;
this
.
progressState
=
ProgressState
.
Infini
te
;
this
.
progressbar
.
infinite
().
show
();
}
},
done
:
()
=>
{
this
.
progressState
=
DoneProgressStat
e
;
this
.
progressState
=
ProgressState
.
Don
e
;
if
(
this
.
isActive
)
{
this
.
progressbar
.
stop
().
hide
();
...
...
@@ -204,22 +210,22 @@ export class ScopedProgressService extends ScopedService implements IProgressSer
showWhile
(
promise
:
Promise
<
any
>
,
delay
?:
number
):
Promise
<
void
>
{
// Join with existing running promise to ensure progress is accurate
if
(
this
.
progressState
.
type
===
WhileProgressState
.
typ
e
)
{
if
(
this
.
progressState
.
type
===
ProgressState
.
Type
.
Whil
e
)
{
promise
=
Promise
.
all
([
promise
,
this
.
progressState
.
whilePromise
]);
}
// Keep Promise in State
this
.
progressState
=
new
WhileProgressStat
e
(
promise
,
delay
||
0
,
Date
.
now
());
this
.
progressState
=
new
ProgressState
.
Whil
e
(
promise
,
delay
||
0
,
Date
.
now
());
let
stop
=
()
=>
{
// If this is not the last promise in the list of joined promises, return early
if
(
this
.
progressState
.
type
===
WhileProgressState
.
typ
e
&&
this
.
progressState
.
whilePromise
!==
promise
)
{
if
(
this
.
progressState
.
type
===
ProgressState
.
Type
.
Whil
e
&&
this
.
progressState
.
whilePromise
!==
promise
)
{
return
;
}
// The while promise is either null or equal the promise we last hooked on
this
.
progressState
=
NoneProgressStat
e
;
this
.
progressState
=
ProgressState
.
Non
e
;
if
(
this
.
isActive
)
{
this
.
progressbar
.
stop
().
hide
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录