Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
01f615e0
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,发现更多精彩内容 >>
提交
01f615e0
编写于
9月 11, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better error handling when calling prep-rename, #58394
上级
dbc44c99
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
18 deletion
+33
-18
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+2
-2
src/vs/editor/contrib/rename/rename.ts
src/vs/editor/contrib/rename/rename.ts
+8
-3
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+1
-1
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+22
-12
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
01f615e0
...
@@ -941,7 +941,7 @@ export interface WorkspaceEdit {
...
@@ -941,7 +941,7 @@ export interface WorkspaceEdit {
}
}
export
interface
Rejection
{
export
interface
Rejection
{
rejectReason
?:
string
;
// TODO@joh, move to rename
rejectReason
?:
string
;
}
}
export
interface
RenameLocation
{
export
interface
RenameLocation
{
range
:
IRange
;
range
:
IRange
;
...
@@ -950,7 +950,7 @@ export interface RenameLocation {
...
@@ -950,7 +950,7 @@ export interface RenameLocation {
export
interface
RenameProvider
{
export
interface
RenameProvider
{
provideRenameEdits
(
model
:
model
.
ITextModel
,
position
:
Position
,
newName
:
string
,
token
:
CancellationToken
):
ProviderResult
<
WorkspaceEdit
&
Rejection
>
;
provideRenameEdits
(
model
:
model
.
ITextModel
,
position
:
Position
,
newName
:
string
,
token
:
CancellationToken
):
ProviderResult
<
WorkspaceEdit
&
Rejection
>
;
resolveRenameLocation
?(
model
:
model
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
RenameLocation
>
;
resolveRenameLocation
?(
model
:
model
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
RenameLocation
&
Rejection
>
;
}
}
...
...
src/vs/editor/contrib/rename/rename.ts
浏览文件 @
01f615e0
...
@@ -46,10 +46,10 @@ class RenameSkeleton {
...
@@ -46,10 +46,10 @@ class RenameSkeleton {
return
this
.
_provider
.
length
>
0
;
return
this
.
_provider
.
length
>
0
;
}
}
async
resolveRenameLocation
(
token
:
CancellationToken
):
Promise
<
RenameLocation
>
{
async
resolveRenameLocation
(
token
:
CancellationToken
):
Promise
<
RenameLocation
&
Rejection
>
{
let
[
provider
]
=
this
.
_provider
;
let
[
provider
]
=
this
.
_provider
;
let
res
:
RenameLocation
;
let
res
:
RenameLocation
&
Rejection
;
if
(
provider
.
resolveRenameLocation
)
{
if
(
provider
.
resolveRenameLocation
)
{
res
=
await
provider
.
resolveRenameLocation
(
this
.
model
,
this
.
position
,
token
);
res
=
await
provider
.
resolveRenameLocation
(
this
.
model
,
this
.
position
,
token
);
...
@@ -136,7 +136,7 @@ class RenameController implements IEditorContribution {
...
@@ -136,7 +136,7 @@ class RenameController implements IEditorContribution {
return
undefined
;
return
undefined
;
}
}
let
loc
:
RenameLocation
;
let
loc
:
RenameLocation
&
Rejection
;
try
{
try
{
loc
=
await
skeleton
.
resolveRenameLocation
(
token
);
loc
=
await
skeleton
.
resolveRenameLocation
(
token
);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -148,6 +148,11 @@ class RenameController implements IEditorContribution {
...
@@ -148,6 +148,11 @@ class RenameController implements IEditorContribution {
return
undefined
;
return
undefined
;
}
}
if
(
loc
.
rejectReason
)
{
MessageController
.
get
(
this
.
editor
).
showMessage
(
loc
.
rejectReason
,
position
);
return
undefined
;
}
let
selection
=
this
.
editor
.
getSelection
();
let
selection
=
this
.
editor
.
getSelection
();
let
selectionStart
=
0
;
let
selectionStart
=
0
;
let
selectionEnd
=
loc
.
text
.
length
;
let
selectionEnd
=
loc
.
text
.
length
;
...
...
src/vs/monaco.d.ts
浏览文件 @
01f615e0
...
@@ -5323,7 +5323,7 @@ declare namespace monaco.languages {
...
@@ -5323,7 +5323,7 @@ declare namespace monaco.languages {
export
interface
RenameProvider
{
export
interface
RenameProvider
{
provideRenameEdits
(
model
:
editor
.
ITextModel
,
position
:
Position
,
newName
:
string
,
token
:
CancellationToken
):
ProviderResult
<
WorkspaceEdit
&
Rejection
>
;
provideRenameEdits
(
model
:
editor
.
ITextModel
,
position
:
Position
,
newName
:
string
,
token
:
CancellationToken
):
ProviderResult
<
WorkspaceEdit
&
Rejection
>
;
resolveRenameLocation
?(
model
:
editor
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
RenameLocation
>
;
resolveRenameLocation
?(
model
:
editor
.
ITextModel
,
position
:
Position
,
token
:
CancellationToken
):
ProviderResult
<
RenameLocation
&
Rejection
>
;
}
}
export
interface
Command
{
export
interface
Command
{
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
01f615e0
...
@@ -492,24 +492,17 @@ class RenameAdapter {
...
@@ -492,24 +492,17 @@ class RenameAdapter {
}
}
return
typeConvert
.
WorkspaceEdit
.
from
(
value
);
return
typeConvert
.
WorkspaceEdit
.
from
(
value
);
},
err
=>
{
},
err
=>
{
if
(
typeof
err
===
'
string
'
)
{
let
rejectReason
=
RenameAdapter
.
_asMessage
(
err
);
return
<
WorkspaceEditDto
>
{
if
(
rejectReason
)
{
edits
:
undefined
,
return
<
WorkspaceEditDto
>
{
rejectReason
,
edits
:
undefined
};
rejectReason
:
err
};
}
else
if
(
err
instanceof
Error
&&
typeof
err
.
message
===
'
string
'
)
{
return
<
WorkspaceEditDto
>
{
edits
:
undefined
,
rejectReason
:
err
.
message
};
}
else
{
}
else
{
// generic error
// generic error
return
TPromise
.
wrapError
<
WorkspaceEditDto
>
(
err
);
return
Promise
.
reject
<
WorkspaceEditDto
>
(
err
);
}
}
});
});
}
}
resolveRenameLocation
(
resource
:
URI
,
position
:
IPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
RenameLocation
>
{
resolveRenameLocation
(
resource
:
URI
,
position
:
IPosition
,
token
:
CancellationToken
):
Thenable
<
modes
.
RenameLocation
&
modes
.
Rejection
>
{
if
(
typeof
this
.
_provider
.
prepareRename
!==
'
function
'
)
{
if
(
typeof
this
.
_provider
.
prepareRename
!==
'
function
'
)
{
return
TPromise
.
as
(
undefined
);
return
TPromise
.
as
(
undefined
);
}
}
...
@@ -539,8 +532,25 @@ class RenameAdapter {
...
@@ -539,8 +532,25 @@ class RenameAdapter {
return
undefined
;
return
undefined
;
}
}
return
{
range
:
typeConvert
.
Range
.
from
(
range
),
text
};
return
{
range
:
typeConvert
.
Range
.
from
(
range
),
text
};
},
err
=>
{
let
rejectReason
=
RenameAdapter
.
_asMessage
(
err
);
if
(
rejectReason
)
{
return
<
modes
.
RenameLocation
&
modes
.
Rejection
>
{
rejectReason
,
range
:
undefined
,
text
:
undefined
};
}
else
{
return
Promise
.
reject
(
err
);
}
});
});
}
}
private
static
_asMessage
(
err
:
any
):
string
{
if
(
typeof
err
===
'
string
'
)
{
return
err
;
}
else
if
(
err
instanceof
Error
&&
typeof
err
.
message
===
'
string
'
)
{
return
err
.
message
;
}
else
{
return
undefined
;
}
}
}
}
class
SuggestAdapter
{
class
SuggestAdapter
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录