Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
39f62eb5
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,发现更多精彩内容 >>
提交
39f62eb5
编写于
6月 09, 2020
作者:
D
David Barbet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review feedback
上级
b7743645
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
64 addition
and
63 deletion
+64
-63
src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs
...ies/LanguageServer/AbstractLanguageServerProtocolTests.cs
+12
-8
src/Features/LanguageServer/Protocol/Extensions/Extensions.cs
...Features/LanguageServer/Protocol/Extensions/Extensions.cs
+3
-3
src/Features/LanguageServer/Protocol/Handler/AbstractRequestHandler.cs
...LanguageServer/Protocol/Handler/AbstractRequestHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs
...Server/Protocol/Handler/CodeActions/CodeActionsHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs
...geServer/Protocol/Handler/Completion/CompletionHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs
...r/Protocol/Handler/Completion/CompletionResolveHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandlerBase.cs
.../Handler/Definitions/AbstractGoToDefinitionHandlerBase.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs
...er/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs
...l/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs
...rotocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs
...r/Protocol/Handler/Highlights/DocumentHighlightHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs
...res/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/IRequestHandler.cs
...atures/LanguageServer/Protocol/Handler/IRequestHandler.cs
+0
-1
src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs
...ndler/ProjectContext/GetTextDocumentWithContextHandler.cs
+3
-3
src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs
...r/Protocol/Handler/References/FindAllReferencesHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs
...Protocol/Handler/References/FindImplementationsHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs
...s/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs
...er/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs
...Server/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs
...erver/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/ILspSolutionProvider.cs
src/Features/LanguageServer/Protocol/ILspSolutionProvider.cs
+2
-2
src/VisualStudio/Core/Def/Implementation/LanguageClient/VisualStudioLspSolutionProvider.cs
...ntation/LanguageClient/VisualStudioLspSolutionProvider.cs
+3
-3
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
...plementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
+4
-4
src/VisualStudio/LiveShare/Impl/AbstractClassificationsHandler.cs
...alStudio/LiveShare/Impl/AbstractClassificationsHandler.cs
+1
-1
src/VisualStudio/LiveShare/Impl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs
...mpl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs
+1
-1
src/VisualStudio/LiveShare/Impl/PreviewCodeActionsHandler.cs
src/VisualStudio/LiveShare/Impl/PreviewCodeActionsHandler.cs
+1
-1
src/VisualStudio/LiveShare/Impl/RunCodeActionsHandler.cs
src/VisualStudio/LiveShare/Impl/RunCodeActionsHandler.cs
+1
-1
src/VisualStudio/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs
...io/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs
+1
-3
未找到文件。
src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs
浏览文件 @
39f62eb5
...
...
@@ -2,10 +2,13 @@
// 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.ComponentModel.Composition
;
using
System.Diagnostics.CodeAnalysis
;
using
System.Linq
;
using
System.Text.RegularExpressions
;
using
System.Threading
;
...
...
@@ -18,6 +21,7 @@
using
Microsoft.CodeAnalysis.LanguageServer.CustomProtocol
;
using
Microsoft.CodeAnalysis.LanguageServer.Handler
;
using
Microsoft.CodeAnalysis.LanguageServer.Handler.Commands
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Composition
;
...
...
@@ -35,7 +39,8 @@ public abstract class AbstractLanguageServerProtocolTests
[
Export
(
typeof
(
ILspSolutionProvider
)),
PartNotDiscoverable
]
internal
class
TestLspSolutionProvider
:
ILspSolutionProvider
{
private
Solution
_currentSolution
;
[
DisallowNull
]
private
Solution
?
_currentSolution
;
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -45,11 +50,10 @@ public TestLspSolutionProvider()
public
void
UpdateSolution
(
Solution
solution
)
{
Contract
.
ThrowIfFalse
(
_currentSolution
==
null
);
_currentSolution
=
solution
;
}
public
Solution
GetCurrentSolution
()
public
Solution
GetCurrentSolution
ForMainWorkspace
()
{
Contract
.
ThrowIfNull
(
_currentSolution
);
return
_currentSolution
;
...
...
@@ -75,7 +79,7 @@ protected virtual ExportProvider GetExportProvider()
.
WithPart
(
typeof
(
LanguageServerProtocol
))
.
WithParts
(
requestHelperTypes
)
.
WithParts
(
executeCommandHandlerTypes
)
.
WithPart
s
(
solutionProviderTypes
));
.
WithPart
(
typeof
(
TestLspSolutionProvider
)
));
return
exportProviderFactory
.
CreateExportProvider
();
}
...
...
@@ -140,7 +144,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
=
null
)
=>
new
LSP
.
SymbolInformation
()
{
Kind
=
kind
,
...
...
@@ -149,7 +153,7 @@ protected static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind ki
ContainerName
=
containerName
};
protected
static
LSP
.
TextDocumentIdentifier
CreateTextDocumentIdentifier
(
Uri
uri
,
ProjectId
projectContext
=
null
)
protected
static
LSP
.
TextDocumentIdentifier
CreateTextDocumentIdentifier
(
Uri
uri
,
ProjectId
?
projectContext
=
null
)
{
var
documentIdentifier
=
new
LSP
.
VSTextDocumentIdentifier
()
{
Uri
=
uri
};
...
...
@@ -162,7 +166,7 @@ protected static LSP.TextDocumentIdentifier CreateTextDocumentIdentifier(Uri uri
return
documentIdentifier
;
}
protected
static
LSP
.
TextDocumentPositionParams
CreateTextDocumentPositionParams
(
LSP
.
Location
caret
,
ProjectId
projectContext
=
null
)
protected
static
LSP
.
TextDocumentPositionParams
CreateTextDocumentPositionParams
(
LSP
.
Location
caret
,
ProjectId
?
projectContext
=
null
)
=>
new
LSP
.
TextDocumentPositionParams
()
{
TextDocument
=
CreateTextDocumentIdentifier
(
caret
.
Uri
,
projectContext
),
...
...
@@ -266,7 +270,7 @@ private void UpdateSolutionProvider(TestWorkspace workspace, Solution solution)
var
locations
=
new
Dictionary
<
string
,
IList
<
LSP
.
Location
>>();
foreach
(
var
testDocument
in
workspace
.
Documents
)
{
var
document
=
solution
.
GetDocument
(
testDocument
.
Id
);
var
document
=
solution
.
Get
Required
Document
(
testDocument
.
Id
);
var
text
=
document
.
GetTextSynchronously
(
CancellationToken
.
None
);
foreach
(
var
(
name
,
spans
)
in
testDocument
.
AnnotatedSpans
)
{
...
...
src/Features/LanguageServer/Protocol/Extensions/Extensions.cs
浏览文件 @
39f62eb5
...
...
@@ -40,7 +40,7 @@ public static ImmutableArray<Document> GetDocuments(this Solution solution, Uri
return
documentIds
.
SelectAsArray
(
id
=>
solution
.
GetRequiredDocument
(
id
));
}
public
static
ImmutableArray
<
Document
>
GetDocumentsFromProvider
(
this
Uri
uri
,
ILspSolutionProvider
solutionProvider
,
string
?
clientName
=
null
)
public
static
ImmutableArray
<
Document
>
GetDocumentsFromProvider
(
this
ILspSolutionProvider
solutionProvider
,
Uri
uri
,
string
?
clientName
=
null
)
{
var
documents
=
solutionProvider
.
GetDocuments
(
uri
);
...
...
@@ -63,9 +63,9 @@ public static ImmutableArray<Document> GetDocumentsFromProvider(this Uri uri, IL
});
}
public
static
Document
?
GetDocument
(
this
TextDocumentIdentifier
documentIdentifier
,
ILspSolutionProvider
solutionProvid
er
,
string
?
clientName
=
null
)
public
static
Document
?
GetDocument
(
this
ILspSolutionProvider
solutionProvider
,
TextDocumentIdentifier
documentIdentifi
er
,
string
?
clientName
=
null
)
{
var
documents
=
documentIdentifier
.
Uri
.
GetDocumentsFromProvider
(
solutionProvider
,
clientName
);
var
documents
=
solutionProvider
.
GetDocumentsFromProvider
(
documentIdentifier
.
Uri
,
clientName
);
if
(
documents
.
Length
==
0
)
{
...
...
src/Features/LanguageServer/Protocol/Handler/Abstract
Base
RequestHandler.cs
→
src/Features/LanguageServer/Protocol/Handler/AbstractRequestHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -10,11 +10,11 @@
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
internal
abstract
class
Abstract
Base
RequestHandler
<
RequestType
,
ResponseType
>
:
IRequestHandler
<
RequestType
,
ResponseType
>
internal
abstract
class
AbstractRequestHandler
<
RequestType
,
ResponseType
>
:
IRequestHandler
<
RequestType
,
ResponseType
>
{
protected
readonly
ILspSolutionProvider
SolutionProvider
;
protected
Abstract
Base
RequestHandler
(
ILspSolutionProvider
solutionProvider
)
protected
AbstractRequestHandler
(
ILspSolutionProvider
solutionProvider
)
{
SolutionProvider
=
solutionProvider
;
}
...
...
src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -26,7 +26,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
/// </summary>
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentCodeActionName
)]
internal
class
CodeActionsHandler
:
Abstract
Base
RequestHandler
<
LSP
.
CodeActionParams
,
LSP
.
SumType
<
LSP
.
Command
,
LSP
.
CodeAction
>[
]>
internal
class
CodeActionsHandler
:
AbstractRequestHandler
<
LSP
.
CodeActionParams
,
LSP
.
SumType
<
LSP
.
Command
,
LSP
.
CodeAction
>[
]>
{
private
readonly
ICodeFixService
_codeFixService
;
private
readonly
ICodeRefactoringService
_codeRefactoringService
;
...
...
@@ -45,7 +45,7 @@ public CodeActionsHandler(ICodeFixService codeFixService, ICodeRefactoringServic
public
override
async
Task
<
LSP
.
SumType
<
LSP
.
Command
,
LSP
.
CodeAction
>[
]>
HandleRequestAsync
(
LSP
.
CodeActionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
var
codeActions
=
await
GetCodeActionsAsync
(
document
,
_codeFixService
,
_codeRefactoringService
,
...
...
src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -24,7 +24,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
/// </summary>
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentCompletionName
)]
internal
class
CompletionHandler
:
Abstract
Base
RequestHandler
<
LSP
.
CompletionParams
,
LSP
.
CompletionItem
[
]>
internal
class
CompletionHandler
:
AbstractRequestHandler
<
LSP
.
CompletionParams
,
LSP
.
CompletionItem
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -35,7 +35,7 @@ public CompletionHandler(ILspSolutionProvider solutionProvider) : base(solutionP
public
override
async
Task
<
LSP
.
CompletionItem
[
]>
HandleRequestAsync
(
LSP
.
CompletionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
Array
.
Empty
<
LSP
.
CompletionItem
>();
...
...
src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -23,7 +23,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
/// </summary>
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentCompletionResolveName
)]
internal
class
CompletionResolveHandler
:
Abstract
Base
RequestHandler
<
LSP
.
CompletionItem
,
LSP
.
CompletionItem
>
internal
class
CompletionResolveHandler
:
AbstractRequestHandler
<
LSP
.
CompletionItem
,
LSP
.
CompletionItem
>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -46,7 +46,7 @@ public CompletionResolveHandler(ILspSolutionProvider solutionProvider) : base(so
var
request
=
data
.
CompletionParams
;
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
completionItem
;
...
...
src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandlerBase.cs
浏览文件 @
39f62eb5
...
...
@@ -17,7 +17,7 @@
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
internal
abstract
class
AbstractGoToDefinitionHandlerBase
<
RequestType
,
ResponseType
>
:
Abstract
Base
RequestHandler
<
RequestType
,
ResponseType
>
internal
abstract
class
AbstractGoToDefinitionHandlerBase
<
RequestType
,
ResponseType
>
:
AbstractRequestHandler
<
RequestType
,
ResponseType
>
{
private
readonly
IMetadataAsSourceFileService
_metadataAsSourceFileService
;
...
...
@@ -28,7 +28,7 @@ protected async Task<LSP.Location[]> GetDefinitionAsync(LSP.TextDocumentPosition
{
var
locations
=
ArrayBuilder
<
LSP
.
Location
>.
GetInstance
();
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
locations
.
ToArrayAndFree
();
...
...
src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
Methods
.
TextDocumentFoldingRangeName
)]
internal
class
FoldingRangesHandler
:
Abstract
Base
RequestHandler
<
FoldingRangeParams
,
FoldingRange
[
]>
internal
class
FoldingRangesHandler
:
AbstractRequestHandler
<
FoldingRangeParams
,
FoldingRange
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -30,7 +30,7 @@ public FoldingRangesHandler(ILspSolutionProvider solutionProvider) : base(soluti
{
var
foldingRanges
=
ArrayBuilder
<
FoldingRange
>.
GetInstance
();
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
foldingRanges
.
ToArrayAndFree
();
...
...
src/Features/LanguageServer/Protocol/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs
浏览文件 @
39f62eb5
...
...
@@ -15,7 +15,7 @@
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
internal
abstract
class
AbstractFormatDocumentHandlerBase
<
RequestType
,
ResponseType
>
:
Abstract
Base
RequestHandler
<
RequestType
,
ResponseType
>
internal
abstract
class
AbstractFormatDocumentHandlerBase
<
RequestType
,
ResponseType
>
:
AbstractRequestHandler
<
RequestType
,
ResponseType
>
{
protected
AbstractFormatDocumentHandlerBase
(
ILspSolutionProvider
solutionProvider
)
:
base
(
solutionProvider
)
{
...
...
@@ -24,7 +24,7 @@ protected AbstractFormatDocumentHandlerBase(ILspSolutionProvider solutionProvide
protected
async
Task
<
LSP
.
TextEdit
[
]>
GetTextEditsAsync
(
LSP
.
TextDocumentIdentifier
documentIdentifier
,
string
?
clientName
,
CancellationToken
cancellationToken
,
LSP
.
Range
?
range
=
null
)
{
var
edits
=
new
ArrayBuilder
<
LSP
.
TextEdit
>();
var
document
=
documentIdentifier
.
GetDocument
(
SolutionProvid
er
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
documentIdentifi
er
,
clientName
);
if
(
document
!=
null
)
{
...
...
src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -21,7 +21,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
Methods
.
TextDocumentOnTypeFormattingName
)]
internal
class
FormatDocumentOnTypeHandler
:
Abstract
Base
RequestHandler
<
DocumentOnTypeFormattingParams
,
TextEdit
[
]>
internal
class
FormatDocumentOnTypeHandler
:
AbstractRequestHandler
<
DocumentOnTypeFormattingParams
,
TextEdit
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -33,7 +33,7 @@ public FormatDocumentOnTypeHandler(ILspSolutionProvider solutionProvider) : base
CancellationToken
cancellationToken
)
{
var
edits
=
new
ArrayBuilder
<
TextEdit
>();
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
!=
null
)
{
var
formattingService
=
document
.
Project
.
LanguageServices
.
GetRequiredService
<
IEditorFormattingService
>();
...
...
src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
Methods
.
TextDocumentDocumentHighlightName
)]
internal
class
DocumentHighlightsHandler
:
Abstract
Base
RequestHandler
<
TextDocumentPositionParams
,
DocumentHighlight
[
]>
internal
class
DocumentHighlightsHandler
:
AbstractRequestHandler
<
TextDocumentPositionParams
,
DocumentHighlight
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -29,7 +29,7 @@ public DocumentHighlightsHandler(ILspSolutionProvider solutionProvider) : base(s
public
override
async
Task
<
DocumentHighlight
[
]>
HandleRequestAsync
(
TextDocumentPositionParams
request
,
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
Array
.
Empty
<
DocumentHighlight
>();
...
...
src/Features/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
Methods
.
TextDocumentHoverName
)]
internal
class
HoverHandler
:
Abstract
Base
RequestHandler
<
TextDocumentPositionParams
,
Hover
?>
internal
class
HoverHandler
:
AbstractRequestHandler
<
TextDocumentPositionParams
,
Hover
?>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -28,7 +28,7 @@ public HoverHandler(ILspSolutionProvider solutionProvider) : base(solutionProvid
public
override
async
Task
<
Hover
?>
HandleRequestAsync
(
TextDocumentPositionParams
request
,
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
null
;
...
...
src/Features/LanguageServer/Protocol/Handler/IRequestHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -27,7 +27,6 @@ internal interface IRequestHandler<RequestType, ResponseType> : IRequestHandler
/// <param name="clientName">the lsp client making the request.</param>
/// <param name="cancellationToken">a cancellation token.</param>
/// <returns>the LSP response.</returns>
///
Task
<
ResponseType
>
HandleRequestAsync
(
RequestType
request
,
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
);
}
}
src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
MSLSPMethods
.
ProjectContextsName
)]
internal
class
GetTextDocumentWithContextHandler
:
Abstract
Base
RequestHandler
<
GetTextDocumentWithContextParams
,
ActiveProjectContexts
?>
internal
class
GetTextDocumentWithContextHandler
:
AbstractRequestHandler
<
GetTextDocumentWithContextParams
,
ActiveProjectContexts
?>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -32,7 +32,7 @@ public GetTextDocumentWithContextHandler(ILspSolutionProvider solutionProvider)
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
documents
=
request
.
TextDocument
.
Uri
.
GetDocumentsFromProvider
(
SolutionProvider
,
clientName
);
var
documents
=
SolutionProvider
.
GetDocumentsFromProvider
(
request
.
TextDocument
.
Uri
,
clientName
);
if
(!
documents
.
Any
())
{
...
...
@@ -68,7 +68,7 @@ public GetTextDocumentWithContextHandler(ILspSolutionProvider solutionProvider)
// ID in GetDocumentIdsWithFilePath, but there's really nothing we can do since we don't have contexts for
// close documents anyways.
var
openDocument
=
documents
.
First
();
var
currentContextDocumentId
=
openDocument
.
Project
.
Solution
.
Workspace
.
GetDocumentIdInCurrentContext
(
documents
.
First
()
.
Id
);
var
currentContextDocumentId
=
openDocument
.
Project
.
Solution
.
Workspace
.
GetDocumentIdInCurrentContext
(
openDocument
.
Id
);
return
Task
.
FromResult
<
ActiveProjectContexts
?>(
new
ActiveProjectContexts
{
...
...
src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -20,7 +20,7 @@
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentReferencesName
),
Shared
]
internal
class
FindAllReferencesHandler
:
Abstract
Base
RequestHandler
<
LSP
.
ReferenceParams
,
LSP
.
VSReferenceItem
[
]>
internal
class
FindAllReferencesHandler
:
AbstractRequestHandler
<
LSP
.
ReferenceParams
,
LSP
.
VSReferenceItem
[
]>
{
private
readonly
IMetadataAsSourceFileService
_metadataAsSourceFileService
;
...
...
@@ -39,7 +39,7 @@ public FindAllReferencesHandler(IMetadataAsSourceFileService metadataAsSourceFil
{
Debug
.
Assert
(
clientCapabilities
.
HasVisualStudioLspCapability
());
var
document
=
referenceParams
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
referenceParams
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
Array
.
Empty
<
LSP
.
VSReferenceItem
>();
...
...
src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentImplementationName
)]
internal
class
FindImplementationsHandler
:
Abstract
Base
RequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]>
internal
class
FindImplementationsHandler
:
AbstractRequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -31,7 +31,7 @@ public FindImplementationsHandler(ILspSolutionProvider solutionProvider) : base(
{
var
locations
=
ArrayBuilder
<
LSP
.
Location
>.
GetInstance
();
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
locations
.
ToArrayAndFree
();
...
...
src/Features/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -20,7 +20,7 @@
namespace
Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentRenameName
),
Shared
]
internal
class
RenameHandler
:
Abstract
Base
RequestHandler
<
LSP
.
RenameParams
,
WorkspaceEdit
?>
internal
class
RenameHandler
:
AbstractRequestHandler
<
LSP
.
RenameParams
,
WorkspaceEdit
?>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -31,7 +31,7 @@ public RenameHandler(ILspSolutionProvider solutionProvider) : base(solutionProvi
public
override
async
Task
<
WorkspaceEdit
?>
HandleRequestAsync
(
RenameParams
request
,
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
WorkspaceEdit
?
workspaceEdit
=
null
;
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
!=
null
)
{
var
oldSolution
=
document
.
Project
.
Solution
;
...
...
src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -21,7 +21,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentSignatureHelpName
)]
internal
class
SignatureHelpHandler
:
Abstract
Base
RequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
SignatureHelp
>
internal
class
SignatureHelpHandler
:
AbstractRequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
SignatureHelp
>
{
private
readonly
IEnumerable
<
Lazy
<
ISignatureHelpProvider
,
OrderableLanguageMetadata
>>
_allProviders
;
...
...
@@ -34,7 +34,7 @@ public SignatureHelpHandler([ImportMany] IEnumerable<Lazy<ISignatureHelpProvider
public
override
async
Task
<
LSP
.
SignatureHelp
>
HandleRequestAsync
(
LSP
.
TextDocumentPositionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
new
LSP
.
SignatureHelp
();
...
...
src/Features/LanguageServer/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -21,7 +21,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
Methods
.
TextDocumentDocumentSymbolName
)]
internal
class
DocumentSymbolsHandler
:
Abstract
Base
RequestHandler
<
DocumentSymbolParams
,
object
[
]>
internal
class
DocumentSymbolsHandler
:
AbstractRequestHandler
<
DocumentSymbolParams
,
object
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -32,7 +32,7 @@ public DocumentSymbolsHandler(ILspSolutionProvider solutionProvider) : base(solu
public
override
async
Task
<
object
[
]>
HandleRequestAsync
(
DocumentSymbolParams
request
,
ClientCapabilities
clientCapabilities
,
string
clientName
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
SolutionProvider
,
clientName
);
var
document
=
SolutionProvider
.
GetDocument
(
request
.
TextDocument
,
clientName
);
if
(
document
==
null
)
{
return
Array
.
Empty
<
SymbolInformation
>();
...
...
src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
Methods
.
WorkspaceSymbolName
)]
internal
class
WorkspaceSymbolsHandler
:
Abstract
Base
RequestHandler
<
WorkspaceSymbolParams
,
SymbolInformation
[
]>
internal
class
WorkspaceSymbolsHandler
:
AbstractRequestHandler
<
WorkspaceSymbolParams
,
SymbolInformation
[
]>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -29,7 +29,7 @@ public WorkspaceSymbolsHandler(ILspSolutionProvider solutionProvider) : base(sol
public
override
async
Task
<
SymbolInformation
[
]>
HandleRequestAsync
(
WorkspaceSymbolParams
request
,
ClientCapabilities
clientCapabilities
,
string
?
clientName
,
CancellationToken
cancellationToken
)
{
var
solution
=
SolutionProvider
.
GetCurrentSolution
();
var
solution
=
SolutionProvider
.
GetCurrentSolution
ForMainWorkspace
();
var
searchTasks
=
Task
.
WhenAll
(
solution
.
Projects
.
Select
(
project
=>
SearchProjectAsync
(
project
,
request
,
cancellationToken
)));
return
(
await
searchTasks
.
ConfigureAwait
(
false
)).
SelectMany
(
s
=>
s
).
ToArray
();
...
...
src/Features/LanguageServer/Protocol/ILspSolutionProvider.cs
浏览文件 @
39f62eb5
...
...
@@ -20,8 +20,8 @@ internal interface ILspSolutionProvider
ImmutableArray
<
Document
>
GetDocuments
(
Uri
documentUri
);
/// <summary>
/// Return the latest solution we know about.
/// Return the latest solution
from the main workspace that
we know about.
/// </summary>
Solution
GetCurrentSolution
();
Solution
GetCurrentSolution
ForMainWorkspace
();
}
}
src/VisualStudio/Core/Def/Implementation/LanguageClient/VisualStudioLspSolutionProvider.cs
浏览文件 @
39f62eb5
...
...
@@ -19,8 +19,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageClient
[
Export
(
typeof
(
ILspSolutionProvider
)),
Shared
]
class
VisualStudioLspSolutionProvider
:
ILspSolutionProvider
{
private
VisualStudioWorkspace
_visualStudioWorkspace
;
private
MiscellaneousFilesWorkspace
_miscellaneousFilesWorkspace
;
private
readonly
VisualStudioWorkspace
_visualStudioWorkspace
;
private
readonly
MiscellaneousFilesWorkspace
_miscellaneousFilesWorkspace
;
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -30,7 +30,7 @@ public VisualStudioLspSolutionProvider(VisualStudioWorkspace visualStudioWorkspa
_miscellaneousFilesWorkspace
=
miscellaneousFilesWorkspace
;
}
public
Solution
GetCurrentSolution
()
public
Solution
GetCurrentSolution
ForMainWorkspace
()
{
return
_visualStudioWorkspace
.
CurrentSolution
;
}
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
浏览文件 @
39f62eb5
...
...
@@ -28,7 +28,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
internal
sealed
partial
class
MiscellaneousFilesWorkspace
:
Workspace
,
IRunningDocumentTableEventListener
{
private
readonly
IMetadataAsSourceFileService
_fileTrackingMetadataAsSourceService
;
private
readonly
IVsTextManager
_t
extManager
;
private
readonly
Lazy
<
IVsTextManager
>
_lazyT
extManager
;
private
readonly
RunningDocumentTableEventTracker
_runningDocumentTableEventTracker
;
...
...
@@ -60,10 +60,10 @@ internal sealed partial class MiscellaneousFilesWorkspace : Workspace, IRunningD
SVsServiceProvider
serviceProvider
)
:
base
(
visualStudioWorkspace
.
Services
.
HostServices
,
WorkspaceKind
.
MiscellaneousFiles
)
{
_foregroundThreadAffinitization
=
new
ForegroundThreadAffinitizedObject
(
threadingContext
,
assertIsForeground
:
tru
e
);
_foregroundThreadAffinitization
=
new
ForegroundThreadAffinitizedObject
(
threadingContext
,
assertIsForeground
:
fals
e
);
_fileTrackingMetadataAsSourceService
=
fileTrackingMetadataAsSourceService
;
_
textManager
=
(
IVsTextManager
)
serviceProvider
.
GetService
(
typeof
(
SVsTextManager
));
_
lazyTextManager
=
new
Lazy
<
IVsTextManager
>(()
=>
(
IVsTextManager
)
serviceProvider
.
GetService
(
typeof
(
SVsTextManager
)
));
var
runningDocumentTable
=
(
IVsRunningDocumentTable
)
serviceProvider
.
GetService
(
typeof
(
SVsRunningDocumentTable
));
_runningDocumentTableEventTracker
=
new
RunningDocumentTableEventTracker
(
threadingContext
,
editorAdaptersFactoryService
,
runningDocumentTable
,
this
);
...
...
@@ -103,7 +103,7 @@ private LanguageInformation TryGetLanguageInformation(string filename)
{
LanguageInformation
languageInformation
=
null
;
if
(
ErrorHandler
.
Succeeded
(
_
textManager
.
MapFilenameToLanguageSID
(
filename
,
out
var
fileLanguageGuid
)))
if
(
ErrorHandler
.
Succeeded
(
_
lazyTextManager
.
Value
.
MapFilenameToLanguageSID
(
filename
,
out
var
fileLanguageGuid
)))
{
_languageInformationByLanguageGuid
.
TryGetValue
(
fileLanguageGuid
,
out
languageInformation
);
}
...
...
src/VisualStudio/LiveShare/Impl/AbstractClassificationsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -36,7 +36,7 @@ protected AbstractClassificationsHandler(ILspSolutionProvider solutionProvider)
public
async
Task
<
object
[
]>
HandleAsync
(
ClassificationParams
request
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
{
request
.
TextDocument
.
Uri
=
requestContext
.
ProtocolConverter
.
FromProtocolUri
(
request
.
TextDocument
.
Uri
);
var
document
=
request
.
TextDocument
.
GetDocument
(
_solutionProvider
);
var
document
=
_solutionProvider
.
GetDocument
(
request
.
TextDocument
);
var
classificationService
=
document
?.
Project
.
LanguageServices
.
GetService
<
IClassificationService
>();
if
(
document
==
null
||
classificationService
==
null
)
...
...
src/VisualStudio/LiveShare/Impl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -39,7 +39,7 @@ public AbstractGoToDefinitionWithFindUsagesServiceHandler(IMetadataAsSourceFileS
public
async
Task
<
object
>
HandleAsync
(
LSP
.
TextDocumentPositionParams
request
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
{
var
document
=
request
.
TextDocument
.
GetDocument
(
_solutionProvider
);
var
document
=
_solutionProvider
.
GetDocument
(
request
.
TextDocument
);
if
(
document
==
null
)
{
return
Array
.
Empty
<
LSP
.
Location
>();
...
...
src/VisualStudio/LiveShare/Impl/PreviewCodeActionsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -35,7 +35,7 @@ public PreviewCodeActionsHandler(ICodeFixService codeFixService, ICodeRefactorin
public
async
Task
<
LSP
.
TextEdit
[
]>
HandleAsync
(
RunCodeActionParams
request
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
{
var
edits
=
ArrayBuilder
<
LSP
.
TextEdit
>.
GetInstance
();
var
document
=
request
.
CodeActionParams
.
TextDocument
.
GetDocument
(
_solutionProvider
);
var
document
=
_solutionProvider
.
GetDocument
(
request
.
CodeActionParams
.
TextDocument
);
var
codeActions
=
await
CodeActionsHandler
.
GetCodeActionsAsync
(
document
,
_codeFixService
,
_codeRefactoringService
,
...
...
src/VisualStudio/LiveShare/Impl/RunCodeActionsHandler.cs
浏览文件 @
39f62eb5
...
...
@@ -54,7 +54,7 @@ public async Task<object> HandleAsync(LSP.ExecuteCommandParams request, RequestC
if
(
request
.
Command
==
CodeActionsHandler
.
RunCodeActionCommandName
)
{
var
runRequest
=
((
JToken
)
request
.
Arguments
.
Single
()).
ToObject
<
RunCodeActionParams
>();
var
document
=
runRequest
.
CodeActionParams
.
TextDocument
.
GetDocument
(
_solutionProvider
);
var
document
=
_solutionProvider
.
GetDocument
(
runRequest
.
CodeActionParams
.
TextDocument
);
var
codeActions
=
await
CodeActionsHandler
.
GetCodeActionsAsync
(
document
,
_codeFixService
,
_codeRefactoringService
,
runRequest
.
CodeActionParams
.
Range
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
src/VisualStudio/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs
浏览文件 @
39f62eb5
...
...
@@ -55,15 +55,13 @@ protected override ExportProvider GetExportProvider()
// Get all of the execute workspace command handlers in M.CA.LanguageServer
var
executeCommandHandlerTypes
=
DesktopTestHelpers
.
GetAllTypesImplementingGivenInterface
(
typeof
(
IExecuteWorkspaceCommandHandler
).
Assembly
,
typeof
(
IExecuteWorkspaceCommandHandler
));
var
solutionProviderTypes
=
DesktopTestHelpers
.
GetAllTypesImplementingGivenInterface
(
typeof
(
TestLspSolutionProvider
).
Assembly
,
typeof
(
ILspSolutionProvider
));
var
exportProviderFactory
=
ExportProviderCache
.
GetOrCreateExportProviderFactory
(
TestExportProvider
.
EntireAssemblyCatalogWithCSharpAndVisualBasic
.
WithPart
(
typeof
(
MockDocumentNavigationServiceFactory
))
.
WithParts
(
liveShareRequestHelperTypes
)
.
WithParts
(
roslynRequestHelperTypes
)
.
WithParts
(
executeCommandHandlerTypes
)
.
WithPart
s
(
solutionProviderTypes
));
.
WithPart
(
typeof
(
TestLspSolutionProvider
)
));
return
exportProviderFactory
.
CreateExportProvider
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录