Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ad984e8f
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,发现更多精彩内容 >>
提交
ad984e8f
编写于
7月 04, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - avoid winjs.promise, add cancelation token
上级
a1a3ab33
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
16 addition
and
14 deletion
+16
-14
src/vs/editor/contrib/codeAction/codeAction.ts
src/vs/editor/contrib/codeAction/codeAction.ts
+3
-3
src/vs/editor/contrib/codeAction/codeActionCommands.ts
src/vs/editor/contrib/codeAction/codeActionCommands.ts
+3
-2
src/vs/editor/contrib/codeAction/codeActionModel.ts
src/vs/editor/contrib/codeAction/codeActionModel.ts
+6
-5
src/vs/editor/contrib/codeAction/codeActionWidget.ts
src/vs/editor/contrib/codeAction/codeActionWidget.ts
+2
-2
src/vs/editor/contrib/codeAction/lightBulbWidget.ts
src/vs/editor/contrib/codeAction/lightBulbWidget.ts
+2
-2
未找到文件。
src/vs/editor/contrib/codeAction/codeAction.ts
浏览文件 @
ad984e8f
...
...
@@ -7,7 +7,6 @@ import { isFalsyOrEmpty, mergeSort, flatten } from 'vs/base/common/arrays';
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
illegalArgument
,
onUnexpectedExternalError
,
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
registerLanguageCommand
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
...
...
@@ -15,8 +14,9 @@ import { CodeAction, CodeActionProviderRegistry, CodeActionContext, CodeActionTr
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
CodeActionFilter
,
CodeActionKind
,
CodeActionTrigger
}
from
'
./codeActionTrigger
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
export
function
getCodeActions
(
model
:
ITextModel
,
rangeOrSelection
:
Range
|
Selection
,
trigger
?:
CodeActionTrigger
):
T
Promise
<
CodeAction
[]
>
{
export
function
getCodeActions
(
model
:
ITextModel
,
rangeOrSelection
:
Range
|
Selection
,
trigger
?:
CodeActionTrigger
,
token
:
CancellationToken
=
CancellationToken
.
None
):
Promise
<
CodeAction
[]
>
{
const
codeActionContext
:
CodeActionContext
=
{
only
:
trigger
&&
trigger
.
filter
&&
trigger
.
filter
.
kind
?
trigger
.
filter
.
kind
.
value
:
undefined
,
trigger
:
trigger
&&
trigger
.
type
===
'
manual
'
?
CodeActionTriggerKind
.
Manual
:
CodeActionTriggerKind
.
Automatic
...
...
@@ -38,7 +38,7 @@ export function getCodeActions(model: ITextModel, rangeOrSelection: Range | Sele
});
});
return
TPromise
.
join
(
promises
)
return
Promise
.
all
(
promises
)
.
then
(
flatten
)
.
then
(
allCodeActions
=>
mergeSort
(
allCodeActions
,
codeActionsComparator
));
}
...
...
src/vs/editor/contrib/codeAction/codeActionCommands.ts
浏览文件 @
ad984e8f
...
...
@@ -25,6 +25,7 @@ import { LightBulbWidget } from './lightBulbWidget';
import
{
escapeRegExpCharacters
}
from
'
vs/base/common/strings
'
;
import
{
IBulkEditService
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
CancelablePromise
}
from
'
vs/base/common/async
'
;
function
contextKeyForSupportedActions
(
kind
:
CodeActionKind
)
{
return
ContextKeyExpr
.
regex
(
...
...
@@ -46,7 +47,7 @@ export class QuickFixController implements IEditorContribution {
private
_lightBulbWidget
:
LightBulbWidget
;
private
_disposables
:
IDisposable
[]
=
[];
private
_activeRequest
:
T
Promise
<
CodeAction
[]
>
|
undefined
;
private
_activeRequest
:
Cancelable
Promise
<
CodeAction
[]
>
|
undefined
;
constructor
(
editor
:
ICodeEditor
,
@
IMarkerService
markerService
:
IMarkerService
,
...
...
@@ -124,7 +125,7 @@ export class QuickFixController implements IEditorContribution {
this
.
_codeActionContextMenu
.
show
(
this
.
_lightBulbWidget
.
model
.
actions
,
coords
);
}
public
triggerFromEditorSelection
(
filter
?:
CodeActionFilter
,
autoApply
?:
CodeActionAutoApply
):
T
Promis
e
<
CodeAction
[]
|
undefined
>
{
public
triggerFromEditorSelection
(
filter
?:
CodeActionFilter
,
autoApply
?:
CodeActionAutoApply
):
T
henabl
e
<
CodeAction
[]
|
undefined
>
{
return
this
.
_model
.
trigger
({
type
:
'
manual
'
,
filter
,
autoApply
});
}
...
...
src/vs/editor/contrib/codeAction/codeActionModel.ts
浏览文件 @
ad984e8f
...
...
@@ -17,6 +17,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
import
{
getCodeActions
}
from
'
./codeAction
'
;
import
{
CodeActionTrigger
}
from
'
./codeActionTrigger
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
createCancelablePromise
,
CancelablePromise
}
from
'
vs/base/common/async
'
;
export
const
SUPPORTED_CODE_ACTIONS
=
new
RawContextKey
<
string
>
(
'
supportedCodeAction
'
,
''
);
...
...
@@ -99,7 +100,7 @@ export class CodeActionOracle {
return
selection
;
}
private
_createEventAndSignalChange
(
trigger
:
CodeActionTrigger
,
selection
:
Selection
|
undefined
):
T
Promis
e
<
CodeAction
[]
|
undefined
>
{
private
_createEventAndSignalChange
(
trigger
:
CodeActionTrigger
,
selection
:
Selection
|
undefined
):
T
henabl
e
<
CodeAction
[]
|
undefined
>
{
if
(
!
selection
)
{
// cancel
this
.
_signalChange
({
...
...
@@ -113,10 +114,10 @@ export class CodeActionOracle {
const
model
=
this
.
_editor
.
getModel
();
const
markerRange
=
this
.
_getRangeOfMarker
(
selection
);
const
position
=
markerRange
?
markerRange
.
getStartPosition
()
:
selection
.
getStartPosition
();
const
actions
=
getCodeActions
(
model
,
selection
,
trigger
);
const
actions
=
createCancelablePromise
(
token
=>
getCodeActions
(
model
,
selection
,
trigger
,
token
)
);
if
(
this
.
_progressService
&&
trigger
.
type
===
'
manual
'
)
{
this
.
_progressService
.
showWhile
(
actions
,
250
);
this
.
_progressService
.
showWhile
(
TPromise
.
wrap
(
actions
)
,
250
);
}
this
.
_signalChange
({
...
...
@@ -134,7 +135,7 @@ export interface CodeActionsComputeEvent {
trigger
:
CodeActionTrigger
;
rangeOrSelection
:
Range
|
Selection
;
position
:
Position
;
actions
:
T
Promise
<
CodeAction
[]
>
;
actions
:
Cancelable
Promise
<
CodeAction
[]
>
;
}
export
class
CodeActionModel
{
...
...
@@ -196,7 +197,7 @@ export class CodeActionModel {
}
}
trigger
(
trigger
:
CodeActionTrigger
):
T
Promis
e
<
CodeAction
[]
|
undefined
>
{
trigger
(
trigger
:
CodeActionTrigger
):
T
henabl
e
<
CodeAction
[]
|
undefined
>
{
if
(
this
.
_codeActionOracle
)
{
return
this
.
_codeActionOracle
.
trigger
(
trigger
);
}
...
...
src/vs/editor/contrib/codeAction/codeActionWidget.ts
浏览文件 @
ad984e8f
...
...
@@ -28,7 +28,7 @@ export class CodeActionContextMenu {
private
readonly
_onApplyCodeAction
:
(
action
:
CodeAction
)
=>
TPromise
<
any
>
)
{
}
show
(
fixes
:
T
Promis
e
<
CodeAction
[]
>
,
at
:
{
x
:
number
;
y
:
number
}
|
Position
)
{
show
(
fixes
:
T
henabl
e
<
CodeAction
[]
>
,
at
:
{
x
:
number
;
y
:
number
}
|
Position
)
{
const
actions
=
fixes
.
then
(
value
=>
{
return
value
.
map
(
action
=>
{
...
...
@@ -53,7 +53,7 @@ export class CodeActionContextMenu {
}
return
at
;
},
getActions
:
()
=>
actions
,
getActions
:
()
=>
TPromise
.
wrap
(
actions
)
,
onHide
:
()
=>
{
this
.
_visible
=
false
;
this
.
_editor
.
focus
();
...
...
src/vs/editor/contrib/codeAction/lightBulbWidget.ts
浏览文件 @
ad984e8f
...
...
@@ -116,7 +116,7 @@ export class LightBulbWidget implements IDisposable, IContentWidget {
this
.
_model
=
value
;
const
selection
=
this
.
_model
.
rangeOrSelection
;
this
.
_model
.
actions
.
done
(
fixes
=>
{
this
.
_model
.
actions
.
then
(
fixes
=>
{
if
(
!
token
.
isCancellationRequested
&&
fixes
&&
fixes
.
length
>
0
)
{
if
(
selection
.
isEmpty
()
&&
fixes
.
every
(
fix
=>
fix
.
kind
&&
CodeActionKind
.
Refactor
.
contains
(
fix
.
kind
)))
{
this
.
hide
();
...
...
@@ -126,7 +126,7 @@ export class LightBulbWidget implements IDisposable, IContentWidget {
}
else
{
this
.
hide
();
}
}
,
err
=>
{
}
).
catch
(
err
=>
{
this
.
hide
();
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录