Skip to content

Commit 45620bd

Browse files
authored
Enable LSP features in razor (.cshtml) files (II) (#278)
* tests/CSharpLanguageServer.Tests/Tooling.fs: make sure global.json is imported when running the tests * src/CSharpLanguageServer/Types.fs: use 'razor' language id for '.cshtml' files * src/CSharpLanguageServer/Handlers/References.fs: add logger * Misc cleanups * Update tests to use common fixtures * Setup fixtures in a more constrained fashion (max ncpu at the time) Also, fix a race in DiagnosticTests.fs:testPushDiagnosticsWork * .github/workflows/test.yaml: change name of the job, build -> test * Merge fixture data folders to increase sharing and reduce the number of test fixture files * Make sure shared fixtures are not being modified * Refactor how fixtures are acquired and shared * tests/CSharpLanguageServer.Tests/DiagnosticTests.fs: attempt to shake out instability in testWorkspaceDiagnosticsWorkWithStreaming * Directory.Packages.props: bump MSBuildPackageVersion
1 parent 218dcc6 commit 45620bd

File tree

78 files changed

+376
-545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+376
-545
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77

88
jobs:
9-
build:
9+
test:
1010
timeout-minutes: 10
1111
strategy:
1212
matrix:

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
66
</PropertyGroup>
77
<PropertyGroup>
8-
<MSBuildPackageVersion>17.14.8</MSBuildPackageVersion>
8+
<MSBuildPackageVersion>17.14.28</MSBuildPackageVersion>
99
<RoslynPackageVersion>4.14.0</RoslynPackageVersion>
1010
<MSBuildLocatorPackageVersion>1.9.1</MSBuildLocatorPackageVersion>
1111
</PropertyGroup>

src/CSharpLanguageServer/Handlers/CodeAction.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ module CodeAction =
313313
let provider (clientCapabilities: ClientCapabilities) : U2<bool, CodeActionOptions> option =
314314
let literalSupport =
315315
clientCapabilities.TextDocument
316-
|> Option.bind (fun x -> x.CodeAction)
317-
|> Option.bind (fun x -> x.CodeActionLiteralSupport)
316+
|> Option.bind _.CodeAction
317+
|> Option.bind _.CodeActionLiteralSupport
318318

319319
match literalSupport with
320320
| Some _ ->
@@ -341,8 +341,8 @@ module CodeAction =
341341

342342
let clientSupportsCodeActionEditResolveWithEditAndData =
343343
context.ClientCapabilities.TextDocument
344-
|> Option.bind (fun x -> x.CodeAction)
345-
|> Option.bind (fun x -> x.ResolveSupport)
344+
|> Option.bind _.CodeAction
345+
|> Option.bind _.ResolveSupport
346346
|> Option.map (fun resolveSupport -> resolveSupport.Properties |> Array.contains "edit")
347347
|> Option.defaultValue false
348348

src/CSharpLanguageServer/Handlers/Completion.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module Completion =
117117
member __.GetDescriptionAsync(doc, item, ct) =
118118
service.GetDescriptionAsync(doc, item, ct)
119119

120-
let provider (clientCapabilities: ClientCapabilities) : CompletionOptions option =
120+
let provider (_cc: ClientCapabilities) : CompletionOptions option =
121121
Some
122122
{ ResolveProvider = Some true
123123
TriggerCharacters = Some([| "."; "'" |])

src/CSharpLanguageServer/Handlers/DocumentSymbol.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ module DocumentSymbol =
288288
async {
289289
let canEmitDocSymbolHierarchy =
290290
context.ClientCapabilities.TextDocument
291-
|> Option.bind (fun cc -> cc.DocumentSymbol)
292-
|> Option.bind (fun cc -> cc.HierarchicalDocumentSymbolSupport)
291+
|> Option.bind _.DocumentSymbol
292+
|> Option.bind _.HierarchicalDocumentSymbolSupport
293293
|> Option.defaultValue false
294294

295295
match context.GetDocument p.TextDocument.Uri with

src/CSharpLanguageServer/Handlers/References.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ open Ionide.LanguageServerProtocol.JsonRpc
55

66
open CSharpLanguageServer.State
77
open CSharpLanguageServer.Conversions
8+
open CSharpLanguageServer.Logging
89

910
[<RequireQualifiedAccess>]
1011
module References =
12+
let private logger = Logging.getLoggerByName "References"
13+
1114
let provider (_: ClientCapabilities) : U2<bool, ReferenceOptions> option = Some(U2.C1 true)
1215

1316
let handle (context: ServerRequestContext) (p: ReferenceParams) : AsyncLspResult<Location[] option> = async {

src/CSharpLanguageServer/Handlers/Rename.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ module Rename =
7171

7272
let private prepareSupport (clientCapabilities: ClientCapabilities) =
7373
clientCapabilities.TextDocument
74-
|> Option.bind (fun x -> x.Rename)
75-
|> Option.bind (fun x -> x.PrepareSupport)
74+
|> Option.bind _.Rename
75+
|> Option.bind _.PrepareSupport
7676
|> Option.defaultValue false
7777

7878
let provider (clientCapabilities: ClientCapabilities) : U2<bool, RenameOptions> option =

src/CSharpLanguageServer/Handlers/Workspace.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ module Workspace =
2626

2727
let dynamicRegistrationForDidChangeWatchedFiles (clientCapabilities: ClientCapabilities) =
2828
clientCapabilities.Workspace
29-
|> Option.bind (fun x -> x.DidChangeWatchedFiles)
30-
|> Option.bind (fun x -> x.DynamicRegistration)
29+
|> Option.bind _.DidChangeWatchedFiles
30+
|> Option.bind _.DynamicRegistration
3131
|> Option.defaultValue false
3232

3333
let didChangeWatchedFilesRegistration (clientCapabilities: ClientCapabilities) : Registration option =

src/CSharpLanguageServer/Types.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let csharpDocumentFilter: TextDocumentFilter =
4646
Pattern = Some "**/*.cs" }
4747

4848
let razorCsharpDocumentFilter: TextDocumentFilter =
49-
{ Language = Some "razor-csharp"
49+
{ Language = Some "razor"
5050
Scheme = Some "file"
5151
Pattern = Some "**/*.cshtml" }
5252

tests/CSharpLanguageServer.Tests/CSharpLanguageServer.Tests.fsproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="FsUnit" />
3029
<PackageReference Include="Microsoft.NET.Test.Sdk" />
3130
<PackageReference Include="NUnit" />
3231
<PackageReference Include="NUnit3TestAdapter" />
33-
<PackageReference Include="coverlet.collector">
34-
<PrivateAssets>all</PrivateAssets>
35-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32+
<PackageReference Include="coverlet.collector">
33+
<PrivateAssets>all</PrivateAssets>
34+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3635
</PackageReference>
3736
</ItemGroup>
3837

0 commit comments

Comments
 (0)