Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
357ac464
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,发现更多精彩内容 >>
提交
357ac464
编写于
1月 31, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't show fix all in js/ts if we only have a single dianostics of that type in the file
Fixes
https://github.com/Microsoft/TypeScript/issues/21458
上级
9affae55
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
5 deletion
+19
-5
extensions/typescript/src/features/diagnostics.ts
extensions/typescript/src/features/diagnostics.ts
+4
-0
extensions/typescript/src/features/quickFixProvider.ts
extensions/typescript/src/features/quickFixProvider.ts
+14
-4
extensions/typescript/src/languageProvider.ts
extensions/typescript/src/languageProvider.ts
+1
-1
未找到文件。
extensions/typescript/src/features/diagnostics.ts
浏览文件 @
357ac464
...
...
@@ -94,4 +94,8 @@ export default class DiagnosticsManager {
const
syntaxDiagnostics
=
this
.
syntaxDiagnostics
.
get
(
file
);
this
.
currentDiagnostics
.
set
(
file
,
semanticDiagnostics
.
concat
(
syntaxDiagnostics
));
}
public
getDiagnostics
(
file
:
Uri
):
Diagnostic
[]
{
return
this
.
currentDiagnostics
.
get
(
file
)
||
[];
}
}
\ No newline at end of file
extensions/typescript/src/features/quickFixProvider.ts
浏览文件 @
357ac464
...
...
@@ -12,6 +12,7 @@ import FormattingConfigurationManager from './formattingConfigurationManager';
import
{
getEditForCodeAction
,
applyCodeActionCommands
}
from
'
../utils/codeAction
'
;
import
{
Command
,
CommandManager
}
from
'
../utils/commandManager
'
;
import
{
createWorkspaceEditFromFileCodeEdits
}
from
'
../utils/workspaceEdit
'
;
import
DiagnosticsManager
from
'
./diagnostics
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
loadMessageBundle
();
...
...
@@ -61,7 +62,8 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
constructor
(
private
readonly
client
:
ITypeScriptServiceClient
,
private
readonly
formattingConfigurationManager
:
FormattingConfigurationManager
,
commandManager
:
CommandManager
commandManager
:
CommandManager
,
private
readonly
diagnosticsManager
:
DiagnosticsManager
)
{
commandManager
.
register
(
new
ApplyCodeActionCommand
(
client
));
this
.
supportedCodeActionProvider
=
new
SupportedCodeActionProvider
(
client
);
...
...
@@ -91,12 +93,13 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
const
results
:
vscode
.
CodeAction
[]
=
[];
for
(
const
diagnostic
of
fixableDiagnostics
)
{
results
.
push
(...
await
this
.
getFixesForDiagnostic
(
file
,
diagnostic
,
token
));
results
.
push
(...
await
this
.
getFixesForDiagnostic
(
document
,
file
,
diagnostic
,
token
));
}
return
results
;
}
private
async
getFixesForDiagnostic
(
document
:
vscode
.
TextDocument
,
file
:
string
,
diagnostic
:
vscode
.
Diagnostic
,
token
:
vscode
.
CancellationToken
...
...
@@ -109,7 +112,7 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
if
(
codeFixesResponse
.
body
)
{
const
results
:
vscode
.
CodeAction
[]
=
[];
for
(
const
tsCodeFix
of
codeFixesResponse
.
body
)
{
results
.
push
(...
await
this
.
getAllFixesForTsCodeAction
(
file
,
diagnostic
,
tsCodeFix
,
token
));
results
.
push
(...
await
this
.
getAllFixesForTsCodeAction
(
document
,
file
,
diagnostic
,
tsCodeFix
,
token
));
}
return
results
;
}
...
...
@@ -117,13 +120,14 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
}
private
async
getAllFixesForTsCodeAction
(
document
:
vscode
.
TextDocument
,
file
:
string
,
diagnostic
:
vscode
.
Diagnostic
,
tsAction
:
Proto
.
CodeFixAction
,
token
:
vscode
.
CancellationToken
):
Promise
<
Iterable
<
vscode
.
CodeAction
>>
{
const
singleFix
=
this
.
getSingleFixForTsCodeAction
(
diagnostic
,
tsAction
);
const
fixAll
=
await
this
.
getFixAllForTsCodeAction
(
file
,
diagnostic
,
tsAction
,
token
);
const
fixAll
=
await
this
.
getFixAllForTsCodeAction
(
document
,
file
,
diagnostic
,
tsAction
,
token
);
return
fixAll
?
[
singleFix
,
fixAll
]
:
[
singleFix
];
}
...
...
@@ -145,6 +149,7 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
}
private
async
getFixAllForTsCodeAction
(
document
:
vscode
.
TextDocument
,
file
:
string
,
diagnostic
:
vscode
.
Diagnostic
,
tsAction
:
Proto
.
CodeFixAction
,
...
...
@@ -154,6 +159,11 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
return
undefined
;
}
// Make sure there are multiple diagnostics of the same type in the file
if
(
!
this
.
diagnosticsManager
.
getDiagnostics
(
document
.
uri
).
some
(
x
=>
x
.
code
===
diagnostic
.
code
&&
x
!==
diagnostic
))
{
return
;
}
const
args
:
Proto
.
GetCombinedCodeFixRequestArgs
=
{
scope
:
{
type
:
'
file
'
,
...
...
extensions/typescript/src/languageProvider.ts
浏览文件 @
357ac464
...
...
@@ -123,7 +123,7 @@ export default class LanguageProvider {
this
.
disposables
.
push
(
languages
.
registerDocumentSymbolProvider
(
selector
,
new
(
await
import
(
'
./features/documentSymbolProvider
'
)).
default
(
client
)));
this
.
disposables
.
push
(
languages
.
registerSignatureHelpProvider
(
selector
,
new
(
await
import
(
'
./features/signatureHelpProvider
'
)).
default
(
client
),
'
(
'
,
'
,
'
));
this
.
disposables
.
push
(
languages
.
registerRenameProvider
(
selector
,
new
(
await
import
(
'
./features/renameProvider
'
)).
default
(
client
)));
this
.
disposables
.
push
(
languages
.
registerCodeActionsProvider
(
selector
,
new
(
await
import
(
'
./features/quickFixProvider
'
)).
default
(
client
,
this
.
formattingOptionsManager
,
commandManager
)));
this
.
disposables
.
push
(
languages
.
registerCodeActionsProvider
(
selector
,
new
(
await
import
(
'
./features/quickFixProvider
'
)).
default
(
client
,
this
.
formattingOptionsManager
,
commandManager
,
this
.
diagnosticsManager
)));
this
.
disposables
.
push
(
languages
.
registerCodeActionsProvider
(
selector
,
new
(
await
import
(
'
./features/refactorProvider
'
)).
default
(
client
,
this
.
formattingOptionsManager
,
commandManager
)));
this
.
registerVersionDependentProviders
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录