Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6a9f98bc
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6a9f98bc
编写于
7月 16, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - migrate rename api command
上级
62f58fc8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
34 deletion
+43
-34
src/vs/editor/browser/editorExtensions.ts
src/vs/editor/browser/editorExtensions.ts
+1
-1
src/vs/editor/contrib/rename/rename.ts
src/vs/editor/contrib/rename/rename.ts
+6
-7
src/vs/workbench/api/common/extHostApiCommands.ts
src/vs/workbench/api/common/extHostApiCommands.ts
+14
-26
src/vs/workbench/test/browser/api/extHostApiCommands.test.ts
src/vs/workbench/test/browser/api/extHostApiCommands.test.ts
+22
-0
未找到文件。
src/vs/editor/browser/editorExtensions.ts
浏览文件 @
6a9f98bc
...
...
@@ -419,7 +419,7 @@ export function registerModelAndPositionCommand(id: string, handler: (model: ITe
const
model
=
accessor
.
get
(
IModelService
).
getModel
(
resource
);
if
(
model
)
{
const
editorPosition
=
Position
.
lift
(
position
);
return
handler
(
model
,
editorPosition
,
args
.
slice
(
2
));
return
handler
(
model
,
editorPosition
,
...
args
.
slice
(
2
));
}
return
accessor
.
get
(
ITextModelService
).
createModelReference
(
resource
).
then
(
reference
=>
{
...
...
src/vs/editor/contrib/rename/rename.ts
浏览文件 @
6a9f98bc
...
...
@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
illegalArgument
,
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IEditorProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
registerEditorAction
,
registerEditorContribution
,
ServicesAccessor
,
EditorAction
,
EditorCommand
,
registerEditorCommand
,
register
DefaultLanguage
Command
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
registerEditorAction
,
registerEditorContribution
,
ServicesAccessor
,
EditorAction
,
EditorCommand
,
registerEditorCommand
,
register
ModelAndPosition
Command
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
...
...
@@ -33,6 +33,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IConfigurationRegistry
,
ConfigurationScope
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/textResourceConfigurationService
'
;
import
{
assertType
}
from
'
vs/base/common/types
'
;
class
RenameSkeleton
{
...
...
@@ -350,11 +351,9 @@ registerEditorCommand(new RenameCommand({
// ---- api bridge command
registerDefaultLanguageCommand
(
'
_executeDocumentRenameProvider
'
,
function
(
model
,
position
,
args
)
{
let
{
newName
}
=
args
;
if
(
typeof
newName
!==
'
string
'
)
{
throw
illegalArgument
(
'
newName
'
);
}
registerModelAndPositionCommand
(
'
_executeDocumentRenameProvider
'
,
function
(
model
,
position
,
...
args
)
{
const
[
newName
]
=
args
;
assertType
(
typeof
newName
===
'
string
'
);
return
rename
(
model
,
position
,
newName
);
});
...
...
src/vs/workbench/api/common/extHostApiCommands.ts
浏览文件 @
6a9f98bc
...
...
@@ -215,6 +215,20 @@ const newCommands: ApiCommand[] = [
[
ApiCommandArgument
.
CallHierarchyItem
],
new
ApiCommandResult
<
IOutgoingCallDto
[],
types
.
CallHierarchyOutgoingCall
[]
>
(
'
A CallHierarchyItem or undefined
'
,
v
=>
v
.
map
(
typeConverters
.
CallHierarchyOutgoingCall
.
to
))
),
// --- rename
new
ApiCommand
(
'
vscode.executeDocumentRenameProvider
'
,
'
_executeDocumentRenameProvider
'
,
'
Execute rename provider.
'
,
[
ApiCommandArgument
.
Uri
,
ApiCommandArgument
.
Position
,
new
ApiCommandArgument
(
'
newName
'
,
'
The new symbol name
'
,
v
=>
typeof
v
===
'
string
'
,
v
=>
v
)],
new
ApiCommandResult
<
IWorkspaceEditDto
,
types
.
WorkspaceEdit
|
undefined
>
(
'
A promise that resolves to a WorkspaceEdit.
'
,
value
=>
{
if
(
!
value
)
{
return
undefined
;
}
if
(
value
.
rejectReason
)
{
throw
new
Error
(
value
.
rejectReason
);
}
return
typeConverters
.
WorkspaceEdit
.
to
(
value
);
})
)
];
...
...
@@ -238,15 +252,6 @@ export class ExtHostApiCommands {
}
registerCommands
()
{
this
.
_register
(
'
vscode.executeDocumentRenameProvider
'
,
this
.
_executeDocumentRenameProvider
,
{
description
:
'
Execute rename provider.
'
,
args
:
[
{
name
:
'
uri
'
,
description
:
'
Uri of a text document
'
,
constraint
:
URI
},
{
name
:
'
position
'
,
description
:
'
Position in a text document
'
,
constraint
:
types
.
Position
},
{
name
:
'
newName
'
,
description
:
'
The new symbol name
'
,
constraint
:
String
}
],
returns
:
'
A promise that resolves to a WorkspaceEdit.
'
});
this
.
_register
(
'
vscode.executeSignatureHelpProvider
'
,
this
.
_executeSignatureHelpProvider
,
{
description
:
'
Execute signature help provider.
'
,
args
:
[
...
...
@@ -376,23 +381,6 @@ export class ExtHostApiCommands {
this
.
_disposables
.
add
(
disposable
);
}
private
_executeDocumentRenameProvider
(
resource
:
URI
,
position
:
types
.
Position
,
newName
:
string
):
Promise
<
types
.
WorkspaceEdit
>
{
const
args
=
{
resource
,
position
:
position
&&
typeConverters
.
Position
.
from
(
position
),
newName
};
return
this
.
_commands
.
executeCommand
<
IWorkspaceEditDto
>
(
'
_executeDocumentRenameProvider
'
,
args
).
then
(
value
=>
{
if
(
!
value
)
{
return
undefined
;
}
if
(
value
.
rejectReason
)
{
return
Promise
.
reject
<
any
>
(
new
Error
(
value
.
rejectReason
));
}
return
typeConverters
.
WorkspaceEdit
.
to
(
value
);
});
}
private
_executeSignatureHelpProvider
(
resource
:
URI
,
position
:
types
.
Position
,
triggerCharacter
:
string
):
Promise
<
types
.
SignatureHelp
|
undefined
>
{
const
args
=
{
resource
,
...
...
src/vs/workbench/test/browser/api/extHostApiCommands.test.ts
浏览文件 @
6a9f98bc
...
...
@@ -47,6 +47,7 @@ import 'vs/editor/contrib/links/getLinks';
import
'
vs/editor/contrib/parameterHints/provideSignatureHelp
'
;
import
'
vs/editor/contrib/smartSelect/smartSelect
'
;
import
'
vs/editor/contrib/suggest/suggest
'
;
import
'
vs/editor/contrib/rename/rename
'
;
const
defaultSelector
=
{
scheme
:
'
far
'
};
const
model
:
ITextModel
=
createTextModel
(
...
...
@@ -232,6 +233,27 @@ suite('ExtHostLanguageFeatureCommands', function () {
});
// --- rename
test
(
'
vscode.executeDocumentRenameProvider
'
,
async
function
()
{
disposables
.
push
(
extHost
.
registerRenameProvider
(
nullExtensionDescription
,
defaultSelector
,
new
class
implements
vscode
.
RenameProvider
{
provideRenameEdits
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
,
newName
:
string
)
{
const
edit
=
new
types
.
WorkspaceEdit
();
edit
.
insert
(
document
.
uri
,
<
types
.
Position
>
position
,
newName
);
return
edit
;
}
}));
await
rpcProtocol
.
sync
();
const
edit
=
await
commands
.
executeCommand
<
vscode
.
WorkspaceEdit
>
(
'
vscode.executeDocumentRenameProvider
'
,
model
.
uri
,
new
types
.
Position
(
0
,
12
),
'
newNameOfThis
'
);
assert
.
ok
(
edit
);
assert
.
equal
(
edit
.
has
(
model
.
uri
),
true
);
const
textEdits
=
edit
.
get
(
model
.
uri
);
assert
.
equal
(
textEdits
.
length
,
1
);
assert
.
equal
(
textEdits
[
0
].
newText
,
'
newNameOfThis
'
);
});
// --- definition
test
(
'
Definition, invalid arguments
'
,
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录