Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
69263017
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,发现更多精彩内容 >>
提交
69263017
编写于
11月 06, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Documenting more js/ts refactorings
上级
fe593912
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
5 deletion
+38
-5
extensions/typescript-language-features/package.json
extensions/typescript-language-features/package.json
+15
-0
extensions/typescript-language-features/package.nls.json
extensions/typescript-language-features/package.nls.json
+6
-0
extensions/typescript-language-features/src/features/refactor.ts
...ons/typescript-language-features/src/features/refactor.ts
+17
-5
未找到文件。
extensions/typescript-language-features/package.json
浏览文件 @
69263017
...
...
@@ -896,6 +896,21 @@
"title"
:
"%codeActions.refactor.extract.type.title%"
,
"description"
:
"%codeActions.refactor.extract.type.description%"
},
{
"kind"
:
"refactor.rewrite.import"
,
"title"
:
"%codeActions.refactor.rewrite.import.title%"
,
"description"
:
"%codeActions.refactor.rewrite.import.description%"
},
{
"kind"
:
"refactor.rewrite.export"
,
"title"
:
"%codeActions.refactor.rewrite.export.title%"
,
"description"
:
"%codeActions.refactor.rewrite.export.description%"
},
{
"kind"
:
"refactor.move.newFile"
,
"title"
:
"%codeActions.refactor.move.newFile.title%"
,
"description"
:
"%codeActions.refactor.move.newFile.description%"
},
{
"kind"
:
"source.organizeImports"
,
"title"
:
"%codeActions.source.organizeImports.title%"
...
...
extensions/typescript-language-features/package.nls.json
浏览文件 @
69263017
...
...
@@ -84,5 +84,11 @@
"codeActions.refactor.extract.type.description"
:
"Extract type to a type alias."
,
"codeActions.refactor.extract.interface.title"
:
"Extract interface"
,
"codeActions.refactor.extract.interface.description"
:
"Extract type to an interface."
,
"codeActions.refactor.rewrite.import.title"
:
"Convert import"
,
"codeActions.refactor.rewrite.import.description"
:
"Convert between named imports and namespace imports."
,
"codeActions.refactor.rewrite.export.title"
:
"Convert export"
,
"codeActions.refactor.rewrite.export.description"
:
"Convert between default export and named export."
,
"codeActions.refactor.move.newFile.title"
:
"Move to a new file"
,
"codeActions.refactor.move.newFile.description"
:
"Move the expression to a new file."
,
"codeActions.source.organizeImports.title"
:
"Organize imports"
}
extensions/typescript-language-features/src/features/refactor.ts
浏览文件 @
69263017
...
...
@@ -148,11 +148,23 @@ const ExtractInterface = Object.freeze<CodeActionKind>({
matches
:
refactor
=>
refactor
.
name
.
includes
(
'
Extract to interface
'
)
});
const
Move
=
Object
.
freeze
<
CodeActionKind
>
({
kind
:
vscode
.
CodeActionKind
.
Refactor
.
append
(
'
move
'
),
matches
:
refactor
=>
refactor
.
name
.
startsWith
(
'
Move
'
)
const
Move
NewFile
=
Object
.
freeze
<
CodeActionKind
>
({
kind
:
vscode
.
CodeActionKind
.
Refactor
.
append
(
'
move
'
)
.
append
(
'
newFile
'
)
,
matches
:
refactor
=>
refactor
.
name
.
startsWith
(
'
Move
to a new file
'
)
});
const
RewriteImport
=
Object
.
freeze
<
CodeActionKind
>
({
kind
:
vscode
.
CodeActionKind
.
RefactorRewrite
.
append
(
'
import
'
),
matches
:
refactor
=>
refactor
.
name
.
startsWith
(
'
Convert import
'
)
});
const
RewriteExport
=
Object
.
freeze
<
CodeActionKind
>
({
kind
:
vscode
.
CodeActionKind
.
RefactorRewrite
.
append
(
'
export
'
),
matches
:
refactor
=>
refactor
.
name
.
startsWith
(
'
Convert export
'
)
});
const
allKnownCodeActionKinds
=
[
ExtractFunction
,
ExtractConstant
,
ExtractType
,
ExtractInterface
,
MoveNewFile
,
RewriteImport
,
RewriteExport
];
class
TypeScriptRefactorProvider
implements
vscode
.
CodeActionProvider
{
public
static
readonly
minVersion
=
API
.
v240
;
...
...
@@ -194,7 +206,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
const
args
:
Proto
.
GetApplicableRefactorsRequestArgs
=
typeConverters
.
Range
.
toFileRangeRequestArgs
(
file
,
rangeOrSelection
);
return
this
.
client
.
execute
(
'
getApplicableRefactors
'
,
args
,
token
);
});
if
(
!
response
||
response
.
type
!==
'
response
'
||
!
response
.
body
)
{
if
(
response
?
.
type
!==
'
response
'
||
!
response
.
body
)
{
return
undefined
;
}
...
...
@@ -250,7 +262,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
}
private
static
getKind
(
refactor
:
Proto
.
RefactorActionInfo
)
{
const
match
=
[
ExtractFunction
,
ExtractConstant
,
ExtractType
,
ExtractInterface
,
Move
]
.
find
(
kind
=>
kind
.
matches
(
refactor
));
const
match
=
allKnownCodeActionKinds
.
find
(
kind
=>
kind
.
matches
(
refactor
));
return
match
?
match
.
kind
:
vscode
.
CodeActionKind
.
Refactor
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录