Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0d031f0c
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,发现更多精彩内容 >>
提交
0d031f0c
编写于
9月 21, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename type for clarity
上级
cd664bc5
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
151 addition
and
57 deletion
+151
-57
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
...entation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
+6
-6
src/EditorFeatures/Test/Diagnostics/MockDiagnosticService.cs
src/EditorFeatures/Test/Diagnostics/MockDiagnosticService.cs
+4
-4
src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs
...ies/LanguageServer/AbstractLanguageServerProtocolTests.cs
+12
-4
src/Features/Core/Portable/Diagnostics/DiagnosticBucket.cs
src/Features/Core/Portable/Diagnostics/DiagnosticBucket.cs
+39
-0
src/Features/Core/Portable/Diagnostics/DiagnosticService.cs
src/Features/Core/Portable/Diagnostics/DiagnosticService.cs
+5
-5
src/Features/Core/Portable/Diagnostics/IDiagnosticService.cs
src/Features/Core/Portable/Diagnostics/IDiagnosticService.cs
+6
-5
src/Features/Core/Portable/Diagnostics/IDiagnosticServiceExtensions.cs
...Core/Portable/Diagnostics/IDiagnosticServiceExtensions.cs
+36
-0
src/Features/LanguageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs
...ageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs
+4
-4
src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs
...LanguageServer/Protocol/Extensions/ProtocolConversions.cs
+1
-1
src/Features/LanguageServer/Protocol/Handler/Initialize/InitializeHandler.cs
...geServer/Protocol/Handler/Initialize/InitializeHandler.cs
+1
-0
src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs
...erver/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs
+12
-4
src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs
...Def/Implementation/LanguageClient/InProcLanguageServer.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
...isualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
+2
-2
src/VisualStudio/Core/Test/Diagnostics/DiagnosticTableDataSourceTests.vb
...o/Core/Test/Diagnostics/DiagnosticTableDataSourceTests.vb
+5
-5
src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionHandler.cs
...on/LanguageServer/Handler/Completion/CompletionHandler.cs
+13
-14
src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs
...anguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs
+2
-2
src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs
...spaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs
+2
-0
未找到文件。
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
浏览文件 @
0d031f0c
...
...
@@ -152,14 +152,14 @@ private void ProduceTags(TaggerContext<TTag> context, DocumentSnapshotSpan spanT
var
suppressedDiagnosticsSpans
=
(
NormalizedSnapshotSpanCollection
?)
null
;
buffer
?.
Properties
.
TryGetProperty
(
PredefinedPreviewTaggerKeys
.
SuppressDiagnosticsSpansKey
,
out
suppressedDiagnosticsSpans
);
var
eventArgs
=
_diagnosticService
.
GetDiagnosticsUpdatedEventArg
s
(
var
buckets
=
_diagnosticService
.
GetDiagnosticBucket
s
(
workspace
,
document
.
Project
.
Id
,
document
.
Id
,
context
.
CancellationToken
);
foreach
(
var
updateArg
in
eventArg
s
)
foreach
(
var
bucket
in
bucket
s
)
{
ProduceTags
(
context
,
spanToTag
,
workspace
,
document
,
suppressedDiagnosticsSpans
,
updateArg
,
cancellationToken
);
suppressedDiagnosticsSpans
,
bucket
,
cancellationToken
);
}
}
...
...
@@ -167,13 +167,13 @@ private void ProduceTags(TaggerContext<TTag> context, DocumentSnapshotSpan spanT
TaggerContext
<
TTag
>
context
,
DocumentSnapshotSpan
spanToTag
,
Workspace
workspace
,
Document
document
,
NormalizedSnapshotSpanCollection
?
suppressedDiagnosticsSpans
,
UpdatedEventArgs
updateArgs
,
CancellationToken
cancellationToken
)
DiagnosticBucket
bucket
,
CancellationToken
cancellationToken
)
{
try
{
var
id
=
updateArgs
.
Id
;
var
id
=
bucket
.
Id
;
var
diagnostics
=
_diagnosticService
.
GetDiagnostics
(
workspace
,
document
.
Project
.
Id
,
document
.
Id
,
id
,
false
,
cancellationToken
);
workspace
,
document
.
Project
.
Id
,
document
.
Id
,
id
,
includeSuppressedDiagnostics
:
false
,
cancellationToken
);
var
isLiveUpdate
=
id
is
ISupportLiveUpdate
;
...
...
src/EditorFeatures/Test/Diagnostics/MockDiagnosticService.cs
浏览文件 @
0d031f0c
...
...
@@ -34,7 +34,7 @@ public MockDiagnosticService()
{
}
public
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
public
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
object
?
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
Assert
.
Equal
(
projectId
,
GetProjectId
(
workspace
));
Assert
.
Equal
(
documentId
,
GetDocumentId
(
workspace
));
...
...
@@ -42,14 +42,14 @@ public ImmutableArray<DiagnosticData> GetDiagnostics(Workspace workspace, Projec
return
_diagnostic
==
null
?
ImmutableArray
<
DiagnosticData
>.
Empty
:
ImmutableArray
.
Create
(
_diagnostic
);
}
public
ImmutableArray
<
UpdatedEventArgs
>
GetDiagnosticsUpdatedEventArgs
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
CancellationToken
cancellationToken
)
public
ImmutableArray
<
DiagnosticBucket
>
GetDiagnosticBuckets
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
CancellationToken
cancellationToken
)
{
Assert
.
Equal
(
projectId
,
GetProjectId
(
workspace
));
Assert
.
Equal
(
documentId
,
GetDocumentId
(
workspace
));
return
_diagnostic
==
null
?
ImmutableArray
<
UpdatedEventArgs
>.
Empty
:
ImmutableArray
.
Create
(
new
UpdatedEventArgs
(
this
,
workspace
,
GetProjectId
(
workspace
),
GetDocumentId
(
workspace
)));
?
ImmutableArray
<
DiagnosticBucket
>.
Empty
:
ImmutableArray
.
Create
(
new
DiagnosticBucket
(
this
,
workspace
,
GetProjectId
(
workspace
),
GetDocumentId
(
workspace
)));
}
internal
void
CreateDiagnosticAndFireEvents
(
Workspace
workspace
,
Location
location
)
...
...
src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs
浏览文件 @
0d031f0c
...
...
@@ -171,7 +171,7 @@ protected static string ApplyTextEdits(LSP.TextEdit[] edits, SourceText original
return
text
.
ToString
();
}
protected
static
LSP
.
SymbolInformation
CreateSymbolInformation
(
LSP
.
SymbolKind
kind
,
string
name
,
LSP
.
Location
location
,
string
?
containerName
=
null
)
protected
static
LSP
.
SymbolInformation
CreateSymbolInformation
(
LSP
.
SymbolKind
kind
,
string
name
,
LSP
.
Location
location
,
string
containerName
=
""
)
=>
new
LSP
.
SymbolInformation
()
{
Kind
=
kind
,
...
...
@@ -223,7 +223,8 @@ protected static LSP.CompletionParams CreateCompletionParams(LSP.Location caret,
string
text
,
LSP
.
CompletionItemKind
kind
,
string
[]
tags
,
LSP
.
CompletionParams
requestParameters
,
bool
preselect
=
false
,
string
[]?
commitCharacters
=
null
)
=>
new
LSP
.
VSCompletionItem
()
{
var
item
=
new
LSP
.
VSCompletionItem
()
{
FilterText
=
text
,
InsertText
=
text
,
...
...
@@ -237,11 +238,18 @@ protected static LSP.CompletionParams CreateCompletionParams(LSP.Location caret,
TextDocument
=
requestParameters
.
TextDocument
,
Position
=
requestParameters
.
Position
},
Icon
=
tags
!=
null
?
new
ImageElement
(
tags
.
ToImmutableArray
().
GetFirstGlyph
().
GetImageId
())
:
null
,
Preselect
=
preselect
,
CommitCharacters
=
commitCharacters
};
if
(
tags
!=
null
)
item
.
Icon
=
new
ImageElement
(
tags
.
ToImmutableArray
().
GetFirstGlyph
().
GetImageId
());
if
(
commitCharacters
!=
null
)
item
.
CommitCharacters
=
commitCharacters
;
return
item
;
}
private
protected
static
CodeActionResolveData
CreateCodeActionResolveData
(
string
uniqueIdentifier
,
LSP
.
Location
location
)
=>
new
CodeActionResolveData
(
uniqueIdentifier
,
location
.
Range
,
CreateTextDocumentIdentifier
(
location
.
Uri
));
...
...
src/Features/Core/Portable/Diagnostics/DiagnosticBucket.cs
0 → 100644
浏览文件 @
0d031f0c
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
namespace
Microsoft.CodeAnalysis.Diagnostics
{
internal
readonly
struct
DiagnosticBucket
{
/// <summary>
/// The identity of update group.
/// </summary>
public
readonly
object
Id
;
/// <summary>
/// <see cref="Workspace"/> this update is associated with.
/// </summary>
public
readonly
Workspace
Workspace
;
/// <summary>
/// <see cref="ProjectId"/> this update is associated with, or <see langword="null"/>.
/// </summary>
public
readonly
ProjectId
?
ProjectId
;
/// <summary>
/// <see cref="DocumentId"/> this update is associated with, or <see langword="null"/>.
/// </summary>
public
readonly
DocumentId
?
DocumentId
;
public
DiagnosticBucket
(
object
id
,
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
)
{
Id
=
id
;
Workspace
=
workspace
;
ProjectId
=
projectId
;
DocumentId
=
documentId
;
}
}
}
src/Features/Core/Portable/Diagnostics/DiagnosticService.cs
浏览文件 @
0d031f0c
...
...
@@ -262,11 +262,11 @@ private ImmutableArray<DiagnosticData> GetSpecificDiagnostics(Workspace workspac
buffer
.
Clear
();
if
(
source
.
SupportGetDiagnostics
)
{
result
.
AddRange
(
source
.
GetDiagnostics
(
workspace
,
projectId
,
documentId
,
null
,
includeSuppressedDiagnostics
,
cancellationToken
));
result
.
AddRange
(
source
.
GetDiagnostics
(
workspace
,
projectId
,
documentId
,
id
:
null
,
includeSuppressedDiagnostics
,
cancellationToken
));
}
else
{
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
null
,
buffer
);
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
id
:
null
,
buffer
);
foreach
(
var
data
in
buffer
)
{
...
...
@@ -283,10 +283,10 @@ private ImmutableArray<DiagnosticData> GetSpecificDiagnostics(Workspace workspac
return
result
.
ToImmutable
();
}
public
ImmutableArray
<
UpdatedEventArgs
>
GetDiagnosticsUpdatedEventArg
s
(
public
ImmutableArray
<
DiagnosticBucket
>
GetDiagnosticBucket
s
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
CancellationToken
cancellationToken
)
{
using
var
_1
=
ArrayBuilder
<
UpdatedEventArgs
>.
GetInstance
(
out
var
result
);
using
var
_1
=
ArrayBuilder
<
DiagnosticBucket
>.
GetInstance
(
out
var
result
);
using
var
_2
=
ArrayBuilder
<
Data
>.
GetInstance
(
out
var
buffer
);
foreach
(
var
source
in
_updateSources
)
...
...
@@ -296,7 +296,7 @@ private ImmutableArray<DiagnosticData> GetSpecificDiagnostics(Workspace workspac
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
id
:
null
,
buffer
);
foreach
(
var
data
in
buffer
)
result
.
AddRange
(
new
UpdatedEventArgs
(
data
.
Id
,
data
.
Workspace
,
data
.
ProjectId
,
data
.
DocumentId
));
result
.
AddRange
(
new
DiagnosticBucket
(
data
.
Id
,
data
.
Workspace
,
data
.
ProjectId
,
data
.
DocumentId
));
}
return
result
.
ToImmutable
();
...
...
src/Features/Core/Portable/Diagnostics/IDiagnosticService.cs
浏览文件 @
0d031f0c
...
...
@@ -2,11 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.Common
;
namespace
Microsoft.CodeAnalysis.Diagnostics
{
...
...
@@ -26,11 +26,12 @@ internal interface IDiagnosticService
/// <summary>
/// Get current diagnostics stored in IDiagnosticUpdateSource
/// </summary>
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
);
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
object
?
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
);
/// <summary>
/// Get current UpdatedEventArgs stored in IDiagnosticUpdateSource
/// Get current buckets stored our diagnostics are grouped into. Specific buckets can be retrieved by calling
/// <see cref="IDiagnosticServiceExtensions.GetDiagnostics(IDiagnosticService, DiagnosticBucket, bool, CancellationToken)"/>.
/// </summary>
ImmutableArray
<
UpdatedEventArgs
>
GetDiagnosticsUpdatedEventArgs
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
CancellationToken
cancellationToken
);
ImmutableArray
<
DiagnosticBucket
>
GetDiagnosticBuckets
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
CancellationToken
cancellationToken
);
}
}
src/Features/Core/Portable/Diagnostics/IDiagnosticServiceExtensions.cs
0 → 100644
浏览文件 @
0d031f0c
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System.Collections.Immutable
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Diagnostics
{
internal
static
class
IDiagnosticServiceExtensions
{
public
static
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
this
IDiagnosticService
service
,
DiagnosticBucket
bucket
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
=>
service
.
GetDiagnostics
(
bucket
.
Workspace
,
bucket
.
ProjectId
,
bucket
.
DocumentId
,
bucket
.
Id
,
includeSuppressedDiagnostics
,
cancellationToken
);
public
static
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
this
IDiagnosticService
service
,
Document
document
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
var
project
=
document
.
Project
;
var
workspace
=
project
.
Solution
.
Workspace
;
using
var
_
=
ArrayBuilder
<
DiagnosticData
>.
GetInstance
(
out
var
result
);
foreach
(
var
bucket
in
service
.
GetDiagnosticBuckets
(
workspace
,
project
.
Id
,
document
.
Id
,
cancellationToken
))
{
Contract
.
ThrowIfFalse
(
workspace
.
Equals
(
bucket
.
Workspace
));
Contract
.
ThrowIfFalse
(
document
.
Id
.
Equals
(
bucket
.
DocumentId
));
var
diagnostics
=
service
.
GetDiagnostics
(
bucket
,
includeSuppressedDiagnostics
,
cancellationToken
);
result
.
AddRange
(
diagnostics
);
}
return
result
.
ToImmutable
();
}
}
}
src/Features/LanguageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs
浏览文件 @
0d031f0c
...
...
@@ -177,17 +177,17 @@ public override async ValueTask OnReferenceFoundAsync(SourceReferenceItem refere
var
result
=
new
LSP
.
VSReferenceItem
{
ContainingMember
=
properties
.
TryGetValue
(
AbstractReferenceFinder
.
ContainingMemberInfoPropertyName
,
out
var
referenceContainingMember
)
?
referenceContainingMember
:
null
,
AbstractReferenceFinder
.
ContainingMemberInfoPropertyName
,
out
var
referenceContainingMember
)
?
referenceContainingMember
:
""
,
ContainingType
=
properties
.
TryGetValue
(
AbstractReferenceFinder
.
ContainingTypeInfoPropertyName
,
out
var
referenceContainingType
)
?
referenceContainingType
:
null
,
AbstractReferenceFinder
.
ContainingTypeInfoPropertyName
,
out
var
referenceContainingType
)
?
referenceContainingType
:
""
,
DefinitionId
=
definitionId
,
DefinitionText
=
definitionText
,
// Only definitions should have a non-null DefinitionText
DisplayPath
=
location
.
Uri
.
LocalPath
,
DocumentName
=
documentSpan
==
default
?
null
:
documentSpan
.
Document
.
Name
,
DocumentName
=
documentSpan
==
default
?
""
:
documentSpan
.
Document
.
Name
,
Id
=
id
,
Kind
=
symbolUsageInfo
.
HasValue
?
ProtocolConversions
.
SymbolUsageInfoToReferenceKinds
(
symbolUsageInfo
.
Value
)
:
Array
.
Empty
<
ReferenceKind
>(),
Location
=
location
,
ProjectName
=
documentSpan
==
default
?
null
:
documentSpan
.
Document
.
Project
.
Name
,
ProjectName
=
documentSpan
==
default
?
""
:
documentSpan
.
Document
.
Project
.
Name
,
ResolutionStatus
=
ResolutionStatusKind
.
ConfirmedAsReference
,
Text
=
text
,
};
...
...
src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs
浏览文件 @
0d031f0c
...
...
@@ -105,7 +105,7 @@ public static LSP.TextEdit TextChangeToTextEdit(TextChange textChange, SourceTex
{
return
new
LSP
.
TextEdit
{
NewText
=
textChange
.
NewText
,
NewText
=
textChange
.
NewText
??
""
,
Range
=
TextSpanToRange
(
textChange
.
Span
,
text
)
};
}
...
...
src/Features/LanguageServer/Protocol/Handler/Initialize/InitializeHandler.cs
浏览文件 @
0d031f0c
...
...
@@ -59,6 +59,7 @@ public Task<LSP.InitializeResult> HandleRequestAsync(LSP.InitializeParams reques
ReferencesProvider
=
true
,
ProjectContextProvider
=
true
,
ExecuteCommandProvider
=
new
LSP
.
ExecuteCommandOptions
(),
SupportsDiagnosticRequests
=
true
,
TextDocumentSync
=
new
LSP
.
TextDocumentSyncOptions
{
Change
=
LSP
.
TextDocumentSyncKind
.
None
...
...
src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs
浏览文件 @
0d031f0c
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.NavigateTo
;
using
Microsoft.VisualStudio.LanguageServer.Protocol
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
...
...
@@ -30,7 +31,8 @@ public override async Task<SymbolInformation[]> HandleRequestAsync(WorkspaceSymb
{
var
solution
=
SolutionProvider
.
GetCurrentSolutionForMainWorkspace
();
var
searchTasks
=
Task
.
WhenAll
(
solution
.
Projects
.
Select
(
project
=>
SearchProjectAsync
(
project
,
request
,
cancellationToken
)));
return
(
await
searchTasks
.
ConfigureAwait
(
false
)).
SelectMany
(
s
=>
s
).
ToArray
();
var
result
=
await
searchTasks
.
ConfigureAwait
(
false
);
return
result
.
SelectMany
(
a
=>
a
).
ToArray
();
// local functions
static
async
Task
<
ImmutableArray
<
SymbolInformation
>>
SearchProjectAsync
(
Project
project
,
WorkspaceSymbolParams
request
,
CancellationToken
cancellationToken
)
...
...
@@ -46,19 +48,25 @@ static async Task<ImmutableArray<SymbolInformation>> SearchProjectAsync(Project
request
.
Query
,
searchService
.
KindsProvided
,
cancellationToken
).
ConfigureAwait
(
false
);
var
projectSymbolsTasks
=
Task
.
WhenAll
(
items
.
Select
(
item
=>
CreateSymbolInformation
(
item
,
cancellationToken
)));
return
(
await
projectSymbolsTasks
.
ConfigureAwait
(
false
)).
ToImmutableArray
();
var
result
=
await
projectSymbolsTasks
.
ConfigureAwait
(
false
);
return
result
.
WhereNotNull
().
ToImmutableArray
();
}
return
ImmutableArray
.
Create
<
SymbolInformation
>();
static
async
Task
<
SymbolInformation
>
CreateSymbolInformation
(
INavigateToSearchResult
result
,
CancellationToken
cancellationToken
)
static
async
Task
<
SymbolInformation
?
>
CreateSymbolInformation
(
INavigateToSearchResult
result
,
CancellationToken
cancellationToken
)
{
var
location
=
await
ProtocolConversions
.
TextSpanToLocationAsync
(
result
.
NavigableItem
.
Document
,
result
.
NavigableItem
.
SourceSpan
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
location
==
null
)
return
null
;
return
new
SymbolInformation
{
Name
=
result
.
Name
,
Kind
=
ProtocolConversions
.
NavigateToKindToSymbolKind
(
result
.
Kind
),
Location
=
await
ProtocolConversions
.
TextSpanToLocationAsync
(
result
.
NavigableItem
.
Document
,
result
.
NavigableItem
.
SourceSpan
,
cancellationToken
).
ConfigureAwait
(
false
)
,
Location
=
location
,
};
}
}
...
...
src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs
浏览文件 @
0d031f0c
...
...
@@ -426,7 +426,7 @@ static LanguageServer.Protocol.Diagnostic ConvertToLspDiagnostic(DiagnosticData
private
bool
IncludeDiagnostic
(
DiagnosticData
diagnostic
)
=>
diagnostic
.
Properties
.
GetOrDefault
(
nameof
(
DocumentPropertiesService
.
DiagnosticsLspClientName
))
==
_clientName
;
private
static
LanguageServer
.
Protocol
.
Range
?
GetDiagnosticRange
(
DiagnosticDataLocation
?
diagnosticDataLocation
,
SourceText
text
)
private
static
LanguageServer
.
Protocol
.
Range
GetDiagnosticRange
(
DiagnosticDataLocation
?
diagnosticDataLocation
,
SourceText
text
)
{
var
linePositionSpan
=
DiagnosticData
.
GetLinePositionSpan
(
diagnosticDataLocation
,
text
,
useMapped
:
true
);
return
ProtocolConversions
.
LinePositionToRange
(
linePositionSpan
);
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
浏览文件 @
0d031f0c
...
...
@@ -166,9 +166,9 @@ private object CreateAggregationKey(object data)
private
void
PopulateInitialData
(
Workspace
workspace
,
IDiagnosticService
diagnosticService
)
{
foreach
(
var
args
in
diagnosticService
.
GetDiagnosticsUpdatedEventArg
s
(
workspace
,
projectId
:
null
,
documentId
:
null
,
cancellationToken
:
CancellationToken
.
None
))
foreach
(
var
bucket
in
diagnosticService
.
GetDiagnosticBucket
s
(
workspace
,
projectId
:
null
,
documentId
:
null
,
cancellationToken
:
CancellationToken
.
None
))
{
OnDataAddedOrChanged
(
args
);
OnDataAddedOrChanged
(
bucket
);
}
}
...
...
src/VisualStudio/Core/Test/Diagnostics/DiagnosticTableDataSourceTests.vb
浏览文件 @
0d031f0c
...
...
@@ -841,16 +841,16 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Return
diagnostics
End
Function
Public
Function
GetDiagnosticsArgs
(
workspace
As
Workspace
,
projectId
As
ProjectId
,
documentId
As
DocumentId
,
cancellationToken
As
CancellationToken
)
As
ImmutableArray
(
Of
UpdatedEventArgs
)
Implements
IDiagnosticService
.
GetDiagnosticsUpdatedEventArg
s
Public
Function
GetDiagnosticsArgs
(
workspace
As
Workspace
,
projectId
As
ProjectId
,
documentId
As
DocumentId
,
cancellationToken
As
CancellationToken
)
As
ImmutableArray
(
Of
DiagnosticBucket
)
Implements
IDiagnosticService
.
GetDiagnosticBucket
s
Assert
.
NotNull
(
workspace
)
Dim
diagnosticsArgs
As
ImmutableArray
(
Of
UpdatedEventArgs
)
Dim
diagnosticsArgs
As
ImmutableArray
(
Of
DiagnosticBucket
)
If
documentId
IsNot
Nothing
Then
diagnosticsArgs
=
Items
.
Where
(
Function
(
t
)
t
.
DocumentId
Is
documentId
)
_
.
Select
(
Function
(
t
)
Return
New
UpdatedEventArgs
(
Return
New
DiagnosticBucket
(
New
ErrorId
(
Me
,
If
(
CObj
(
t
.
DocumentId
),
t
.
ProjectId
)),
workspace
,
t
.
ProjectId
,
t
.
DocumentId
)
End
Function
).
ToImmutableArrayOrEmpty
()
...
...
@@ -858,14 +858,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
diagnosticsArgs
=
Items
.
Where
(
Function
(
t
)
t
.
ProjectId
Is
projectId
)
_
.
Select
(
Function
(
t
)
Return
New
UpdatedEventArgs
(
Return
New
DiagnosticBucket
(
New
ErrorId
(
Me
,
If
(
CObj
(
t
.
DocumentId
),
t
.
ProjectId
)),
workspace
,
t
.
ProjectId
,
t
.
DocumentId
)
End
Function
).
ToImmutableArrayOrEmpty
()
Else
diagnosticsArgs
=
Items
.
Select
(
Function
(
t
)
Return
New
UpdatedEventArgs
(
Return
New
DiagnosticBucket
(
New
ErrorId
(
Me
,
If
(
CObj
(
t
.
DocumentId
),
t
.
ProjectId
)),
workspace
,
t
.
ProjectId
,
t
.
DocumentId
)
End
Function
).
ToImmutableArrayOrEmpty
()
...
...
src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionHandler.cs
浏览文件 @
0d031f0c
...
...
@@ -56,24 +56,12 @@ public override async Task<CompletionItem[]> HandleRequestAsync(CompletionParams
private
static
CompletionItem
CreateCompletionItem
(
XamlCompletionItem
xamlCompletion
,
DocumentId
documentId
,
SourceText
text
,
Position
position
)
{
TextEdit
?
textEdit
=
null
;
if
(
xamlCompletion
.
Span
.
HasValue
)
{
textEdit
=
new
TextEdit
{
NewText
=
xamlCompletion
.
InsertText
,
Range
=
ProtocolConversions
.
LinePositionToRange
(
text
.
Lines
.
GetLinePositionSpan
(
xamlCompletion
.
Span
.
Value
))
};
}
return
new
VSCompletionItem
var
item
=
new
VSCompletionItem
{
Label
=
xamlCompletion
.
DisplayText
,
CommitCharacters
=
xamlCompletion
.
CommitCharacters
,
Detail
=
xamlCompletion
.
Detail
,
InsertText
=
xamlCompletion
.
InsertText
,
TextEdit
=
textEdit
,
Preselect
=
xamlCompletion
.
Preselect
,
SortText
=
xamlCompletion
.
SortText
,
FilterText
=
xamlCompletion
.
FilterText
,
...
...
@@ -82,9 +70,20 @@ private static CompletionItem CreateCompletionItem(XamlCompletionItem xamlComple
Icon
=
xamlCompletion
.
Icon
,
Data
=
new
CompletionResolveData
{
ProjectGuid
=
documentId
.
ProjectId
.
Id
,
DocumentGuid
=
documentId
.
Id
,
Position
=
position
,
DisplayText
=
xamlCompletion
.
DisplayText
}
};
if
(
xamlCompletion
.
Span
.
HasValue
)
{
item
.
TextEdit
=
new
TextEdit
{
NewText
=
xamlCompletion
.
InsertText
,
Range
=
ProtocolConversions
.
LinePositionToRange
(
text
.
Lines
.
GetLinePositionSpan
(
xamlCompletion
.
Span
.
Value
))
};
}
return
item
;
}
private
static
CompletionItem
[]
CreateErrorItem
(
string
message
,
string
?
details
=
null
)
private
static
CompletionItem
[]
CreateErrorItem
(
string
message
,
string
details
=
""
)
{
var
item
=
new
CompletionItem
{
...
...
src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs
浏览文件 @
0d031f0c
...
...
@@ -53,12 +53,12 @@ public override async Task<LSP.DocumentOnAutoInsertResponseItem[]> HandleRequest
return
response
.
ToArray
();
}
var
insertText
=
result
.
TextChange
.
NewText
;
var
insertText
=
result
.
TextChange
.
NewText
??
""
;
var
insertFormat
=
LSP
.
InsertTextFormat
.
Plaintext
;
if
(
result
.
CaretOffset
.
HasValue
)
{
insertFormat
=
LSP
.
InsertTextFormat
.
Snippet
;
insertText
=
insertText
?
.
Insert
(
result
.
CaretOffset
.
Value
,
"$0"
);
insertText
=
insertText
.
Insert
(
result
.
CaretOffset
.
Value
,
"$0"
);
}
response
.
Add
(
new
LSP
.
DocumentOnAutoInsertResponseItem
...
...
src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs
浏览文件 @
0d031f0c
...
...
@@ -372,8 +372,10 @@ public override int WriteTimeout
public
override
Task
CopyToAsync
(
Stream
destination
,
int
bufferSize
,
CancellationToken
cancellationToken
)
=>
_stream
.
CopyToAsync
(
destination
,
bufferSize
,
cancellationToken
);
#pragma warning disable CS0672 // Member overrides obsolete member
public
override
object
InitializeLifetimeService
()
=>
throw
new
NotSupportedException
();
#pragma warning restore CS0672 // Member overrides obsolete member
#if !NETCOREAPP
public
override
ObjRef
CreateObjRef
(
Type
requestedType
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录