Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit ebfc5ef

Browse files
cartermpnosami
authored andcommitted
Sequentialize GetAllUsesOfAllSymolsInFile (dotnet#10357)
1 parent 6ebb769 commit ebfc5ef

File tree

18 files changed

+795
-212
lines changed

18 files changed

+795
-212
lines changed

src/fsharp/service/FSharpCheckerResults.fs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,16 +1872,18 @@ type FSharpCheckFileResults
18721872
member __.DependencyFiles = dependencyFiles
18731873

18741874
member __.GetAllUsesOfAllSymbolsInFile(?cancellationToken: CancellationToken ) =
1875-
threadSafeOp
1876-
(fun () -> [| |])
1875+
threadSafeOp
1876+
(fun () -> Seq.empty)
18771877
(fun scope ->
18781878
let cenv = scope.SymbolEnv
1879-
[| for symbolUseChunk in scope.ScopeSymbolUses.AllUsesOfSymbols do
1880-
for symbolUse in symbolUseChunk do
1881-
cancellationToken |> Option.iter (fun ct -> ct.ThrowIfCancellationRequested())
1882-
if symbolUse.ItemOccurence <> ItemOccurence.RelatedText then
1883-
let symbol = FSharpSymbol.Create(cenv, symbolUse.Item)
1884-
yield FSharpSymbolUse(scope.TcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range) |])
1879+
seq {
1880+
for symbolUseChunk in scope.ScopeSymbolUses.AllUsesOfSymbols do
1881+
for symbolUse in symbolUseChunk do
1882+
cancellationToken |> Option.iter (fun ct -> ct.ThrowIfCancellationRequested())
1883+
if symbolUse.ItemOccurence <> ItemOccurence.RelatedText then
1884+
let symbol = FSharpSymbol.Create(cenv, symbolUse.Item)
1885+
FSharpSymbolUse(scope.TcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range)
1886+
})
18851887

18861888
member __.GetUsesOfSymbolInFile(symbol:FSharpSymbol, ?cancellationToken: CancellationToken) =
18871889
threadSafeOp

src/fsharp/service/FSharpCheckerResults.fsi

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace FSharp.Compiler.SourceCodeServices
44

5+
6+
open System.Threading
57
open FSharp.Compiler
68
open FSharp.Compiler.AbstractIL.IL
79
open FSharp.Compiler.AbstractIL.Internal.Library
@@ -17,7 +19,7 @@ open FSharp.Compiler.SyntaxTree
1719
open FSharp.Compiler.TypedTree
1820
open FSharp.Compiler.TcGlobals
1921
open FSharp.Compiler.Text
20-
open FSharp.Compiler.TypeChecker
22+
open FSharp.Compiler.CheckDeclarations
2123

2224
/// Represents the reason why the GetDeclarationLocation operation failed.
2325
[<RequireQualifiedAccess>]
@@ -117,13 +119,7 @@ type public FSharpCheckFileResults =
117119
/// <param name="getAllEntities">
118120
/// Function that returns all entities from current and referenced assemblies.
119121
/// </param>
120-
/// <param name="hasTextChangedSinceLastTypecheck">
121-
/// If text has been used from a captured name resolution from the typecheck, then
122-
/// callback to the client to check if the text has changed. If it has, then give up
123-
/// and assume that we're going to repeat the operation later on.
124-
/// </param>
125-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
126-
member GetDeclarationListInfo : parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async<FSharpDeclarationListInfo>
122+
member GetDeclarationListInfo: parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpDeclarationListInfo
127123

128124
/// <summary>Get the items for a declaration list in FSharpSymbol format</summary>
129125
///
@@ -143,13 +139,7 @@ type public FSharpCheckFileResults =
143139
/// <param name="getAllEntities">
144140
/// Function that returns all entities from current and referenced assemblies.
145141
/// </param>
146-
/// <param name="hasTextChangedSinceLastTypecheck">
147-
/// If text has been used from a captured name resolution from the typecheck, then
148-
/// callback to the client to check if the text has changed. If it has, then give up
149-
/// and assume that we're going to repeat the operation later on.
150-
/// </param>
151-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
152-
member GetDeclarationListSymbols : parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async<FSharpSymbolUse list list>
142+
member GetDeclarationListSymbols: parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpSymbolUse list list
153143

154144
/// <summary>Compute a formatted tooltip for the given location</summary>
155145
///
@@ -158,8 +148,7 @@ type public FSharpCheckFileResults =
158148
/// <param name="lineText">The text of the line where the information is being requested.</param>
159149
/// <param name="names">The identifiers at the location where the information is being requested.</param>
160150
/// <param name="tokenTag">Used to discriminate between 'identifiers', 'strings' and others. For strings, an attempt is made to give a tooltip for a #r "..." location. Use a value from FSharpTokenInfo.Tag, or FSharpTokenTag.Identifier, unless you have other information available.</param>
161-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
162-
member GetStructuredToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int * ?userOpName: string -> Async<FSharpStructuredToolTipText>
151+
member GetStructuredToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> FSharpStructuredToolTipText
163152

164153
/// <summary>Compute a formatted tooltip for the given location</summary>
165154
///
@@ -168,35 +157,30 @@ type public FSharpCheckFileResults =
168157
/// <param name="lineText">The text of the line where the information is being requested.</param>
169158
/// <param name="names">The identifiers at the location where the information is being requested.</param>
170159
/// <param name="tokenTag">Used to discriminate between 'identifiers', 'strings' and others. For strings, an attempt is made to give a tooltip for a #r "..." location. Use a value from FSharpTokenInfo.Tag, or FSharpTokenTag.Identifier, unless you have other information available.</param>
171-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
172-
member GetToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int * ?userOpName: string -> Async<FSharpToolTipText>
160+
member GetToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> FSharpToolTipText
173161

174162
/// <summary>Compute the Visual Studio F1-help key identifier for the given location, based on name resolution results</summary>
175163
///
176164
/// <param name="line">The line number where the information is being requested.</param>
177165
/// <param name="colAtEndOfNames">The column number at the end of the identifiers where the information is being requested.</param>
178166
/// <param name="lineText">The text of the line where the information is being requested.</param>
179167
/// <param name="names">The identifiers at the location where the information is being requested.</param>
180-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
181-
member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async<string option>
182-
168+
member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list -> string option
183169

184170
/// <summary>Compute a set of method overloads to show in a dialog relevant to the given code location.</summary>
185171
///
186172
/// <param name="line">The line number where the information is being requested.</param>
187173
/// <param name="colAtEndOfNames">The column number at the end of the identifiers where the information is being requested.</param>
188174
/// <param name="lineText">The text of the line where the information is being requested.</param>
189175
/// <param name="names">The identifiers at the location where the information is being requested.</param>
190-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
191-
member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option * ?userOpName: string -> Async<FSharpMethodGroup>
176+
member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option -> FSharpMethodGroup
192177

193178
/// <summary>Compute a set of method overloads to show in a dialog relevant to the given code location. The resulting method overloads are returned as symbols.</summary>
194179
/// <param name="line">The line number where the information is being requested.</param>
195180
/// <param name="colAtEndOfNames">The column number at the end of the identifiers where the information is being requested.</param>
196181
/// <param name="lineText">The text of the line where the information is being requested.</param>
197182
/// <param name="names">The identifiers at the location where the information is being requested.</param>
198-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
199-
member GetMethodsAsSymbols : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async<FSharpSymbolUse list option>
183+
member GetMethodsAsSymbols : line:int * colAtEndOfNames:int * lineText:string * names:string list -> FSharpSymbolUse list option
200184

201185
/// <summary>Resolve the names at the given location to the declaration location of the corresponding construct.</summary>
202186
///
@@ -205,17 +189,15 @@ type public FSharpCheckFileResults =
205189
/// <param name="lineText">The text of the line where the information is being requested.</param>
206190
/// <param name="names">The identifiers at the location where the information is being requested.</param>
207191
/// <param name="preferFlag">If not given, then get the location of the symbol. If false, then prefer the location of the corresponding symbol in the implementation of the file (rather than the signature if present). If true, prefer the location of the corresponding symbol in the signature of the file (rather than the implementation).</param>
208-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
209-
member GetDeclarationLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?preferFlag:bool * ?userOpName: string -> Async<FSharpFindDeclResult>
192+
member GetDeclarationLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?preferFlag:bool -> FSharpFindDeclResult
210193

211194
/// <summary>Resolve the names at the given location to a use of symbol.</summary>
212195
///
213196
/// <param name="line">The line number where the information is being requested.</param>
214197
/// <param name="colAtEndOfNames">The column number at the end of the identifiers where the information is being requested.</param>
215198
/// <param name="lineText">The text of the line where the information is being requested.</param>
216199
/// <param name="names">The identifiers at the location where the information is being requested.</param>
217-
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
218-
member GetSymbolUseAtLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async<FSharpSymbolUse option>
200+
member GetSymbolUseAtLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list -> FSharpSymbolUse option
219201

220202
/// <summary>Get any extra colorization info that is available after the typecheck</summary>
221203
member GetSemanticClassification : range option -> struct (range * SemanticClassificationType)[]
@@ -228,21 +210,21 @@ type public FSharpCheckFileResults =
228210
member GetFormatSpecifierLocationsAndArity : unit -> (range*int)[]
229211

230212
/// Get all textual usages of all symbols throughout the file
231-
member GetAllUsesOfAllSymbolsInFile : unit -> Async<FSharpSymbolUse[]>
213+
member GetAllUsesOfAllSymbolsInFile : ?cancellationToken: CancellationToken -> seq<FSharpSymbolUse>
232214

233215
/// Get the textual usages that resolved to the given symbol throughout the file
234-
member GetUsesOfSymbolInFile : symbol:FSharpSymbol -> Async<FSharpSymbolUse[]>
216+
member GetUsesOfSymbolInFile : symbol:FSharpSymbol * ?cancellationToken: CancellationToken -> FSharpSymbolUse[]
235217

236-
member internal GetVisibleNamespacesAndModulesAtPoint : pos -> Async<ModuleOrNamespaceRef[]>
218+
member internal GetVisibleNamespacesAndModulesAtPoint : pos -> ModuleOrNamespaceRef[]
237219

238220
/// Find the most precise display environment for the given line and column.
239221
member GetDisplayContextForPos : cursorPos : pos -> FSharpDisplayContext option
240222

241223
/// Determines if a long ident is resolvable at a specific point.
242-
member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item * ?userOpName: string -> Async<bool>
224+
member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item -> bool
243225

244226
/// Determines if a long ident is resolvable at a specific point.
245-
member IsRelativeNameResolvableFromSymbol: cursorPos : pos * plid : string list * symbol: FSharpSymbol * ?userOpName: string -> Async<bool>
227+
member IsRelativeNameResolvableFromSymbol: cursorPos : pos * plid : string list * symbol: FSharpSymbol -> bool
246228

247229
/// Represents complete typechecked implementation file, including its typechecked signatures if any.
248230
member ImplementationFile: FSharpImplementationFileContents option
@@ -254,7 +236,6 @@ type public FSharpCheckFileResults =
254236
static member internal MakeEmpty :
255237
filename: string *
256238
creationErrors: FSharpErrorInfo[] *
257-
reactorOps: IReactorOperations *
258239
keepAssemblyContents: bool
259240
-> FSharpCheckFileResults
260241
@@ -270,7 +251,6 @@ type public FSharpCheckFileResults =
270251
creationErrors: FSharpErrorInfo[] *
271252
parseErrors: FSharpErrorInfo[] *
272253
tcErrors: FSharpErrorInfo[] *
273-
reactorOps : IReactorOperations *
274254
keepAssemblyContents: bool *
275255
ccuSigForFile: ModuleOrNamespaceType *
276256
thisCcu: CcuThunk *
@@ -298,7 +278,6 @@ type public FSharpCheckFileResults =
298278
loadClosure: LoadClosure option *
299279
backgroundDiagnostics: (PhasedDiagnostic * FSharpErrorSeverity)[] *
300280
reactorOps: IReactorOperations *
301-
textSnapshotInfo : obj option *
302281
userOpName: string *
303282
isIncompleteTypeCheckEnvironment: bool *
304283
builder: IncrementalBuilder *
@@ -337,10 +316,10 @@ type public FSharpCheckProjectResults =
337316
member ProjectContext: FSharpProjectContext
338317

339318
/// Get the textual usages that resolved to the given symbol throughout the project
340-
member GetUsesOfSymbol: symbol:FSharpSymbol -> Async<FSharpSymbolUse[]>
319+
member GetUsesOfSymbol: symbol:FSharpSymbol * ?cancellationToken: CancellationToken -> FSharpSymbolUse[]
341320

342321
/// Get all textual usages of all symbols throughout the project
343-
member GetAllUsesOfAllSymbols: unit -> Async<FSharpSymbolUse[]>
322+
member GetAllUsesOfAllSymbols: ?cancellationToken: CancellationToken -> FSharpSymbolUse[]
344323

345324
/// Indicates if critical errors existed in the project options
346325
member HasCriticalErrors: bool

0 commit comments

Comments
 (0)