Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e4f9f7b7
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,发现更多精彩内容 >>
提交
e4f9f7b7
编写于
4月 17, 2020
作者:
D
David Barbet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove indirection layer
上级
9c0e7a1a
变更
27
展开全部
隐藏空白更改
内联
并排
Showing
27 changed file
with
110 addition
and
308 deletion
+110
-308
src/Features/LanguageServer/Protocol/Extensions/Extensions.cs
...Features/LanguageServer/Protocol/Extensions/Extensions.cs
+11
-1
src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs
...geServer/Protocol/Handler/Completion/CompletionHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs
...ver/Protocol/Handler/Definitions/GoToDefinitionHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs
...Protocol/Handler/References/FindImplementationsHandler.cs
+2
-2
src/Features/LanguageServer/Protocol/LanguageServerProtocol.cs
...eatures/LanguageServer/Protocol/LanguageServerProtocol.cs
+1
-230
src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs
...eServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs
...er/ProtocolUnitTests/Completion/CompletionResolveTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs
...ageServer/ProtocolUnitTests/Completion/CompletionTests.cs
+5
-5
src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs
...rver/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs
.../ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs
...ver/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs
...ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs
.../ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentTests.cs
...erver/ProtocolUnitTests/Formatting/FormatDocumentTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs
...er/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs
...ures/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Initialize/InitializeTests.cs
...ageServer/ProtocolUnitTests/Initialize/InitializeTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs
...ocolUnitTests/References/FindAllReferencesHandlerTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/References/FindImplementationsTests.cs
.../ProtocolUnitTests/References/FindImplementationsTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs
...es/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs
...ver/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs
...eServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs
+2
-1
src/Features/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs
...Server/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs
+2
-1
src/VisualStudio/Core/Def/Implementation/LanguageClient/AbstractLanguageServerClient.cs
...ementation/LanguageClient/AbstractLanguageServerClient.cs
+6
-5
src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs
...Def/Implementation/LanguageClient/InProcLanguageServer.cs
+40
-25
src/VisualStudio/Core/Def/Implementation/LanguageClient/RazorLanguageClient.cs
.../Def/Implementation/LanguageClient/RazorLanguageClient.cs
+1
-1
src/VisualStudio/LiveShare/Impl/Shims/TypeScriptHandlerShims.cs
...sualStudio/LiveShare/Impl/Shims/TypeScriptHandlerShims.cs
+6
-18
未找到文件。
src/Features/LanguageServer/Protocol/Extensions/Extensions.cs
浏览文件 @
e4f9f7b7
...
...
@@ -7,6 +7,7 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.LanguageServer.Protocol
;
using
Microsoft.VisualStudio.Text.Adornments
;
...
...
@@ -28,7 +29,16 @@ public static Document GetDocumentFromURI(this Solution solution, Uri fileName)
var
documentId
=
solution
.
GetDocumentIdsWithFilePath
(
fileName
.
AbsolutePath
).
FirstOrDefault
()
??
solution
.
GetDocumentIdsWithFilePath
(
fileName
.
LocalPath
).
FirstOrDefault
();
return
solution
.
GetDocument
(
documentId
);
var
document
=
solution
.
GetDocument
(
documentId
);
var
documentPropertiesService
=
document
.
Services
.
GetService
<
DocumentPropertiesService
>();
if
(
documentPropertiesService
.
DesignTimeOnly
)
{
return
null
;
}
return
document
;
}
public
static
async
Task
<
int
>
GetPositionFromLinePositionAsync
(
this
Document
document
,
LinePosition
linePosition
,
CancellationToken
cancellationToken
)
...
...
src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs
浏览文件 @
e4f9f7b7
...
...
@@ -24,7 +24,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
/// </summary>
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentCompletionName
)]
internal
class
CompletionHandler
:
IRequestHandler
<
LSP
.
CompletionParams
,
LSP
.
SumType
<
LSP
.
CompletionItem
[],
LSP
.
CompletionList
>?
>
internal
class
CompletionHandler
:
IRequestHandler
<
LSP
.
CompletionParams
,
LSP
.
CompletionItem
[
]
>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -32,7 +32,7 @@ public CompletionHandler()
{
}
public
async
Task
<
LSP
.
SumType
<
LSP
.
CompletionItem
[],
LSP
.
CompletionList
>?
>
HandleRequestAsync
(
Solution
solution
,
LSP
.
CompletionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
public
async
Task
<
LSP
.
CompletionItem
[
]
>
HandleRequestAsync
(
Solution
solution
,
LSP
.
CompletionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
CancellationToken
cancellationToken
)
{
var
document
=
solution
.
GetDocumentFromURI
(
request
.
TextDocument
.
Uri
);
...
...
src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs
浏览文件 @
e4f9f7b7
...
...
@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentDefinitionName
)]
internal
class
GoToDefinitionHandler
:
GoToDefinitionHandlerBase
,
IRequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
SumType
<
LSP
.
Location
,
LSP
.
Location
[
]>
?
>
internal
class
GoToDefinitionHandler
:
GoToDefinitionHandlerBase
,
IRequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]
>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -24,7 +24,7 @@ public GoToDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileSe
{
}
public
async
Task
<
LSP
.
SumType
<
LSP
.
Location
,
LSP
.
Location
[
]>
?
>
HandleRequestAsync
(
Solution
solution
,
LSP
.
TextDocumentPositionParams
request
,
public
async
Task
<
LSP
.
Location
[
]
>
HandleRequestAsync
(
Solution
solution
,
LSP
.
TextDocumentPositionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
CancellationToken
cancellationToken
)
{
return
await
GetDefinitionAsync
(
solution
,
request
,
typeOnly
:
false
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
...
...
src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs
浏览文件 @
e4f9f7b7
...
...
@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
[
Shared
]
[
ExportLspMethod
(
LSP
.
Methods
.
TextDocumentImplementationName
)]
internal
class
FindImplementationsHandler
:
IRequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
SumType
<
LSP
.
Location
,
LSP
.
Location
[
]>
?
>
internal
class
FindImplementationsHandler
:
IRequestHandler
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]
>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -26,7 +26,7 @@ public FindImplementationsHandler()
{
}
public
async
Task
<
LSP
.
SumType
<
LSP
.
Location
,
LSP
.
Location
[
]>
?
>
HandleRequestAsync
(
Solution
solution
,
LSP
.
TextDocumentPositionParams
request
,
public
async
Task
<
LSP
.
Location
[
]
>
HandleRequestAsync
(
Solution
solution
,
LSP
.
TextDocumentPositionParams
request
,
LSP
.
ClientCapabilities
clientCapabilities
,
CancellationToken
cancellationToken
)
{
var
locations
=
ArrayBuilder
<
LSP
.
Location
>.
GetInstance
();
...
...
src/Features/LanguageServer/Protocol/LanguageServerProtocol.cs
浏览文件 @
e4f9f7b7
此差异已折叠。
点击以展开。
src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -37,7 +37,8 @@ void M()
private
static
async
Task
<
LSP
.
Command
[
]>
RunGetCodeActionsAsync
(
Solution
solution
,
LSP
.
Location
caret
,
LSP
.
ClientCapabilities
clientCapabilities
=
null
)
{
var
results
=
await
GetLanguageServer
(
solution
).
GetCodeActionsAsync
(
solution
,
CreateCodeActionParams
(
caret
),
clientCapabilities
,
CancellationToken
.
None
);
var
results
=
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
CodeActionParams
,
LSP
.
SumType
<
LSP
.
Command
,
LSP
.
CodeAction
>[
]>
(
LSP
.
Methods
.
TextDocumentCodeActionName
,
solution
,
CreateCodeActionParams
(
caret
),
clientCapabilities
,
CancellationToken
.
None
);
return
results
.
Select
(
r
=>
(
LSP
.
Command
)
r
).
ToArray
();
}
...
...
src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -39,7 +39,8 @@ void M()
}
private
static
async
Task
<
object
>
RunResolveCompletionItemAsync
(
Solution
solution
,
LSP
.
CompletionItem
completionItem
,
LSP
.
ClientCapabilities
clientCapabilities
=
null
)
=>
await
GetLanguageServer
(
solution
).
ResolveCompletionItemAsync
(
solution
,
completionItem
,
clientCapabilities
,
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
CompletionItem
,
LSP
.
CompletionItem
>(
LSP
.
Methods
.
TextDocumentCompletionResolveName
,
solution
,
completionItem
,
clientCapabilities
,
CancellationToken
.
None
);
private
static
LSP
.
VSCompletionItem
CreateResolvedCompletionItem
(
string
text
,
LSP
.
CompletionItemKind
kind
,
string
[]
tags
,
LSP
.
CompletionParams
requestParameters
,
ClassifiedTextElement
description
,
string
detail
,
string
documentation
)
...
...
src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -30,8 +30,7 @@ void M()
var
clientCapabilities
=
new
LSP
.
VSClientCapabilities
{
SupportsVisualStudioExtensions
=
true
};
var
results
=
await
RunGetCompletionsAsync
(
workspace
.
CurrentSolution
,
locations
[
"caret"
].
Single
(),
clientCapabilities
).
ConfigureAwait
(
false
);
var
completionItems
=
(
LSP
.
CompletionItem
[])
results
.
Value
;
AssertJsonEquals
(
expected
,
completionItems
.
First
());
AssertJsonEquals
(
expected
,
results
.
First
());
}
[
Fact
]
...
...
@@ -56,12 +55,13 @@ void M()
var
expected
=
CreateCompletionItem
(
"A"
,
LSP
.
CompletionItemKind
.
Class
,
new
string
[]
{
"Class"
,
"Internal"
},
CreateCompletionParams
(
locations
[
"caret"
].
Single
()));
var
clientCapabilities
=
new
LSP
.
VSClientCapabilities
{
SupportsVisualStudioExtensions
=
true
};
var
results
=
(
LSP
.
CompletionItem
[])
await
RunGetCompletionsAsync
(
solution
,
locations
[
"caret"
].
Single
(),
clientCapabilities
);
var
results
=
await
RunGetCompletionsAsync
(
solution
,
locations
[
"caret"
].
Single
(),
clientCapabilities
);
Assert
.
False
(
results
.
Any
(
item
=>
"Console"
==
item
.
Label
));
}
private
static
async
Task
<
LSP
.
SumType
<
LSP
.
CompletionItem
[],
LSP
.
CompletionList
>?>
RunGetCompletionsAsync
(
Solution
solution
,
LSP
.
Location
caret
,
LSP
.
ClientCapabilities
clientCapabilities
=
null
)
=>
await
GetLanguageServer
(
solution
).
GetCompletionsAsync
(
solution
,
CreateCompletionParams
(
caret
),
clientCapabilities
,
CancellationToken
.
None
);
private
static
async
Task
<
LSP
.
CompletionItem
[
]>
RunGetCompletionsAsync
(
Solution
solution
,
LSP
.
Location
caret
,
LSP
.
ClientCapabilities
clientCapabilities
=
null
)
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
CompletionParams
,
LSP
.
CompletionItem
[
]>
(
LSP
.
Methods
.
TextDocumentCompletionName
,
solution
,
CreateCompletionParams
(
caret
),
clientCapabilities
,
CancellationToken
.
None
);
}
}
src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -76,6 +76,7 @@ void M()
}
private
static
async
Task
<
LSP
.
Location
[
]>
RunGotoDefinitionAsync
(
Solution
solution
,
LSP
.
Location
caret
)
=>
(
LSP
.
Location
[])
await
GetLanguageServer
(
solution
).
GoToDefinitionAsync
(
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]>
(
LSP
.
Methods
.
TextDocumentDefinitionName
,
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
}
}
src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -75,6 +75,7 @@ class B
}
private
static
async
Task
<
LSP
.
Location
[
]>
RunGotoTypeDefinitionAsync
(
Solution
solution
,
LSP
.
Location
caret
)
=>
await
GetLanguageServer
(
solution
).
GoToTypeDefinitionAsync
(
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]>
(
LSP
.
Methods
.
TextDocumentTypeDefinitionName
,
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
}
}
src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -69,7 +69,8 @@ private static async Task<LSP.FoldingRange[]> RunGetFoldingRangeAsync(Solution s
TextDocument
=
CreateTextDocumentIdentifier
(
new
Uri
(
document
.
FilePath
))
};
return
await
GetLanguageServer
(
solution
).
GetFoldingRangeAsync
(
solution
,
request
,
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
return
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
FoldingRangeParams
,
LSP
.
FoldingRange
[
]>
(
LSP
.
Methods
.
TextDocumentFoldingRangeName
,
solution
,
request
,
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
}
private
static
LSP
.
FoldingRange
CreateFoldingRange
(
LSP
.
FoldingRangeKind
kind
,
LSP
.
Range
range
)
...
...
src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -46,7 +46,8 @@ void M()
private
static
async
Task
<
LSP
.
TextEdit
[
]>
RunFormatDocumentOnTypeAsync
(
Solution
solution
,
string
characterTyped
,
LSP
.
Location
locationTyped
)
=>
await
GetLanguageServer
(
solution
)
.
FormatDocumentOnTypeAsync
(
solution
,
CreateDocumentOnTypeFormattingParams
(
characterTyped
,
locationTyped
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
.
ExecuteRequestAsync
<
LSP
.
DocumentOnTypeFormattingParams
,
LSP
.
TextEdit
[
]>
(
LSP
.
Methods
.
TextDocumentOnTypeFormattingName
,
solution
,
CreateDocumentOnTypeFormattingParams
(
characterTyped
,
locationTyped
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
private
static
LSP
.
DocumentOnTypeFormattingParams
CreateDocumentOnTypeFormattingParams
(
string
characterTyped
,
LSP
.
Location
locationTyped
)
=>
new
LSP
.
DocumentOnTypeFormattingParams
()
...
...
src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -42,7 +42,8 @@ void M()
}
private
static
async
Task
<
LSP
.
TextEdit
[
]>
RunFormatDocumentRangeAsync
(
Solution
solution
,
LSP
.
Location
location
)
=>
await
GetLanguageServer
(
solution
).
FormatDocumentRangeAsync
(
solution
,
CreateDocumentRangeFormattingParams
(
location
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
DocumentRangeFormattingParams
,
LSP
.
TextEdit
[
]>
(
LSP
.
Methods
.
TextDocumentRangeFormattingName
,
solution
,
CreateDocumentRangeFormattingParams
(
location
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
private
static
LSP
.
DocumentRangeFormattingParams
CreateDocumentRangeFormattingParams
(
LSP
.
Location
location
)
=>
new
LSP
.
DocumentRangeFormattingParams
()
...
...
src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -43,7 +43,8 @@ void M()
}
private
static
async
Task
<
LSP
.
TextEdit
[
]>
RunFormatDocumentAsync
(
Solution
solution
,
Uri
uri
)
=>
await
GetLanguageServer
(
solution
).
FormatDocumentAsync
(
solution
,
CreateDocumentFormattingParams
(
uri
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
DocumentFormattingParams
,
LSP
.
TextEdit
[
]>
(
LSP
.
Methods
.
TextDocumentFormattingName
,
solution
,
CreateDocumentFormattingParams
(
uri
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
private
static
LSP
.
DocumentFormattingParams
CreateDocumentFormattingParams
(
Uri
uri
)
=>
new
LSP
.
DocumentFormattingParams
()
...
...
src/Features/LanguageServer/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -61,7 +61,8 @@ void M()
private
static
async
Task
<
LSP
.
DocumentHighlight
[
]>
RunGetDocumentHighlightAsync
(
Solution
solution
,
LSP
.
Location
caret
)
{
var
results
=
await
GetLanguageServer
(
solution
).
GetDocumentHighlightAsync
(
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
var
results
=
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
TextDocumentPositionParams
,
LSP
.
DocumentHighlight
[
]>
(
LSP
.
Methods
.
TextDocumentDocumentHighlightName
,
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
Array
.
Sort
(
results
,
(
h1
,
h2
)
=>
{
var
compareKind
=
h1
.
Kind
.
CompareTo
(
h2
.
Kind
);
...
...
src/Features/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -137,7 +137,8 @@ private string Method(int i)
}
private
static
async
Task
<
LSP
.
Hover
>
RunGetHoverAsync
(
Solution
solution
,
LSP
.
Location
caret
)
=>
await
GetLanguageServer
(
solution
).
GetHoverAsync
(
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Hover
>(
LSP
.
Methods
.
TextDocumentHoverName
,
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
private
static
LSP
.
Hover
CreateHover
(
LSP
.
Location
location
,
string
text
)
=>
new
LSP
.
Hover
()
...
...
src/Features/LanguageServer/ProtocolUnitTests/Initialize/InitializeTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -23,7 +23,8 @@ public async Task TestInitializeAsync()
}
private
static
async
Task
<
LSP
.
InitializeResult
>
RunInitializeAsync
(
Solution
solution
,
LSP
.
InitializeParams
request
)
=>
await
GetLanguageServer
(
solution
).
InitializeAsync
(
solution
,
request
,
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
InitializeParams
,
LSP
.
InitializeResult
>(
LSP
.
Methods
.
InitializeName
,
solution
,
request
,
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
private
static
void
AssertServerCapabilities
(
LSP
.
ServerCapabilities
actual
)
{
...
...
src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -129,7 +129,8 @@ private static async Task<LSP.VSReferenceItem[]> RunFindAllReferencesAsync(Solut
SupportsVisualStudioExtensions
=
true
};
return
await
GetLanguageServer
(
solution
).
GetDocumentReferencesAsync
(
solution
,
CreateReferenceParams
(
caret
),
vsClientCapabilities
,
CancellationToken
.
None
);
return
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
ReferenceParams
,
LSP
.
VSReferenceItem
[
]>
(
LSP
.
Methods
.
TextDocumentReferencesName
,
solution
,
CreateReferenceParams
(
caret
),
vsClientCapabilities
,
CancellationToken
.
None
);
}
private
static
void
AssertValidDefinitionProperties
(
LSP
.
ReferenceItem
[]
referenceItems
,
int
definitionIndex
)
...
...
src/Features/LanguageServer/ProtocolUnitTests/References/FindImplementationsTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -80,6 +80,7 @@ void M()
}
private
static
async
Task
<
LSP
.
Location
[
]>
RunFindImplementationAsync
(
Solution
solution
,
LSP
.
Location
caret
)
=>
(
LSP
.
Location
[])
await
GetLanguageServer
(
solution
).
FindImplementationsAsync
(
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
TextDocumentPositionParams
,
LSP
.
Location
[
]>
(
LSP
.
Methods
.
TextDocumentImplementationName
,
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
}
}
src/Features/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -45,6 +45,7 @@ private static LSP.RenameParams CreateRenameParams(LSP.Location location, string
};
private
static
async
Task
<
WorkspaceEdit
>
RunRenameAsync
(
Solution
solution
,
LSP
.
Location
renameLocation
,
string
renamevalue
)
=>
await
GetLanguageServer
(
solution
).
RenameAsync
(
solution
,
CreateRenameParams
(
renameLocation
,
renamevalue
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
RenameParams
,
LSP
.
WorkspaceEdit
>(
LSP
.
Methods
.
TextDocumentRenameName
,
solution
,
CreateRenameParams
(
renameLocation
,
renamevalue
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
}
}
src/Features/LanguageServer/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -45,7 +45,8 @@ int M2(string a)
}
private
static
async
Task
<
LSP
.
SignatureHelp
>
RunGetSignatureHelpAsync
(
Solution
solution
,
LSP
.
Location
caret
)
=>
await
GetLanguageServer
(
solution
).
GetSignatureHelpAsync
(
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
=>
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
TextDocumentPositionParams
,
LSP
.
SignatureHelp
>(
LSP
.
Methods
.
TextDocumentSignatureHelpName
,
solution
,
CreateTextDocumentPositionParams
(
caret
),
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
private
static
LSP
.
SignatureInformation
CreateSignatureInformation
(
string
methodLabal
,
string
methodDocumentation
,
string
parameterLabel
,
string
parameterDocumentation
)
=>
new
LSP
.
SignatureInformation
()
...
...
src/Features/LanguageServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -102,7 +102,8 @@ private static async Task<object[]> RunGetDocumentSymbolsAsync(Solution solution
}
};
return
await
GetLanguageServer
(
solution
).
GetDocumentSymbolsAsync
(
solution
,
request
,
clientCapabilities
,
CancellationToken
.
None
);
return
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
DocumentSymbolParams
,
object
[
]>
(
LSP
.
Methods
.
TextDocumentDocumentSymbolName
,
solution
,
request
,
clientCapabilities
,
CancellationToken
.
None
);
}
private
static
void
AssertDocumentSymbolEquals
(
LSP
.
DocumentSymbol
expected
,
LSP
.
DocumentSymbol
actual
)
...
...
src/Features/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs
浏览文件 @
e4f9f7b7
...
...
@@ -156,7 +156,8 @@ private static async Task<LSP.SymbolInformation[]> RunGetWorkspaceSymbolsAsync(S
Query
=
query
};
return
await
GetLanguageServer
(
solution
).
GetWorkspaceSymbolsAsync
(
solution
,
request
,
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
return
await
GetLanguageServer
(
solution
).
ExecuteRequestAsync
<
LSP
.
WorkspaceSymbolParams
,
LSP
.
SymbolInformation
[
]>
(
LSP
.
Methods
.
WorkspaceSymbolName
,
solution
,
request
,
new
LSP
.
ClientCapabilities
(),
CancellationToken
.
None
);
}
}
}
src/VisualStudio/Core/Def/Implementation/LanguageClient/AbstractLanguageServerClient.cs
浏览文件 @
e4f9f7b7
...
...
@@ -27,11 +27,12 @@ internal abstract class AbstractLanguageServerClient : ILanguageClient
private
InProcLanguageServer
?
_languageServer
;
/// <summary>
/// Allows the implementation to specify if hover should be supported from this language client.
/// Can be removed as soon as LSP supports classifications in hover.
/// Tracking - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/918138/
/// Allows the implementation to specify if c# razor features should be supported from this Language server.
/// Can be removed as soon as
/// - LSP supports classifications in hover https://devdiv.visualstudio.com/DevDiv/_workitems/edit/918138/
/// - Live share supports client name - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1106064/
/// </summary>
protected
virtual
bool
Supports
Hover
=>
false
;
protected
virtual
bool
Supports
RazorFeatures
=>
false
;
/// <summary>
/// Gets the name of the language client (displayed to the user).
...
...
@@ -78,7 +79,7 @@ public Task<Connection> ActivateAsync(CancellationToken token)
Contract
.
ThrowIfFalse
(
_languageServer
==
null
,
"This language server has already been initialized"
);
var
(
clientStream
,
serverStream
)
=
FullDuplexStream
.
CreatePair
();
_languageServer
=
new
InProcLanguageServer
(
serverStream
,
serverStream
,
_languageServerProtocol
,
_workspace
,
_diagnosticService
,
clientName
:
_diagnosticsClientName
,
Supports
Hover
);
_languageServer
=
new
InProcLanguageServer
(
serverStream
,
serverStream
,
_languageServerProtocol
,
_workspace
,
_diagnosticService
,
clientName
:
_diagnosticsClientName
,
Supports
RazorFeatures
);
return
Task
.
FromResult
(
new
Connection
(
clientStream
,
clientStream
));
}
...
...
src/VisualStudio/Core/Def/Implementation/LanguageClient/InProcLanguageServer.cs
浏览文件 @
e4f9f7b7
...
...
@@ -9,7 +9,6 @@
using
System.Collections.Immutable
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.Remoting.Messaging
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis
;
...
...
@@ -40,7 +39,7 @@ internal class InProcLanguageServer
private
readonly
string
?
_clientName
;
private
readonly
JsonRpc
_jsonRpc
;
private
readonly
LanguageServerProtocol
_protocol
;
private
readonly
bool
_supports
Hover
;
private
readonly
bool
_supports
RazorFeatures
;
private
readonly
CodeAnalysis
.
Workspace
_workspace
;
// The VS LSP client supports streaming using IProgress<T> on various requests.
...
...
@@ -68,7 +67,7 @@ internal class InProcLanguageServer
{
_protocol
=
protocol
;
_workspace
=
workspace
;
_supports
Hover
=
supportsHover
;
_supports
RazorFeatures
=
supportsHover
;
_jsonRpc
=
new
JsonRpc
(
outputStream
,
inputStream
,
this
);
_jsonRpc
.
StartListening
();
...
...
@@ -92,10 +91,12 @@ public async Task<InitializeResult> InitializeAsync(JToken input, CancellationTo
// sends additional VS specific capabilities, so directly deserialize them into the VSClientCapabilities
// to avoid losing them.
_clientCapabilities
=
input
[
"capabilities"
].
ToObject
<
VSClientCapabilities
>(
JsonSerializer
);
var
serverCapabilities
=
await
_protocol
.
InitializeAsync
(
_workspace
.
CurrentSolution
,
input
.
ToObject
<
InitializeParams
>(
JsonSerializer
),
_clientCapabilities
,
cancellationToken
).
ConfigureAwait
(
false
);
var
serverCapabilities
=
await
_protocol
.
ExecuteRequestAsync
<
InitializeParams
,
InitializeResult
>(
Methods
.
InitializeName
,
_workspace
.
CurrentSolution
,
input
.
ToObject
<
InitializeParams
>(
JsonSerializer
),
_clientCapabilities
,
cancellationToken
).
ConfigureAwait
(
false
);
// As soon as LSP supports classifications in hover, we can remove this and always advertise hover support.
// Tracking - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/918138/
serverCapabilities
.
Capabilities
.
HoverProvider
=
_supports
Hover
;
serverCapabilities
.
Capabilities
.
HoverProvider
=
_supports
RazorFeatures
;
return
serverCapabilities
;
}
...
...
@@ -124,101 +125,115 @@ public void Exit()
}
[
JsonRpcMethod
(
Methods
.
TextDocumentDefinitionName
)]
public
Task
<
SumType
<
LSP
.
Location
,
LSP
.
Location
[
]>
?
>
GetTextDocumentDefinitionAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
public
Task
<
LSP
.
Location
[
]
>
GetTextDocumentDefinitionAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
textDocumentPositionParams
=
input
.
ToObject
<
TextDocumentPositionParams
>(
JsonSerializer
);
return
_protocol
.
GoToDefinitionAsync
(
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
TextDocumentPositionParams
,
LSP
.
Location
[
]>
(
Methods
.
TextDocumentDefinitionName
,
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentRenameName
)]
public
Task
<
WorkspaceEdit
>
GetTextDocumentRenameAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
renameParams
=
input
.
ToObject
<
RenameParams
>(
JsonSerializer
);
return
_protocol
.
RenameAsync
(
_workspace
.
CurrentSolution
,
renameParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
RenameParams
,
WorkspaceEdit
>(
Methods
.
TextDocumentRenameName
,
_workspace
.
CurrentSolution
,
renameParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentReferencesName
)]
public
Task
<
VSReferenceItem
[
]>
GetTextDocumentReferencesAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
referencesParams
=
input
.
ToObject
<
ReferenceParams
>(
JsonSerializer
);
return
_protocol
.
GetDocumentReferencesAsync
(
_workspace
.
CurrentSolution
,
referencesParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
ReferenceParams
,
VSReferenceItem
[
]>
(
Methods
.
TextDocumentReferencesName
,
_workspace
.
CurrentSolution
,
referencesParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentCompletionName
)]
public
Task
<
SumType
<
CompletionItem
[],
CompletionList
>?
>
GetTextDocumentCompletionAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
public
Task
<
CompletionItem
[
]
>
GetTextDocumentCompletionAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
completionParams
=
input
.
ToObject
<
CompletionParams
>(
JsonSerializer
);
return
_protocol
.
GetCompletionsAsync
(
_workspace
.
CurrentSolution
,
completionParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
CompletionParams
,
CompletionItem
[
]>
(
Methods
.
TextDocumentCompletionName
,
_workspace
.
CurrentSolution
,
completionParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentCompletionResolveName
)]
public
Task
<
CompletionItem
>
ResolveCompletionItemAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
completionItem
=
input
.
ToObject
<
CompletionItem
>(
JsonSerializer
);
return
_protocol
.
ResolveCompletionItemAsync
(
_workspace
.
CurrentSolution
,
completionItem
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
CompletionItem
,
CompletionItem
>(
Methods
.
TextDocumentCompletionResolveName
,
_workspace
.
CurrentSolution
,
completionItem
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentDocumentHighlightName
)]
public
Task
<
DocumentHighlight
[
]>
GetTextDocumentDocumentHighlightsAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
textDocumentPositionParams
=
input
.
ToObject
<
TextDocumentPositionParams
>(
JsonSerializer
);
return
_protocol
.
GetDocumentHighlightAsync
(
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
TextDocumentPositionParams
,
DocumentHighlight
[
]>
(
Methods
.
TextDocumentDocumentHighlightName
,
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentHoverName
)]
public
Task
<
Hover
>
GetTextDocumentDocumentHoverAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
textDocumentPositionParams
=
input
.
ToObject
<
TextDocumentPositionParams
>();
return
_protocol
.
GetHoverAsync
(
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
TextDocumentPositionParams
,
Hover
>(
Methods
.
TextDocumentHoverName
,
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentDocumentSymbolName
)]
public
Task
<
object
[
]>
GetTextDocumentDocumentSymbolsAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
documentSymbolParams
=
input
.
ToObject
<
DocumentSymbolParams
>(
JsonSerializer
);
return
_protocol
.
GetDocumentSymbolsAsync
(
_workspace
.
CurrentSolution
,
documentSymbolParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
DocumentSymbolParams
,
object
[
]>
(
Methods
.
TextDocumentDocumentSymbolName
,
_workspace
.
CurrentSolution
,
documentSymbolParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentFormattingName
)]
public
Task
<
TextEdit
[
]>
GetTextDocumentFormattingAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
documentFormattingParams
=
input
.
ToObject
<
DocumentFormattingParams
>(
JsonSerializer
);
return
_protocol
.
FormatDocumentAsync
(
_workspace
.
CurrentSolution
,
documentFormattingParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
DocumentFormattingParams
,
TextEdit
[
]>
(
Methods
.
TextDocumentFormattingName
,
_workspace
.
CurrentSolution
,
documentFormattingParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentOnTypeFormattingName
)]
public
Task
<
TextEdit
[
]>
GetTextDocumentFormattingOnTypeAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
documentOnTypeFormattingParams
=
input
.
ToObject
<
DocumentOnTypeFormattingParams
>(
JsonSerializer
);
return
_protocol
.
FormatDocumentOnTypeAsync
(
_workspace
.
CurrentSolution
,
documentOnTypeFormattingParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
DocumentOnTypeFormattingParams
,
TextEdit
[
]>
(
Methods
.
TextDocumentOnTypeFormattingName
,
_workspace
.
CurrentSolution
,
documentOnTypeFormattingParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentImplementationName
)]
public
Task
<
SumType
<
LSP
.
Location
,
LSP
.
Location
[
]>
?
>
GetTextDocumentImplementationsAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
public
Task
<
LSP
.
Location
[
]
>
GetTextDocumentImplementationsAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
textDocumentPositionParams
=
input
.
ToObject
<
TextDocumentPositionParams
>(
JsonSerializer
);
return
_protocol
.
FindImplementationsAsync
(
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
var
textDocumentPositionParams
=
input
.
ToObject
<
TextDocumentPositionParams
>();
return
_protocol
.
ExecuteRequestAsync
<
TextDocumentPositionParams
,
LSP
.
Location
[
]>
(
Methods
.
TextDocumentImplementationName
,
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentRangeFormattingName
)]
public
Task
<
TextEdit
[
]>
GetTextDocumentRangeFormattingAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
documentRangeFormattingParams
=
input
.
ToObject
<
DocumentRangeFormattingParams
>(
JsonSerializer
);
return
_protocol
.
FormatDocumentRangeAsync
(
_workspace
.
CurrentSolution
,
documentRangeFormattingParams
,
_clientCapabilities
,
cancellationToken
);
return
_protocol
.
ExecuteRequestAsync
<
DocumentRangeFormattingParams
,
TextEdit
[
]>
(
Methods
.
TextDocumentRangeFormattingName
,
_workspace
.
CurrentSolution
,
documentRangeFormattingParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
TextDocumentSignatureHelpName
)]
public
async
Task
<
SignatureHelp
>
GetTextDocumentSignatureHelpAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
public
Task
<
SignatureHelp
>
GetTextDocumentSignatureHelpAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
textDocumentPositionParams
=
input
.
ToObject
<
TextDocumentPositionParams
>(
JsonSerializer
);
return
await
_protocol
.
GetSignatureHelpAsync
(
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
).
ConfigureAwait
(
false
);
return
_protocol
.
ExecuteRequestAsync
<
TextDocumentPositionParams
,
SignatureHelp
>(
Methods
.
TextDocumentSignatureHelpName
,
_workspace
.
CurrentSolution
,
textDocumentPositionParams
,
_clientCapabilities
,
cancellationToken
);
}
[
JsonRpcMethod
(
Methods
.
WorkspaceSymbolName
)]
public
async
Task
<
SymbolInformation
[
]>
GetWorkspaceSymbolsAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
public
Task
<
SymbolInformation
[
]>
GetWorkspaceSymbolsAsync
(
JToken
input
,
CancellationToken
cancellationToken
)
{
var
workspaceSymbolParams
=
input
.
ToObject
<
WorkspaceSymbolParams
>(
JsonSerializer
);
return
await
_protocol
.
GetWorkspaceSymbolsAsync
(
_workspace
.
CurrentSolution
,
workspaceSymbolParams
,
_clientCapabilities
,
cancellationToken
).
ConfigureAwait
(
false
);
return
_protocol
.
ExecuteRequestAsync
<
WorkspaceSymbolParams
,
SymbolInformation
[
]>
(
Methods
.
WorkspaceSymbolName
,
_workspace
.
CurrentSolution
,
workspaceSymbolParams
,
_clientCapabilities
,
cancellationToken
);
}
#pragma warning disable VSTHRD100 // Avoid async void methods
...
...
src/VisualStudio/Core/Def/Implementation/LanguageClient/RazorLanguageClient.cs
浏览文件 @
e4f9f7b7
...
...
@@ -32,7 +32,7 @@ internal class RazorLanguageClient : AbstractLanguageServerClient
{
public
const
string
ClientName
=
"RazorCSharp"
;
protected
override
bool
Supports
Hover
=>
true
;
protected
override
bool
Supports
RazorFeatures
=>
true
;
/// <summary>
/// Gets the name of the language client (displayed to the user).
...
...
src/VisualStudio/LiveShare/Impl/Shims/TypeScriptHandlerShims.cs
浏览文件 @
e4f9f7b7
...
...
@@ -30,7 +30,7 @@
namespace
Microsoft.VisualStudio.LanguageServices.LiveShare
{
[
ExportLspRequestHandler
(
LiveShareConstants
.
TypeScriptContractName
,
Methods
.
TextDocumentCompletionName
)]
internal
class
TypeScriptCompletionHandlerShim
:
CompletionHandler
,
ILspRequestHandler
<
object
,
object
?
,
Solution
>
internal
class
TypeScriptCompletionHandlerShim
:
CompletionHandler
,
ILspRequestHandler
<
object
,
LanguageServer
.
Protocol
.
CompletionItem
[]
,
Solution
>
{
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
...
...
@@ -38,18 +38,13 @@ public TypeScriptCompletionHandlerShim()
{
}
public
async
Task
<
object
?
>
HandleAsync
(
object
input
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
public
Task
<
LanguageServer
.
Protocol
.
CompletionItem
[
]
>
HandleAsync
(
object
input
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
{
// The VS LSP client supports streaming using IProgress<T> on various requests.
// However, this is not yet supported through Live Share, so deserialization fails on the IProgress<T> property.
// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1043376 tracks Live Share support for this (committed for 16.6).
var
request
=
((
JObject
)
input
).
ToObject
<
CompletionParams
>(
InProcLanguageServer
.
JsonSerializer
);
// The return definition for TextDocumentCompletionName is SumType<CompletionItem[], CompletionList>.
// However Live Share is unable to handle a SumType return when using ILspRequestHandler.
// So instead we just return the actual value from the SumType.
// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1059193 tracks the fix.
var
result
=
await
base
.
HandleRequestAsync
(
requestContext
.
Context
,
request
,
requestContext
.
GetClientCapabilities
(),
cancellationToken
).
ConfigureAwait
(
false
);
return
result
?.
Value
;
return
base
.
HandleRequestAsync
(
requestContext
.
Context
,
request
,
requestContext
.
GetClientCapabilities
(),
cancellationToken
);
}
}
...
...
@@ -175,7 +170,7 @@ public Task<TextEdit[]> HandleAsync(DocumentOnTypeFormattingParams request, Requ
}
[
ExportLspRequestHandler
(
LiveShareConstants
.
TypeScriptContractName
,
Methods
.
TextDocumentImplementationName
)]
internal
class
TypeScriptFindImplementationsHandlerShim
:
FindImplementationsHandler
,
ILspRequestHandler
<
TextDocumentPositionParams
,
object
?
,
Solution
>
internal
class
TypeScriptFindImplementationsHandlerShim
:
FindImplementationsHandler
,
ILspRequestHandler
<
TextDocumentPositionParams
,
LanguageServer
.
Protocol
.
Location
[]
,
Solution
>
{
private
readonly
IThreadingContext
_threadingContext
;
...
...
@@ -184,15 +179,8 @@ internal class TypeScriptFindImplementationsHandlerShim : FindImplementationsHan
public
TypeScriptFindImplementationsHandlerShim
(
IThreadingContext
threadingContext
)
=>
_threadingContext
=
threadingContext
;
public
async
Task
<
object
?>
HandleAsync
(
TextDocumentPositionParams
request
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
{
// The return definition for TextDocumentImplementationName is SumType<Location, Location[]>.
// However Live Share is unable to handle a SumType return when using ILspRequestHandler.
// So instead we just return the actual value from the SumType.
// https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1059193 tracks the fix.
var
result
=
await
base
.
HandleRequestAsync
(
requestContext
.
Context
,
request
,
requestContext
.
GetClientCapabilities
(),
cancellationToken
).
ConfigureAwait
(
false
);
return
result
?.
Value
;
}
public
Task
<
LanguageServer
.
Protocol
.
Location
[
]>
HandleAsync
(
TextDocumentPositionParams
request
,
RequestContext
<
Solution
>
requestContext
,
CancellationToken
cancellationToken
)
=>
base
.
HandleRequestAsync
(
requestContext
.
Context
,
request
,
requestContext
.
GetClientCapabilities
(),
cancellationToken
);
protected
override
async
Task
FindImplementationsAsync
(
IFindUsagesService
findUsagesService
,
Document
document
,
int
position
,
SimpleFindUsagesContext
context
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录