Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
86437420
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
86437420
编写于
2月 14, 2020
作者:
A
Allison Chou
提交者:
GitHub
2月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #41619 from allisonchou/NexusDiagnosticBug
Fix for LSP diagnostic bugs
上级
6a099895
126516ee
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
28 addition
and
7 deletion
+28
-7
src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs
...LanguageServer/Protocol/Extensions/ProtocolConversions.cs
+3
-1
src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs
...Def/Implementation/LanguageClient/InProcLanguageServer.cs
+25
-6
未找到文件。
src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs
浏览文件 @
86437420
...
...
@@ -164,10 +164,12 @@ public static LSP.DiagnosticSeverity DiagnosticSeverityToLspDiagnositcSeverity(D
{
switch
(
severity
)
{
// TO-DO: Add new LSP diagnostic severity for hidden diagnostics
// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1063158
case
DiagnosticSeverity
.
Hidden
:
return
LSP
.
DiagnosticSeverity
.
Hint
;
case
DiagnosticSeverity
.
Info
:
return
LSP
.
DiagnosticSeverity
.
Information
;
return
LSP
.
DiagnosticSeverity
.
Hint
;
case
DiagnosticSeverity
.
Warning
:
return
LSP
.
DiagnosticSeverity
.
Warning
;
case
DiagnosticSeverity
.
Error
:
...
...
src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs
浏览文件 @
86437420
...
...
@@ -17,6 +17,7 @@
using
Microsoft.VisualStudio.LanguageServer.Protocol
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
Roslyn.Utilities
;
using
StreamJsonRpc
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
...
...
@@ -79,7 +80,20 @@ public Task<InitializeResult> Initialize(JToken input, CancellationToken cancell
}
[
JsonRpcMethod
(
Methods
.
InitializedName
)]
public
Task
Initialized
()
=>
Task
.
CompletedTask
;
public
async
Task
Initialized
()
{
// Publish diagnostics for all open documents immediately following initialization.
var
solution
=
_workspace
.
CurrentSolution
;
var
openDocuments
=
_workspace
.
GetOpenDocumentIds
();
foreach
(
var
documentId
in
openDocuments
)
{
var
document
=
solution
.
GetDocument
(
documentId
);
if
(
document
!=
null
)
{
await
PublishDiagnosticsAsync
(
document
).
ConfigureAwait
(
false
);
}
}
}
[
JsonRpcMethod
(
Methods
.
ShutdownName
)]
public
object
?
Shutdown
(
CancellationToken
_
)
=>
null
;
...
...
@@ -190,9 +204,7 @@ private async void DiagnosticService_DiagnosticsUpdated(object sender, Diagnosti
}
// LSP does not currently support publishing diagnostics incrememntally, so we re-publish all diagnostics.
var
diagnostics
=
await
GetDiagnosticsAsync
(
e
.
Solution
,
document
,
CancellationToken
.
None
).
ConfigureAwait
(
false
);
var
publishDiagnosticsParams
=
new
PublishDiagnosticParams
{
Diagnostics
=
diagnostics
,
Uri
=
document
.
GetURI
()
};
await
_jsonRpc
.
NotifyWithParameterObjectAsync
(
Methods
.
TextDocumentPublishDiagnosticsName
,
publishDiagnosticsParams
).
ConfigureAwait
(
false
);
await
PublishDiagnosticsAsync
(
document
).
ConfigureAwait
(
false
);
}
}
catch
(
Exception
ex
)
when
(
FatalError
.
ReportWithoutCrash
(
ex
))
...
...
@@ -200,9 +212,16 @@ private async void DiagnosticService_DiagnosticsUpdated(object sender, Diagnosti
}
}
private
async
Task
<
LanguageServer
.
Protocol
.
Diagnostic
[
]>
GetDiagnosticsAsync
(
Solution
solution
,
Document
document
,
CancellationToken
cancellationToken
)
private
async
Task
PublishDiagnosticsAsync
(
Document
document
)
{
var
diagnostics
=
await
GetDiagnosticsAsync
(
document
,
CancellationToken
.
None
).
ConfigureAwait
(
false
);
var
publishDiagnosticsParams
=
new
PublishDiagnosticParams
{
Diagnostics
=
diagnostics
,
Uri
=
document
.
GetURI
()
};
await
_jsonRpc
.
NotifyWithParameterObjectAsync
(
Methods
.
TextDocumentPublishDiagnosticsName
,
publishDiagnosticsParams
).
ConfigureAwait
(
false
);
}
private
async
Task
<
LanguageServer
.
Protocol
.
Diagnostic
[
]>
GetDiagnosticsAsync
(
Document
document
,
CancellationToken
cancellationToken
)
{
var
diagnostics
=
_diagnosticService
.
GetDiagnostics
(
s
olution
.
Workspace
,
document
.
Project
.
Id
,
document
.
Id
,
null
,
false
,
cancellationToken
);
var
diagnostics
=
_diagnosticService
.
GetDiagnostics
(
document
.
Project
.
S
olution
.
Workspace
,
document
.
Project
.
Id
,
document
.
Id
,
null
,
false
,
cancellationToken
);
var
text
=
await
document
.
GetTextAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
return
diagnostics
.
Select
(
diagnostic
=>
new
LanguageServer
.
Protocol
.
Diagnostic
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录