Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1ca1b444
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,发现更多精彩内容 >>
提交
1ca1b444
编写于
9月 05, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - less asWinJsPromise-usage, #56137
上级
81ab31f5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
12 deletion
+12
-12
src/vs/editor/contrib/rename/rename.ts
src/vs/editor/contrib/rename/rename.ts
+12
-12
未找到文件。
src/vs/editor/contrib/rename/rename.ts
浏览文件 @
1ca1b444
...
...
@@ -18,7 +18,6 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
RenameInputField
from
'
./renameInputField
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
WorkspaceEdit
,
RenameProviderRegistry
,
RenameProvider
,
RenameLocation
}
from
'
vs/editor/common/modes
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
...
...
@@ -30,6 +29,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import
{
IBulkEditService
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
class
RenameSkeleton
{
...
...
@@ -46,13 +46,13 @@ class RenameSkeleton {
return
this
.
_provider
.
length
>
0
;
}
async
resolveRenameLocation
():
Promise
<
RenameLocation
>
{
async
resolveRenameLocation
(
token
:
CancellationToken
):
Promise
<
RenameLocation
>
{
let
[
provider
]
=
this
.
_provider
;
let
res
:
RenameLocation
;
if
(
provider
.
resolveRenameLocation
)
{
res
=
await
asWinJsPromise
(
token
=>
provider
.
resolveRenameLocation
(
this
.
model
,
this
.
position
,
token
)
);
res
=
await
provider
.
resolveRenameLocation
(
this
.
model
,
this
.
position
,
token
);
}
if
(
!
res
)
{
...
...
@@ -68,7 +68,7 @@ class RenameSkeleton {
return
res
;
}
async
provideRenameEdits
(
newName
:
string
,
i
:
number
=
0
,
rejects
:
string
[]
=
[],
position
:
Position
=
this
.
positio
n
):
Promise
<
WorkspaceEdit
>
{
async
provideRenameEdits
(
newName
:
string
,
i
:
number
=
0
,
rejects
:
string
[]
=
[],
token
:
CancellationToke
n
):
Promise
<
WorkspaceEdit
>
{
if
(
i
>=
this
.
_provider
.
length
)
{
return
{
...
...
@@ -78,18 +78,18 @@ class RenameSkeleton {
}
let
provider
=
this
.
_provider
[
i
];
let
result
=
await
asWinJsPromise
((
token
)
=>
provider
.
provideRenameEdits
(
this
.
model
,
this
.
position
,
newName
,
token
)
);
let
result
=
await
provider
.
provideRenameEdits
(
this
.
model
,
this
.
position
,
newName
,
token
);
if
(
!
result
)
{
return
this
.
provideRenameEdits
(
newName
,
i
+
1
,
rejects
.
concat
(
nls
.
localize
(
'
no result
'
,
"
No result.
"
)));
return
this
.
provideRenameEdits
(
newName
,
i
+
1
,
rejects
.
concat
(
nls
.
localize
(
'
no result
'
,
"
No result.
"
))
,
token
);
}
else
if
(
result
.
rejectReason
)
{
return
this
.
provideRenameEdits
(
newName
,
i
+
1
,
rejects
.
concat
(
result
.
rejectReason
));
return
this
.
provideRenameEdits
(
newName
,
i
+
1
,
rejects
.
concat
(
result
.
rejectReason
)
,
token
);
}
return
result
;
}
}
export
async
function
rename
(
model
:
ITextModel
,
position
:
Position
,
newName
:
string
):
Promise
<
WorkspaceEdit
>
{
return
new
RenameSkeleton
(
model
,
position
).
provideRenameEdits
(
newName
);
return
new
RenameSkeleton
(
model
,
position
).
provideRenameEdits
(
newName
,
undefined
,
undefined
,
CancellationToken
.
None
);
}
// --- register actions and commands
...
...
@@ -127,7 +127,7 @@ class RenameController implements IEditorContribution {
return
RenameController
.
ID
;
}
public
async
run
():
Promise
<
void
>
{
public
async
run
(
token
:
CancellationToken
):
Promise
<
void
>
{
const
position
=
this
.
editor
.
getPosition
();
const
skeleton
=
new
RenameSkeleton
(
this
.
editor
.
getModel
(),
position
);
...
...
@@ -138,7 +138,7 @@ class RenameController implements IEditorContribution {
let
loc
:
RenameLocation
;
try
{
loc
=
await
skeleton
.
resolveRenameLocation
();
loc
=
await
skeleton
.
resolveRenameLocation
(
token
);
}
catch
(
e
)
{
MessageController
.
get
(
this
.
editor
).
showMessage
(
e
,
position
);
return
undefined
;
...
...
@@ -172,7 +172,7 @@ class RenameController implements IEditorContribution {
const
state
=
new
EditorState
(
this
.
editor
,
CodeEditorStateFlag
.
Position
|
CodeEditorStateFlag
.
Value
|
CodeEditorStateFlag
.
Selection
|
CodeEditorStateFlag
.
Scroll
);
const
renameOperation
=
Promise
.
resolve
(
skeleton
.
provideRenameEdits
(
newNameOrFocusFlag
,
0
,
[],
Range
.
lift
(
loc
.
range
).
getStartPosition
()
).
then
(
result
=>
{
const
renameOperation
=
Promise
.
resolve
(
skeleton
.
provideRenameEdits
(
newNameOrFocusFlag
,
0
,
[],
token
).
then
(
result
=>
{
if
(
result
.
rejectReason
)
{
if
(
state
.
validate
(
this
.
editor
))
{
MessageController
.
get
(
this
.
editor
).
showMessage
(
result
.
rejectReason
,
this
.
editor
.
getPosition
());
...
...
@@ -254,7 +254,7 @@ export class RenameAction extends EditorAction {
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
TPromise
<
void
>
{
let
controller
=
RenameController
.
get
(
editor
);
if
(
controller
)
{
return
TPromise
.
wrap
(
controller
.
run
());
return
TPromise
.
wrap
(
controller
.
run
(
CancellationToken
.
None
));
}
return
undefined
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录