Skip to content

Commit ba04065

Browse files
committed
chore(Lsp.Workspace): make project arg non-optional for workspaceFolderSymbolLocations
1 parent 0b89fc8 commit ba04065

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

src/CSharpLanguageServer/Handlers/CallHierarchy.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ module CallHierarchy =
2929
: AsyncLspResult<CallHierarchyItem[] option> =
3030
async {
3131
match! workspaceDocumentSymbol context.Workspace AnyDocument p.TextDocument.Uri p.Position with
32-
| Some wf, Some(symbol, _, _) when isCallableSymbol symbol ->
33-
let! locations, updatedWf = workspaceFolderSymbolLocations symbol None wf
32+
| Some wf, Some(symbol, project, _) when isCallableSymbol symbol ->
33+
let! locations, updatedWf = workspaceFolderSymbolLocations symbol project wf
3434

3535
context.Emit(WorkspaceFolderChange updatedWf)
3636

src/CSharpLanguageServer/Handlers/Definition.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Definition =
1818
async {
1919
match! workspaceDocumentSymbol context.Workspace AnyDocument p.TextDocument.Uri p.Position with
2020
| Some wf, Some(symbol, project, _) ->
21-
let! locations, updatedWf = workspaceFolderSymbolLocations symbol (Some project) wf
21+
let! locations, updatedWf = workspaceFolderSymbolLocations symbol project wf
2222

2323
context.Emit(WorkspaceFolderChange updatedWf)
2424

src/CSharpLanguageServer/Handlers/Implementation.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Implementation =
1515
let provider (_cc: ClientCapabilities) : U3<bool, ImplementationOptions, ImplementationRegistrationOptions> option =
1616
Some(U3.C1 true)
1717

18-
let findImplLocationsOfSymbol wf (sym: ISymbol) = async {
18+
let findImplLocationsOfSymbol wf project (sym: ISymbol) = async {
1919
let! ct = Async.CancellationToken
2020

2121
let! impls =
@@ -27,7 +27,7 @@ module Implementation =
2727
let locations = System.Collections.Generic.List<Location>()
2828

2929
for i in impls do
30-
let! implLocations, wf = workspaceFolderSymbolLocations i None updatedWf
30+
let! implLocations, wf = workspaceFolderSymbolLocations i project updatedWf
3131

3232
locations.AddRange(implLocations)
3333
updatedWf <- wf
@@ -43,8 +43,8 @@ module Implementation =
4343
let! wf, symInfo = workspaceDocumentSymbol context.Workspace AnyDocument p.TextDocument.Uri p.Position
4444

4545
match wf, symInfo with
46-
| Some wf, Some(sym, _, _) ->
47-
let! impls, updatedWf = findImplLocationsOfSymbol wf sym
46+
| Some wf, Some(sym, project, _) ->
47+
let! impls, updatedWf = findImplLocationsOfSymbol wf project sym
4848
context.Emit(WorkspaceFolderChange updatedWf)
4949

5050
return impls |> Declaration.C2 |> U2.C1 |> Some |> LspResult.success

src/CSharpLanguageServer/Handlers/TypeDefinition.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module TypeDefinition =
3434
match typeSymbol with
3535
| None -> async.Return([], wf)
3636
| Some symbol -> async {
37-
let! aggregatedLspLocations, updatedWf = workspaceFolderSymbolLocations symbol (Some project) wf
37+
let! aggregatedLspLocations, updatedWf = workspaceFolderSymbolLocations symbol project wf
3838

3939
context.Emit(WorkspaceFolderChange updatedWf)
4040
return (aggregatedLspLocations, updatedWf)

src/CSharpLanguageServer/Handlers/TypeHierarchy.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module TypeHierarchy =
2828
async {
2929
match! workspaceDocumentSymbol context.Workspace AnyDocument p.TextDocument.Uri p.Position with
3030
| Some wf, Some(symbol, project, _) when isTypeSymbol symbol ->
31-
let! symLocations, updatedWf = workspaceFolderSymbolLocations symbol (Some project) wf
31+
let! symLocations, updatedWf = workspaceFolderSymbolLocations symbol project wf
3232

3333
context.Emit(WorkspaceFolderChange updatedWf)
3434

@@ -64,7 +64,7 @@ module TypeHierarchy =
6464
let mutable updatedWf = wf
6565

6666
for typeSym in supertypes do
67-
let! locations, wf = workspaceFolderSymbolLocations typeSym (Some project) updatedWf
67+
let! locations, wf = workspaceFolderSymbolLocations typeSym project updatedWf
6868

6969
let typeSymItems =
7070
locations |> Seq.map (TypeHierarchyItem.fromSymbolAndLocation typeSym)
@@ -120,7 +120,7 @@ module TypeHierarchy =
120120
let mutable updatedWf = wf
121121

122122
for typeSym in subtypes do
123-
let! locations, wf = workspaceFolderSymbolLocations typeSym (Some project) updatedWf
123+
let! locations, wf = workspaceFolderSymbolLocations typeSym project updatedWf
124124

125125
let typeSymItems =
126126
locations |> Seq.map (TypeHierarchyItem.fromSymbolAndLocation typeSym)

src/CSharpLanguageServer/Lsp/Workspace.fs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ type LspWorkspaceDocumentType =
4141
| AnyDocument
4242

4343
let workspaceFolderResolveSymbolLocation
44-
(project: Microsoft.CodeAnalysis.Project option)
45-
sym
44+
(project: Microsoft.CodeAnalysis.Project)
45+
(symbol: Microsoft.CodeAnalysis.ISymbol)
4646
(l: Microsoft.CodeAnalysis.Location)
4747
(folder: LspWorkspaceFolder)
4848
=
4949
async {
50-
match l.IsInMetadata, l.IsInSource, project with
51-
| true, _, Some project ->
50+
match l.IsInMetadata, l.IsInSource with
51+
| true, _ ->
5252
let! ct = Async.CancellationToken
5353
let! compilation = project.GetCompilationAsync(ct) |> Async.AwaitTask
5454

55-
let fullName = sym |> symbolGetContainingTypeOrThis |> symbolGetFullReflectionName
55+
let fullName =
56+
symbol |> symbolGetContainingTypeOrThis |> symbolGetFullReflectionName
5657

5758
let containingAssemblyName =
5859
l.MetadataModule |> nonNull "l.MetadataModule" |> _.ContainingAssembly.Name
@@ -85,7 +86,7 @@ let workspaceFolderResolveSymbolLocation
8586
// figure out location on the document (approx implementation)
8687
let! syntaxTree = mdDocument.GetSyntaxTreeAsync(ct) |> Async.AwaitTask
8788

88-
let collector = DocumentSymbolCollectorForMatchingSymbolName(uri, sym)
89+
let collector = DocumentSymbolCollectorForMatchingSymbolName(uri, symbol)
8990
let! root = syntaxTree.GetRootAsync(ct) |> Async.AwaitTask
9091
collector.Visit(root)
9192

@@ -100,20 +101,20 @@ let workspaceFolderResolveSymbolLocation
100101
| [] -> [ fallbackLocationInMetadata ], folder
101102
| ls -> ls, folder
102103

103-
| false, true, _ ->
104+
| false, true ->
104105
return
105106
match (Location.fromRoslynLocation l) with
106107
| Some loc -> [ loc ], folder
107108
| None -> [], folder
108109

109-
| _, _, _ -> return [], folder
110+
| _, _ -> return [], folder
110111
}
111112

112113
/// The process of retrieving locations may update LspWorkspaceFolder itself,
113114
/// thus return value is a pair of symbol location list * LspWorkspaceFolder
114115
let workspaceFolderSymbolLocations
115116
(symbol: Microsoft.CodeAnalysis.ISymbol)
116-
(project: Microsoft.CodeAnalysis.Project option)
117+
(project: Microsoft.CodeAnalysis.Project)
117118
folder
118119
=
119120
async {

0 commit comments

Comments
 (0)