From 2f7ac1a95067c780073bd9e354469f58ed286dc2 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Tue, 20 Oct 2020 14:27:04 -0700 Subject: [PATCH 01/12] Allowing IncrementalBuilder cache to be used on any thread --- src/fsharp/service/service.fs | 90 +++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 6a239d6bf83..b7c4a580ad4 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -355,28 +355,37 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC // /// Cache of builds keyed by options. let incrementalBuildersCache = - MruCache + MruCache (keepStrongly=projectCacheSize, keepMax=projectCacheSize, areSame = FSharpProjectOptions.AreSameForChecking, areSimilar = FSharpProjectOptions.UseSameProject) + let tryGetBuilder options = + incrementalBuildersCache.TryGet (AssumeAnyCallerThreadWithoutEvidence(), options) + + let tryGetSimilarBuilder options = + incrementalBuildersCache.TryGetSimilar (AssumeAnyCallerThreadWithoutEvidence(), options) + + let tryGetAnyBuilder options = + incrementalBuildersCache.TryGetAny (AssumeAnyCallerThreadWithoutEvidence(), options) + let getOrCreateBuilder (ctok, options, userOpName) = cancellable { RequireCompilationThread ctok - match incrementalBuildersCache.TryGet (ctok, options) with + match tryGetBuilder options with | Some (builderOpt,creationErrors) -> Logger.Log LogCompilerFunctionId.Service_IncrementalBuildersCache_GettingCache return builderOpt,creationErrors | None -> Logger.Log LogCompilerFunctionId.Service_IncrementalBuildersCache_BuildingNewCache let! (builderOpt,creationErrors) as info = CreateOneIncrementalBuilder (ctok, options, userOpName) - incrementalBuildersCache.Set (ctok, options, info) + incrementalBuildersCache.Set (AssumeAnyCallerThreadWithoutEvidence(), options, info) return builderOpt, creationErrors } let getSimilarOrCreateBuilder (ctok, options, userOpName) = RequireCompilationThread ctok - match incrementalBuildersCache.TryGetSimilar (ctok, options) with + match tryGetSimilarBuilder options with | Some res -> Cancellable.ret res // The builder does not exist at all. Create it. | None -> getOrCreateBuilder (ctok, options, userOpName) @@ -590,7 +599,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC cancellable { let! _builderOpt,_creationErrors = getOrCreateBuilder (ctok, options, userOpName) - match incrementalBuildersCache.TryGetAny (ctok, options) with + match tryGetAnyBuilder options with | Some (Some builder, creationErrors) -> match bc.GetCachedCheckFileResult(builder, filename, sourceText, options) with | Some (_, checkResults) -> return Some (builder, creationErrors, Some (FSharpCheckFileAnswer.Succeeded checkResults)) @@ -920,39 +929,40 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC member bc.InvalidateConfiguration(options : FSharpProjectOptions, startBackgroundCompileIfAlreadySeen, userOpName) = let startBackgroundCompileIfAlreadySeen = defaultArg startBackgroundCompileIfAlreadySeen implicitlyStartBackgroundWork - // This operation can't currently be cancelled nor awaited - reactor.EnqueueOp(userOpName, "InvalidateConfiguration: Stamp(" + (options.Stamp |> Option.defaultValue 0L).ToString() + ")", options.ProjectFileName, fun ctok -> - // If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it - // will have the effect of releasing memory associated with the previous builder, but costs some time. - if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then - - // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, - // including by incrementalBuildersCache.Set. - let newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) |> Cancellable.runWithoutCancellation - incrementalBuildersCache.Set(ctok, options, newBuilderInfo) - - // Start working on the project. Also a somewhat arbitrary choice - if startBackgroundCompileIfAlreadySeen then - bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) - - member bc.ClearCache(options : FSharpProjectOptions seq, userOpName) = - // This operation can't currently be cancelled nor awaited - reactor.EnqueueOp(userOpName, "ClearCache", String.Empty, fun ctok -> - options - |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(ctok, options))) + + // If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it + // will have the effect of releasing memory associated with the previous builder, but costs some time. + if incrementalBuildersCache.ContainsSimilarKey (AssumeAnyCallerThreadWithoutEvidence(), options) then + // This operation can't currently be cancelled nor awaited + reactor.EnqueueOp(userOpName, "InvalidateConfiguration: Stamp(" + (options.Stamp |> Option.defaultValue 0L).ToString() + ")", options.ProjectFileName, fun ctok -> + // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, + // including by incrementalBuildersCache.Set. + let newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) |> Cancellable.runWithoutCancellation + incrementalBuildersCache.Set(AssumeAnyCallerThreadWithoutEvidence(), options, newBuilderInfo) + + // Start working on the project. Also a somewhat arbitrary choice + if startBackgroundCompileIfAlreadySeen then + bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) + + member bc.ClearCache(options : FSharpProjectOptions seq) = + let ctok = AssumeAnyCallerThreadWithoutEvidence() + options + |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(ctok, options)) member __.NotifyProjectCleaned (options : FSharpProjectOptions, userOpName) = - reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> - cancellable { - // If there was a similar entry (as there normally will have been) then re-establish an empty builder . This - // is a somewhat arbitrary choice - it will have the effect of releasing memory associated with the previous - // builder, but costs some time. - if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then - // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, - // including by incrementalBuildersCache.Set. - let! newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) - incrementalBuildersCache.Set(ctok, options, newBuilderInfo) - }) + // If there was a similar entry (as there normally will have been) then re-establish an empty builder . This + // is a somewhat arbitrary choice - it will have the effect of releasing memory associated with the previous + // builder, but costs some time. + if incrementalBuildersCache.ContainsSimilarKey (AssumeAnyCallerThreadWithoutEvidence(), options) then + reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> + cancellable { + // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, + // including by incrementalBuildersCache.Set. + let! newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) + incrementalBuildersCache.Set(AssumeAnyCallerThreadWithoutEvidence(), options, newBuilderInfo) + }) + else + async { () } member __.CheckProjectInBackground (options, userOpName) = reactor.SetBackgroundOp (Some (userOpName, "CheckProjectInBackground", options.ProjectFileName, (fun ctok ct -> @@ -997,7 +1007,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC checkFileInProjectCachePossiblyStale.Clear ltok checkFileInProjectCache.Clear ltok parseFileCache.Clear(ltok)) - incrementalBuildersCache.Clear ctok + incrementalBuildersCache.Clear(AssumeAnyCallerThreadWithoutEvidence()) frameworkTcImportsCache.Clear ctok scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Clear ltok) cancellable.Return ()) @@ -1008,7 +1018,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC checkFileInProjectCachePossiblyStale.Resize(ltok, keepStrongly=1) checkFileInProjectCache.Resize(ltok, keepStrongly=1) parseFileCache.Resize(ltok, keepStrongly=1)) - incrementalBuildersCache.Resize(ctok, keepStrongly=1, keepMax=1) + incrementalBuildersCache.Resize(AssumeAnyCallerThreadWithoutEvidence(), keepStrongly=1, keepMax=1) frameworkTcImportsCache.Downsize(ctok) scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Resize(ltok,keepStrongly=1, keepMax=1)) cancellable.Return ()) @@ -1245,8 +1255,8 @@ type FSharpChecker(legacyReferenceResolver, /// Clear the internal cache of the given projects. member __.ClearCache(options: FSharpProjectOptions seq, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - backgroundCompiler.ClearCache(options, userOpName) + let _userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.ClearCache(options) /// This function is called when a project has been cleaned, and thus type providers should be refreshed. member __.NotifyProjectCleaned(options: FSharpProjectOptions, ?userOpName: string) = From 70840216019f23786c025fe3e3964f9236819b8e Mon Sep 17 00:00:00 2001 From: Will Smith Date: Wed, 21 Oct 2020 08:30:07 -0700 Subject: [PATCH 02/12] Put if statements back in the reactor queue --- src/fsharp/service/service.fs | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index b7c4a580ad4..2e3e34cbf85 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -930,19 +930,19 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC member bc.InvalidateConfiguration(options : FSharpProjectOptions, startBackgroundCompileIfAlreadySeen, userOpName) = let startBackgroundCompileIfAlreadySeen = defaultArg startBackgroundCompileIfAlreadySeen implicitlyStartBackgroundWork - // If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it - // will have the effect of releasing memory associated with the previous builder, but costs some time. - if incrementalBuildersCache.ContainsSimilarKey (AssumeAnyCallerThreadWithoutEvidence(), options) then - // This operation can't currently be cancelled nor awaited - reactor.EnqueueOp(userOpName, "InvalidateConfiguration: Stamp(" + (options.Stamp |> Option.defaultValue 0L).ToString() + ")", options.ProjectFileName, fun ctok -> - // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, - // including by incrementalBuildersCache.Set. - let newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) |> Cancellable.runWithoutCancellation - incrementalBuildersCache.Set(AssumeAnyCallerThreadWithoutEvidence(), options, newBuilderInfo) - - // Start working on the project. Also a somewhat arbitrary choice - if startBackgroundCompileIfAlreadySeen then - bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) + // This operation can't currently be cancelled nor awaited + reactor.EnqueueOp(userOpName, "InvalidateConfiguration: Stamp(" + (options.Stamp |> Option.defaultValue 0L).ToString() + ")", options.ProjectFileName, fun ctok -> + // If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it + // will have the effect of releasing memory associated with the previous builder, but costs some time. + if incrementalBuildersCache.ContainsSimilarKey (AssumeAnyCallerThreadWithoutEvidence(), options) then + // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, + // including by incrementalBuildersCache.Set. + let newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) |> Cancellable.runWithoutCancellation + incrementalBuildersCache.Set(AssumeAnyCallerThreadWithoutEvidence(), options, newBuilderInfo) + + // Start working on the project. Also a somewhat arbitrary choice + if startBackgroundCompileIfAlreadySeen then + bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) member bc.ClearCache(options : FSharpProjectOptions seq) = let ctok = AssumeAnyCallerThreadWithoutEvidence() @@ -950,19 +950,17 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(ctok, options)) member __.NotifyProjectCleaned (options : FSharpProjectOptions, userOpName) = - // If there was a similar entry (as there normally will have been) then re-establish an empty builder . This - // is a somewhat arbitrary choice - it will have the effect of releasing memory associated with the previous - // builder, but costs some time. - if incrementalBuildersCache.ContainsSimilarKey (AssumeAnyCallerThreadWithoutEvidence(), options) then - reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> - cancellable { + reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> + cancellable { + // If there was a similar entry (as there normally will have been) then re-establish an empty builder . This + // is a somewhat arbitrary choice - it will have the effect of releasing memory associated with the previous + // builder, but costs some time. + if incrementalBuildersCache.ContainsSimilarKey (AssumeAnyCallerThreadWithoutEvidence(), options) then // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, // including by incrementalBuildersCache.Set. let! newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) incrementalBuildersCache.Set(AssumeAnyCallerThreadWithoutEvidence(), options, newBuilderInfo) - }) - else - async { () } + }) member __.CheckProjectInBackground (options, userOpName) = reactor.SetBackgroundOp (Some (userOpName, "CheckProjectInBackground", options.ProjectFileName, (fun ctok ct -> From 8669a135bed38f04ccb8cd767b40a90084378b02 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Wed, 21 Oct 2020 10:37:43 -0700 Subject: [PATCH 03/12] Queueing ClearCache --- src/fsharp/service/service.fs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 2e3e34cbf85..6276534350c 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -944,10 +944,12 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC if startBackgroundCompileIfAlreadySeen then bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) - member bc.ClearCache(options : FSharpProjectOptions seq) = - let ctok = AssumeAnyCallerThreadWithoutEvidence() - options - |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(ctok, options)) + member bc.ClearCache(options : FSharpProjectOptions seq, userOpName) = + // This operation can't currently be cancelled nor awaited + reactor.EnqueueOp(userOpName, "ClearCache", String.Empty, fun _ -> + let ctok = AssumeAnyCallerThreadWithoutEvidence() + options + |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(ctok, options))) member __.NotifyProjectCleaned (options : FSharpProjectOptions, userOpName) = reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> @@ -1253,8 +1255,8 @@ type FSharpChecker(legacyReferenceResolver, /// Clear the internal cache of the given projects. member __.ClearCache(options: FSharpProjectOptions seq, ?userOpName: string) = - let _userOpName = defaultArg userOpName "Unknown" - backgroundCompiler.ClearCache(options) + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.ClearCache(options, userOpName) /// This function is called when a project has been cleaned, and thus type providers should be refreshed. member __.NotifyProjectCleaned(options: FSharpProjectOptions, ?userOpName: string) = From 1c22bfd6a97c9f711a1c8f7bb27aeebe85269940 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 16:47:14 +0100 Subject: [PATCH 04/12] start of ctok work --- src/absil/illib.fs | 4 +- src/fsharp/InternalCollections.fs | 45 +++--- src/fsharp/InternalCollections.fsi | 13 +- src/fsharp/service/FSharpCheckerResults.fs | 135 ++++++++---------- src/fsharp/service/FSharpCheckerResults.fsi | 22 +-- src/fsharp/service/service.fs | 54 ++++--- .../SurfaceArea.netstandard.fs | 3 +- 7 files changed, 127 insertions(+), 149 deletions(-) diff --git a/src/absil/illib.fs b/src/absil/illib.fs index 90709ee6cc7..fa02946959f 100644 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -636,9 +636,9 @@ let DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent (_ctok: Co /// Represents a place in the compiler codebase where we assume we are executing on a compilation thread let AssumeCompilationThreadWithoutEvidence () = Unchecked.defaultof -/// Represents a token that indicates execution on a any of several potential user threads calling the F# compiler services. +/// Represents a token that indicates execution on any of several potential user threads calling the F# compiler services. type AnyCallerThreadToken() = interface ExecutionToken -let AssumeAnyCallerThreadWithoutEvidence () = Unchecked.defaultof +let AnyCallerThread = Unchecked.defaultof /// A base type for various types of tokens that must be passed when a lock is taken. /// Each different static lock should declare a new subtype of this type. diff --git a/src/fsharp/InternalCollections.fs b/src/fsharp/InternalCollections.fs index 0df85d590bd..9dbb40ced9d 100755 --- a/src/fsharp/InternalCollections.fs +++ b/src/fsharp/InternalCollections.fs @@ -12,18 +12,13 @@ type internal ValueStrength<'T when 'T : not struct> = | Weak of WeakReference<'T> #endif -type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStrongly:int, areSimilar, ?requiredToKeep, ?onStrongDiscard, ?keepMax: int) = +type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStrongly:int, areSimilar, ?requiredToKeep, ?keepMax: int) = /// The list of items stored. Youngest is at the end of the list. /// The choice of order is somewhat arbitrary. If the other way then adding /// items would be O(1) and removing O(N). let mutable refs:('Key*ValueStrength<'Value>) list = [] let mutable keepStrongly = keepStrongly - // Only set a strong discard function if keepMax is explicitly set to keepStrongly, i.e. there are no weak entries in this lookup. - do assert (onStrongDiscard.IsNone || Some keepStrongly = keepMax) - - let strongDiscard x = match onStrongDiscard with None -> () | Some f -> f x - // The 75 here determines how long the list should be passed the end of strongly held // references. Some operations are O(N) and we don't want to let things get out of // hand. @@ -56,8 +51,8 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro /// Remove a particular key value. let RemoveImpl (data, key) = - let discard,keep = data |> List.partition (fun (similarKey,_)-> areSimilar(key,similarKey)) - keep, discard + let keep = data |> List.filter (fun (similarKey,_)-> not (areSimilar(key,similarKey))) + keep let TryGetKeyValueImpl(data,key) = match TryPeekKeyValueImpl(data,key) with @@ -75,27 +70,26 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro | Weak(weakReference) -> #if FX_NO_GENERIC_WEAKREFERENCE match weakReference.Target with - | null -> assert onStrongDiscard.IsNone; () + | null -> () | value -> yield key,(value:?>'Value) ] #else match weakReference.TryGetTarget () with - | false, _ -> assert onStrongDiscard.IsNone; () + | false, _ -> () | true, value -> yield key, value ] #endif - let AssignWithStrength(tok,newData,discard1) = + let AssignWithStrength(tok,newData) = let actualLength = List.length newData let tossThreshold = max 0 (actualLength - keepMax) // Delete everything less than this threshold let weakThreshold = max 0 (actualLength - keepStrongly) // Weaken everything less than this threshold let newData = newData|> List.mapi( fun n kv -> n,kv ) // Place the index. - let newData,discard2 = newData |> List.partition (fun (n:int,v) -> n >= tossThreshold || requiredToKeep (snd v)) + let newData = newData |> List.filter (fun (n:int,v) -> n >= tossThreshold || requiredToKeep (snd v)) let newData = newData |> List.map( fun (n:int,(k,v)) -> let handle = if n(keepStro k,handle ) ignore tok // Updating refs requires tok refs <- newData - discard1 |> List.iter (snd >> strongDiscard) - discard2 |> List.iter (snd >> snd >> strongDiscard) member al.TryPeekKeyValue(tok, key) = // Returns the original key value as well since it may be different depending on equality test. @@ -117,43 +109,42 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro member al.TryGetKeyValue(tok, key) = let data = FilterAndHold(tok) let result,newData = TryGetKeyValueImpl(data,key) - AssignWithStrength(tok,newData,[]) + AssignWithStrength(tok,newData) result member al.TryGet(tok, key) = let data = FilterAndHold(tok) let result,newData = TryGetKeyValueImpl(data,key) - AssignWithStrength(tok,newData,[]) + AssignWithStrength(tok,newData) match result with | Some(_,value) -> Some(value) | None -> None member al.Put(tok, key,value) = let data = FilterAndHold(tok) - let data,discard = if Exists(data,key) then RemoveImpl (data,key) else data,[] + let data = if Exists(data,key) then RemoveImpl (data,key) else data let data = Add(data,key,value) - AssignWithStrength(tok,data,discard) // This will remove extras + AssignWithStrength(tok,data) // This will remove extras member al.Remove(tok, key) = let data = FilterAndHold(tok) - let newData,discard = RemoveImpl (data,key) - AssignWithStrength(tok,newData,discard) + let newData = RemoveImpl (data,key) + AssignWithStrength(tok,newData) member al.Clear(tok) = - let discards = FilterAndHold(tok) - AssignWithStrength(tok,[], discards) + let _discards = FilterAndHold(tok) + AssignWithStrength(tok,[]) member al.Resize(tok, newKeepStrongly, ?newKeepMax) = let newKeepMax = defaultArg newKeepMax 75 keepStrongly <- newKeepStrongly keepMax <- max newKeepStrongly newKeepMax - do assert (onStrongDiscard.IsNone || keepStrongly = keepMax) let keep = FilterAndHold(tok) - AssignWithStrength(tok,keep, []) + AssignWithStrength(tok,keep) -type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongly, areSame, ?isStillValid : 'Key*'Value->bool, ?areSimilar, ?requiredToKeep, ?onStrongDiscard, ?keepMax) = +type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongly, areSame, ?isStillValid : 'Key*'Value->bool, ?areSimilar, ?requiredToKeep, ?keepMax) = /// Default behavior of areSimilar function is areSame. let areSimilar = defaultArg areSimilar areSame @@ -161,7 +152,7 @@ type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongl /// The list of items in the cache. Youngest is at the end of the list. /// The choice of order is somewhat arbitrary. If the other way then adding /// items would be O(1) and removing O(N). - let cache = AgedLookup<'Token, 'Key,'Value>(keepStrongly=keepStrongly,areSimilar=areSimilar,?onStrongDiscard=onStrongDiscard,?keepMax=keepMax,?requiredToKeep=requiredToKeep) + let cache = AgedLookup<'Token, 'Key,'Value>(keepStrongly=keepStrongly,areSimilar=areSimilar, ?keepMax=keepMax,?requiredToKeep=requiredToKeep) /// Whether or not this result value is still valid. let isStillValid = defaultArg isStillValid (fun _ -> true) diff --git a/src/fsharp/InternalCollections.fsi b/src/fsharp/InternalCollections.fsi index 748aef6a079..392a1469372 100755 --- a/src/fsharp/InternalCollections.fsi +++ b/src/fsharp/InternalCollections.fsi @@ -11,25 +11,31 @@ namespace Internal.Utilities.Collections new : keepStrongly:int * areSimilar:('Key * 'Key -> bool) * ?requiredToKeep:('Value -> bool) - * ?onStrongDiscard : ('Value -> unit) // this may only be set if keepTotal=keepStrongly, i.e. not weak entries * ?keepMax: int -> AgedLookup<'Token,'Key,'Value> + /// Lookup the value without making it the most recent. /// Returns the original key value because the areSame function /// may have unified two different keys. member TryPeekKeyValue : 'Token * key:'Key -> ('Key*'Value) option + /// Lookup a value and make it the most recent. /// Returns the original key value because the areSame function /// may have unified two different keys. member TryGetKeyValue : 'Token * key: 'Key -> ('Key*'Value) option + /// Lookup a value and make it the most recent. Return None if it wasn't there. member TryGet : 'Token * key:'Key -> 'Value option + /// Add an element to the collection. Make it the most recent. member Put : 'Token * 'Key * 'Value -> unit + /// Remove the given value from the collection. member Remove : 'Token * key:'Key -> unit + /// Remove all elements. member Clear : 'Token -> unit + /// Resize member Resize : 'Token * keepStrongly: int * ?keepMax : int -> unit @@ -39,9 +45,7 @@ namespace Internal.Utilities.Collections /// that aren't what was originally passed to the Set function. /// /// Concurrency: This collection is thread-safe, though concurrent use may result in different - /// threads seeing different live sets of cached items, and may result in the onDiscard action - /// being called multiple times. In practice this means the collection is only safe for concurrent - /// access if there is no discard action to execute. + /// threads seeing different live sets of cached items. /// /// - areSimilar: Keep at most once association for two similar keys (as given by areSimilar) type internal MruCache<'Token, 'Key,'Value when 'Value : not struct> = @@ -50,7 +54,6 @@ namespace Internal.Utilities.Collections * ?isStillValid:('Key * 'Value -> bool) * ?areSimilar:('Key * 'Key -> bool) * ?requiredToKeep:('Value -> bool) - * ?onDiscard:('Value -> unit) * ?keepMax:int -> MruCache<'Token,'Key,'Value> diff --git a/src/fsharp/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index 08c8c57a177..5eadd670d83 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -147,7 +147,7 @@ type internal TypeCheckInfo // Is not keyed on 'Names' collection because this is invariant for the current position in // this unchanged file. Keyed on lineStr though to prevent a change to the currently line // being available against a stale scope. - let getToolTipTextCache = AgedLookup>(getToolTipTextSize,areSimilar=(fun (x,y) -> x = y)) + let getToolTipTextCache = AgedLookup>(getToolTipTextSize,areSimilar=(fun (x,y) -> x = y)) let amap = tcImports.GetImportMap() let infoReader = InfoReader(g,amap) @@ -744,11 +744,10 @@ type internal TypeCheckInfo items |> List.map DefaultCompletionItem, denv, m /// Get the auto-complete items at a particular location. - let GetDeclItemsForNamesAtPosition(ctok: CompilationThreadToken, parseResultsOpt: FSharpParseFileResults option, origLongIdentOpt: string list option, + let GetDeclItemsForNamesAtPosition(parseResultsOpt: FSharpParseFileResults option, origLongIdentOpt: string list option, residueOpt:string option, lastDotPos: int option, line:int, lineStr:string, colAtEndOfNamesAndResidue, filterCtors, resolveOverloads, getAllSymbols: unit -> AssemblySymbol list, hasTextChangedSinceLastTypecheck: (obj * range -> bool)) : (CompletionItem list * DisplayEnv * CompletionContext option * range) option = - RequireCompilationThread ctok // the operations in this method need the reactor thread let loc = match colAtEndOfNamesAndResidue with @@ -918,13 +917,13 @@ type internal TypeCheckInfo scope.IsRelativeNameResolvable(cursorPos, plid, symbol.Item) /// Get the auto-complete items at a location - member __.GetDeclarations (ctok, parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck) = + member __.GetDeclarations (parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck) = let isInterfaceFile = SourceFileImpl.IsInterfaceFile mainInputFileName ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some partialName.QualifyingIdents, + GetDeclItemsForNamesAtPosition(parseResultsOpt, Some partialName.QualifyingIdents, Some partialName.PartialIdent, partialName.LastDotPos, line, lineStr, partialName.EndColumn + 1, ResolveTypeNamesToCtors, ResolveOverloads.Yes, getAllEntities, hasTextChangedSinceLastTypecheck) @@ -945,13 +944,13 @@ type internal TypeCheckInfo FSharpDeclarationListInfo.Error msg) /// Get the symbols for auto-complete items at a location - member __.GetDeclarationListSymbols (ctok, parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck) = + member __.GetDeclarationListSymbols (parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck) = let isInterfaceFile = SourceFileImpl.IsInterfaceFile mainInputFileName ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition(ctok, parseResultsOpt, Some partialName.QualifyingIdents, + GetDeclItemsForNamesAtPosition(parseResultsOpt, Some partialName.QualifyingIdents, Some partialName.PartialIdent, partialName.LastDotPos, line, lineStr, partialName.EndColumn + 1, ResolveTypeNamesToCtors, ResolveOverloads.Yes, getAllEntities, hasTextChangedSinceLastTypecheck) @@ -1028,9 +1027,7 @@ type internal TypeCheckInfo []) /// Get the "reference resolution" tooltip for at a location - member __.GetReferenceResolutionStructuredToolTipText(ctok, line,col) = - - RequireCompilationThread ctok // the operations in this method need the reactor thread but the reasons why are not yet grounded + member __.GetReferenceResolutionStructuredToolTipText(line,col) = let pos = mkPos line col let isPosMatch(pos, ar:AssemblyReference) : bool = @@ -1077,12 +1074,12 @@ type internal TypeCheckInfo FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) // GetToolTipText: return the "pop up" (or "Quick Info") text given a certain context. - member __.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names) = + member __.GetStructuredToolTipText(line, lineStr, colAtEndOfNames, names) = let Compute() = ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition(ctok, None, Some names, None, None, + GetDeclItemsForNamesAtPosition(None, Some names, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes, (fun() -> []), (fun _ -> false)) @@ -1097,19 +1094,19 @@ type internal TypeCheckInfo // See devdiv bug 646520 for rationale behind truncating and caching these quick infos (they can be big!) let key = line,colAtEndOfNames,lineStr - match getToolTipTextCache.TryGet (ctok, key) with + match getToolTipTextCache.TryGet (AnyCallerThread, key) with | Some res -> res | None -> let res = Compute() - getToolTipTextCache.Put(ctok, key,res) + getToolTipTextCache.Put(AnyCallerThread, key,res) res - member __.GetF1Keyword (ctok, line, lineStr, colAtEndOfNames, names) : string option = + member __.GetF1Keyword (line, lineStr, colAtEndOfNames, names) : string option = ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition(ctok, None, Some names, None, None, + GetDeclItemsForNamesAtPosition(None, Some names, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No, (fun() -> []), (fun _ -> false)) @@ -1142,12 +1139,12 @@ type internal TypeCheckInfo Trace.TraceInformation(sprintf "FCS: recovering from error in GetF1Keyword: '%s'" msg) None) - member __.GetMethods (ctok, line, lineStr, colAtEndOfNames, namesOpt) = + member __.GetMethods (line, lineStr, colAtEndOfNames, namesOpt) = ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition(ctok, None, namesOpt, None, None, + GetDeclItemsForNamesAtPosition(None, namesOpt, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No, (fun() -> []), (fun _ -> false)) @@ -1166,11 +1163,11 @@ type internal TypeCheckInfo Trace.TraceInformation(sprintf "FCS: recovering from error in GetMethods: '%s'" msg) FSharpMethodGroup(msg,[| |])) - member __.GetMethodsAsSymbols (ctok, line, lineStr, colAtEndOfNames, names) = + member __.GetMethodsAsSymbols (line, lineStr, colAtEndOfNames, names) = ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition (ctok, None, Some names, None, + GetDeclItemsForNamesAtPosition (None, Some names, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No, (fun() -> []), (fun _ -> false)) @@ -1186,12 +1183,12 @@ type internal TypeCheckInfo Trace.TraceInformation(sprintf "FCS: recovering from error in GetMethodsAsSymbols: '%s'" msg) None) - member __.GetDeclarationLocation (ctok, line, lineStr, colAtEndOfNames, names, preferFlag) = + member __.GetDeclarationLocation (line, lineStr, colAtEndOfNames, names, preferFlag) = ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition (ctok, None, Some names, None, None, + GetDeclItemsForNamesAtPosition (None, Some names, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes, (fun() -> []), (fun _ -> false)) @@ -1295,11 +1292,11 @@ type internal TypeCheckInfo Trace.TraceInformation(sprintf "FCS: recovering from error in GetDeclarationLocation: '%s'" msg) FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown msg)) - member __.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) = + member __.GetSymbolUseAtLocation (line, lineStr, colAtEndOfNames, names) = ErrorScope.Protect Range.range0 (fun () -> let declItemsOpt = - GetDeclItemsForNamesAtPosition (ctok, None, Some names, None, None, + GetDeclItemsForNamesAtPosition (None, Some names, None, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes, (fun() -> []), (fun _ -> false)) @@ -1777,29 +1774,15 @@ type FSharpCheckFileResults scopeOptX: TypeCheckInfo option, dependencyFiles: string[], builderX: IncrementalBuilder option, - reactorOpsX:IReactorOperations, keepAssemblyContents: bool) = - // This may be None initially - let mutable details = match scopeOptX with None -> None | Some scopeX -> Some (scopeX, builderX, reactorOpsX) - - // Run an operation that needs to access a builder and be run in the reactor thread - let reactorOp userOpName opName dflt f = - async { - match details with - | None -> - return dflt - | Some (scope, _, reactor) -> - // Increment the usage count to ensure the builder doesn't get released while running operations asynchronously. - let! res = reactor.EnqueueAndAwaitOpAsync(userOpName, opName, filename, fun ctok -> f ctok scope |> cancellable.Return) - return res - } + let details = match scopeOptX with None -> None | Some scopeX -> Some (scopeX, builderX) // Run an operation that can be called from any thread let threadSafeOp dflt f = match details with | None -> dflt() - | Some (scope, _builderOpt, _ops) -> f scope + | Some (scope, _builderOpt) -> f scope member __.Errors = errors @@ -1811,74 +1794,78 @@ type FSharpCheckFileResults | _ -> None /// Intellisense autocompletions - member __.GetDeclarationListInfo(parseResultsOpt, line, lineStr, partialName, ?getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" + member __.GetDeclarationListInfo(parseResultsOpt, line, lineStr, partialName, ?getAllEntities, ?hasTextChangedSinceLastTypecheck) = let getAllEntities = defaultArg getAllEntities (fun() -> []) let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false) - reactorOp userOpName "GetDeclarations" FSharpDeclarationListInfo.Empty (fun ctok scope -> - scope.GetDeclarations(ctok, parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) + threadSafeOp (fun () -> FSharpDeclarationListInfo.Empty) (fun scope -> + scope.GetDeclarations(parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) + |> async.Return - member __.GetDeclarationListSymbols(parseResultsOpt, line, lineStr, partialName, ?getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" + member __.GetDeclarationListSymbols(parseResultsOpt, line, lineStr, partialName, ?getAllEntities, ?hasTextChangedSinceLastTypecheck) = let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false) let getAllEntities = defaultArg getAllEntities (fun() -> []) - reactorOp userOpName "GetDeclarationListSymbols" List.empty (fun ctok scope -> - scope.GetDeclarationListSymbols(ctok, parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) + threadSafeOp (fun () -> []) (fun scope -> + scope.GetDeclarationListSymbols(parseResultsOpt, line, lineStr, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) + |> async.Return /// Resolve the names at the given location to give a data tip member __.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" let dflt = FSharpToolTipText [] match tokenTagToTokenId tokenTag with | TOKEN_IDENT -> - reactorOp userOpName "GetStructuredToolTipText" dflt (fun ctok scope -> - scope.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names)) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetStructuredToolTipText(line, lineStr, colAtEndOfNames, names)) | TOKEN_STRING | TOKEN_STRING_TEXT -> - reactorOp userOpName "GetReferenceResolutionToolTipText" dflt (fun ctok scope -> - scope.GetReferenceResolutionStructuredToolTipText(ctok, line, colAtEndOfNames) ) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetReferenceResolutionStructuredToolTipText(line, colAtEndOfNames) ) | _ -> - async.Return dflt + dflt + |> async.Return member info.GetToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, userOpName) = info.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, ?userOpName=userOpName) |> Tooltips.Map Tooltips.ToFSharpToolTipText member __.GetF1Keyword (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetF1Keyword" None (fun ctok scope -> - scope.GetF1Keyword (ctok, line, lineStr, colAtEndOfNames, names)) + threadSafeOp (fun () -> None) (fun scope -> + scope.GetF1Keyword (line, lineStr, colAtEndOfNames, names)) + |> async.Return // Resolve the names at the given location to a set of methods member __.GetMethods(line, colAtEndOfNames, lineStr, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" let dflt = FSharpMethodGroup("",[| |]) - reactorOp userOpName "GetMethods" dflt (fun ctok scope -> - scope.GetMethods (ctok, line, lineStr, colAtEndOfNames, names)) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetMethods (line, lineStr, colAtEndOfNames, names)) + |> async.Return member __.GetDeclarationLocation (line, colAtEndOfNames, lineStr, names, ?preferFlag, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" let dflt = FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "") - reactorOp userOpName "GetDeclarationLocation" dflt (fun ctok scope -> - scope.GetDeclarationLocation (ctok, line, lineStr, colAtEndOfNames, names, preferFlag)) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetDeclarationLocation (line, lineStr, colAtEndOfNames, names, preferFlag)) + |> async.Return member __.GetSymbolUseAtLocation (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetSymbolUseAtLocation" None (fun ctok scope -> - scope.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) + threadSafeOp (fun () -> None) (fun scope -> + scope.GetSymbolUseAtLocation (line, lineStr, colAtEndOfNames, names) |> Option.map (fun (sym,denv,m) -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m))) + |> async.Return member __.GetMethodsAsSymbols (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetMethodsAsSymbols" None (fun ctok scope -> - scope.GetMethodsAsSymbols (ctok, line, lineStr, colAtEndOfNames, names) + threadSafeOp (fun () -> None) (fun scope -> + scope.GetMethodsAsSymbols (line, lineStr, colAtEndOfNames, names) |> Option.map (fun (symbols,denv,m) -> symbols |> List.map (fun sym -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m)))) + |> async.Return member __.GetSymbolAtLocation (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetSymbolAtLocation" None (fun ctok scope -> - scope.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) + threadSafeOp (fun () -> None) (fun scope -> + scope.GetSymbolUseAtLocation (line, lineStr, colAtEndOfNames, names) |> Option.map (fun (sym,_,_) -> sym)) + |> async.Return member info.GetFormatSpecifierLocations() = info.GetFormatSpecifierLocationsAndArity() |> Array.map fst @@ -1942,22 +1929,22 @@ type FSharpCheckFileResults member __.IsRelativeNameResolvable(pos: pos, plid: string list, item: Item, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "IsRelativeNameResolvable" true (fun ctok scope -> - RequireCompilationThread ctok + threadSafeOp (fun () -> true) (fun scope -> scope.IsRelativeNameResolvable(pos, plid, item)) + |> async.Return member __.IsRelativeNameResolvableFromSymbol(pos: pos, plid: string list, symbol: FSharpSymbol, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "IsRelativeNameResolvableFromSymbol" true (fun ctok scope -> - RequireCompilationThread ctok + threadSafeOp (fun () -> true) (fun scope -> scope.IsRelativeNameResolvableFromSymbol(pos, plid, symbol)) + |> async.Return member __.GetDisplayContextForPos(pos: pos) : Async = let userOpName = "CodeLens" - reactorOp userOpName "GetDisplayContextAtPos" None (fun ctok scope -> - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok + threadSafeOp (fun () -> None) (fun scope -> let (nenv, _), _ = scope.GetBestDisplayEnvForPos pos Some(FSharpDisplayContext(fun _ -> nenv.DisplayEnv))) + |> async.Return member __.ImplementationFile = if not keepAssemblyContents then invalidOp "The 'keepAssemblyContents' flag must be set to true on the FSharpChecker in order to access the checked contents of assemblies" diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index ac682055a7b..6e97ce7ffa2 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -123,7 +123,7 @@ type public FSharpCheckFileResults = /// and assume that we're going to repeat the operation later on. /// /// An optional string used for tracing compiler operations associated with this request. - member GetDeclarationListInfo : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async + member GetDeclarationListInfo : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) -> Async /// Get the items for a declaration list in FSharpSymbol format /// @@ -149,7 +149,7 @@ type public FSharpCheckFileResults = /// and assume that we're going to repeat the operation later on. /// /// An optional string used for tracing compiler operations associated with this request. - member GetDeclarationListSymbols : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async + member GetDeclarationListSymbols : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) -> Async /// Compute a formatted tooltip for the given location /// @@ -159,7 +159,7 @@ type public FSharpCheckFileResults = /// The identifiers at the location where the information is being requested. /// 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. /// An optional string used for tracing compiler operations associated with this request. - member GetStructuredToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int * ?userOpName: string -> Async + member GetStructuredToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> Async /// Compute a formatted tooltip for the given location /// @@ -169,7 +169,7 @@ type public FSharpCheckFileResults = /// The identifiers at the location where the information is being requested. /// 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. /// An optional string used for tracing compiler operations associated with this request. - member GetToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int * ?userOpName: string -> Async + member GetToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> Async /// Compute the Visual Studio F1-help key identifier for the given location, based on name resolution results /// @@ -178,7 +178,7 @@ type public FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// An optional string used for tracing compiler operations associated with this request. - member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async + member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list -> Async /// Compute a set of method overloads to show in a dialog relevant to the given code location. @@ -188,7 +188,7 @@ type public FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// An optional string used for tracing compiler operations associated with this request. - member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option * ?userOpName: string -> Async + member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option -> Async /// 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. /// The line number where the information is being requested. @@ -196,7 +196,7 @@ type public FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// An optional string used for tracing compiler operations associated with this request. - member GetMethodsAsSymbols : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async + member GetMethodsAsSymbols : line:int * colAtEndOfNames:int * lineText:string * names:string list -> Async /// Resolve the names at the given location to the declaration location of the corresponding construct. /// @@ -206,7 +206,7 @@ type public FSharpCheckFileResults = /// The identifiers at the location where the information is being requested. /// 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). /// An optional string used for tracing compiler operations associated with this request. - member GetDeclarationLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?preferFlag:bool * ?userOpName: string -> Async + member GetDeclarationLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?preferFlag:bool -> Async /// Resolve the names at the given location to a use of symbol. /// @@ -215,7 +215,7 @@ type public FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// An optional string used for tracing compiler operations associated with this request. - member GetSymbolUseAtLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async + member GetSymbolUseAtLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list -> Async /// Get any extra colorization info that is available after the typecheck member GetSemanticClassification : range option -> struct (range * SemanticClassificationType)[] @@ -239,10 +239,10 @@ type public FSharpCheckFileResults = member GetDisplayContextForPos : pos : pos -> Async /// Determines if a long ident is resolvable at a specific point. - member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item * ?userOpName: string -> Async + member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item -> Async /// Determines if a long ident is resolvable at a specific point. - member IsRelativeNameResolvableFromSymbol: cursorPos : pos * plid : string list * symbol: FSharpSymbol * ?userOpName: string -> Async + member IsRelativeNameResolvableFromSymbol: cursorPos : pos * plid : string list * symbol: FSharpSymbol -> Async /// Represents complete typechecked implementation file, including its typechecked signatures if any. member ImplementationFile: FSharpImplementationFileContents option diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 6a239d6bf83..5daf9dae681 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -273,11 +273,10 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.backgroundCompiler.scriptClosureCache /// Information about the derived script closure. let scriptClosureCache = - MruCache(projectCacheSize, + MruCache(projectCacheSize, areSame=FSharpProjectOptions.AreSameForChecking, areSimilar=FSharpProjectOptions.UseSameProject) - let scriptClosureCacheLock = Lock() let frameworkTcImportsCache = FrameworkImportsCache(frameworkTcImportsCacheStrongSize) // We currently share one global dependency provider for all scripts for the FSharpChecker. @@ -313,7 +312,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC self.TryGetLogicalTimeStampForProject(cache, ctok, opts, userOpName + ".TimeStampReferencedProject("+nm+")") member x.FileName = nm } ] - let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options)) + let loadClosure = scriptClosureCache.TryGet(AnyCallerThread, options) let! builderOpt, diagnostics = IncrementalBuilder.TryCreateIncrementalBuilderForProjectOptions @@ -355,28 +354,27 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC // /// Cache of builds keyed by options. let incrementalBuildersCache = - MruCache + MruCache (keepStrongly=projectCacheSize, keepMax=projectCacheSize, areSame = FSharpProjectOptions.AreSameForChecking, areSimilar = FSharpProjectOptions.UseSameProject) let getOrCreateBuilder (ctok, options, userOpName) = cancellable { - RequireCompilationThread ctok - match incrementalBuildersCache.TryGet (ctok, options) with + match incrementalBuildersCache.TryGet(AnyCallerThread, options) with | Some (builderOpt,creationErrors) -> Logger.Log LogCompilerFunctionId.Service_IncrementalBuildersCache_GettingCache return builderOpt,creationErrors | None -> Logger.Log LogCompilerFunctionId.Service_IncrementalBuildersCache_BuildingNewCache let! (builderOpt,creationErrors) as info = CreateOneIncrementalBuilder (ctok, options, userOpName) - incrementalBuildersCache.Set (ctok, options, info) + incrementalBuildersCache.Set (AnyCallerThread, options, info) return builderOpt, creationErrors } let getSimilarOrCreateBuilder (ctok, options, userOpName) = RequireCompilationThread ctok - match incrementalBuildersCache.TryGetSimilar (ctok, options) with + match incrementalBuildersCache.TryGetSimilar (AnyCallerThread, options) with | Some res -> Cancellable.ret res // The builder does not exist at all. Create it. | None -> getOrCreateBuilder (ctok, options, userOpName) @@ -536,7 +534,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC try // Get additional script #load closure information if applicable. // For scripts, this will have been recorded by GetProjectOptionsFromScript. - let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options)) + let loadClosure = scriptClosureCache.TryGet(AnyCallerThread, options) let! checkAnswer = FSharpCheckFileResults.CheckOneFile (parseResults, @@ -590,7 +588,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC cancellable { let! _builderOpt,_creationErrors = getOrCreateBuilder (ctok, options, userOpName) - match incrementalBuildersCache.TryGetAny (ctok, options) with + match incrementalBuildersCache.TryGetAny (AnyCallerThread, options) with | Some (Some builder, creationErrors) -> match bc.GetCachedCheckFileResult(builder, filename, sourceText, options) with | Some (_, checkResults) -> return Some (builder, creationErrors, Some (FSharpCheckFileAnswer.Succeeded checkResults)) @@ -735,7 +733,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC let untypedErrors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (errorOptions, false, filename, untypedErrors, suggestNamesForErrors) |] let tcErrors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (errorOptions, false, filename, tcErrors, suggestNamesForErrors) |] let parseResults = FSharpParseFileResults(errors = untypedErrors, input = parseTreeOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated) - let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options) ) + let loadClosure = scriptClosureCache.TryGet(AnyCallerThread, options) let typedResults = FSharpCheckFileResults.Make (filename, @@ -914,7 +912,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC ExtraProjectInfo=extraProjectInfo Stamp = optionsStamp } - scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Set(ltok, options, loadClosure)) // Save the full load closure for later correlation. + scriptClosureCache.Set(AnyCallerThread, options, loadClosure) // Save the full load closure for later correlation. return options, errors.Diagnostics }) @@ -924,12 +922,11 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC reactor.EnqueueOp(userOpName, "InvalidateConfiguration: Stamp(" + (options.Stamp |> Option.defaultValue 0L).ToString() + ")", options.ProjectFileName, fun ctok -> // If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it // will have the effect of releasing memory associated with the previous builder, but costs some time. - if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then + if incrementalBuildersCache.ContainsSimilarKey (AnyCallerThread, options) then - // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, - // including by incrementalBuildersCache.Set. + // We do not need to decrement here - it is done by disposal. let newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) |> Cancellable.runWithoutCancellation - incrementalBuildersCache.Set(ctok, options, newBuilderInfo) + incrementalBuildersCache.Set(AnyCallerThread, options, newBuilderInfo) // Start working on the project. Also a somewhat arbitrary choice if startBackgroundCompileIfAlreadySeen then @@ -939,7 +936,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC // This operation can't currently be cancelled nor awaited reactor.EnqueueOp(userOpName, "ClearCache", String.Empty, fun ctok -> options - |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(ctok, options))) + |> Seq.iter (fun options -> incrementalBuildersCache.RemoveAnySimilar(AnyCallerThread, options))) member __.NotifyProjectCleaned (options : FSharpProjectOptions, userOpName) = reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> @@ -947,11 +944,10 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC // If there was a similar entry (as there normally will have been) then re-establish an empty builder . This // is a somewhat arbitrary choice - it will have the effect of releasing memory associated with the previous // builder, but costs some time. - if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then - // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, - // including by incrementalBuildersCache.Set. + if incrementalBuildersCache.ContainsSimilarKey (AnyCallerThread, options) then + // We do not need to decrement here - it is done by disposal. let! newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) - incrementalBuildersCache.Set(ctok, options, newBuilderInfo) + incrementalBuildersCache.Set(AnyCallerThread, options, newBuilderInfo) }) member __.CheckProjectInBackground (options, userOpName) = @@ -997,9 +993,9 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC checkFileInProjectCachePossiblyStale.Clear ltok checkFileInProjectCache.Clear ltok parseFileCache.Clear(ltok)) - incrementalBuildersCache.Clear ctok + incrementalBuildersCache.Clear (AnyCallerThread) frameworkTcImportsCache.Clear ctok - scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Clear ltok) + scriptClosureCache.Clear (AnyCallerThread) cancellable.Return ()) member __.DownsizeCaches(userOpName) = @@ -1010,7 +1006,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC parseFileCache.Resize(ltok, keepStrongly=1)) incrementalBuildersCache.Resize(ctok, keepStrongly=1, keepMax=1) frameworkTcImportsCache.Downsize(ctok) - scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Resize(ltok,keepStrongly=1, keepMax=1)) + scriptClosureCache.Resize(AnyCallerThread,keepStrongly=1, keepMax=1) cancellable.Return ()) member __.FrameworkImportsCache = frameworkTcImportsCache @@ -1041,7 +1037,7 @@ type FSharpChecker(legacyReferenceResolver, // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.braceMatchCache. Most recently used cache for brace matching. Accessed on the // background UI thread, not on the compiler thread. // - // This cache is safe for concurrent access because there is no onDiscard action for the items in the cache. + // This cache is safe for concurrent access. let braceMatchCache = MruCache(braceMatchCacheSize, areSimilar = AreSimilarForParsing, areSame = AreSameForParsing) let mutable maxMemoryReached = false @@ -1078,11 +1074,11 @@ type FSharpChecker(legacyReferenceResolver, let userOpName = defaultArg userOpName "Unknown" let hash = sourceText.GetHashCode() async { - match braceMatchCache.TryGet(AssumeAnyCallerThreadWithoutEvidence(), (filename, hash, options)) with + match braceMatchCache.TryGet(AnyCallerThread, (filename, hash, options)) with | Some res -> return res | None -> let res = ParseAndCheckFile.matchBraces(sourceText, filename, options, userOpName, suggestNamesForErrors) - braceMatchCache.Set(AssumeAnyCallerThreadWithoutEvidence(), (filename, hash, options), res) + braceMatchCache.Set(AnyCallerThread, (filename, hash, options), res) return res } @@ -1209,7 +1205,7 @@ type FSharpChecker(legacyReferenceResolver, ic.ClearCaches() member __.ClearCachesAsync(?userOpName: string) = - let utok = AssumeAnyCallerThreadWithoutEvidence() + let utok = AnyCallerThread let userOpName = defaultArg userOpName "Unknown" braceMatchCache.Clear(utok) backgroundCompiler.ClearCachesAsync(userOpName) @@ -1225,7 +1221,7 @@ type FSharpChecker(legacyReferenceResolver, let userOpName = "MaxMemoryReached" backgroundCompiler.CompleteAllQueuedOps() maxMemoryReached <- true - braceMatchCache.Resize(AssumeAnyCallerThreadWithoutEvidence(), keepStrongly=10) + braceMatchCache.Resize(AnyCallerThread, keepStrongly=10) backgroundCompiler.DownsizeCaches(userOpName) |> Async.RunSynchronously maxMemEvent.Trigger( () ) diff --git a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs index e4a89018279..9b68a080c4a 100644 --- a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs +++ b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs @@ -18421,7 +18421,8 @@ FSharp.Compiler.AbstractIL.Internal.Library+ValueOrCancelled`1[TResult]: Int32 g FSharp.Compiler.AbstractIL.Internal.Library+ValueOrCancelled`1[TResult]: System.String ToString() FSharp.Compiler.AbstractIL.Internal.Library+ValueOrCancelled`1[TResult]: ValueOrCancelled`1 NewCancelled(System.OperationCanceledException) FSharp.Compiler.AbstractIL.Internal.Library+ValueOrCancelled`1[TResult]: ValueOrCancelled`1 NewValue(TResult) -FSharp.Compiler.AbstractIL.Internal.Library: AnyCallerThreadToken AssumeAnyCallerThreadWithoutEvidence() +FSharp.Compiler.AbstractIL.Internal.Library: AnyCallerThreadToken AnyCallerThread +FSharp.Compiler.AbstractIL.Internal.Library: AnyCallerThreadToken get_AnyCallerThread() FSharp.Compiler.AbstractIL.Internal.Library: Boolean String.EndsWithOrdinal(System.String, System.String) FSharp.Compiler.AbstractIL.Internal.Library: Boolean String.StartsWithOrdinal(System.String, System.String) FSharp.Compiler.AbstractIL.Internal.Library: Boolean isNilOrSingleton[a](Microsoft.FSharp.Collections.FSharpList`1[a]) From 67d47c1fefcd96e453895cafda501b095210e101 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 17:14:56 +0100 Subject: [PATCH 05/12] fix calls --- src/fsharp/service/FSharpCheckerResults.fs | 8 ++++---- src/fsharp/service/FSharpCheckerResults.fsi | 1 - src/fsharp/service/ServiceDeclarationLists.fs | 14 ++++++-------- src/fsharp/service/service.fs | 17 ++++++++--------- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/fsharp/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index 5eadd670d83..44ee7a9fb15 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -1966,8 +1966,8 @@ type FSharpCheckFileResults override __.ToString() = "FSharpCheckFileResults(" + filename + ")" - static member MakeEmpty(filename: string, creationErrors: FSharpErrorInfo[], reactorOps, keepAssemblyContents) = - FSharpCheckFileResults (filename, creationErrors, None, [| |], None, reactorOps, keepAssemblyContents) + static member MakeEmpty(filename: string, creationErrors: FSharpErrorInfo[], keepAssemblyContents) = + FSharpCheckFileResults (filename, creationErrors, None, [| |], None, keepAssemblyContents) static member JoinErrors(isIncompleteTypeCheckEnvironment, creationErrors: FSharpErrorInfo[], @@ -2006,7 +2006,7 @@ type FSharpCheckFileResults None, implFileOpt, openDeclarations) let errors = FSharpCheckFileResults.JoinErrors(isIncompleteTypeCheckEnvironment, creationErrors, parseErrors, tcErrors) - FSharpCheckFileResults (mainInputFileName, errors, Some tcFileInfo, dependencyFiles, Some builder, reactorOps, keepAssemblyContents) + FSharpCheckFileResults (mainInputFileName, errors, Some tcFileInfo, dependencyFiles, Some builder, keepAssemblyContents) static member CheckOneFile (parseResults: FSharpParseFileResults, @@ -2041,7 +2041,7 @@ type FSharpCheckFileResults return FSharpCheckFileAnswer.Aborted | Result.Ok tcFileInfo -> let errors = FSharpCheckFileResults.JoinErrors(isIncompleteTypeCheckEnvironment, creationErrors, parseErrors, tcErrors) - let results = FSharpCheckFileResults (mainInputFileName, errors, Some tcFileInfo, dependencyFiles, Some builder, reactorOps, keepAssemblyContents) + let results = FSharpCheckFileResults (mainInputFileName, errors, Some tcFileInfo, dependencyFiles, Some builder, keepAssemblyContents) return FSharpCheckFileAnswer.Succeeded(results) } diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index 6e97ce7ffa2..abbb49bba6d 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -254,7 +254,6 @@ type public FSharpCheckFileResults = static member internal MakeEmpty : filename: string * creationErrors: FSharpErrorInfo[] * - reactorOps: IReactorOperations * keepAssemblyContents: bool -> FSharpCheckFileResults diff --git a/src/fsharp/service/ServiceDeclarationLists.fs b/src/fsharp/service/ServiceDeclarationLists.fs index 29fa45f4cf6..5ce4fe70063 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fs +++ b/src/fsharp/service/ServiceDeclarationLists.fs @@ -479,16 +479,14 @@ type FSharpDeclarationListItem(name: string, nameInCode: string, fullName: strin member __.NameInCode = nameInCode member __.StructuredDescriptionTextAsync = - let userOpName = "ToolTip" match info with - | Choice1Of2 (items: CompletionItem list, infoReader, m, denv, reactor:IReactorOperations) -> + | Choice1Of2 (items: CompletionItem list, infoReader, m, denv) -> // reactor causes the lambda to execute on the background compiler thread, through the Reactor - reactor.EnqueueAndAwaitOpAsync (userOpName, "StructuredDescriptionTextAsync", name, fun ctok -> - RequireCompilationThread ctok - cancellable.Return(FSharpToolTipText(items |> List.map (fun x -> SymbolHelpers.FormatStructuredDescriptionOfItem true infoReader m denv x.ItemWithInst))) - ) - | Choice2Of2 result -> - async.Return result + FSharpToolTipText(items |> List.map (fun x -> SymbolHelpers.FormatStructuredDescriptionOfItem true infoReader m denv x.ItemWithInst)) + |> async.Return + + | Choice2Of2 result -> + async.Return result member decl.DescriptionTextAsync = decl.StructuredDescriptionTextAsync diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 5daf9dae681..f3faf6a2a30 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -387,7 +387,6 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC let parseCacheLock = Lock() - // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.parseFileInProjectCache. Most recently used cache for parsing files. let parseFileCache = MruCache(parseFileCacheSize, areSimilar = AreSimilarForParsing, areSame = AreSameForParsing) @@ -631,7 +630,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC reactor.CancelBackgroundOp() // cancel the background work, since we will start new work after we're done let! builderOpt,creationErrors = execWithReactorAsync (fun ctok -> getOrCreateBuilder (ctok, options, userOpName)) match builderOpt with - | None -> return FSharpCheckFileAnswer.Succeeded (FSharpCheckFileResults.MakeEmpty(filename, creationErrors, reactorOps, keepAssemblyContents)) + | None -> return FSharpCheckFileAnswer.Succeeded (FSharpCheckFileResults.MakeEmpty(filename, creationErrors, keepAssemblyContents)) | Some builder -> // Check the cache. We can only use cached results when there is no work to do to bring the background builder up-to-date let cachedResults = bc.GetCachedCheckFileResult(builder, filename, sourceText, options) @@ -712,7 +711,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC match builderOpt with | None -> let parseResults = FSharpParseFileResults(creationErrors, None, true, [| |]) - let typedResults = FSharpCheckFileResults.MakeEmpty(filename, creationErrors, reactorOps, keepAssemblyContents) + let typedResults = FSharpCheckFileResults.MakeEmpty(filename, creationErrors, keepAssemblyContents) return (parseResults, typedResults) | Some builder -> let! (parseTreeOpt, _, _, untypedErrors) = builder.GetParseResultsForFile (ctok, filename) @@ -792,13 +791,13 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC /// Try to get recent approximate type check results for a file. member __.TryGetRecentCheckResultsForFile(filename: string, options:FSharpProjectOptions, sourceText: ISourceText option, _userOpName: string) = - match sourceText with - | Some sourceText -> - parseCacheLock.AcquireLock (fun ltok -> + parseCacheLock.AcquireLock (fun ltok -> + match sourceText with + | Some sourceText -> match checkFileInProjectCache.TryGet(ltok,(filename,sourceText.GetHashCode(),options)) with | Some (a,b,c,_) -> Some (a,b,c) - | None -> parseCacheLock.AcquireLock (fun ltok -> checkFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options)))) - | None -> parseCacheLock.AcquireLock (fun ltok -> checkFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options))) + | None -> checkFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options)) + | None -> checkFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options))) /// Parse and typecheck the whole project (the implementation, called recursively as project graph is evaluated) member private __.ParseAndCheckProjectImpl(options, ctok, userOpName) = @@ -1004,7 +1003,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC checkFileInProjectCachePossiblyStale.Resize(ltok, keepStrongly=1) checkFileInProjectCache.Resize(ltok, keepStrongly=1) parseFileCache.Resize(ltok, keepStrongly=1)) - incrementalBuildersCache.Resize(ctok, keepStrongly=1, keepMax=1) + incrementalBuildersCache.Resize(AnyCallerThread, keepStrongly=1, keepMax=1) frameworkTcImportsCache.Downsize(ctok) scriptClosureCache.Resize(AnyCallerThread,keepStrongly=1, keepMax=1) cancellable.Return ()) From e802f43bcd66e5189b8d80cadf8ae5c78217bcee Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 18:46:56 +0100 Subject: [PATCH 06/12] fix tests --- .../FSharpScript.fs | 2 +- src/fsharp/service/FSharpCheckerResults.fsi | 23 +-- .../service/ServiceInterfaceStubGenerator.fs | 6 +- .../service/ServiceInterfaceStubGenerator.fsi | 2 +- tests/service/CSharpProjectAnalysis.fs | 3 - tests/service/Common.fs | 4 +- tests/service/EditorTests.fs | 43 ++-- tests/service/MultiProjectAnalysisTests.fs | 39 ++-- tests/service/ProjectAnalysisTests.fs | 192 +++++++++--------- tests/service/Symbols.fs | 2 - .../CodeFix/AddOpenCodeFixProvider.fs | 2 +- .../ImplementInterfaceCodeFixProvider.fs | 4 +- .../CodeFix/RenameUnusedValue.fs | 2 +- .../CodeLens/FSharpCodeLensService.fs | 5 +- .../FSharp.Editor/Completion/SignatureHelp.fs | 2 +- .../DocumentHighlightsService.fs | 4 +- .../InlineRename/InlineRenameService.fs | 2 +- .../LanguageService/SymbolHelpers.fs | 10 +- .../Navigation/FindUsagesService.fs | 6 +- .../Navigation/GoToDefinition.fs | 12 +- .../QuickInfo/QuickInfoProvider.fs | 20 +- .../BackgroundRequests.fs | 2 +- .../FSharp.LanguageService/GotoDefinition.fs | 2 +- .../FSharp.LanguageService/Intellisense.fs | 84 ++++---- .../UnitTests/GoToDefinitionServiceTests.fs | 2 +- 25 files changed, 220 insertions(+), 255 deletions(-) diff --git a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs index 8830fe7b1f0..7012154ba9c 100644 --- a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs +++ b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs @@ -62,7 +62,7 @@ type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVer let! parseResults, checkResults, _projectResults = fsi.ParseAndCheckInteraction(text) let lineText = text.Split('\n').[line - 1] let partialName = QuickParse.GetPartialLongNameEx(lineText, column - 1) - let! declarationListInfos = checkResults.GetDeclarationListInfo(Some parseResults, line, lineText, partialName) + let declarationListInfos = checkResults.GetDeclarationListInfo(Some parseResults, line, lineText, partialName) return declarationListInfos.Items } diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index b197d3a88bb..b7fb69ac705 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -119,12 +119,7 @@ type public FSharpCheckFileResults = /// /// Function that returns all entities from current and referenced assemblies. /// - member GetDeclarationListInfo : - ParsedFileResultsOpt:FSharpParseFileResults option * - line: int * - lineText:string * - partialName: PartialLongName * - ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpDeclarationListInfo + member GetDeclarationListInfo: ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpDeclarationListInfo /// Get the items for a declaration list in FSharpSymbol format /// @@ -144,13 +139,7 @@ type public FSharpCheckFileResults = /// /// Function that returns all entities from current and referenced assemblies. /// - member GetDeclarationListSymbols: - ParsedFileResultsOpt:FSharpParseFileResults option * - line: int * - lineText:string * - partialName: PartialLongName * - ?getAllEntities: (unit -> AssemblySymbol list) - -> FSharpSymbolUse list list + member GetDeclarationListSymbols: ParsedFileResultsOpt:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpSymbolUse list list /// Compute a formatted tooltip for the given location /// @@ -159,13 +148,7 @@ type public FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// 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. - member GetStructuredToolTipText : - line:int * - colAtEndOfNames:int * - lineText:string * - names:string list * - tokenTag:int - -> FSharpStructuredToolTipText + member GetStructuredToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> FSharpStructuredToolTipText /// Compute a formatted tooltip for the given location /// diff --git a/src/fsharp/service/ServiceInterfaceStubGenerator.fs b/src/fsharp/service/ServiceInterfaceStubGenerator.fs index be58d530de8..e303bb39b75 100644 --- a/src/fsharp/service/ServiceInterfaceStubGenerator.fs +++ b/src/fsharp/service/ServiceInterfaceStubGenerator.fs @@ -549,7 +549,7 @@ module InterfaceStubGenerator = /// (1) Crack ASTs to get member names and their associated ranges /// (2) Check symbols of those members based on ranges /// (3) If any symbol found, capture its member signature - let getImplementedMemberSignatures (getMemberByLocation: string * range -> Async) displayContext interfaceData = + let getImplementedMemberSignatures (getMemberByLocation: string * range -> FSharpSymbolUse option) displayContext interfaceData = let formatMemberSignature (symbolUse: FSharpSymbolUse) = match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as m -> @@ -567,10 +567,10 @@ module InterfaceStubGenerator = //fail "Should only accept symbol uses of members." None async { - let! symbolUses = + let symbolUses = getMemberNameAndRanges interfaceData |> List.toArray - |> Array.mapAsync getMemberByLocation + |> Array.map getMemberByLocation return symbolUses |> Array.choose (Option.bind formatMemberSignature >> Option.map String.Concat) |> Set.ofArray } diff --git a/src/fsharp/service/ServiceInterfaceStubGenerator.fsi b/src/fsharp/service/ServiceInterfaceStubGenerator.fsi index 6f4ed525f5f..8d22896fdd3 100644 --- a/src/fsharp/service/ServiceInterfaceStubGenerator.fsi +++ b/src/fsharp/service/ServiceInterfaceStubGenerator.fsi @@ -28,7 +28,7 @@ module InterfaceStubGenerator = /// positions of 'member', which indicate the indentation for generating new members val getMemberNameAndRanges : InterfaceData -> (string * range) list - val getImplementedMemberSignatures : getMemberByLocation: (string * range -> Async) -> FSharpDisplayContext -> InterfaceData -> Async> + val getImplementedMemberSignatures : getMemberByLocation: (string * range -> FSharpSymbolUse option) -> FSharpDisplayContext -> InterfaceData -> Async> /// Check whether an entity is an interface or type abbreviation of an interface val isInterface : FSharpEntity -> bool diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs index 5c0d2474b94..10fd567ad39 100644 --- a/tests/service/CSharpProjectAnalysis.fs +++ b/tests/service/CSharpProjectAnalysis.fs @@ -108,7 +108,6 @@ let _ = CSharpOuterClass.InnerClass.StaticMember() let results, _ = getProjectReferences(content, [csharpAssembly], None, None) results.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString()) |> shouldEqual [|"FSharp"; "Compiler"; "Service"; "Tests"; "FSharp"; "InnerEnum"; @@ -130,7 +129,6 @@ let _ = CSharpClass(0) let results, _ = getProjectReferences(content, [csharpAssembly], None, None) let ctor = results.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously |> Seq.map (fun su -> su.Symbol) |> Seq.find (function :? FSharpMemberOrFunctionOrValue as mfv -> mfv.IsConstructor | _ -> false) match (ctor :?> FSharpMemberOrFunctionOrValue).DeclaringEntity with @@ -144,7 +142,6 @@ let getEntitiesUses source = let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll" let results, _ = getProjectReferences(source, [csharpAssembly], None, None) results.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously |> Seq.choose (fun su -> match su.Symbol with | :? FSharpEntity as entity -> Some entity diff --git a/tests/service/Common.fs b/tests/service/Common.fs index ce05828bb95..e1b8c81f5b9 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -346,11 +346,11 @@ let inline dumpErrors results = let getSymbolUses (results: FSharpCheckFileResults) = - results.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + results.GetAllUsesOfAllSymbolsInFile() let getSymbolUsesFromSource (source: string) = let _, typeCheckResults = getParseAndCheckResults source - typeCheckResults.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + typeCheckResults.GetAllUsesOfAllSymbolsInFile() let getSymbols (symbolUses: FSharpSymbolUse[]) = symbolUses |> Array.map (fun symbolUse -> symbolUse.Symbol) diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 6c50d1e8906..b10ee676460 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -82,14 +82,14 @@ let ``Intro test`` () = msg.Message.Contains("Missing qualification after '.'") |> shouldEqual true // Get tool tip at the specified location - let tip = typeCheckResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken) |> Async.RunSynchronously + let tip = typeCheckResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken) // (sprintf "%A" tip).Replace("\n","") |> shouldEqual """FSharpToolTipText [Single ("val foo : unit -> unitFull name: Test.foo",None)]""" // Get declarations (autocomplete) for a location let partialName = { QualifyingIdents = []; PartialIdent = "msg"; EndColumn = 22; LastDotPos = None } - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], partialName, (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], partialName, (fun _ -> [])) CollectionAssert.AreEquivalent(stringMethods,[ for item in decls.Items -> item.Name ]) // Get overloads of the String.Concat method - let methods = typeCheckResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously + let methods = typeCheckResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) methods.MethodName |> shouldEqual "Concat" @@ -148,7 +148,7 @@ let ``GetMethodsAsSymbols should return all overloads of a method as FSharpSymbo let inputLines = input.Split('\n') let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let methodsSymbols = typeCheckResults.GetMethodsAsSymbols(5, 27, inputLines.[4], ["String"; "Concat"]) |> Async.RunSynchronously + let methodsSymbols = typeCheckResults.GetMethodsAsSymbols(5, 27, inputLines.[4], ["String"; "Concat"]) match methodsSymbols with | Some methods -> [ for ms in methods do @@ -289,7 +289,7 @@ let ``Expression typing test`` () = // gives the results for the string type. // for col in 42..43 do - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 2, inputLines.[1], PartialLongName.Empty(col), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 2, inputLines.[1], PartialLongName.Empty(col), (fun _ -> [])) let autoCompleteSet = set [ for item in decls.Items -> item.Name ] autoCompleteSet |> shouldEqual (set stringMethods) @@ -310,7 +310,7 @@ type Test() = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(20), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(20), (fun _ -> [])) let item = decls.Items |> Array.tryFind (fun d -> d.Name = "abc") decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true @@ -327,7 +327,7 @@ type Test() = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(21), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(21), (fun _ -> [])) let item = decls.Items |> Array.tryFind (fun d -> d.Name = "abc") decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true @@ -344,7 +344,7 @@ type Test() = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun _ -> [])) decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true @@ -364,7 +364,7 @@ type B(bar) = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], PartialLongName.Empty(17), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], PartialLongName.Empty(17), (fun _ -> [])) decls.Items |> Seq.exists (fun d -> d.Name = "bar") |> shouldEqual true @@ -387,7 +387,7 @@ type B(bar) = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 9, inputLines.[8], PartialLongName.Empty(7), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 9, inputLines.[8], PartialLongName.Empty(7), (fun _ -> [])) decls.Items |> Seq.exists (fun d -> d.Name = "bar") |> shouldEqual true @@ -404,7 +404,7 @@ type Test() = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(20), (fun () -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(20), (fun () -> [])) //decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A" decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true @@ -421,7 +421,7 @@ type Test() = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(21), (fun () -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(21), (fun () -> [])) //decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A" decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true @@ -438,7 +438,7 @@ type Test() = let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun () -> []), fun _ -> false)|> Async.RunSynchronously + let decls = typeCheckResults.GetDeclarationListSymbols(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun () -> [])) //decls |> List.map (fun d -> d.Head.Symbol.DisplayName) |> printfn "---> decls = %A" decls |> Seq.exists (fun d -> d.Head.Symbol.DisplayName = "abc") |> shouldEqual true @@ -625,7 +625,6 @@ type DU = Case1 let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.map (fun su -> let r = su.RangeAlternate r.StartLine, r.StartColumn, r.EndLine, r.EndColumn) @@ -644,7 +643,6 @@ let _ = arr.[..number2] let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.map (fun su -> let r = su.RangeAlternate su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn)) @@ -678,7 +676,7 @@ let test3 = System.Text.RegularExpressions.RegexOptions.Compiled """ let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input) - let allSymbols = typeCheckResults.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + let allSymbols = typeCheckResults.GetAllUsesOfAllSymbolsInFile() let enums = allSymbols |> Array.choose(fun s -> match s.Symbol with :? FSharpEntity as e when e.IsEnum -> Some e | _ -> None) @@ -731,7 +729,6 @@ let _ = let file = "/home/user/Test.fsx" let _, typeCheckResults = parseAndCheckScript(file, input) typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.map (fun su -> let r = su.RangeAlternate su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn)) @@ -778,7 +775,6 @@ type Class1() = let file = "/home/user/Test.fsx" let _, typeCheckResults = parseAndCheckScript(file, input) typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.map (fun su -> let r = su.RangeAlternate su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn)) @@ -828,7 +824,6 @@ let x: T() let file = "/home/user/Test.fsx" let _, typeCheckResults = parseAndCheckScript(file, input) typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.map (fun su -> let r = su.RangeAlternate let isConstructor = @@ -1142,7 +1137,6 @@ let _ = Threading.Buzz = null let file = "/home/user/Test.fsx" let _, typeCheckResults = parseAndCheckScript(file, input) typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.map (fun su -> let r = su.RangeAlternate su.Symbol.ToString(), (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn)) @@ -1164,7 +1158,7 @@ let ``GetDeclarationLocation should not require physical file`` () = let input = "let abc = 1\nlet xyz = abc" let file = "/home/user/Test.fsx" let _, typeCheckResults = parseAndCheckScript(file, input) - let location = typeCheckResults.GetDeclarationLocation(2, 13, "let xyz = abc", ["abc"]) |> Async.RunSynchronously + let location = typeCheckResults.GetDeclarationLocation(2, 13, "let xyz = abc", ["abc"]) match location with | FSharpFindDeclResult.DeclFound r -> Some (r.StartLine, r.StartColumn, r.EndLine, r.EndColumn, "<=== Found here." ) | _ -> Some (0 , 0 , 0 , 0 , "Not Found. Should not require physical file." ) @@ -1211,7 +1205,7 @@ let _ = RegexTypedStatic.IsMatch<"ABC" >( (*$*) ) // TEST: no assert on Ctrl-sp let ``Test TPProject all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(TPProject.options) |> Async.RunSynchronously - let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() let allSymbolUsesInfo = [ for s in allSymbolUses -> s.Symbol.DisplayName, tups s.RangeAlternate, attribsOfSymbol s.Symbol ] //printfn "allSymbolUsesInfo = \n----\n%A\n----" allSymbolUsesInfo @@ -1291,7 +1285,7 @@ let ``Test TPProject quick info`` () = let lineText = TPProject.fileLines1.[lineNum] if lineText.Contains(".IsMatch") then let colAtEndOfNames = lineText.IndexOf(".IsMatch") + ".IsMatch".Length - let res = typeCheckResults.GetToolTipTextAlternate(lineNum, colAtEndOfNames, lineText, ["RegexTypedStatic";"IsMatch"], FSharpTokenTag.IDENT) |> Async.RunSynchronously + let res = typeCheckResults.GetToolTipTextAlternate(lineNum, colAtEndOfNames, lineText, ["RegexTypedStatic";"IsMatch"], FSharpTokenTag.IDENT) yield lineNum, extractToolTipText res ] //printfn "toolTips = \n----\n%A\n----" toolTips @@ -1325,7 +1319,7 @@ let ``Test TPProject param info`` () = let lineText = TPProject.fileLines1.[lineNum] if lineText.Contains(".IsMatch") then let colAtEndOfNames = lineText.IndexOf(".IsMatch") + ".IsMatch".Length - let meths = typeCheckResults.GetMethodsAlternate(lineNum, colAtEndOfNames, lineText, Some ["RegexTypedStatic";"IsMatch"]) |> Async.RunSynchronously + let meths = typeCheckResults.GetMethodsAlternate(lineNum, colAtEndOfNames, lineText, Some ["RegexTypedStatic";"IsMatch"]) let elems = [ for meth in meths.Methods do yield extractToolTipText meth.Description, meth.HasParameters, [ for p in meth.Parameters -> p.ParameterName ], [ for p in meth.StaticParameters -> p.ParameterName ] ] @@ -1357,7 +1351,6 @@ let ``FSharpField.IsNameGenerated`` () = let _, typeCheckResults = parseAndCheckScript(file, source) let symbols = typeCheckResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously symbols |> Array.choose (fun su -> match su.Symbol with diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index c3b1e0cb91c..a5863d15cba 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -149,17 +149,17 @@ let ``Test multi project 1 all symbols`` () = let mp = checker.ParseAndCheckProject(MultiProject1.options) |> Async.RunSynchronously let x1FromProject1A = - [ for s in p1A.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in p1A.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "x1" then yield s.Symbol ] |> List.head let x1FromProjectMultiProject = - [ for s in mp.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mp.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "x1" then yield s.Symbol ] |> List.head let bFromProjectMultiProject = - [ for s in mp.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mp.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "b" then yield s.Symbol ] |> List.head @@ -171,12 +171,10 @@ let ``Test multi project 1 all symbols`` () = let usesOfx1FromProject1AInMultiProject1 = mp.GetUsesOfSymbol(x1FromProject1A) - |> Async.RunSynchronously |> Array.map (fun s -> s.Symbol.DisplayName, MultiProject1.cleanFileName s.FileName, tups s.Symbol.DeclarationLocation.Value) let usesOfx1FromMultiProject1InMultiProject1 = mp.GetUsesOfSymbol(x1FromProjectMultiProject) - |> Async.RunSynchronously |> Array.map (fun s -> s.Symbol.DisplayName, MultiProject1.cleanFileName s.FileName, tups s.Symbol.DeclarationLocation.Value) usesOfx1FromProject1AInMultiProject1 |> shouldEqual usesOfx1FromMultiProject1InMultiProject1 @@ -189,7 +187,7 @@ let ``Test multi project 1 xmldoc`` () = let mp = checker.ParseAndCheckProject(MultiProject1.options) |> Async.RunSynchronously let symbolFromProject1A sym = - [ for s in p1A.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in p1A.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = sym then yield s.Symbol ] |> List.head @@ -197,17 +195,17 @@ let ``Test multi project 1 xmldoc`` () = let x3FromProject1A = symbolFromProject1A "x3" let x1FromProjectMultiProject = - [ for s in mp.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mp.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "x1" then yield s.Symbol ] |> List.head let ctorFromProjectMultiProject = - [ for s in mp.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mp.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "C" then yield s.Symbol ] |> List.head let case1FromProjectMultiProject = - [ for s in mp.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mp.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "Case1" then yield s.Symbol ] |> List.head @@ -347,13 +345,13 @@ let ``Test ManyProjectsStressTest all symbols`` () = let jointProjectResults = checker.ParseAndCheckProject(ManyProjectsStressTest.jointProject.Options) |> Async.RunSynchronously let vsFromJointProject = - [ for s in jointProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in jointProjectResults.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "v" then yield s.Symbol ] for (p,pResults) in projectsResults do let vFromProject = - [ for s in pResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in pResults.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "v" then yield s.Symbol ] |> List.head vFromProject.Assembly.FileName.IsNone |> shouldEqual true // For now, the assembly being analyzed doesn't return a filename @@ -362,7 +360,6 @@ let ``Test ManyProjectsStressTest all symbols`` () = let usesFromJointProject = jointProjectResults.GetUsesOfSymbol(vFromProject) - |> Async.RunSynchronously |> Array.map (fun s -> s.Symbol.DisplayName, ManyProjectsStressTest.cleanFileName s.FileName, tups s.Symbol.DeclarationLocation.Value) usesFromJointProject.Length |> shouldEqual 1 @@ -441,7 +438,7 @@ let ``Test multi project symbols should pick up changes in dependent projects`` //---------------- Get a symbol from project 1 and look up its uses in both projects -------------------- - let xSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(3, 4, "", ["x"]) |> Async.RunSynchronously + let xSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(3, 4, "", ["x"]) xSymbolUse.IsSome |> shouldEqual true let xSymbol = xSymbolUse.Value.Symbol @@ -459,7 +456,6 @@ let ``Test multi project symbols should pick up changes in dependent projects`` let usesOfXSymbolInProject1 = wholeProjectResults1.GetUsesOfSymbol(xSymbol) - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString(), MultiProjectDirty1.cleanFileName su.FileName, tups su.RangeAlternate) usesOfXSymbolInProject1 @@ -468,7 +464,6 @@ let ``Test multi project symbols should pick up changes in dependent projects`` let usesOfXSymbolInProject2 = wholeProjectResults2.GetUsesOfSymbol(xSymbol) - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString(), MultiProjectDirty2.cleanFileName su.FileName, tups su.RangeAlternate) usesOfXSymbolInProject2 @@ -497,7 +492,7 @@ let ``Test multi project symbols should pick up changes in dependent projects`` checker.GetBackgroundCheckResultsForFileInProject(MultiProjectDirty1.fileName1, proj1options) |> Async.RunSynchronously - let xSymbolUseAfterChange1 = backgroundTypedParse1AfterChange1.GetSymbolUseAtLocation(4, 4, "", ["x"]) |> Async.RunSynchronously + let xSymbolUseAfterChange1 = backgroundTypedParse1AfterChange1.GetSymbolUseAtLocation(4, 4, "", ["x"]) xSymbolUseAfterChange1.IsSome |> shouldEqual true let xSymbolAfterChange1 = xSymbolUseAfterChange1.Value.Symbol @@ -510,7 +505,6 @@ let ``Test multi project symbols should pick up changes in dependent projects`` let usesOfXSymbolInProject1AfterChange1 = wholeProjectResults1AfterChange1.GetUsesOfSymbol(xSymbolAfterChange1) - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString(), MultiProjectDirty1.cleanFileName su.FileName, tups su.RangeAlternate) usesOfXSymbolInProject1AfterChange1 @@ -519,7 +513,6 @@ let ``Test multi project symbols should pick up changes in dependent projects`` let usesOfXSymbolInProject2AfterChange1 = wholeProjectResults2AfterChange1.GetUsesOfSymbol(xSymbolAfterChange1) - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString(), MultiProjectDirty2.cleanFileName su.FileName, tups su.RangeAlternate) usesOfXSymbolInProject2AfterChange1 @@ -556,14 +549,13 @@ let ``Test multi project symbols should pick up changes in dependent projects`` checker.GetBackgroundCheckResultsForFileInProject(MultiProjectDirty1.fileName1, proj1options) |> Async.RunSynchronously - let xSymbolUseAfterChange2 = backgroundTypedParse1AfterChange2.GetSymbolUseAtLocation(4, 4, "", ["x"]) |> Async.RunSynchronously + let xSymbolUseAfterChange2 = backgroundTypedParse1AfterChange2.GetSymbolUseAtLocation(4, 4, "", ["x"]) xSymbolUseAfterChange2.IsSome |> shouldEqual true let xSymbolAfterChange2 = xSymbolUseAfterChange2.Value.Symbol let usesOfXSymbolInProject1AfterChange2 = wholeProjectResults1AfterChange2.GetUsesOfSymbol(xSymbolAfterChange2) - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString(), MultiProjectDirty1.cleanFileName su.FileName, tups su.RangeAlternate) usesOfXSymbolInProject1AfterChange2 @@ -573,7 +565,6 @@ let ``Test multi project symbols should pick up changes in dependent projects`` let usesOfXSymbolInProject2AfterChange2 = wholeProjectResults2AfterChange2.GetUsesOfSymbol(xSymbolAfterChange2) - |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString(), MultiProjectDirty2.cleanFileName su.FileName, tups su.RangeAlternate) usesOfXSymbolInProject2AfterChange2 @@ -684,12 +675,12 @@ let ``Test multi project 2 all symbols`` () = // These all get the symbol in A, but from three different project compilations/checks let symFromA = - [ for s in mpA.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mpA.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "InternalMember" then yield s.Symbol ] |> List.head let symFromB = - [ for s in mpB.GetAllUsesOfAllSymbols() |> Async.RunSynchronously do + [ for s in mpB.GetAllUsesOfAllSymbols() do if s.Symbol.DisplayName = "InternalMember" then yield s.Symbol ] |> List.head @@ -770,7 +761,7 @@ let ``Test active patterns' XmlDocSig declared in referenced projects`` () = checker.GetBackgroundCheckResultsForFileInProject(MultiProject3.fileName1, MultiProject3.options) |> Async.RunSynchronously - let divisibleBySymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(7,7,"",["DivisibleBy"]) |> Async.RunSynchronously + let divisibleBySymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(7,7,"",["DivisibleBy"]) divisibleBySymbolUse.IsSome |> shouldEqual true let divisibleBySymbol = divisibleBySymbolUse.Value.Symbol divisibleBySymbol.ToString() |> shouldEqual "symbol DivisibleBy" diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 9122d855425..cb576325591 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -324,13 +324,13 @@ let ``Test project1 xxx symbols`` () = checker.GetBackgroundCheckResultsForFileInProject(Project1.fileName1, Project1.options) |> Async.RunSynchronously - let xSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(9,9,"",["xxx"]) |> Async.RunSynchronously + let xSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(9,9,"",["xxx"]) let xSymbolUse = xSymbolUseOpt.Value let xSymbol = xSymbolUse.Symbol xSymbol.ToString() |> shouldEqual "val xxx" let usesOfXSymbol = - [ for su in wholeProjectResults.GetUsesOfSymbol(xSymbol) |> Async.RunSynchronously do + [ for su in wholeProjectResults.GetUsesOfSymbol(xSymbol) do yield Project1.cleanFileName su.FileName , tups su.RangeAlternate, attribsOfSymbol su.Symbol ] usesOfXSymbol |> shouldEqual @@ -348,7 +348,7 @@ let ``Test project1 all uses of all signature symbols`` () = let allUsesOfAllSymbols = [ for s in allSymbols do yield s.ToString(), - [ for s in wholeProjectResults.GetUsesOfSymbol(s) |> Async.RunSynchronously -> + [ for s in wholeProjectResults.GetUsesOfSymbol(s) -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) ] ] let expected = [("N", [("file2", ((1, 7), (1, 8)))]); @@ -413,7 +413,7 @@ let ``Test project1 all uses of all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously let allUsesOfAllSymbols = - [ for s in wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously -> + [ for s in wholeProjectResults.GetAllUsesOfAllSymbols() -> s.Symbol.DisplayName, s.Symbol.FullName, Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate, attribsOfSymbol s.Symbol ] let expected = [("C", "M.C", "file1", ((3, 5), (3, 6)), ["class"]); @@ -564,16 +564,16 @@ let ``Test file explicit parse symbols`` () = |> Async.RunSynchronously |> function FSharpCheckFileAnswer.Succeeded x -> x | _ -> failwith "unexpected aborted" - let xSymbolUse2Opt = checkResults1.GetSymbolUseAtLocation(9,9,"",["xxx"]) |> Async.RunSynchronously + let xSymbolUse2Opt = checkResults1.GetSymbolUseAtLocation(9,9,"",["xxx"]) let xSymbol2 = xSymbolUse2Opt.Value.Symbol let usesOfXSymbol2 = - [| for s in wholeProjectResults.GetUsesOfSymbol(xSymbol2) |> Async.RunSynchronously -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) |] + [| for s in wholeProjectResults.GetUsesOfSymbol(xSymbol2) -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) |] let usesOfXSymbol21 = - [| for s in checkResults1.GetUsesOfSymbolInFile(xSymbol2) |> Async.RunSynchronously -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) |] + [| for s in checkResults1.GetUsesOfSymbolInFile(xSymbol2) -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) |] let usesOfXSymbol22 = - [| for s in checkResults2.GetUsesOfSymbolInFile(xSymbol2) |> Async.RunSynchronously -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) |] + [| for s in checkResults2.GetUsesOfSymbolInFile(xSymbol2) -> (Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate) |] usesOfXSymbol2 |> shouldEqual [|("file1", ((6, 4), (6, 7))); @@ -610,7 +610,7 @@ let ``Test file explicit parse all symbols`` () = |> Async.RunSynchronously |> function FSharpCheckFileAnswer.Succeeded x -> x | _ -> failwith "unexpected aborted" - let usesOfSymbols = checkResults1.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + let usesOfSymbols = checkResults1.GetAllUsesOfAllSymbolsInFile() let cleanedUsesOfSymbols = [ for s in usesOfSymbols -> s.Symbol.DisplayName, Project1.cleanFileName s.FileName, tupsZ s.RangeAlternate, attribsOfSymbol s.Symbol ] @@ -717,7 +717,7 @@ let ``Test project2 all uses of all signature symbols`` () = let allSymbols = allSymbolsInEntities true wholeProjectResults.AssemblySignature.Entities let allUsesOfAllSymbols = [ for s in allSymbols do - let uses = [ for s in wholeProjectResults.GetUsesOfSymbol(s) |> Async.RunSynchronously -> (if s.FileName = Project2.fileName1 then "file1" else "??"), tupsZ s.RangeAlternate ] + let uses = [ for s in wholeProjectResults.GetUsesOfSymbol(s) -> (if s.FileName = Project2.fileName1 then "file1" else "??"), tupsZ s.RangeAlternate ] yield s.ToString(), uses ] let expected = [("M", [("file1", ((1, 7), (1, 8)))]); @@ -755,7 +755,7 @@ let ``Test project2 all uses of all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project2.options) |> Async.RunSynchronously let allUsesOfAllSymbols = - [ for s in wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously -> + [ for s in wholeProjectResults.GetAllUsesOfAllSymbols() -> s.Symbol.DisplayName, (if s.FileName = Project2.fileName1 then "file1" else "???"), tupsZ s.RangeAlternate, attribsOfSymbol s.Symbol ] let expected = [("int", "file1", ((4, 13), (4, 16)), ["abbrev"]); @@ -1029,7 +1029,7 @@ let ``Test project3 all uses of all signature symbols`` () = let allUsesOfAllSymbols = [ for s in allSymbols do - let uses = [ for s in wholeProjectResults.GetUsesOfSymbol(s) |> Async.RunSynchronously -> + let uses = [ for s in wholeProjectResults.GetUsesOfSymbol(s) -> ((if s.FileName = Project3.fileName1 then "file1" else "??"), tupsZ s.RangeAlternate, attribsOfSymbolUse s, attribsOfSymbol s.Symbol) ] yield s.ToString(), uses ] @@ -1320,7 +1320,7 @@ let ``Test project4 all uses of all signature symbols`` () = let allSymbols = allSymbolsInEntities false wholeProjectResults.AssemblySignature.Entities let allUsesOfAllSymbols = [ for s in allSymbols do - let uses = [ for s in wholeProjectResults.GetUsesOfSymbol(s) |> Async.RunSynchronously -> (if s.FileName = Project4.fileName1 then "file1" else "??"), tupsZ s.RangeAlternate ] + let uses = [ for s in wholeProjectResults.GetUsesOfSymbol(s) -> (if s.FileName = Project4.fileName1 then "file1" else "??"), tupsZ s.RangeAlternate ] yield s.ToString(), uses ] let expected = [("M", [("file1", ((1, 7), (1, 8)))]); @@ -1346,14 +1346,14 @@ let ``Test project4 T symbols`` () = checker.GetBackgroundCheckResultsForFileInProject(Project4.fileName1, Project4.options) |> Async.RunSynchronously - let tSymbolUse2 = backgroundTypedParse1.GetSymbolUseAtLocation(4,19,"",["T"]) |> Async.RunSynchronously + let tSymbolUse2 = backgroundTypedParse1.GetSymbolUseAtLocation(4,19,"",["T"]) tSymbolUse2.IsSome |> shouldEqual true let tSymbol2 = tSymbolUse2.Value.Symbol tSymbol2.ToString() |> shouldEqual "generic parameter T" tSymbol2.ImplementationLocation.IsSome |> shouldEqual true - let uses = backgroundTypedParse1.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + let uses = backgroundTypedParse1.GetAllUsesOfAllSymbolsInFile() let allUsesOfAllSymbols = [ for s in uses -> s.Symbol.ToString(), (if s.FileName = Project4.fileName1 then "file1" else "??"), tupsZ s.RangeAlternate ] allUsesOfAllSymbols |> shouldEqual @@ -1375,7 +1375,7 @@ let ``Test project4 T symbols`` () = ("val twice", "file1", ((5, 11), (5, 16))); ("M", "file1", ((1, 7), (1, 8)))] - let tSymbolUse3 = backgroundTypedParse1.GetSymbolUseAtLocation(4,11,"",["T"]) |> Async.RunSynchronously + let tSymbolUse3 = backgroundTypedParse1.GetSymbolUseAtLocation(4,11,"",["T"]) tSymbolUse3.IsSome |> shouldEqual true let tSymbol3 = tSymbolUse3.Value.Symbol tSymbol3.ToString() |> shouldEqual "generic parameter T" @@ -1383,7 +1383,7 @@ let ``Test project4 T symbols`` () = tSymbol3.ImplementationLocation.IsSome |> shouldEqual true let usesOfTSymbol2 = - wholeProjectResults.GetUsesOfSymbol(tSymbol2) |> Async.RunSynchronously + wholeProjectResults.GetUsesOfSymbol(tSymbol2) |> Array.map (fun su -> su.FileName , tupsZ su.RangeAlternate) |> Array.map (fun (a,b) -> (if a = Project4.fileName1 then "file1" else "??"), b) @@ -1393,13 +1393,13 @@ let ``Test project4 T symbols`` () = let usesOfTSymbol3 = wholeProjectResults.GetUsesOfSymbol(tSymbol3) - |> Async.RunSynchronously + |> Array.map (fun su -> su.FileName , tupsZ su.RangeAlternate) |> Array.map (fun (a,b) -> (if a = Project4.fileName1 then "file1" else "??"), b) usesOfTSymbol3 |> shouldEqual usesOfTSymbol2 - let uSymbolUse2 = backgroundTypedParse1.GetSymbolUseAtLocation(6,23,"",["U"]) |> Async.RunSynchronously + let uSymbolUse2 = backgroundTypedParse1.GetSymbolUseAtLocation(6,23,"",["U"]) uSymbolUse2.IsSome |> shouldEqual true let uSymbol2 = uSymbolUse2.Value.Symbol uSymbol2.ToString() |> shouldEqual "generic parameter U" @@ -1408,7 +1408,7 @@ let ``Test project4 T symbols`` () = let usesOfUSymbol2 = wholeProjectResults.GetUsesOfSymbol(uSymbol2) - |> Async.RunSynchronously + |> Array.map (fun su -> su.FileName , tupsZ su.RangeAlternate) |> Array.map (fun (a,b) -> (if a = Project4.fileName1 then "file1" else "??"), b) @@ -1473,7 +1473,7 @@ let ``Test project 5 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.FullName, Project5.cleanFileName su.FileName, tupsZ su.RangeAlternate, attribsOfSymbolUse su) allUsesOfAllSymbols |> shouldEqual @@ -1541,7 +1541,7 @@ let ``Test complete active patterns' exact ranges from uses of symbols`` () = checker.GetBackgroundCheckResultsForFileInProject(Project5.fileName1, Project5.options) |> Async.RunSynchronously - let oddSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(11,8,"",["Odd"]) |> Async.RunSynchronously + let oddSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(11,8,"",["Odd"]) oddSymbolUse.IsSome |> shouldEqual true let oddSymbol = oddSymbolUse.Value.Symbol oddSymbol.ToString() |> shouldEqual "symbol Odd" @@ -1557,7 +1557,7 @@ let ``Test complete active patterns' exact ranges from uses of symbols`` () = let oddEntity = oddGroup.DeclaringEntity.Value oddEntity.ToString() |> shouldEqual "ActivePatterns" - let evenSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(10,9,"",["Even"]) |> Async.RunSynchronously + let evenSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(10,9,"",["Even"]) evenSymbolUse.IsSome |> shouldEqual true let evenSymbol = evenSymbolUse.Value.Symbol evenSymbol.ToString() |> shouldEqual "symbol Even" @@ -1574,12 +1574,12 @@ let ``Test complete active patterns' exact ranges from uses of symbols`` () = let usesOfEvenSymbol = wholeProjectResults.GetUsesOfSymbol(evenSymbol) - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), Project5.cleanFileName su.FileName, tupsZ su.RangeAlternate) let usesOfOddSymbol = wholeProjectResults.GetUsesOfSymbol(oddSymbol) - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), Project5.cleanFileName su.FileName, tupsZ su.RangeAlternate) usesOfEvenSymbol |> shouldEqual @@ -1601,7 +1601,7 @@ let ``Test partial active patterns' exact ranges from uses of symbols`` () = checker.GetBackgroundCheckResultsForFileInProject(Project5.fileName1, Project5.options) |> Async.RunSynchronously - let floatSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(22,10,"",["Float"]) |> Async.RunSynchronously + let floatSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(22,10,"",["Float"]) floatSymbolUse.IsSome |> shouldEqual true let floatSymbol = floatSymbolUse.Value.Symbol floatSymbol.ToString() |> shouldEqual "symbol Float" @@ -1619,7 +1619,7 @@ let ``Test partial active patterns' exact ranges from uses of symbols`` () = let usesOfFloatSymbol = wholeProjectResults.GetUsesOfSymbol(floatSymbol) - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), Project5.cleanFileName su.FileName, tups su.RangeAlternate) usesOfFloatSymbol |> shouldEqual @@ -1629,7 +1629,7 @@ let ``Test partial active patterns' exact ranges from uses of symbols`` () = // Should also return its definition let floatSymUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(14,11,"",["Float"]) - |> Async.RunSynchronously + floatSymUseOpt.IsSome |> shouldEqual true @@ -1674,7 +1674,7 @@ let ``Test project 6 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), Project6.cleanFileName su.FileName, tupsZ su.RangeAlternate, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -1730,16 +1730,16 @@ let ``Test project 7 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project7.cleanFileName su.FileName, tups su.RangeAlternate) let arg1symbol = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.pick (fun x -> if x.Symbol.DisplayName = "arg1" then Some x.Symbol else None) let arg1uses = wholeProjectResults.GetUsesOfSymbol(arg1symbol) - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), Option.map tups su.Symbol.DeclarationLocation, Project7.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbol su.Symbol) arg1uses |> shouldEqual [|("val arg1", Some ((5, 20), (5, 24)), "file1", ((5, 20), (5, 24)), []); @@ -1791,7 +1791,7 @@ let ``Test project 8 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project8.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols @@ -1820,11 +1820,11 @@ let ``Test project 8 all symbols`` () = let arg1symbol = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.pick (fun x -> if x.Symbol.DisplayName = "xxx" then Some x.Symbol else None) let arg1uses = wholeProjectResults.GetUsesOfSymbol(arg1symbol) - |> Async.RunSynchronously + |> Array.map (fun su -> Option.map tups su.Symbol.DeclarationLocation, Project8.cleanFileName su.FileName, tups su.RangeAlternate) arg1uses |> shouldEqual @@ -1871,7 +1871,7 @@ let ``Test project 9 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project9.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -1897,11 +1897,11 @@ let ``Test project 9 all symbols`` () = let arg1symbol = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.pick (fun x -> if x.Symbol.DisplayName = "IsInfinity" then Some x.Symbol else None) let arg1uses = wholeProjectResults.GetUsesOfSymbol(arg1symbol) - |> Async.RunSynchronously + |> Array.map (fun su -> Option.map tups su.Symbol.DeclarationLocation, Project9.cleanFileName su.FileName, tups su.RangeAlternate) arg1uses |> shouldEqual @@ -1950,7 +1950,7 @@ let ``Test Project10 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project10.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -1975,7 +1975,7 @@ let ``Test Project10 all symbols`` () = let querySymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(7,23,"",["query"]) - |> Async.RunSynchronously + let querySymbolUse = querySymbolUseOpt.Value let querySymbol = querySymbolUse.Symbol @@ -1983,7 +1983,7 @@ let ``Test Project10 all symbols`` () = let querySymbolUse2Opt = backgroundTypedParse1.GetSymbolUseAtLocation(7,22,"",["query"]) - |> Async.RunSynchronously + let querySymbolUse2 = querySymbolUse2Opt.Value let querySymbol2 = querySymbolUse2.Symbol @@ -2030,7 +2030,7 @@ let ``Test Project11 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project11.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -2099,7 +2099,7 @@ let ``Test Project12 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project12.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -2166,7 +2166,7 @@ let ``Test Project13 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project13.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -2185,12 +2185,12 @@ let ``Test Project13 all symbols`` () = ("ExternalTypes", "ExternalTypes", "file1", ((2, 7), (2, 20)), ["defn"], ["module"])|] - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "Object") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "Object") let objEntity = objSymbol.Symbol :?> FSharpEntity let objMemberNames = [ for x in objEntity.MembersFunctionsAndValues -> x.DisplayName ] set objMemberNames |> shouldEqual (set [".ctor"; "ToString"; "Equals"; "Equals"; "ReferenceEquals"; "GetHashCode"; "GetType"; "Finalize"; "MemberwiseClone"]) - let dtSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "DateTime") + let dtSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "DateTime") let dtEntity = dtSymbol.Symbol :?> FSharpEntity let dtPropNames = [ for x in dtEntity.MembersFunctionsAndValues do if x.IsProperty then yield x.DisplayName ] @@ -2317,7 +2317,7 @@ let ``Test Project14 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project14.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su) allUsesOfAllSymbols |> shouldEqual @@ -2385,7 +2385,7 @@ let ``Test Project15 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project15.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su) allUsesOfAllSymbols |> shouldEqual @@ -2472,7 +2472,7 @@ let ``Test Project16 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project16.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -2577,8 +2577,8 @@ let ``Test Project16 sig symbols are equal to impl symbols`` () = | _ -> failwithf "Parsing aborted unexpectedly..." - let symbolsSig = checkResultsSig.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously - let symbolsImpl = checkResultsImpl.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + let symbolsSig = checkResultsSig.GetAllUsesOfAllSymbolsInFile() + let symbolsImpl = checkResultsImpl.GetAllUsesOfAllSymbolsInFile() // Test that all 'definition' symbols in the signature (or implementation) have a matching symbol in the // implementation (or signature). @@ -2626,7 +2626,7 @@ let ``Test Project16 sym locations`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.choose (fun su -> match fmtLoc su.Symbol.SignatureLocation, fmtLoc su.Symbol.DeclarationLocation, fmtLoc su.Symbol.ImplementationLocation with | Some a, Some b, Some c -> Some (su.Symbol.ToString(), a, b, c) @@ -2677,7 +2677,7 @@ let ``Test project16 DeclaringEntity`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project16.options) |> Async.RunSynchronously - let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() for sym in allSymbolsUses do match sym.Symbol with | :? FSharpEntity as e when not e.IsNamespace || e.AccessPath.Contains(".") -> @@ -2742,7 +2742,7 @@ let ``Test Project17 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project17.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols @@ -2828,7 +2828,7 @@ let ``Test Project18 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project18.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, (match su.Symbol with :? FSharpEntity as e -> e.IsNamespace | _ -> false)) @@ -2884,7 +2884,7 @@ let ``Test Project19 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project19.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -2956,14 +2956,14 @@ let ``Test Project20 all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project20.options) |> Async.RunSynchronously - let tSymbolUse = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.RangeAlternate.StartLine = 5 && su.Symbol.ToString() = "generic parameter T") + let tSymbolUse = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.RangeAlternate.StartLine = 5 && su.Symbol.ToString() = "generic parameter T") let tSymbol = tSymbolUse.Symbol let allUsesOfTSymbol = wholeProjectResults.GetUsesOfSymbol(tSymbol) - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project20.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfTSymbol |> shouldEqual @@ -3019,7 +3019,7 @@ let ``Test Project21 all symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project21.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) allUsesOfAllSymbols |> shouldEqual @@ -3094,7 +3094,7 @@ let ``Test Project22 IList contents`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + let ilistTypeUse = allUsesOfAllSymbols @@ -3176,7 +3176,7 @@ let ``Test Project22 IList properties`` () = let ilistTypeUse = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.find (fun su -> su.Symbol.DisplayName = "IList") let ilistTypeDefn = ilistTypeUse.Symbol :?> FSharpEntity @@ -3235,7 +3235,7 @@ let ``Test Project23 whole project errors`` () = let ``Test Project23 property`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project23.options) |> Async.RunSynchronously - let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() let classTypeUse = allSymbolsUses |> Array.find (fun su -> su.Symbol.DisplayName = "Class") let classTypeDefn = classTypeUse.Symbol :?> FSharpEntity @@ -3299,11 +3299,11 @@ let ``Test Project23 property`` () = let ``Test Project23 extension properties' getters/setters should refer to the correct declaring entities`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project23.options) |> Async.RunSynchronously - let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() let extensionMembers = allSymbolsUses |> Array.rev |> Array.filter (fun su -> su.Symbol.DisplayName = "Value") extensionMembers - |> Array.collect (fun memb -> wholeProjectResults.GetUsesOfSymbol(memb.Symbol) |> Async.RunSynchronously) + |> Array.collect (fun memb -> wholeProjectResults.GetUsesOfSymbol(memb.Symbol) ) |> Array.collect (fun x -> [| match x.Symbol with @@ -3408,7 +3408,7 @@ let ``Test Project24 all symbols`` () = let allUses = backgroundTypedParse1.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously + |> Array.map (fun s -> (s.Symbol.DisplayName, Project24.cleanFileName s.FileName, tups s.RangeAlternate, attribsOfSymbolUse s, attribsOfSymbol s.Symbol)) allUses |> shouldEqual @@ -3515,7 +3515,7 @@ let ``Test symbol uses of properties with both getters and setters`` () = let getAllSymbolUses = backgroundTypedParse1.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously + |> Array.map (fun s -> (s.Symbol.DisplayName, Project24.cleanFileName s.FileName, tups s.RangeAlternate, attribsOfSymbol s.Symbol)) getAllSymbolUses |> shouldEqual @@ -3600,13 +3600,13 @@ let ``Test symbol uses of properties with both getters and setters`` () = let getSampleSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(9,20,"",["NameGet"]) - |> Async.RunSynchronously + let getSampleSymbol = getSampleSymbolUseOpt.Value.Symbol let usesOfGetSampleSymbol = backgroundTypedParse1.GetUsesOfSymbolInFile(getSampleSymbol) - |> Async.RunSynchronously + |> Array.map (fun s -> (Project24.cleanFileName s.FileName, tups s.RangeAlternate)) usesOfGetSampleSymbol |> shouldEqual [|("file1", ((9, 13), (9, 20))); ("file1", ((36, 9), (36, 37)))|] @@ -3663,7 +3663,7 @@ let ``Test Project25 symbol uses of type-provided members`` () = let allUses = backgroundTypedParse1.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously + |> Array.map (fun s -> (s.Symbol.FullName, Project25.cleanFileName s.FileName, tups s.RangeAlternate, attribsOfSymbol s.Symbol)) allUses |> shouldEqual @@ -3699,13 +3699,13 @@ let ``Test Project25 symbol uses of type-provided members`` () = ["member"]); ("TypeProviderTests", "file1", ((2, 7), (2, 24)), ["module"])|] let getSampleSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(5,25,"",["GetSample"]) - |> Async.RunSynchronously + let getSampleSymbol = getSampleSymbolUseOpt.Value.Symbol let usesOfGetSampleSymbol = backgroundTypedParse1.GetUsesOfSymbolInFile(getSampleSymbol) - |> Async.RunSynchronously + |> Array.map (fun s -> (Project25.cleanFileName s.FileName, tups s.RangeAlternate)) usesOfGetSampleSymbol |> shouldEqual [|("file1", ((5, 8), (5, 25))); ("file1", ((10, 8), (10, 78)))|] @@ -3722,13 +3722,13 @@ let ``Test symbol uses of type-provided types`` () = let getSampleSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(4,26,"",["XmlProvider"]) - |> Async.RunSynchronously + let getSampleSymbol = getSampleSymbolUseOpt.Value.Symbol let usesOfGetSampleSymbol = backgroundTypedParse1.GetUsesOfSymbolInFile(getSampleSymbol) - |> Async.RunSynchronously + |> Array.map (fun s -> (Project25.cleanFileName s.FileName, tups s.RangeAlternate)) usesOfGetSampleSymbol |> shouldEqual [|("file1", ((4, 15), (4, 26))); ("file1", ((10, 8), (10, 19)))|] @@ -3742,13 +3742,13 @@ let ``Test symbol uses of fully-qualified records`` () = let getSampleSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(7,11,"",["Record"]) - |> Async.RunSynchronously + let getSampleSymbol = getSampleSymbolUseOpt.Value.Symbol let usesOfGetSampleSymbol = backgroundTypedParse1.GetUsesOfSymbolInFile(getSampleSymbol) - |> Async.RunSynchronously + |> Array.map (fun s -> (Project25.cleanFileName s.FileName, tups s.RangeAlternate)) usesOfGetSampleSymbol |> shouldEqual [|("file1", ((7, 5), (7, 11))); ("file1", ((8, 10), (8, 16)))|] @@ -3794,11 +3794,11 @@ let ``Test Project26 parameter symbols`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), su.Symbol.DisplayName, Project13.cleanFileName su.FileName, tups su.RangeAlternate, attribsOfSymbolUse su, attribsOfSymbol su.Symbol) - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "Class") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "Class") let objEntity = objSymbol.Symbol :?> FSharpEntity let rec isByRef (ty: FSharpType) = @@ -4023,7 +4023,7 @@ let ``Test project29 event symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project29.options) |> Async.RunSynchronously - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "INotifyPropertyChanged") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "INotifyPropertyChanged") let objEntity = objSymbol.Symbol :?> FSharpEntity let objMethodsCurriedParameterGroups = @@ -4080,7 +4080,7 @@ let ``Test project30 Format attributes`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project30.options) |> Async.RunSynchronously - let moduleSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "Module") + let moduleSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "Module") let moduleEntity = moduleSymbol.Symbol :?> FSharpEntity let moduleAttributes = @@ -4094,7 +4094,7 @@ let ``Test project30 Format attributes`` () = [("[ (4))>]", "[ (4))>]")]) - let memberSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "Member") + let memberSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "Member") let memberEntity = memberSymbol.Symbol :?> FSharpMemberOrFunctionOrValue let memberAttributes = @@ -4143,7 +4143,7 @@ let ``Test project31 C# type attributes`` () = if not runningOnMono then let wholeProjectResults = checker.ParseAndCheckProject(Project31.options) |> Async.RunSynchronously - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "List") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "List") let objEntity = objSymbol.Symbol :?> FSharpEntity let attributes = objEntity.Attributes |> Seq.filter (fun attrib -> attrib.AttributeType.DisplayName <> "__DynamicallyInvokableAttribute") @@ -4165,7 +4165,7 @@ let ``Test project31 C# method attributes`` () = if not runningOnMono then let wholeProjectResults = checker.ParseAndCheckProject(Project31.options) |> Async.RunSynchronously - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "Console") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "Console") let objEntity = objSymbol.Symbol :?> FSharpEntity let objMethodsAttributes = @@ -4192,7 +4192,7 @@ let ``Test project31 Format C# type attributes`` () = if not runningOnMono then let wholeProjectResults = checker.ParseAndCheckProject(Project31.options) |> Async.RunSynchronously - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "List") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "List") let objEntity = objSymbol.Symbol :?> FSharpEntity let attributes = objEntity.Attributes |> Seq.filter (fun attrib -> attrib.AttributeType.DisplayName <> "__DynamicallyInvokableAttribute") @@ -4209,7 +4209,7 @@ let ``Test project31 Format C# method attributes`` () = if not runningOnMono then let wholeProjectResults = checker.ParseAndCheckProject(Project31.options) |> Async.RunSynchronously - let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.find (fun su -> su.Symbol.DisplayName = "Console") + let objSymbol = wholeProjectResults.GetAllUsesOfAllSymbols() |> Array.find (fun su -> su.Symbol.DisplayName = "Console") let objEntity = objSymbol.Symbol :?> FSharpEntity let objMethodsAttributes = @@ -4267,11 +4267,11 @@ let ``Test Project32 should be able to find sig symbols`` () = checker.GetBackgroundCheckResultsForFileInProject(Project32.sigFileName1, Project32.options) |> Async.RunSynchronously - let sigSymbolUseOpt = sigBackgroundTypedParse1.GetSymbolUseAtLocation(4,5,"",["func"]) |> Async.RunSynchronously + let sigSymbolUseOpt = sigBackgroundTypedParse1.GetSymbolUseAtLocation(4,5,"",["func"]) let sigSymbol = sigSymbolUseOpt.Value.Symbol let usesOfSigSymbol = - [ for su in wholeProjectResults.GetUsesOfSymbol(sigSymbol) |> Async.RunSynchronously do + [ for su in wholeProjectResults.GetUsesOfSymbol(sigSymbol) do yield Project32.cleanFileName su.FileName , tups su.RangeAlternate, attribsOfSymbol su.Symbol ] usesOfSigSymbol |> shouldEqual @@ -4286,11 +4286,11 @@ let ``Test Project32 should be able to find impl symbols`` () = checker.GetBackgroundCheckResultsForFileInProject(Project32.fileName1, Project32.options) |> Async.RunSynchronously - let implSymbolUseOpt = implBackgroundTypedParse1.GetSymbolUseAtLocation(3,5,"",["func"]) |> Async.RunSynchronously + let implSymbolUseOpt = implBackgroundTypedParse1.GetSymbolUseAtLocation(3,5,"",["func"]) let implSymbol = implSymbolUseOpt.Value.Symbol let usesOfImplSymbol = - [ for su in wholeProjectResults.GetUsesOfSymbol(implSymbol) |> Async.RunSynchronously do + [ for su in wholeProjectResults.GetUsesOfSymbol(implSymbol) do yield Project32.cleanFileName su.FileName , tups su.RangeAlternate, attribsOfSymbol su.Symbol ] usesOfImplSymbol |> shouldEqual @@ -4330,7 +4330,7 @@ let ``Test Project33 whole project errors`` () = let ``Test Project33 extension methods`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project33.options) |> Async.RunSynchronously - let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() let implModuleUse = allSymbolsUses |> Array.find (fun su -> su.Symbol.DisplayName = "Impl") let implModuleDefn = implModuleUse.Symbol :?> FSharpEntity @@ -4430,7 +4430,7 @@ type Test = [] let ``Test project35 CurriedParameterGroups should be available for nested functions`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project35.options) |> Async.RunSynchronously - let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() let findByDisplayName name = Array.find (fun (su:FSharpSymbolUse) -> su.Symbol.DisplayName = name) @@ -4582,7 +4582,7 @@ let callToOverload = B(5).Overload(4) [] let ``Test project36 FSharpMemberOrFunctionOrValue.IsBaseValue`` () = Project36.wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + |> Array.pick (fun (su:FSharpSymbolUse) -> if su.Symbol.DisplayName = "base" then Some (su.Symbol :?> FSharpMemberOrFunctionOrValue) @@ -4695,7 +4695,7 @@ let ``Test project37 typeof and arrays in attribute constructor arguments`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project37.options) |> Async.RunSynchronously - let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() for su in allSymbolsUses do match su.Symbol with | :? FSharpMemberOrFunctionOrValue as funcSymbol -> @@ -4749,7 +4749,7 @@ let ``Test project37 DeclaringEntity`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project37.options) |> Async.RunSynchronously - let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols() for sym in allSymbolsUses do match sym.Symbol with | :? FSharpEntity as e when not e.IsNamespace || e.AccessPath.Contains(".") -> @@ -4918,7 +4918,7 @@ let uses () = let ``Test project39 all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project39.options) |> Async.RunSynchronously - let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() let typeTextOfAllSymbolUses = [ for s in allSymbolUses do match s.Symbol with @@ -4993,7 +4993,7 @@ let g (x: C) = x.IsItAnA,x.IsItAnAMethod() let ``Test Project40 all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project40.options) |> Async.RunSynchronously - let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() let allSymbolUsesInfo = [ for s in allSymbolUses -> s.Symbol.DisplayName, tups s.RangeAlternate, attribsOfSymbol s.Symbol ] allSymbolUsesInfo |> shouldEqual [("option", ((4, 10), (4, 16)), ["abbrev"]); ("x", ((4, 7), (4, 8)), []); @@ -5063,7 +5063,7 @@ module M let ``Test project41 all symbols`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project41.options) |> Async.RunSynchronously - let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously + let allSymbolUses = wholeProjectResults.GetAllUsesOfAllSymbols() let allSymbolUsesInfo = [ for s in allSymbolUses do let pos = diff --git a/tests/service/Symbols.fs b/tests/service/Symbols.fs index b0932e9075d..11f5984b5d6 100644 --- a/tests/service/Symbols.fs +++ b/tests/service/Symbols.fs @@ -38,7 +38,6 @@ match "foo" with let _, checkResults = parseAndCheckFile fileName source options checkResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.filter (fun su -> su.RangeAlternate.StartLine = line && su.Symbol :? FSharpActivePatternCase) |> Array.map (fun su -> su.Symbol :?> FSharpActivePatternCase) @@ -119,7 +118,6 @@ let x = 123 let _, checkResults = parseAndCheckFile fileName source options checkResults.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously |> Array.tryFind (fun su -> su.Symbol.DisplayName = "x") |> Option.orElseWith (fun _ -> failwith "Could not get symbol") |> Option.map (fun su -> su.Symbol :?> FSharpMemberOrFunctionOrValue) diff --git a/vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs b/vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs index 387caea14d9..477d35820ef 100644 --- a/vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs +++ b/vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs @@ -106,7 +106,7 @@ type internal FSharpAddOpenCodeFixProvider let! symbol = asyncMaybe { let! lexerSymbol = Tokenizer.getSymbolAtPosition(document.Id, sourceText, context.Span.End, document.FilePath, defines, SymbolLookupKind.Greedy, false, false) - return! checkResults.GetSymbolUseAtLocation(Line.fromZ linePos.Line, lexerSymbol.Ident.idRange.EndColumn, line.ToString(), lexerSymbol.FullIsland, userOpName=userOpName) + return checkResults.GetSymbolUseAtLocation(Line.fromZ linePos.Line, lexerSymbol.Ident.idRange.EndColumn, line.ToString(), lexerSymbol.FullIsland) } |> liftAsync do! Option.guard symbol.IsNone diff --git a/vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs b/vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs index 2415fa3baca..7035085b70d 100644 --- a/vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs +++ b/vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs @@ -120,7 +120,7 @@ type internal FSharpImplementInterfaceCodeFixProvider let! sourceText = context.Document.GetTextAsync(cancellationToken) |> Async.AwaitTask let getMemberByLocation(name, range: range) = let lineStr = sourceText.Lines.[range.EndLine-1].ToString() - results.GetSymbolUseAtLocation(range.EndLine, range.EndColumn, lineStr, [name], userOpName=userOpName) + results.GetSymbolUseAtLocation(range.EndLine, range.EndColumn, lineStr, [name]) let! implementedMemberSignatures = InterfaceStubGenerator.getImplementedMemberSignatures getMemberByLocation displayContext state.InterfaceData let newSourceText = applyImplementInterface sourceText state displayContext implementedMemberSignatures entity indentSize verboseMode @@ -174,7 +174,7 @@ type internal FSharpImplementInterfaceCodeFixProvider let lineContents = textLine.ToString() let! options = context.Document.GetOptionsAsync(cancellationToken) let tabSize = options.GetOption(FormattingOptions.TabSize, FSharpConstants.FSharpLanguageName) - let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, lineContents, symbol.FullIsland, userOpName=userOpName) + let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, lineContents, symbol.FullIsland) let! entity, displayContext = match symbolUse.Symbol with | :? FSharpEntity as entity -> diff --git a/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs b/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs index 2a185cdbb8e..f85fda9cd32 100644 --- a/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs +++ b/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs @@ -63,7 +63,7 @@ type internal FSharpRenameUnusedValueCodeFixProvider let defines = CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions let! lexerSymbol = Tokenizer.getSymbolAtPosition (document.Id, sourceText, context.Span.Start, document.FilePath, defines, SymbolLookupKind.Greedy, false, false) let lineText = (sourceText.Lines.GetLineFromPosition context.Span.Start).ToString() - let! symbolUse = checkResults.GetSymbolUseAtLocation(m.StartLine, m.EndColumn, lineText, lexerSymbol.FullIsland, userOpName=userOpName) + let! symbolUse = checkResults.GetSymbolUseAtLocation(m.StartLine, m.EndColumn, lineText, lexerSymbol.FullIsland) let symbolName = symbolUse.Symbol.DisplayName match symbolUse.Symbol with diff --git a/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs b/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs index dd2b8271dc8..79b0f97cfd0 100644 --- a/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs +++ b/vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs @@ -160,7 +160,8 @@ type internal FSharpCodeLensService #if DEBUG logInfof "Getting uses of all symbols!" #endif - let! symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile() |> liftAsync + let! ct = Async.CancellationToken |> liftAsync + let symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile(ct) let textSnapshot = buffer.CurrentSnapshot #if DEBUG logInfof "Updating due to buffer edit!" @@ -184,7 +185,7 @@ type internal FSharpCodeLensService if (lineNumber >= 0 || lineNumber < textSnapshot.LineCount) then match func.FullTypeSafe with | Some _ -> - let! maybeContext = checkFileResults.GetDisplayContextForPos(func.DeclarationLocation.Start) + let maybeContext = checkFileResults.GetDisplayContextForPos(func.DeclarationLocation.Start) let displayContext = Option.defaultValue displayContext maybeContext let typeLayout = func.FormatLayout displayContext diff --git a/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs b/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs index b6899193ed2..b8735eab97e 100644 --- a/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs +++ b/vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs @@ -75,7 +75,7 @@ type internal FSharpSignatureHelpProvider let lidEnd = nwpl.LongIdEndLocation // Get the methods - let! methodGroup = checkFileResults.GetMethods(lidEnd.Line, lidEnd.Column, "", Some names) + let methodGroup = checkFileResults.GetMethods(lidEnd.Line, lidEnd.Column, "", Some names) let methods = methodGroup.Methods diff --git a/vsintegration/src/FSharp.Editor/DocumentHighlights/DocumentHighlightsService.fs b/vsintegration/src/FSharp.Editor/DocumentHighlights/DocumentHighlightsService.fs index ade8eb32a8f..bcc0bd3629b 100644 --- a/vsintegration/src/FSharp.Editor/DocumentHighlights/DocumentHighlightsService.fs +++ b/vsintegration/src/FSharp.Editor/DocumentHighlights/DocumentHighlightsService.fs @@ -60,8 +60,8 @@ type internal FSharpDocumentHighlightsService [] (checkerP let fcsTextLineNumber = Line.fromZ textLinePos.Line let! symbol = Tokenizer.getSymbolAtPosition(documentKey, sourceText, position, filePath, defines, SymbolLookupKind.Greedy, false, false) let! _, _, checkFileResults = checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, options, languageServicePerformanceOptions, userOpName = userOpName) - let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland, userOpName=userOpName) - let! symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbolUse.Symbol) |> liftAsync + let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland) + let symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbolUse.Symbol) return [| for symbolUse in symbolUses do match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, symbolUse.RangeAlternate) with diff --git a/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs b/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs index 15704641c09..0fd8e3171f7 100644 --- a/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs +++ b/vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs @@ -157,7 +157,7 @@ type internal InlineRenameService let fcsTextLineNumber = Line.fromZ textLinePos.Line let! symbol = Tokenizer.getSymbolAtPosition(document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Greedy, false, false) let! _, _, checkFileResults = checker.ParseAndCheckDocument(document, options, userOpName = userOpName) - let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.Text.ToString(), symbol.FullIsland, userOpName=userOpName) + let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.Text.ToString(), symbol.FullIsland) let! declLoc = symbolUse.GetDeclarationLocation(document) let! span = RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, symbolUse.RangeAlternate) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs b/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs index 37635ea5d69..1be896711b4 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs @@ -30,8 +30,9 @@ module internal SymbolHelpers = let! symbol = Tokenizer.getSymbolAtPosition(document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Greedy, false, false) let settings = document.FSharpOptions let! _, _, checkFileResults = checker.ParseAndCheckDocument(document.FilePath, textVersionHash, sourceText, projectOptions, settings.LanguageServicePerformance, userOpName = userOpName) - let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland, userOpName=userOpName) - let! symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbolUse.Symbol) |> liftAsync + let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland) + let! ct = Async.CancellationToken |> liftAsync + let symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbolUse.Symbol, cancellationToken=ct) return symbolUses } @@ -75,7 +76,8 @@ module internal SymbolHelpers = match declLoc with | SymbolDeclarationLocation.CurrentDocument -> - let! symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbol) + let! ct = Async.CancellationToken + let symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbol, ct) return toDict (symbolUses |> Seq.map (fun symbolUse -> symbolUse.RangeAlternate)) | SymbolDeclarationLocation.Projects (projects, isInternalToProject) -> let symbolUseRanges = ImmutableArray.CreateBuilder() @@ -125,7 +127,7 @@ module internal SymbolHelpers = let textLine = sourceText.Lines.GetLineFromPosition(symbolSpan.Start) let textLinePos = sourceText.Lines.GetLinePosition(symbolSpan.Start) let fcsTextLineNumber = Line.fromZ textLinePos.Line - let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.Text.ToString(), symbol.FullIsland, userOpName=userOpName) + let! symbolUse = checkFileResults.GetSymbolUseAtLocation(fcsTextLineNumber, symbol.Ident.idRange.EndColumn, textLine.Text.ToString(), symbol.FullIsland) let! declLoc = symbolUse.GetDeclarationLocation(document) let newText = textChanger originalText // defer finding all symbol uses throughout the solution diff --git a/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs b/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs index d0ce7ed88cf..e60aa9f4db1 100644 --- a/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs +++ b/vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs @@ -58,8 +58,8 @@ type internal FSharpFindUsagesService let defines = CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions let! symbol = Tokenizer.getSymbolAtPosition(document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Greedy, false, false) - let! symbolUse = checkFileResults.GetSymbolUseAtLocation(lineNumber, symbol.Ident.idRange.EndColumn, textLine, symbol.FullIsland, userOpName=userOpName) - let! declaration = checkFileResults.GetDeclarationLocation (lineNumber, symbol.Ident.idRange.EndColumn, textLine, symbol.FullIsland, false, userOpName=userOpName) |> liftAsync + let! symbolUse = checkFileResults.GetSymbolUseAtLocation(lineNumber, symbol.Ident.idRange.EndColumn, textLine, symbol.FullIsland) + let declaration = checkFileResults.GetDeclarationLocation (lineNumber, symbol.Ident.idRange.EndColumn, textLine, symbol.FullIsland, false) let tags = FSharpGlyphTags.GetTags(Tokenizer.GetGlyphForSymbol (symbolUse.Symbol, symbol.Kind)) let declarationRange = @@ -108,7 +108,7 @@ type internal FSharpFindUsagesService match symbolUse.GetDeclarationLocation document with | Some SymbolDeclarationLocation.CurrentDocument -> - let! symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbolUse.Symbol) |> liftAsync + let symbolUses = checkFileResults.GetUsesOfSymbolInFile(symbolUse.Symbol) for symbolUse in symbolUses do match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, symbolUse.RangeAlternate) with | Some textSpan -> diff --git a/vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs b/vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs index 18221c0f316..7de8934fed6 100644 --- a/vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs +++ b/vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs @@ -180,7 +180,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP let! _, _, checkFileResults = checker.ParseAndCheckDocument (originDocument, projectOptions, sourceText=sourceText, userOpName=userOpName) let idRange = lexerSymbol.Ident.idRange - let! fsSymbolUse = checkFileResults.GetSymbolUseAtLocation (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland, userOpName=userOpName) + let! fsSymbolUse = checkFileResults.GetSymbolUseAtLocation (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland) let symbol = fsSymbolUse.Symbol // if the tooltip was spawned in an implementation file and we have a range targeting // a signature file, try to find the corresponding implementation file and target the @@ -192,7 +192,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP let! implSourceText = implDoc.GetTextAsync () let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(implDoc, CancellationToken.None, userOpName) let! _, _, checkFileResults = checker.ParseAndCheckDocument (implDoc, projectOptions, sourceText=implSourceText, userOpName=userOpName) - let! symbolUses = checkFileResults.GetUsesOfSymbolInFile symbol |> liftAsync + let symbolUses = checkFileResults.GetUsesOfSymbolInFile symbol let! implSymbol = symbolUses |> Array.tryHead let! implTextSpan = RoslynHelpers.TryFSharpRangeToTextSpan (implSourceText, implSymbol.RangeAlternate) return FSharpGoToDefinitionNavigableItem (implDoc, implTextSpan) @@ -213,7 +213,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP match checkFileAnswer with | FSharpCheckFileAnswer.Aborted -> return! None | FSharpCheckFileAnswer.Succeeded checkFileResults -> - let! symbolUses = checkFileResults.GetUsesOfSymbolInFile targetSymbolUse.Symbol |> liftAsync + let symbolUses = checkFileResults.GetUsesOfSymbolInFile targetSymbolUse.Symbol let! implSymbol = symbolUses |> Array.tryHead return implSymbol.RangeAlternate } @@ -235,8 +235,8 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP let! lexerSymbol = Tokenizer.getSymbolAtPosition (originDocument.Id, sourceText, position,originDocument.FilePath, defines, SymbolLookupKind.Greedy, false, false) let idRange = lexerSymbol.Ident.idRange - let! declarations = checkFileResults.GetDeclarationLocation (fcsTextLineNumber, lexerSymbol.Ident.idRange.EndColumn, textLine.ToString(), lexerSymbol.FullIsland, preferSignature, userOpName=userOpName) |> liftAsync - let! targetSymbolUse = checkFileResults.GetSymbolUseAtLocation (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland, userOpName=userOpName) + let declarations = checkFileResults.GetDeclarationLocation (fcsTextLineNumber, lexerSymbol.Ident.idRange.EndColumn, textLine.ToString(), lexerSymbol.FullIsland, preferSignature) + let! targetSymbolUse = checkFileResults.GetSymbolUseAtLocation (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland) match declarations with | FSharpFindDeclResult.ExternalDecl (assembly, targetExternalSym) -> @@ -276,7 +276,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP let navItem = FSharpGoToDefinitionNavigableItem (implDocument, implTextSpan) return (navItem, idRange) else // jump from implementation to the corresponding signature - let! declarations = checkFileResults.GetDeclarationLocation (fcsTextLineNumber, lexerSymbol.Ident.idRange.EndColumn, textLine.ToString(), lexerSymbol.FullIsland, true, userOpName=userOpName) |> liftAsync + let declarations = checkFileResults.GetDeclarationLocation (fcsTextLineNumber, lexerSymbol.Ident.idRange.EndColumn, textLine.ToString(), lexerSymbol.FullIsland, true) match declarations with | FSharpFindDeclResult.DeclFound targetRange -> let! sigDocument = originDocument.Project.Solution.TryGetDocumentFromPath targetRange.FileName diff --git a/vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs b/vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs index f5e4b1611f1..1db993a005b 100644 --- a/vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs +++ b/vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs @@ -61,16 +61,16 @@ module internal FSharpQuickInfo = let! extLexerSymbol = Tokenizer.getSymbolAtPosition(extDocId, extSourceText, extSpan.Start, declRange.FileName, extDefines, SymbolLookupKind.Greedy, true, true) let! _, _, extCheckFileResults = checker.ParseAndCheckDocument(extDocument, extProjectOptions, allowStaleResults=true, sourceText=extSourceText, userOpName = userOpName) - let! extQuickInfoText = + let extQuickInfoText = extCheckFileResults.GetStructuredToolTipText - (declRange.StartLine, extLexerSymbol.Ident.idRange.EndColumn, extLineText, extLexerSymbol.FullIsland, FSharpTokenTag.IDENT, userOpName=userOpName) |> liftAsync + (declRange.StartLine, extLexerSymbol.Ident.idRange.EndColumn, extLineText, extLexerSymbol.FullIsland, FSharpTokenTag.IDENT) match extQuickInfoText with | FSharpToolTipText [] | FSharpToolTipText [FSharpStructuredToolTipElement.None] -> return! None | extQuickInfoText -> let! extSymbolUse = - extCheckFileResults.GetSymbolUseAtLocation(declRange.StartLine, extLexerSymbol.Ident.idRange.EndColumn, extLineText, extLexerSymbol.FullIsland, userOpName=userOpName) + extCheckFileResults.GetSymbolUseAtLocation(declRange.StartLine, extLexerSymbol.Ident.idRange.EndColumn, extLineText, extLexerSymbol.FullIsland) let! span = RoslynHelpers.TryFSharpRangeToTextSpan (extSourceText, extLexerSymbol.Range) return { StructuredText = extQuickInfoText @@ -104,9 +104,9 @@ module internal FSharpQuickInfo = /// Gets the QuickInfo information for the orignal target let getTargetSymbolQuickInfo (symbol, tag) = asyncMaybe { - let! targetQuickInfo = + let targetQuickInfo = checkFileResults.GetStructuredToolTipText - (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland,tag, userOpName=userOpName) |> liftAsync + (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland,tag) match targetQuickInfo with | FSharpToolTipText [] @@ -125,7 +125,7 @@ module internal FSharpQuickInfo = return lexerSymbol.Range, None, Some targetQuickInfo | _ -> - let! symbolUse = checkFileResults.GetSymbolUseAtLocation (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland, userOpName=userOpName) + let! symbolUse = checkFileResults.GetSymbolUseAtLocation (fcsTextLineNumber, idRange.EndColumn, lineText, lexerSymbol.FullIsland) // if the target is in a signature file, adjusting the quick info is unnecessary if isSignatureFile document.FilePath then @@ -133,7 +133,7 @@ module internal FSharpQuickInfo = return symbolUse.RangeAlternate, None, Some targetQuickInfo else // find the declaration location of the target symbol, with a preference for signature files - let! findSigDeclarationResult = checkFileResults.GetDeclarationLocation (idRange.StartLine, idRange.EndColumn, lineText, lexerSymbol.FullIsland, preferFlag=true, userOpName=userOpName) |> liftAsync + let findSigDeclarationResult = checkFileResults.GetDeclarationLocation (idRange.StartLine, idRange.EndColumn, lineText, lexerSymbol.FullIsland, preferFlag=true) // it is necessary to retrieve the backup quick info because this acquires // the textSpan designating where we want the quick info to appear. @@ -149,7 +149,7 @@ module internal FSharpQuickInfo = // is not the corresponding module implementation file for that signature, // the doccoms from the signature will overwrite any doccoms that might be // present on the definition/implementation - let! findImplDefinitionResult = checkFileResults.GetDeclarationLocation (idRange.StartLine, idRange.EndColumn, lineText, lexerSymbol.FullIsland, preferFlag=false, userOpName=userOpName) |> liftAsync + let findImplDefinitionResult = checkFileResults.GetDeclarationLocation (idRange.StartLine, idRange.EndColumn, lineText, lexerSymbol.FullIsland, preferFlag=false) match findImplDefinitionResult with | FSharpFindDeclResult.DeclNotFound _ @@ -189,12 +189,12 @@ type internal FSharpAsyncQuickInfoSource let textLineNumber = textLine.LineNumber + 1 // Roslyn line numbers are zero-based let defines = CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions let! symbol = Tokenizer.getSymbolAtPosition (documentId, sourceText, position, filePath, defines, SymbolLookupKind.Precise, true, true) - let! res = checkFileResults.GetStructuredToolTipText (textLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland, FSharpTokenTag.IDENT, userOpName=FSharpQuickInfo.userOpName) |> liftAsync + let res = checkFileResults.GetStructuredToolTipText (textLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland, FSharpTokenTag.IDENT) match res with | FSharpToolTipText [] | FSharpToolTipText [FSharpStructuredToolTipElement.None] -> return! None | _ -> - let! symbolUse = checkFileResults.GetSymbolUseAtLocation (textLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland, userOpName=FSharpQuickInfo.userOpName) + let! symbolUse = checkFileResults.GetSymbolUseAtLocation (textLineNumber, symbol.Ident.idRange.EndColumn, textLine.ToString(), symbol.FullIsland) let! symbolSpan = RoslynHelpers.TryFSharpRangeToTextSpan (sourceText, symbol.Range) return { StructuredText = res Span = symbolSpan diff --git a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs index 7bc288a5516..3eeed24d470 100644 --- a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs +++ b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs @@ -192,7 +192,7 @@ type internal FSharpLanguageServiceBackgroundRequests_DEPRECATED // Type-checking let typedResults,aborted = - match interactiveChecker.CheckFileInProjectAllowingStaleCachedResults(parseResults,req.FileName,req.Timestamp,req.Text,checkOptions,req.Snapshot) |> Async.RunSynchronously with + match interactiveChecker.CheckFileInProjectAllowingStaleCachedResults(parseResults,req.FileName,req.Timestamp,req.Text,checkOptions) |> Async.RunSynchronously with | None -> None,false | Some FSharpCheckFileAnswer.Aborted -> // isResultObsolete returned true during the type check. diff --git a/vsintegration/src/FSharp.LanguageService/GotoDefinition.fs b/vsintegration/src/FSharp.LanguageService/GotoDefinition.fs index aa4e9441f8a..0506ed63abe 100644 --- a/vsintegration/src/FSharp.LanguageService/GotoDefinition.fs +++ b/vsintegration/src/FSharp.LanguageService/GotoDefinition.fs @@ -72,7 +72,7 @@ module internal GotoDefinition = Strings.GotoDefinitionFailed_NotIdentifier() |> GotoDefinitionResult_DEPRECATED.MakeError else - match typedResults.GetDeclarationLocation (line+1, colIdent, lineStr, qualId, false) |> Async.RunSynchronously with + match typedResults.GetDeclarationLocation (line+1, colIdent, lineStr, qualId, false) with | FSharpFindDeclResult.DeclNotFound(reason) -> if makeAnotherAttempt then gotoDefinition true else diff --git a/vsintegration/src/FSharp.LanguageService/Intellisense.fs b/vsintegration/src/FSharp.LanguageService/Intellisense.fs index 4a26458bc82..cc235cea15d 100644 --- a/vsintegration/src/FSharp.LanguageService/Intellisense.fs +++ b/vsintegration/src/FSharp.LanguageService/Intellisense.fs @@ -329,7 +329,7 @@ type internal FSharpIntellisenseInfo_DEPRECATED // This can happen e.g. if you are typing quickly and the typecheck results are stale enough that you don't have a captured resolution for // the name you just typed, but fresh enough that you do have the right name-resolution-environment to look up the name. let lidEnd = nwpl.LongIdEndLocation - let methods = typedResults.GetMethods(lidEnd.Line, lidEnd.Column, "", Some names) |> Async.RunSynchronously + let methods = typedResults.GetMethods(lidEnd.Line, lidEnd.Column, "", Some names) // If the name is an operator ending with ">" then it is a mistake // we can't tell whether " >(" is a generic method call or an operator use @@ -377,40 +377,40 @@ type internal FSharpIntellisenseInfo_DEPRECATED reraise() else None - let hasTextChangedSinceLastTypecheck (curTextSnapshot: ITextSnapshot, oldTextSnapshot: ITextSnapshot, ((sl:int,sc:int),(el:int,ec:int))) = - // compare the text from (sl,sc) to (el,ec) to see if it changed from the old snapshot to the current one - // (sl,sc)-(el,ec) are line/col positions in the current snapshot - if el >= oldTextSnapshot.LineCount then - true // old did not even have 'el' many lines, note 'el' is zero-based - else - assert(el < curTextSnapshot.LineCount) - let oldFirstLine = oldTextSnapshot.GetLineFromLineNumber sl - let oldLastLine = oldTextSnapshot.GetLineFromLineNumber el - if oldFirstLine.Length < sc || oldLastLine.Length < ec then - true // one of old lines was not even long enough to contain the position we're looking at - else - let posOfStartInOld = oldFirstLine.Start.Position + sc - let posOfEndInOld = oldLastLine.Start.Position + ec - let curFirstLine = curTextSnapshot.GetLineFromLineNumber sl - let curLastLine = curTextSnapshot.GetLineFromLineNumber el - assert(curFirstLine.Length >= sc) - assert(curLastLine.Length >= ec) - let posOfStartInCur = curFirstLine.Start.Position + sc - let posOfEndInCur = curLastLine.Start.Position + ec - if posOfEndInCur - posOfStartInCur <> posOfEndInOld - posOfStartInOld then - true // length of text between two endpoints changed - else - let mutable oldPos = posOfStartInOld - let mutable curPos = posOfStartInCur - let mutable ok = true - while ok && oldPos < posOfEndInOld do - let oldChar = oldTextSnapshot.[oldPos] - let curChar = curTextSnapshot.[curPos] - if oldChar <> curChar then - ok <- false - oldPos <- oldPos + 1 - curPos <- curPos + 1 - not ok + //let hasTextChangedSinceLastTypecheck (curTextSnapshot: ITextSnapshot, oldTextSnapshot: ITextSnapshot, ((sl:int,sc:int),(el:int,ec:int))) = + // // compare the text from (sl,sc) to (el,ec) to see if it changed from the old snapshot to the current one + // // (sl,sc)-(el,ec) are line/col positions in the current snapshot + // if el >= oldTextSnapshot.LineCount then + // true // old did not even have 'el' many lines, note 'el' is zero-based + // else + // assert(el < curTextSnapshot.LineCount) + // let oldFirstLine = oldTextSnapshot.GetLineFromLineNumber sl + // let oldLastLine = oldTextSnapshot.GetLineFromLineNumber el + // if oldFirstLine.Length < sc || oldLastLine.Length < ec then + // true // one of old lines was not even long enough to contain the position we're looking at + // else + // let posOfStartInOld = oldFirstLine.Start.Position + sc + // let posOfEndInOld = oldLastLine.Start.Position + ec + // let curFirstLine = curTextSnapshot.GetLineFromLineNumber sl + // let curLastLine = curTextSnapshot.GetLineFromLineNumber el + // assert(curFirstLine.Length >= sc) + // assert(curLastLine.Length >= ec) + // let posOfStartInCur = curFirstLine.Start.Position + sc + // let posOfEndInCur = curLastLine.Start.Position + ec + // if posOfEndInCur - posOfStartInCur <> posOfEndInOld - posOfStartInOld then + // true // length of text between two endpoints changed + // else + // let mutable oldPos = posOfStartInOld + // let mutable curPos = posOfStartInCur + // let mutable ok = true + // while ok && oldPos < posOfEndInOld do + // let oldChar = oldTextSnapshot.[oldPos] + // let curChar = curTextSnapshot.[curPos] + // if oldChar <> curChar then + // ok <- false + // oldPos <- oldPos + 1 + // curPos <- curPos + 1 + // not ok /// Implements the corresponding abstract member from IntellisenseInfo in MPF. override scope.GetDataTipText(line, col) = @@ -453,7 +453,7 @@ type internal FSharpIntellisenseInfo_DEPRECATED // Correct the identifier (e.g. to correctly handle active pattern names that end with "BAR" token) let tokenTag = QuickParse.CorrectIdentifierToken s tokenTag - let dataTip = typedResults.GetStructuredToolTipText(Range.Line.fromZ line, colAtEndOfNames, lineText, qualId, tokenTag) |> Async.RunSynchronously + let dataTip = typedResults.GetStructuredToolTipText(Range.Line.fromZ line, colAtEndOfNames, lineText, qualId, tokenTag) match dataTip with | FSharpStructuredToolTipText.FSharpToolTipText [] when makeSecondAttempt -> getDataTip true @@ -488,7 +488,7 @@ type internal FSharpIntellisenseInfo_DEPRECATED | _ -> false /// Implements the corresponding abstract member from IntellisenseInfo in MPF. - override scope.GetDeclarations(textSnapshot, line, col, reason) = + override scope.GetDeclarations(_textSnapshot, line, col, reason) = assert(FSharpIntellisenseInfo_DEPRECATED.IsReasonRequiringSyncParse(reason)) async { try @@ -531,11 +531,11 @@ type internal FSharpIntellisenseInfo_DEPRECATED let pname = QuickParse.GetPartialLongNameEx(lineText, col-1) let _x = 1 // for breakpoint - let detectTextChange (oldTextSnapshotInfo: obj, range) = - let oldTextSnapshot = oldTextSnapshotInfo :?> ITextSnapshot - hasTextChangedSinceLastTypecheck (textSnapshot, oldTextSnapshot, Range.Range.toZ range) + //let detectTextChange (oldTextSnapshotInfo: obj, range) = + // let oldTextSnapshot = oldTextSnapshotInfo :?> ITextSnapshot + // hasTextChangedSinceLastTypecheck (textSnapshot, oldTextSnapshot, Range.Range.toZ range) - let! decls = typedResults.GetDeclarationListInfo(untypedParseInfoOpt, Range.Line.fromZ line, lineText, pname, (fun() -> []), detectTextChange) + let decls = typedResults.GetDeclarationListInfo(untypedParseInfoOpt, Range.Line.fromZ line, lineText, pname, (fun() -> [])) return (new FSharpDeclarations_DEPRECATED(documentationBuilder, decls.Items, reason) :> Declarations_DEPRECATED) else // no TypeCheckInfo in ParseResult. @@ -595,7 +595,7 @@ type internal FSharpIntellisenseInfo_DEPRECATED | Some(s,colAtEndOfNames, _) -> if typedResults.HasFullTypeCheckInfo then let qualId = PrettyNaming.GetLongNameFromString s - match typedResults.GetF1Keyword(Range.Line.fromZ line,colAtEndOfNames, lineText, qualId) |> Async.RunSynchronously with + match typedResults.GetF1Keyword(Range.Line.fromZ line,colAtEndOfNames, lineText, qualId) with | Some s -> Some s | None -> None else None diff --git a/vsintegration/tests/UnitTests/GoToDefinitionServiceTests.fs b/vsintegration/tests/UnitTests/GoToDefinitionServiceTests.fs index 4408b27e5ac..31cdd24a75f 100644 --- a/vsintegration/tests/UnitTests/GoToDefinitionServiceTests.fs +++ b/vsintegration/tests/UnitTests/GoToDefinitionServiceTests.fs @@ -55,7 +55,7 @@ module GoToDefinitionServiceTests = let! lexerSymbol = Tokenizer.getSymbolAtPosition(documentKey, sourceText, position, filePath, defines, SymbolLookupKind.Greedy, false, false) let! _, _, checkFileResults = checker.ParseAndCheckDocument (filePath, textVersionHash, sourceText, options, LanguageServicePerformanceOptions.Default, userOpName=userOpName) |> Async.RunSynchronously - let declarations = checkFileResults.GetDeclarationLocation (fcsTextLineNumber, lexerSymbol.Ident.idRange.EndColumn, textLine.ToString(), lexerSymbol.FullIsland, false, userOpName=userOpName) |> Async.RunSynchronously + let declarations = checkFileResults.GetDeclarationLocation (fcsTextLineNumber, lexerSymbol.Ident.idRange.EndColumn, textLine.ToString(), lexerSymbol.FullIsland, false) match declarations with | FSharpFindDeclResult.DeclFound range -> return range From 7024592808403144e6beb9567abf90f62a81b485 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 18:56:08 +0100 Subject: [PATCH 07/12] update FCS docs --- docs/fcs/caches.fsx | 2 +- docs/fcs/compiler.fsx | 2 +- docs/fcs/corelib.fsx | 2 +- docs/fcs/editor.fsx | 6 ++---- docs/fcs/filesystem.fsx | 2 +- docs/fcs/interactive.fsx | 2 +- docs/fcs/ja/compiler.fsx | 2 +- docs/fcs/ja/corelib.fsx | 2 +- docs/fcs/ja/editor.fsx | 16 ++++++++-------- docs/fcs/ja/filesystem.fsx | 2 +- docs/fcs/ja/interactive.fsx | 6 +++--- docs/fcs/ja/project.fsx | 9 ++++----- docs/fcs/ja/symbols.fsx | 7 ++++--- docs/fcs/ja/tokenizer.fsx | 2 +- docs/fcs/ja/untypedtree.fsx | 9 +++++---- docs/fcs/project.fsx | 13 ++----------- docs/fcs/queue.fsx | 2 +- docs/fcs/react.fsx | 2 +- docs/fcs/symbols.fsx | 4 ++-- docs/fcs/tokenizer.fsx | 2 +- docs/fcs/typedtree.fsx | 2 +- docs/fcs/untypedtree.fsx | 2 +- 22 files changed, 44 insertions(+), 54 deletions(-) diff --git a/docs/fcs/caches.fsx b/docs/fcs/caches.fsx index 2f63c4b394e..442015bda58 100644 --- a/docs/fcs/caches.fsx +++ b/docs/fcs/caches.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Notes on the FSharpChecker caches ================================================= diff --git a/docs/fcs/compiler.fsx b/docs/fcs/compiler.fsx index a7e5303a06b..d4c48325408 100644 --- a/docs/fcs/compiler.fsx +++ b/docs/fcs/compiler.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Hosted Compiler =============== diff --git a/docs/fcs/corelib.fsx b/docs/fcs/corelib.fsx index a0c1e85f029..e2aaf41a7db 100644 --- a/docs/fcs/corelib.fsx +++ b/docs/fcs/corelib.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Notes on FSharp.Core.dll ================================================= diff --git a/docs/fcs/editor.fsx b/docs/fcs/editor.fsx index 46ddd882e58..144d6e74374 100644 --- a/docs/fcs/editor.fsx +++ b/docs/fcs/editor.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Editor services ================================== @@ -166,8 +166,7 @@ where we need to perform the completion. // Get declarations (autocomplete) for a location let decls = checkFileResults.GetDeclarationListInfo - (Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun () -> []), fun _ -> false) - |> Async.RunSynchronously + (Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun () -> [])) // Print the names of available items for item in decls.Items do @@ -199,7 +198,6 @@ changes): // Get overloads of the String.Concat method let methods = checkFileResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) - |> Async.RunSynchronously // Print concatenated parameter lists for mi in methods.Methods do diff --git a/docs/fcs/filesystem.fsx b/docs/fcs/filesystem.fsx index ad0a57712b9..b70174de514 100644 --- a/docs/fcs/filesystem.fsx +++ b/docs/fcs/filesystem.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Virtualized File System ========================================== diff --git a/docs/fcs/interactive.fsx b/docs/fcs/interactive.fsx index 6226bcbee16..4dd10119f3d 100644 --- a/docs/fcs/interactive.fsx +++ b/docs/fcs/interactive.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Interactive Service: Embedding F# Interactive ============================================= diff --git a/docs/fcs/ja/compiler.fsx b/docs/fcs/ja/compiler.fsx index 788c715294f..8b14ea3f007 100644 --- a/docs/fcs/ja/compiler.fsx +++ b/docs/fcs/ja/compiler.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラの組み込み ==================== diff --git a/docs/fcs/ja/corelib.fsx b/docs/fcs/ja/corelib.fsx index ea9ee87f8fb..aa5acd33689 100644 --- a/docs/fcs/ja/corelib.fsx +++ b/docs/fcs/ja/corelib.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス: FSharp.Core.dll についてのメモ ================================================== diff --git a/docs/fcs/ja/editor.fsx b/docs/fcs/ja/editor.fsx index f8a33e9a75a..efbd5936ede 100644 --- a/docs/fcs/ja/editor.fsx +++ b/docs/fcs/ja/editor.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス: エディタサービス ==================================== @@ -29,6 +29,7 @@ open System open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Text // インタラクティブチェッカーのインスタンスを作成 let checker = FSharpChecker.Create() @@ -56,7 +57,7 @@ printfn "%s" msg. let inputLines = input.Split('\n') let file = "/home/user/Test.fsx" -let projOptions, _errors1 = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously +let projOptions, _errors1 = checker.GetProjectOptionsFromScript(file, SourceText.ofString input) |> Async.RunSynchronously let parsingOptions, _errors2 = checker.GetParsingOptionsFromProjectOptions(projOptions) @@ -73,7 +74,7 @@ let parsingOptions, _errors2 = checker.GetParsingOptionsFromProjectOptions(projO *) // パースを実行 let parseFileResults = - checker.ParseFile(file, input, parsingOptions) + checker.ParseFile(file, SourceText.ofString input, parsingOptions) |> Async.RunSynchronously (** `TypeCheckResults` に備えられた興味深い機能の紹介に入る前に、 @@ -84,7 +85,7 @@ F#コードにエラーがあった場合も何らかの型チェックの結果 // 型チェックを実行 let checkFileAnswer = - checker.CheckFileInProject(parseFileResults, file, 0, input, projOptions) + checker.CheckFileInProject(parseFileResults, file, 0, SourceText.ofString input, projOptions) |> Async.RunSynchronously (** @@ -92,7 +93,7 @@ let checkFileAnswer = *) let parseResults2, checkFileAnswer2 = - checker.ParseAndCheckFileInProject(file, 0, input, projOptions) + checker.ParseAndCheckFileInProject(file, 0, SourceText.ofString input, projOptions) |> Async.RunSynchronously (** @@ -178,8 +179,7 @@ printfn "%A" tip // 特定の位置における宣言(自動補完)を取得する let decls = checkFileResults.GetDeclarationListInfo - (Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun _ -> []), fun _ -> false) - |> Async.RunSynchronously + (Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun _ -> [])) // 利用可能な項目を表示 for item in decls.Items do @@ -213,7 +213,7 @@ for item in decls.Items do *) //String.Concatメソッドのオーバーロードを取得する let methods = - checkFileResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously + checkFileResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) // 連結された引数リストを表示 for mi in methods.Methods do diff --git a/docs/fcs/ja/filesystem.fsx b/docs/fcs/ja/filesystem.fsx index 0680f34122f..5b0db49b294 100644 --- a/docs/fcs/ja/filesystem.fsx +++ b/docs/fcs/ja/filesystem.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス: ファイルシステム仮想化 ========================================== diff --git a/docs/fcs/ja/interactive.fsx b/docs/fcs/ja/interactive.fsx index 59bae44f01b..b2a27e02760 100644 --- a/docs/fcs/ja/interactive.fsx +++ b/docs/fcs/ja/interactive.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** インタラクティブサービス: F# Interactiveの組み込み ================================================== @@ -55,8 +55,8 @@ open System.IO open System.Text // 入出力のストリームを初期化 -let sbOut = new StringBuilder() -let sbErr = new StringBuilder() +let sbOut = StringBuilder() +let sbErr = StringBuilder() let inStream = new StringReader("") let outStream = new StringWriter(sbOut) let errStream = new StringWriter(sbErr) diff --git a/docs/fcs/ja/project.fsx b/docs/fcs/ja/project.fsx index 8b70e3df5f7..4f59e11da94 100644 --- a/docs/fcs/ja/project.fsx +++ b/docs/fcs/ja/project.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス: プロジェクトの分析 ====================================== @@ -25,6 +25,7 @@ open System open System.Collections.Generic open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Text // インタラクティブチェッカーのインスタンスを作成 let checker = FSharpChecker.Create() @@ -157,7 +158,6 @@ let backgroundParseResults1, backgroundTypedParse1 = let xSymbol = backgroundTypedParse1.GetSymbolUseAtLocation(9,9,"",["xxx"]) - |> Async.RunSynchronously (** それぞれのシンボルに対して、シンボルへの参照を検索することもできます: @@ -187,7 +187,7 @@ let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() *) let parseResults1, checkAnswer1 = - checker.ParseAndCheckFileInProject(Inputs.fileName1, 0, Inputs.fileSource1, projectOptions) + checker.ParseAndCheckFileInProject(Inputs.fileName1, 0, SourceText.ofString Inputs.fileSource1, projectOptions) |> Async.RunSynchronously let checkResults1 = @@ -196,7 +196,7 @@ let checkResults1 = | _ -> failwith "想定外の終了状態です" let parseResults2, checkAnswer2 = - checker.ParseAndCheckFileInProject(Inputs.fileName2, 0, Inputs.fileSource2, projectOptions) + checker.ParseAndCheckFileInProject(Inputs.fileName2, 0, SourceText.ofString Inputs.fileSource2, projectOptions) |> Async.RunSynchronously let checkResults2 = @@ -210,7 +210,6 @@ let checkResults2 = let xSymbol2 = checkResults1.GetSymbolUseAtLocation(9,9,"",["xxx"]) - |> Async.RunSynchronously let usesOfXSymbol2 = wholeProjectResults.GetUsesOfSymbol(xSymbol2.Value.Symbol) diff --git a/docs/fcs/ja/symbols.fsx b/docs/fcs/ja/symbols.fsx index ff62b0de6b2..bc5994c612d 100644 --- a/docs/fcs/ja/symbols.fsx +++ b/docs/fcs/ja/symbols.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス: シンボルの処理 ================================== @@ -22,6 +22,7 @@ open System open System.IO open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Text // インタラクティブチェッカーのインスタンスを作成 let checker = FSharpChecker.Create() @@ -77,7 +78,7 @@ type C() = member x.P = 1 """ let parseFileResults, checkFileResults = - parseAndTypeCheckSingleFile(file, input2) + parseAndTypeCheckSingleFile(file, SourceText.ofString input2) (** これでコードに対する部分的なアセンブリのシグネチャが取得できるようになります: @@ -204,7 +205,7 @@ for assembly in projectContext.GetReferencedAssemblies() do *) let parseAndCheckScript (file, input) = let projOptions, errors = - checker.GetProjectOptionsFromScript(file, input) + checker.GetProjectOptionsFromScript(file, SourceText.ofString input) |> Async.RunSynchronously let projResults = diff --git a/docs/fcs/ja/tokenizer.fsx b/docs/fcs/ja/tokenizer.fsx index 4daf29b7ead..a1aa9080aea 100644 --- a/docs/fcs/ja/tokenizer.fsx +++ b/docs/fcs/ja/tokenizer.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス:F#トークナイザを使用する ============================================ diff --git a/docs/fcs/ja/untypedtree.fsx b/docs/fcs/ja/untypedtree.fsx index 447e3742fff..f4050109d2c 100644 --- a/docs/fcs/ja/untypedtree.fsx +++ b/docs/fcs/ja/untypedtree.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../artifacts/bin/fcs/net461" +#I "../../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** コンパイラサービス:型無し構文木の処理 ====================================== @@ -42,6 +42,7 @@ #r "FSharp.Compiler.Service.dll" open System open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Text (** ### 型無しパースの実行 @@ -70,14 +71,14 @@ let getUntypedTree (file, input) = // 1つのスクリプトファイルから推測される「プロジェクト」用の // コンパイラオプションを取得する let projOptions, errors = - checker.GetProjectOptionsFromScript(file, input) + checker.GetProjectOptionsFromScript(file, SourceText.ofString input) |> Async.RunSynchronously let parsingOptions, _errors = checker.GetParsingOptionsFromProjectOptions(projOptions) // コンパイラの第1フェーズを実行する let untypedRes = - checker.ParseFile(file, input, parsingOptions) + checker.ParseFile(file, SourceText.ofString input, parsingOptions) |> Async.RunSynchronously match untypedRes.ParseTree with @@ -101,7 +102,7 @@ ASTを理解するには ASTに関連する要素は以下の名前空間に含まれています: *) -open FSharp.Compiler.Ast +open FSharp.Compiler.SyntaxTree (** ASTを処理する場合、異なる文法的要素に対するパターンマッチを行うような diff --git a/docs/fcs/project.fsx b/docs/fcs/project.fsx index 7573b7f9bab..7988face34e 100644 --- a/docs/fcs/project.fsx +++ b/docs/fcs/project.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Project Analysis ================================== @@ -175,7 +175,6 @@ You can now resolve symbols in each file: let xSymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(9,9,"",["xxx"]) - |> Async.RunSynchronously let xSymbolUse = xSymbolUseOpt.Value @@ -196,14 +195,13 @@ For each symbol, you can look up the references to that symbol: *) let usesOfXSymbol = wholeProjectResults.GetUsesOfSymbol(xSymbol) - |> Async.RunSynchronously (** You can iterate all the defined symbols in the inferred signature and find where they are used: *) let allUsesOfAllSignatureSymbols = [ for s in allSymbols do - let uses = wholeProjectResults.GetUsesOfSymbol(s) |> Async.RunSynchronously + let uses = wholeProjectResults.GetUsesOfSymbol(s) yield s.ToString(), uses ] (** @@ -211,7 +209,6 @@ You can also look at all the symbols uses in the whole project (including uses o *) let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously (** You can also request checks of updated versions of files within the project (note that the other files @@ -243,7 +240,6 @@ Again, you can resolve symbols and ask for references: let xSymbolUse2Opt = checkResults1.GetSymbolUseAtLocation(9,9,"",["xxx"]) - |> Async.RunSynchronously let xSymbolUse2 = xSymbolUse2Opt.Value @@ -251,26 +247,21 @@ let xSymbol2 = xSymbolUse2.Symbol let usesOfXSymbol2 = wholeProjectResults.GetUsesOfSymbol(xSymbol2) - |> Async.RunSynchronously - (** Or ask for all the symbols uses in the file (including uses of symbols with local scope) *) let allUsesOfAllSymbolsInFile1 = checkResults1.GetAllUsesOfAllSymbolsInFile() - |> Async.RunSynchronously (** Or ask for all the uses of one symbol in one file: *) let allUsesOfXSymbolInFile1 = checkResults1.GetUsesOfSymbolInFile(xSymbol2) - |> Async.RunSynchronously let allUsesOfXSymbolInFile2 = checkResults2.GetUsesOfSymbolInFile(xSymbol2) - |> Async.RunSynchronously (** diff --git a/docs/fcs/queue.fsx b/docs/fcs/queue.fsx index 7cf14a7b709..88a5af258ec 100644 --- a/docs/fcs/queue.fsx +++ b/docs/fcs/queue.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Notes on the FSharpChecker operations queue ================================================= diff --git a/docs/fcs/react.fsx b/docs/fcs/react.fsx index be108b92adb..07c9195e0b5 100644 --- a/docs/fcs/react.fsx +++ b/docs/fcs/react.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Reacting to Changes ============================================ diff --git a/docs/fcs/symbols.fsx b/docs/fcs/symbols.fsx index ab6b4657dcf..16607beb122 100644 --- a/docs/fcs/symbols.fsx +++ b/docs/fcs/symbols.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Working with symbols ============================================ @@ -207,7 +207,7 @@ Now do it for a particular input: let tmpFile = Path.ChangeExtension(System.IO.Path.GetTempFileName() , "fs") File.WriteAllText(tmpFile, input2) -let projectResults = parseAndCheckScript(tmpFile, input2) +let projectResults = parseAndCheckScript(tmpFile, SourceText.ofString input2) (** diff --git a/docs/fcs/tokenizer.fsx b/docs/fcs/tokenizer.fsx index 93a1dd3bf16..7994379d6f7 100644 --- a/docs/fcs/tokenizer.fsx +++ b/docs/fcs/tokenizer.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Using the F# tokenizer ========================================= diff --git a/docs/fcs/typedtree.fsx b/docs/fcs/typedtree.fsx index 385822335e9..f5fbf1d7ab9 100644 --- a/docs/fcs/typedtree.fsx +++ b/docs/fcs/typedtree.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Processing typed expression tree ================================================= diff --git a/docs/fcs/untypedtree.fsx b/docs/fcs/untypedtree.fsx index 162fedfa196..61e97709836 100644 --- a/docs/fcs/untypedtree.fsx +++ b/docs/fcs/untypedtree.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../artifacts/bin/fcs/net461" +#I "../../artifacts/bin/FSharp.Compiler.Service/Debug/netstandard2.0" (** Compiler Services: Processing untyped syntax tree ================================================= From 32d884f892351343c970867775373281995d625d Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 18:58:42 +0100 Subject: [PATCH 08/12] delete old code --- .../FSharp.LanguageService/Intellisense.fs | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/vsintegration/src/FSharp.LanguageService/Intellisense.fs b/vsintegration/src/FSharp.LanguageService/Intellisense.fs index cc235cea15d..76b3c7b36d0 100644 --- a/vsintegration/src/FSharp.LanguageService/Intellisense.fs +++ b/vsintegration/src/FSharp.LanguageService/Intellisense.fs @@ -377,41 +377,6 @@ type internal FSharpIntellisenseInfo_DEPRECATED reraise() else None - //let hasTextChangedSinceLastTypecheck (curTextSnapshot: ITextSnapshot, oldTextSnapshot: ITextSnapshot, ((sl:int,sc:int),(el:int,ec:int))) = - // // compare the text from (sl,sc) to (el,ec) to see if it changed from the old snapshot to the current one - // // (sl,sc)-(el,ec) are line/col positions in the current snapshot - // if el >= oldTextSnapshot.LineCount then - // true // old did not even have 'el' many lines, note 'el' is zero-based - // else - // assert(el < curTextSnapshot.LineCount) - // let oldFirstLine = oldTextSnapshot.GetLineFromLineNumber sl - // let oldLastLine = oldTextSnapshot.GetLineFromLineNumber el - // if oldFirstLine.Length < sc || oldLastLine.Length < ec then - // true // one of old lines was not even long enough to contain the position we're looking at - // else - // let posOfStartInOld = oldFirstLine.Start.Position + sc - // let posOfEndInOld = oldLastLine.Start.Position + ec - // let curFirstLine = curTextSnapshot.GetLineFromLineNumber sl - // let curLastLine = curTextSnapshot.GetLineFromLineNumber el - // assert(curFirstLine.Length >= sc) - // assert(curLastLine.Length >= ec) - // let posOfStartInCur = curFirstLine.Start.Position + sc - // let posOfEndInCur = curLastLine.Start.Position + ec - // if posOfEndInCur - posOfStartInCur <> posOfEndInOld - posOfStartInOld then - // true // length of text between two endpoints changed - // else - // let mutable oldPos = posOfStartInOld - // let mutable curPos = posOfStartInCur - // let mutable ok = true - // while ok && oldPos < posOfEndInOld do - // let oldChar = oldTextSnapshot.[oldPos] - // let curChar = curTextSnapshot.[curPos] - // if oldChar <> curChar then - // ok <- false - // oldPos <- oldPos + 1 - // curPos <- curPos + 1 - // not ok - /// Implements the corresponding abstract member from IntellisenseInfo in MPF. override scope.GetDataTipText(line, col) = // in cases like 'A' when cursor in on '<' there is an ambiguity that cannot be resolved based only on lexer information @@ -531,10 +496,6 @@ type internal FSharpIntellisenseInfo_DEPRECATED let pname = QuickParse.GetPartialLongNameEx(lineText, col-1) let _x = 1 // for breakpoint - //let detectTextChange (oldTextSnapshotInfo: obj, range) = - // let oldTextSnapshot = oldTextSnapshotInfo :?> ITextSnapshot - // hasTextChangedSinceLastTypecheck (textSnapshot, oldTextSnapshot, Range.Range.toZ range) - let decls = typedResults.GetDeclarationListInfo(untypedParseInfoOpt, Range.Line.fromZ line, lineText, pname, (fun() -> [])) return (new FSharpDeclarations_DEPRECATED(documentationBuilder, decls.Items, reason) :> Declarations_DEPRECATED) else From 9b9506cadb93e0ca930712afa989ea558f2a59b6 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 20:19:22 +0100 Subject: [PATCH 09/12] fix baselines --- .../SurfaceArea.netstandard.fs | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs index 9b68a080c4a..40141d35d45 100644 --- a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs +++ b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs @@ -21443,19 +21443,19 @@ FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.Sourc FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpOpenDeclaration[] get_OpenDeclarations() FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpProjectContext ProjectContext FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpProjectContext get_ProjectContext() -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpDeclarationListInfo] GetDeclarationListInfo(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults], Int32, System.String, FSharp.Compiler.PartialLongName, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.AssemblySymbol]]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.Object,FSharp.Compiler.Range+range],System.Boolean]], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpFindDeclResult] GetDeclarationLocation(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpMethodGroup] GetMethods(Int32, Int32, System.String, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[]] GetAllUsesOfAllSymbolsInFile() -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[]] GetUsesOfSymbolInFile(FSharp.Compiler.SourceCodeServices.FSharpSymbol) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[Internal.Utilities.StructuredFormat.Layout]] GetStructuredToolTipText(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Int32, Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String]] GetToolTipText(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Int32, Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse]]] GetDeclarationListSymbols(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults], Int32, System.String, FSharp.Compiler.PartialLongName, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.AssemblySymbol]]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.Object,FSharp.Compiler.Range+range],System.Boolean]], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpDisplayContext]] GetDisplayContextForPos(pos) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse]] GetSymbolUseAtLocation(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse]]] GetMethodsAsSymbols(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.FSharpOption`1[System.String]] GetF1Keyword(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Control.FSharpAsync`1[System.Boolean] IsRelativeNameResolvableFromSymbol(pos, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.SourceCodeServices.FSharpSymbol, Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpDeclarationListInfo GetDeclarationListInfo(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults], Int32, System.String, FSharp.Compiler.PartialLongName, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.AssemblySymbol]]]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpFindDeclResult GetDeclarationLocation(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpMethodGroup GetMethods(Int32, Int32, System.String, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[] GetAllUsesOfAllSymbolsInFile(Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[] GetUsesOfSymbolInFile(FSharp.Compiler.SourceCodeServices.FSharpSymbol, Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[Internal.Utilities.StructuredFormat.Layout] GetStructuredToolTipText(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Int32) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String] GetToolTipText(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Int32) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Collections.FSharpList`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse]] GetDeclarationListSymbols(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults], Int32, System.String, FSharp.Compiler.PartialLongName, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.AssemblySymbol]]]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpDisplayContext] GetDisplayContextForPos(pos) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse] GetSymbolUseAtLocation(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse]] GetMethodsAsSymbols(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[System.String] GetF1Keyword(Int32, Int32, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Boolean IsRelativeNameResolvableFromSymbol(pos, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.SourceCodeServices.FSharpSymbol) FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpImplementationFileContents] ImplementationFile FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpImplementationFileContents] get_ImplementationFile() FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults: System.String ToString() @@ -21475,8 +21475,8 @@ FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: FSharp.Compiler.So FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: FSharp.Compiler.SourceCodeServices.FSharpErrorInfo[] get_Errors() FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: FSharp.Compiler.SourceCodeServices.FSharpProjectContext ProjectContext FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: FSharp.Compiler.SourceCodeServices.FSharpProjectContext get_ProjectContext() -FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[]] GetAllUsesOfAllSymbols() -FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[]] GetUsesOfSymbol(FSharp.Compiler.SourceCodeServices.FSharpSymbol) +FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[] GetAllUsesOfAllSymbols(Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) +FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: FSharp.Compiler.SourceCodeServices.FSharpSymbolUse[] GetUsesOfSymbol(FSharp.Compiler.SourceCodeServices.FSharpSymbol, Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: System.String ToString() FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: System.String[] DependencyFiles FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults: System.String[] get_DependencyFiles() @@ -21497,20 +21497,20 @@ FSharp.Compiler.SourceCodeServices.FSharpChecker: Int32 get_GlobalForegroundPars FSharp.Compiler.SourceCodeServices.FSharpChecker: Int32 get_GlobalForegroundTypeCheckCountStatistic() FSharp.Compiler.SourceCodeServices.FSharpChecker: Int32 get_MaxMemory() FSharp.Compiler.SourceCodeServices.FSharpChecker: Int32 get_PauseBeforeBackgroundWork() -FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpCheckFileAnswer] CheckFileInProject(FSharp.Compiler.SourceCodeServices.FSharpParseFileResults, System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.Object], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpCheckFileAnswer] CheckFileInProject(FSharp.Compiler.SourceCodeServices.FSharpParseFileResults, System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpCheckProjectResults] ParseAndCheckProject(FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults] GetBackgroundParseResultsForFileInProject(System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults] ParseFile(System.String, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpParsingOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults] ParseFileInProject(System.String, System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults] ParseFileNoCache(System.String, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpParsingOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpCheckFileAnswer]] CheckFileInProjectAllowingStaleCachedResults(FSharp.Compiler.SourceCodeServices.FSharpParseFileResults, System.String, Int32, System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.Object], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpCheckFileAnswer]] CheckFileInProjectAllowingStaleCachedResults(FSharp.Compiler.SourceCodeServices.FSharpParseFileResults, System.String, Int32, System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.Unit] NotifyProjectCleaned(FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Collections.Generic.IEnumerable`1[FSharp.Compiler.Range+range]] FindBackgroundReferencesInFile(System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, FSharp.Compiler.SourceCodeServices.FSharpSymbol, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Range+range,FSharp.Compiler.Range+range][]] MatchBraces(System.String, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpParsingOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Range+range,FSharp.Compiler.Range+range][]] MatchBraces(System.String, System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpErrorInfo[],System.Int32]] Compile(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SyntaxTree+ParsedInput], System.String, System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpErrorInfo[],System.Int32]] Compile(System.String[], Microsoft.FSharp.Core.FSharpOption`1[System.String]) -FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults,FSharp.Compiler.SourceCodeServices.FSharpCheckFileAnswer]] ParseAndCheckFileInProject(System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.Object], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults,FSharp.Compiler.SourceCodeServices.FSharpCheckFileAnswer]] ParseAndCheckFileInProject(System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpParseFileResults,FSharp.Compiler.SourceCodeServices.FSharpCheckFileResults]] GetBackgroundCheckResultsForFileInProject(System.String, FSharp.Compiler.SourceCodeServices.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpProjectOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SourceCodeServices.FSharpErrorInfo]]] GetProjectOptionsFromScript(System.String, FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.String[]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Object], Microsoft.FSharp.Core.FSharpOption`1[System.Int64], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.SourceCodeServices.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`3[FSharp.Compiler.SourceCodeServices.FSharpErrorInfo[],System.Int32,Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.Assembly]]] CompileToDynamicAssembly(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.SyntaxTree+ParsedInput], System.String, Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[System.IO.TextWriter,System.IO.TextWriter]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String]) @@ -21563,6 +21563,10 @@ FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.C FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[Internal.Utilities.StructuredFormat.Layout]] get_StructuredDescriptionTextAsync() FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String]] DescriptionTextAsync FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String]] get_DescriptionTextAsync() +FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[Internal.Utilities.StructuredFormat.Layout] StructuredDescriptionText +FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[Internal.Utilities.StructuredFormat.Layout] get_StructuredDescriptionText() +FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String] DescriptionText +FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String] get_DescriptionText() FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpAccessibility] Accessibility FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpAccessibility] get_Accessibility() FSharp.Compiler.SourceCodeServices.FSharpDeclarationListItem: Microsoft.FSharp.Core.FSharpOption`1[System.String] NamespaceToOpen @@ -25315,7 +25319,6 @@ FSharp.Compiler.SourceCodeServices.Symbol: Microsoft.FSharp.Core.FSharpOption`1[ FSharp.Compiler.SourceCodeServices.Symbol: System.Tuple`2[FSharp.Compiler.SourceCodeServices.FSharpEntity,Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpType]] getEntityAbbreviatedType(FSharp.Compiler.SourceCodeServices.FSharpEntity) FSharp.Compiler.SourceCodeServices.Tooltips: FSharp.Compiler.SourceCodeServices.FSharpToolTipElement`1[System.String] ToFSharpToolTipElement(FSharp.Compiler.SourceCodeServices.FSharpToolTipElement`1[Internal.Utilities.StructuredFormat.Layout]) FSharp.Compiler.SourceCodeServices.Tooltips: FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[System.String] ToFSharpToolTipText(FSharp.Compiler.SourceCodeServices.FSharpToolTipText`1[Internal.Utilities.StructuredFormat.Layout]) -FSharp.Compiler.SourceCodeServices.Tooltips: Microsoft.FSharp.Control.FSharpAsync`1[T2] Map[T1,T2](Microsoft.FSharp.Core.FSharpFunc`2[T1,T2], Microsoft.FSharp.Control.FSharpAsync`1[T1]) FSharp.Compiler.SourceCodeServices.UnresolvedReferencesSet: Boolean Equals(FSharp.Compiler.SourceCodeServices.UnresolvedReferencesSet) FSharp.Compiler.SourceCodeServices.UnresolvedReferencesSet: Boolean Equals(System.Object) FSharp.Compiler.SourceCodeServices.UnresolvedReferencesSet: Boolean Equals(System.Object, System.Collections.IEqualityComparer) From d4693c163f2d5f3917851bdc62c21e02d7cf1608 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 21:11:04 +0100 Subject: [PATCH 10/12] test no longer applicable --- .../Tests.LanguageService.Completion.fs | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs index d7ee09bf479..2ae86637bc1 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs @@ -5192,32 +5192,6 @@ let x = query { for bbbb in abbbbc(*D0*) do gpatcc.AssertExactly(0,0) - [] - member this.``BadCompletionAfterQuicklyTyping.Bug177519.NowWorking``() = - // this test is similar to "Bug72561.Noteworthy" but uses name resolutions rather than expression typings - // name resolutions currently still respond with stale info - let code = [ "let A = 42" - "let B = \"\"" - "A. // quickly backspace and retype B. --> exact name resolution code path" ] - let (_, _, file) = this.CreateSingleFileProject(code) - - TakeCoffeeBreak(this.VS) - let gpatcc = GlobalParseAndTypeCheckCounter.StartNew(this.VS) - let code2= [ "let A = 42" - "let B = \"\"" - "B. // quickly backspace and retype B. --> exact name resolution code path" ] - ReplaceFileInMemoryWithoutCoffeeBreak file code2 - MoveCursorToEndOfMarker(file, "B.") - // Note: no TakeCoffeeBreak(this.VS) - let completions = AutoCompleteAtCursor file - AssertCompListIsEmpty(completions) // empty completion list means second-chance intellisense will kick in - // if we wait... - TakeCoffeeBreak(this.VS) - let completions = AutoCompleteAtCursor file - // ... we get the expected answer - AssertCompListContainsAll(completions, ["Chars"]) // has correct string info - gpatcc.AssertExactly(0,0) - //*********************************************Previous Completion test and helper***** member private this.VerifyCompListDoesNotContainAnyAtStartOfMarker(fileContents : string, marker : string, list : string list) = let (solution, project, file) = this.CreateSingleFileProject(fileContents) From bbd79e7219e3e704c87f4c4ecf15f48211c84045 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 22 Oct 2020 21:27:33 +0100 Subject: [PATCH 11/12] remove dead union case --- src/fsharp/service/FSharpCheckerResults.fs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/fsharp/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index 14918bfa1e8..e76eb308cdc 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -99,7 +99,6 @@ type internal NameResResult = | Members of (ItemWithInst list * DisplayEnv * range) | Cancel of DisplayEnv * range | Empty - | TypecheckStaleAndTextChanged [] type ResolveOverloads = @@ -626,7 +625,6 @@ type internal TypeCheckInfo | _ -> ValueNone match nameResItems with - | NameResResult.TypecheckStaleAndTextChanged -> None // second-chance intellisense will try again | NameResResult.Cancel(denv,m) -> Some([], denv, m) | NameResResult.Members(FilterRelevantItems getItem exactMatchResidueOpt (items, denv, m)) -> // lookup based on name resolution results successful From 0d2a2b25bfe28982ada23649d3fcb1595e9d8894 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 27 Oct 2020 17:24:04 +0000 Subject: [PATCH 12/12] fix build --- src/fsharp/service/FSharpCheckerResults.fs | 48 +++++++++---------- src/fsharp/service/FSharpCheckerResults.fsi | 2 +- .../service/ServiceDeclarationLists.fsi | 2 +- src/fsharp/service/service.fs | 2 +- src/fsharp/service/service.fsi | 6 +-- .../BackgroundRequests.fs | 4 +- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/fsharp/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index e708dba1784..9de684583c1 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -1780,56 +1780,56 @@ type FSharpCheckFileResults | _ -> None /// Intellisense autocompletions - member __.GetDeclarationListInfo(parseResultsOpt, line, lineStr, partialName, ?getAllEntities) = + member __.GetDeclarationListInfo(parsedFileResults, line, lineText, partialName, ?getAllEntities) = let getAllEntities = defaultArg getAllEntities (fun() -> []) threadSafeOp (fun () -> FSharpDeclarationListInfo.Empty) (fun scope -> - scope.GetDeclarations(parseResultsOpt, line, lineStr, partialName, getAllEntities)) + scope.GetDeclarations(parsedFileResults, line, lineText, partialName, getAllEntities)) - member __.GetDeclarationListSymbols(parseResultsOpt, line, lineStr, partialName, ?getAllEntities) = + member __.GetDeclarationListSymbols(parsedFileResults, line, lineText, partialName, ?getAllEntities) = let getAllEntities = defaultArg getAllEntities (fun() -> []) threadSafeOp (fun () -> []) (fun scope -> - scope.GetDeclarationListSymbols(parseResultsOpt, line, lineStr, partialName, getAllEntities)) + scope.GetDeclarationListSymbols(parsedFileResults, line, lineText, partialName, getAllEntities)) /// Resolve the names at the given location to give a data tip - member __.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag) = + member __.GetStructuredToolTipText(line, colAtEndOfNames, lineText, names, tokenTag) = let dflt = FSharpToolTipText [] match tokenTagToTokenId tokenTag with | TOKEN_IDENT -> threadSafeOp (fun () -> dflt) (fun scope -> - scope.GetStructuredToolTipText(line, lineStr, colAtEndOfNames, names)) + scope.GetStructuredToolTipText(line, lineText, colAtEndOfNames, names)) | TOKEN_STRING | TOKEN_STRING_TEXT -> threadSafeOp (fun () -> dflt) (fun scope -> scope.GetReferenceResolutionStructuredToolTipText(line, colAtEndOfNames) ) | _ -> dflt - member info.GetToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag) = - info.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag) + member info.GetToolTipText(line, colAtEndOfNames, lineText, names, tokenTag) = + info.GetStructuredToolTipText(line, colAtEndOfNames, lineText, names, tokenTag) |> Tooltips.ToFSharpToolTipText - member __.GetF1Keyword (line, colAtEndOfNames, lineStr, names) = + member __.GetF1Keyword (line, colAtEndOfNames, lineText, names) = threadSafeOp (fun () -> None) (fun scope -> - scope.GetF1Keyword (line, lineStr, colAtEndOfNames, names)) + scope.GetF1Keyword (line, lineText, colAtEndOfNames, names)) // Resolve the names at the given location to a set of methods - member __.GetMethods(line, colAtEndOfNames, lineStr, names) = + member __.GetMethods(line, colAtEndOfNames, lineText, names) = let dflt = FSharpMethodGroup("",[| |]) threadSafeOp (fun () -> dflt) (fun scope -> - scope.GetMethods (line, lineStr, colAtEndOfNames, names)) + scope.GetMethods (line, lineText, colAtEndOfNames, names)) - member __.GetDeclarationLocation (line, colAtEndOfNames, lineStr, names, ?preferFlag) = + member __.GetDeclarationLocation (line, colAtEndOfNames, lineText, names, ?preferFlag) = let dflt = FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "") threadSafeOp (fun () -> dflt) (fun scope -> - scope.GetDeclarationLocation (line, lineStr, colAtEndOfNames, names, preferFlag)) + scope.GetDeclarationLocation (line, lineText, colAtEndOfNames, names, preferFlag)) - member __.GetSymbolUseAtLocation (line, colAtEndOfNames, lineStr, names) = + member __.GetSymbolUseAtLocation (line, colAtEndOfNames, lineText, names) = threadSafeOp (fun () -> None) (fun scope -> - scope.GetSymbolUseAtLocation (line, lineStr, colAtEndOfNames, names) + scope.GetSymbolUseAtLocation (line, lineText, colAtEndOfNames, names) |> Option.map (fun (sym,denv,m) -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m))) - member __.GetMethodsAsSymbols (line, colAtEndOfNames, lineStr, names) = + member __.GetMethodsAsSymbols (line, colAtEndOfNames, lineText, names) = threadSafeOp (fun () -> None) (fun scope -> - scope.GetMethodsAsSymbols (line, lineStr, colAtEndOfNames, names) + scope.GetMethodsAsSymbols (line, lineText, colAtEndOfNames, names) |> Option.map (fun (symbols,denv,m) -> symbols |> List.map (fun sym -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m)))) @@ -1897,17 +1897,17 @@ type FSharpCheckFileResults (fun () -> [| |]) (fun scope -> scope.GetVisibleNamespacesAndModulesAtPosition(pos) |> List.toArray) - member __.IsRelativeNameResolvable(pos: pos, plid: string list, item: Item) = + member __.IsRelativeNameResolvable(cursorPos: pos, plid: string list, item: Item) = threadSafeOp (fun () -> true) (fun scope -> - scope.IsRelativeNameResolvable(pos, plid, item)) + scope.IsRelativeNameResolvable(cursorPos, plid, item)) - member __.IsRelativeNameResolvableFromSymbol(pos: pos, plid: string list, symbol: FSharpSymbol) = + member __.IsRelativeNameResolvableFromSymbol(cursorPos: pos, plid: string list, symbol: FSharpSymbol) = threadSafeOp (fun () -> true) (fun scope -> - scope.IsRelativeNameResolvableFromSymbol(pos, plid, symbol)) + scope.IsRelativeNameResolvableFromSymbol(cursorPos, plid, symbol)) - member __.GetDisplayContextForPos(pos: pos) = + member __.GetDisplayContextForPos(cursorPos: pos) = threadSafeOp (fun () -> None) (fun scope -> - let (nenv, _), _ = scope.GetBestDisplayEnvForPos pos + let (nenv, _), _ = scope.GetBestDisplayEnvForPos cursorPos Some(FSharpDisplayContext(fun _ -> nenv.DisplayEnv))) member __.ImplementationFile = diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index e481b8be98b..023c23d3ac7 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -218,7 +218,7 @@ type public FSharpCheckFileResults = member internal GetVisibleNamespacesAndModulesAtPoint : pos -> ModuleOrNamespaceRef[] /// Find the most precise display environment for the given line and column. - member GetDisplayContextForPos : cursorPos : pos -> Async + member GetDisplayContextForPos : cursorPos : pos -> FSharpDisplayContext option /// Determines if a long ident is resolvable at a specific point. member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item -> bool diff --git a/src/fsharp/service/ServiceDeclarationLists.fsi b/src/fsharp/service/ServiceDeclarationLists.fsi index 828119bd625..68a5093d6d3 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fsi +++ b/src/fsharp/service/ServiceDeclarationLists.fsi @@ -63,7 +63,7 @@ type public FSharpDeclarationListInfo = member IsError : bool // Implementation details used by other code in the compiler - static member internal Create : infoReader:InfoReader * m:range * denv:DisplayEnv * getAccessibility:(Item -> FSharpAccessibility option) * items:CompletionItem list * currentNamespace:string[] option * isAttributeApplicationContex:bool -> FSharpDeclarationListInfo + static member internal Create : infoReader:InfoReader * m:range * denv:DisplayEnv * getAccessibility:(Item -> FSharpAccessibility option) * items:CompletionItem list * currentNamespace:string[] option * isAttributeApplicationContext:bool -> FSharpDeclarationListInfo static member internal Error : message:string -> FSharpDeclarationListInfo diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index d7c54282770..24c5cd08ea7 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -1012,7 +1012,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC parseFileCache.Resize(ltok, newKeepStrongly=1)) incrementalBuildersCache.Resize(AnyCallerThread, newKeepStrongly=1, newKeepMax=1) frameworkTcImportsCache.Downsize(ctok) - scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Resize(ltok,newKeepStrongly=1, newKeepMax=1)) + scriptClosureCache.Resize(AnyCallerThread,newKeepStrongly=1, newKeepMax=1) cancellable.Return ()) member __.FrameworkImportsCache = frameworkTcImportsCache diff --git a/src/fsharp/service/service.fsi b/src/fsharp/service/service.fsi index 42443eae7f1..09d6469860f 100755 --- a/src/fsharp/service/service.fsi +++ b/src/fsharp/service/service.fsi @@ -157,7 +157,7 @@ type public FSharpChecker = /// The options for the project or script. /// An optional string used for tracing compiler operations associated with this request. [] - member CheckFileInProjectAllowingStaleCachedResults : parseResults: FSharpParseFileResults * filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async + member CheckFileInProjectAllowingStaleCachedResults : parseResults: FSharpParseFileResults * filename: string * fileVersion: int * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async /// /// @@ -177,7 +177,7 @@ type public FSharpChecker = /// The full source for the file. /// The options for the project or script. /// An optional string used for tracing compiler operations associated with this request. - member CheckFileInProject : parseResults: FSharpParseFileResults * filename: string * fileversion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?userOpName: string -> Async + member CheckFileInProject : parseResults: FSharpParseFileResults * filename: string * fileVersion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?userOpName: string -> Async /// /// @@ -196,7 +196,7 @@ type public FSharpChecker = /// The source for the file. /// The options for the project or script. /// An optional string used for tracing compiler operations associated with this request. - member ParseAndCheckFileInProject : filename: string * fileversion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?userOpName: string -> Async + member ParseAndCheckFileInProject : filename: string * fileVersion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?userOpName: string -> Async /// /// Parse and typecheck all files in a project. diff --git a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs index 3eeed24d470..c7549282ed0 100644 --- a/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs +++ b/vsintegration/src/FSharp.LanguageService/BackgroundRequests.fs @@ -178,8 +178,8 @@ type internal FSharpLanguageServiceBackgroundRequests_DEPRECATED interactiveChecker.TryGetRecentCheckResultsForFile(req.FileName,checkOptions) match possibleShortcutResults with - | Some (parseResults,typedResults,fileversion) -> - defaultArg syncParseInfoOpt parseResults,Some typedResults, false, false, fileversion // Note: untypedparse and typed results have different timestamps/snapshots, typed may be staler + | Some (parseResults,typedResults,fileVersion) -> + defaultArg syncParseInfoOpt parseResults,Some typedResults, false, false, fileVersion // Note: untypedparse and typed results have different timestamps/snapshots, typed may be staler | None -> // Perform a fresh two-phase parse of the source file let parseResults =