Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
49d05f99
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,发现更多精彩内容 >>
提交
49d05f99
编写于
3月 03, 2021
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `CodeActionTriggerKind` api proposal
For #118084 Fixes #118087
上级
20f06e04
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
52 addition
and
10 deletion
+52
-10
extensions/typescript-language-features/src/languageFeatures/quickFix.ts
...script-language-features/src/languageFeatures/quickFix.ts
+1
-1
extensions/typescript-language-features/src/languageFeatures/refactor.ts
...script-language-features/src/languageFeatures/refactor.ts
+6
-6
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+28
-0
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/common/extHostLanguageFeatures.ts
src/vs/workbench/api/common/extHostLanguageFeatures.ts
+2
-1
src/vs/workbench/api/common/extHostTypeConverters.ts
src/vs/workbench/api/common/extHostTypeConverters.ts
+13
-0
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+1
-1
未找到文件。
extensions/typescript-language-features/src/languageFeatures/quickFix.ts
浏览文件 @
49d05f99
...
...
@@ -223,7 +223,7 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider<VsCodeCode
_range
:
vscode
.
Range
,
context
:
vscode
.
CodeActionContext
,
token
:
vscode
.
CancellationToken
):
Promise
<
vscode
.
CodeAction
[]
>
{
):
Promise
<
VsCode
CodeAction
[]
>
{
const
file
=
this
.
client
.
toOpenedFilePath
(
document
);
if
(
!
file
)
{
return
[];
...
...
extensions/typescript-language-features/src/languageFeatures/refactor.ts
浏览文件 @
49d05f99
...
...
@@ -284,7 +284,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
context
:
vscode
.
CodeActionContext
,
token
:
vscode
.
CancellationToken
):
Promise
<
TsCodeAction
[]
|
undefined
>
{
if
(
!
this
.
shouldTrigger
(
rangeOrSelection
,
context
))
{
if
(
!
this
.
shouldTrigger
(
context
))
{
return
undefined
;
}
if
(
!
this
.
client
.
toOpenedFilePath
(
document
))
{
...
...
@@ -335,10 +335,10 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
}
private
toTsTriggerReason
(
context
:
vscode
.
CodeActionContext
):
Proto
.
RefactorTriggerReason
|
undefined
{
if
(
!
context
.
only
)
{
return
;
if
(
context
.
triggerKind
===
vscode
.
CodeActionTriggerKind
.
Manual
)
{
return
'
invoked
'
;
}
return
'
invoked
'
;
return
undefined
;
}
private
convertApplicableRefactors
(
...
...
@@ -384,12 +384,12 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
return
codeAction
;
}
private
shouldTrigger
(
rangeOrSelection
:
vscode
.
Range
|
vscode
.
Selection
,
context
:
vscode
.
CodeActionContext
)
{
private
shouldTrigger
(
context
:
vscode
.
CodeActionContext
)
{
if
(
context
.
only
&&
!
vscode
.
CodeActionKind
.
Refactor
.
contains
(
context
.
only
))
{
return
false
;
}
return
rangeOrSelection
instanceof
vscode
.
Selection
;
return
context
.
triggerKind
===
vscode
.
CodeActionTriggerKind
.
Manual
;
}
private
static
getKind
(
refactor
:
Proto
.
RefactorActionInfo
)
{
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
49d05f99
...
...
@@ -2800,4 +2800,32 @@ declare module 'vscode' {
}
//#endregion
//#region https://github.com/microsoft/vscode/issues/118084
/**
* The reason why code actions were requested.
*/
export
enum
CodeActionTriggerKind
{
/**
* Code actions were requested automatically.
*
* This typically happens when current selection in a file changes, but can
* also be triggered when file content changes.
*/
Automatic
=
1
,
/**
* Code actions were requested maually by the user or an extension.
*/
Manual
=
2
,
}
export
interface
CodeActionContext
{
/**
* The reason why code actions were requested.
*/
readonly
triggerKind
:
CodeActionTriggerKind
;
}
//#endregion
}
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
49d05f99
...
...
@@ -1151,7 +1151,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
CandidatePortSource
:
CandidatePortSource
,
CodeAction
:
extHostTypes
.
CodeAction
,
CodeActionKind
:
extHostTypes
.
CodeActionKind
,
CodeActionTrigger
:
extHostTypes
.
CodeActionTrigger
,
CodeActionTrigger
Kind
:
extHostTypes
.
CodeActionTriggerKind
,
CodeLens
:
extHostTypes
.
CodeLens
,
Color
:
extHostTypes
.
Color
,
ColorInformation
:
extHostTypes
.
ColorInformation
,
...
...
src/vs/workbench/api/common/extHostLanguageFeatures.ts
浏览文件 @
49d05f99
...
...
@@ -412,7 +412,8 @@ class CodeActionAdapter {
const
codeActionContext
:
vscode
.
CodeActionContext
=
{
diagnostics
:
allDiagnostics
,
only
:
context
.
only
?
new
CodeActionKind
(
context
.
only
)
:
undefined
only
:
context
.
only
?
new
CodeActionKind
(
context
.
only
)
:
undefined
,
triggerKind
:
typeConvert
.
CodeActionTriggerKind
.
to
(
context
.
trigger
),
};
return
asPromise
(()
=>
this
.
_provider
.
provideCodeActions
(
doc
,
ran
,
codeActionContext
,
token
)).
then
((
commandsOrActions
):
extHostProtocol
.
ICodeActionListDto
|
undefined
=>
{
...
...
src/vs/workbench/api/common/extHostTypeConverters.ts
浏览文件 @
49d05f99
...
...
@@ -1712,3 +1712,16 @@ export namespace TestResults {
};
}
}
export
namespace
CodeActionTriggerKind
{
export
function
to
(
value
:
modes
.
CodeActionTriggerType
):
types
.
CodeActionTriggerKind
{
switch
(
value
)
{
case
modes
.
CodeActionTriggerType
.
Auto
:
return
types
.
CodeActionTriggerKind
.
Automatic
;
case
modes
.
CodeActionTriggerType
.
Manual
:
return
types
.
CodeActionTriggerKind
.
Manual
;
}
}
}
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
49d05f99
...
...
@@ -1178,7 +1178,7 @@ export class DocumentSymbol {
}
export
enum
CodeActionTrigger
{
export
enum
CodeActionTrigger
Kind
{
Automatic
=
1
,
Manual
=
2
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录