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 ================================================= 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/InternalCollections.fs b/src/fsharp/InternalCollections.fs index f317fe2fa7c..a936a10d38e 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, ?onDiscard, ?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=onDiscard,?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 c4411c03fe5..402b4de20c8 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 * newKeepStrongly: int * ?newKeepMax : 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/absil/illib.fs b/src/fsharp/absil/illib.fs index da10b5eea94..264427d4f87 100644 --- a/src/fsharp/absil/illib.fs +++ b/src/fsharp/absil/illib.fs @@ -637,9 +637,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/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index c8f7f2e6003..9de684583c1 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -9,6 +9,7 @@ open System open System.Diagnostics open System.IO open System.Reflection +open System.Threading open FSharp.Core.Printf open FSharp.Compiler @@ -99,7 +100,6 @@ type internal NameResResult = | Members of (ItemWithInst list * DisplayEnv * range) | Cancel of DisplayEnv * range | Empty - | TypecheckStaleAndTextChanged [] type ResolveOverloads = @@ -136,19 +136,15 @@ type internal TypeCheckInfo // This is a name resolution environment to use if no better match can be found. sFallback: NameResolutionEnv, loadClosure : LoadClosure option, - reactorOps : IReactorOperations, - textSnapshotInfo:obj option, implFileOpt: TypedImplFile option, openDeclarations: OpenDeclaration[]) = - let textSnapshotInfo = defaultArg textSnapshotInfo null - // These strings are potentially large and the editor may choose to hold them for a while. // Use this cache to fold together data tip text results that are the same. // 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) @@ -221,7 +217,7 @@ type internal TypeCheckInfo items // Filter items to show only valid & return Some if there are any - let ReturnItemsOfType (items: ItemWithInst list) g denv (m:range) filterCtors hasTextChangedSinceLastTypecheck = + let ReturnItemsOfType (items: ItemWithInst list) g denv (m:range) filterCtors = let items = items |> RemoveDuplicateItems g @@ -229,10 +225,7 @@ type internal TypeCheckInfo |> FilterItemsForCtors filterCtors if not (isNil items) then - if hasTextChangedSinceLastTypecheck(textSnapshotInfo, m) then - NameResResult.TypecheckStaleAndTextChanged // typecheck is stale, wait for second-chance IntelliSense to bring up right result - else - NameResResult.Members (items, denv, m) + NameResResult.Members (items, denv, m) else NameResResult.Empty @@ -256,7 +249,7 @@ type internal TypeCheckInfo /// Looks at the exact name resolutions that occurred during type checking /// If 'membersByResidue' is specified, we look for members of the item obtained /// from the name resolution and filter them by the specified residue (?) - let GetPreciseItemsFromNameResolution(line, colAtEndOfNames, membersByResidue, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck) = + let GetPreciseItemsFromNameResolution(line, colAtEndOfNames, membersByResidue, filterCtors, resolveOverloads) = let endOfNamesPos = mkPos line colAtEndOfNames // Logic below expects the list to be in reverse order of resolution @@ -269,7 +262,7 @@ type internal TypeCheckInfo | CNR(Item.Types(_,(ty::_)), _, denv, nenv, ad, m)::_, Some _ -> let items = ResolveCompletionsInType ncenv nenv (ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m)) m ad true ty let items = List.map ItemWithNoInst items - ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck + ReturnItemsOfType items g denv m filterCtors // Value reference from the name resolution. Primarily to disallow "let x.$ = 1" // In most of the cases, value references can be obtained from expression typings or from environment, @@ -302,7 +295,7 @@ type internal TypeCheckInfo let items = ResolveCompletionsInType ncenv nenv (ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m)) m ad false ty let items = List.map ItemWithNoInst items - ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck + ReturnItemsOfType items g denv m filterCtors // No residue, so the items are the full resolution of the name | CNR(_, _, denv, _, _, m) :: _, None -> @@ -312,7 +305,7 @@ type internal TypeCheckInfo // "into" is special magic syntax, not an identifier or a library call. It is part of capturedNameResolutions as an // implementation detail of syntax coloring, but we should not report name resolution results for it, to prevent spurious QuickInfo. |> List.filter (fun item -> match item.Item with Item.CustomOperation(CustomOperations.Into,_,_) -> false | _ -> true) - ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck + ReturnItemsOfType items g denv m filterCtors | _, _ -> NameResResult.Empty let TryGetTypeFromNameResolution(line, colAtEndOfNames, membersByResidue, resolveOverloads) = @@ -338,7 +331,7 @@ type internal TypeCheckInfo | _ -> [] ) - let GetNamedParametersAndSettableFields endOfExprPos hasTextChangedSinceLastTypecheck = + let GetNamedParametersAndSettableFields endOfExprPos = let cnrs = GetCapturedNameResolutions endOfExprPos ResolveOverloads.No |> ResizeArray.toList |> List.rev let result = match cnrs with @@ -364,7 +357,7 @@ type internal TypeCheckInfo NameResResult.Empty | Some (denv, m, items) -> let items = List.map ItemWithNoInst items - ReturnItemsOfType items g denv m TypeNameResolutionFlag.ResolveTypeNamesToTypeRefs hasTextChangedSinceLastTypecheck + ReturnItemsOfType items g denv m TypeNameResolutionFlag.ResolveTypeNamesToTypeRefs /// finds captured typing for the given position let GetExprTypingForPosition(endOfExprPos) = @@ -408,7 +401,7 @@ type internal TypeCheckInfo /// Looks at the exact expression types at the position to the left of the /// residue then the source when it was typechecked. - let GetPreciseCompletionListFromExprTypings(parseResults:FSharpParseFileResults, endOfExprPos, filterCtors, hasTextChangedSinceLastTypecheck: (obj * range -> bool)) = + let GetPreciseCompletionListFromExprTypings(parseResults:FSharpParseFileResults, endOfExprPos, filterCtors) = let thereWereSomeQuals, quals = GetExprTypingForPosition(endOfExprPos) @@ -424,18 +417,15 @@ type internal TypeCheckInfo | Some(input) -> match UntypedParseImpl.GetRangeOfExprLeftOfDot(endOfExprPos,Some(input)) with // TODO we say "colAtEndOfNames" everywhere, but that's not really a good name ("foo . $" hit Ctrl-Space at $) | Some( exprRange) -> - if hasTextChangedSinceLastTypecheck(textSnapshotInfo, exprRange) then - None, true // typecheck is stale, wait for second-chance IntelliSense to bring up right result - else - // See bug 130733. We have an up-to-date sync parse, and know the exact range of the prior expression. - // The quals all already have the same ending position, so find one with a matching starting position, if it exists. - // If not, then the stale typecheck info does not have a capturedExpressionTyping for this exact expression, and the - // user can wait for typechecking to catch up and second-chance intellisense to give the right result. - let qual = - quals |> Array.tryFind (fun (_,_,_,r) -> - ignore(r) // for breakpoint - posEq exprRange.Start r.Start) - qual, false + // We have an up-to-date sync parse, and know the exact range of the prior expression. + // The quals all already have the same ending position, so find one with a matching starting position, if it exists. + // If not, then the stale typecheck info does not have a capturedExpressionTyping for this exact expression, and the + // user can wait for typechecking to catch up and second-chance intellisense to give the right result. + let qual = + quals |> Array.tryFind (fun (_,_,_,r) -> + ignore(r) // for breakpoint + posEq exprRange.Start r.Start) + qual, false | None -> // TODO In theory I think we should never get to this code path; it would be nice to add an assert. // In practice, we do get here in some weird cases like "2.0 .. 3.0" and hitting Ctrl-Space in between the two dots of the range operator. @@ -576,7 +566,7 @@ type internal TypeCheckInfo let getItem (x: ItemWithInst) = x.Item let GetDeclaredItems (parseResultsOpt: FSharpParseFileResults option, lineStr: string, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, - filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, isInRangeOperator, allSymbols: unit -> AssemblySymbol list) = + filterCtors, resolveOverloads, isInRangeOperator, allSymbols: unit -> AssemblySymbol list) = // Are the last two chars (except whitespaces) = ".." let isLikeRangeOp = @@ -591,7 +581,7 @@ type internal TypeCheckInfo // This is based on position (i.e. colAtEndOfNamesAndResidue). This is not used if a residueOpt is given. let nameResItems = match residueOpt with - | None -> GetPreciseItemsFromNameResolution(line, colAtEndOfNamesAndResidue, None, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck) + | None -> GetPreciseItemsFromNameResolution(line, colAtEndOfNamesAndResidue, None, filterCtors,resolveOverloads) | Some residue -> // deals with cases when we have spaces between dot and\or identifier, like A . $ // if this is our case - then we need to locate end position of the name skipping whitespaces @@ -601,7 +591,7 @@ type internal TypeCheckInfo match FindFirstNonWhitespacePosition lineStr (p - 1) with | Some colAtEndOfNames -> let colAtEndOfNames = colAtEndOfNames + 1 // convert 0-based to 1-based - GetPreciseItemsFromNameResolution(line, colAtEndOfNames, Some(residue), filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck) + GetPreciseItemsFromNameResolution(line, colAtEndOfNames, Some(residue), filterCtors,resolveOverloads) | None -> NameResResult.Empty | _ -> NameResResult.Empty @@ -636,7 +626,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 @@ -660,7 +649,7 @@ type internal TypeCheckInfo match UntypedParseImpl.TryFindExpressionASTLeftOfDotLeftOfCursor(mkPos line colAtEndOfNamesAndResidue,parseResults.ParseTree) with | Some(pos,_) -> - GetPreciseCompletionListFromExprTypings(parseResults, pos, filterCtors, hasTextChangedSinceLastTypecheck), true + GetPreciseCompletionListFromExprTypings(parseResults, pos, filterCtors), true | None -> // Can get here in a case like: if "f xxx yyy" is legal, and we do "f xxx y" // We have no interest in expression typings, those are only useful for dot-completion. We want to fallback @@ -745,11 +734,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)) + getAllSymbols: unit -> AssemblySymbol list) : (CompletionItem list * DisplayEnv * CompletionContext option * range) option = - RequireCompilationThread ctok // the operations in this method need the reactor thread let loc = match colAtEndOfNamesAndResidue with @@ -793,7 +781,7 @@ type internal TypeCheckInfo match GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid) |> toCompletionItems with | [],_,_ -> // no record fields found, return completion list as if we were outside any computation expression - GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck, false, fun() -> []) + GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors,resolveOverloads, false, fun() -> []) | result -> Some(result) // Completion at ' { XXX = ... with ... } " @@ -813,11 +801,11 @@ type internal TypeCheckInfo // Completion at ' SomeMethod( ... ) ' with named arguments | Some(CompletionContext.ParameterList (endPos, fields)) -> - let results = GetNamedParametersAndSettableFields endPos hasTextChangedSinceLastTypecheck + let results = GetNamedParametersAndSettableFields endPos let declaredItems = GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, - hasTextChangedSinceLastTypecheck, false, getAllSymbols) + false, getAllSymbols) match results with | NameResResult.Members(items, denv, m) -> @@ -839,7 +827,7 @@ type internal TypeCheckInfo | _ -> declaredItems | Some(CompletionContext.AttributeApplication) -> - GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols) + GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, false, getAllSymbols) |> Option.map (fun (items, denv, m) -> items |> List.filter (fun cItem -> @@ -849,7 +837,7 @@ type internal TypeCheckInfo | _ -> false), denv, m) | Some(CompletionContext.OpenDeclaration isOpenType) -> - GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols) + GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, false, getAllSymbols) |> Option.map (fun (items, denv, m) -> items |> List.filter (fun x -> @@ -860,7 +848,7 @@ type internal TypeCheckInfo // Completion at '(x: ...)" | Some (CompletionContext.PatternType) -> - GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, false, getAllSymbols) + GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, false, getAllSymbols) |> Option.map (fun (items, denv, m) -> items |> List.filter (fun cItem -> @@ -885,7 +873,7 @@ type internal TypeCheckInfo let isInRangeOperator = (match cc with Some (CompletionContext.RangeOperator) -> true | _ -> false) GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, lastDotPos, line, loc, filterCtors, resolveOverloads, - hasTextChangedSinceLastTypecheck, isInRangeOperator, getAllSymbols) + isInRangeOperator, getAllSymbols) res |> Option.map (fun (items, denv, m) -> items, denv, completionContext, m) @@ -919,16 +907,16 @@ 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) = 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) + getAllEntities) match declItemsOpt with | None -> FSharpDeclarationListInfo.Empty @@ -940,22 +928,22 @@ type internal TypeCheckInfo |> Option.bind (fun x -> x.ParseTree) |> Option.map (fun parsedInput -> UntypedParseImpl.GetFullNameOfSmallestModuleOrNamespaceAtPoint(parsedInput, mkPos line 0)) let isAttributeApplication = ctx = Some CompletionContext.AttributeApplication - FSharpDeclarationListInfo.Create(infoReader,m,denv,getAccessibility,items,reactorOps,currentNamespaceOrModule,isAttributeApplication)) + FSharpDeclarationListInfo.Create(infoReader,m,denv,getAccessibility,items,currentNamespaceOrModule,isAttributeApplication)) (fun msg -> Trace.TraceInformation(sprintf "FCS: recovering from error in GetDeclarations: '%s'" msg) 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) = 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) + getAllEntities) match declItemsOpt with | None -> List.Empty @@ -1029,9 +1017,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 = @@ -1078,14 +1064,14 @@ 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)) + ResolveOverloads.Yes, (fun() -> [])) match declItemsOpt with | None -> FSharpToolTipText [] @@ -1098,21 +1084,21 @@ 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)) + ResolveOverloads.No, (fun() -> [])) match declItemsOpt with | None -> None @@ -1143,14 +1129,14 @@ 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)) + ResolveOverloads.No, (fun() -> [])) match declItemsOpt with | None -> FSharpMethodGroup("",[| |]) @@ -1167,14 +1153,14 @@ 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)) + (fun() -> [])) match declItemsOpt with | None | Some ([],_,_,_) -> None @@ -1187,14 +1173,14 @@ 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)) + ResolveOverloads.Yes, (fun() -> [])) match declItemsOpt with | None @@ -1296,13 +1282,13 @@ 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)) + ResolveOverloads.Yes, (fun() -> [])) match declItemsOpt with | None | Some ([], _, _, _) -> None @@ -1656,8 +1642,6 @@ module internal ParseAndCheckFile = // These are the errors and warnings seen by the background compiler for the entire antecedent backgroundDiagnostics: (PhasedDiagnostic * FSharpErrorSeverity)[], reactorOps: IReactorOperations, - // Used by 'FSharpDeclarationListInfo' to check the IncrementalBuilder is still alive. - textSnapshotInfo : obj option, userOpName: string, suggestNamesForErrors: bool) = async { @@ -1747,8 +1731,6 @@ module internal ParseAndCheckFile = sink.GetSymbolUses(), tcEnvAtEnd.NameEnv, loadClosure, - reactorOps, - textSnapshotInfo, List.tryHead implFiles, sink.GetOpenDeclarations()) |> Result.Ok @@ -1778,29 +1760,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 @@ -1812,73 +1780,62 @@ type FSharpCheckFileResults | _ -> None /// Intellisense autocompletions - member __.GetDeclarationListInfo(parsedFileResults, line, lineText, partialName, ?getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" + member __.GetDeclarationListInfo(parsedFileResults, line, lineText, partialName, ?getAllEntities) = let getAllEntities = defaultArg getAllEntities (fun() -> []) - let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false) - reactorOp userOpName "GetDeclarations" FSharpDeclarationListInfo.Empty (fun ctok scope -> - scope.GetDeclarations(ctok, parsedFileResults, line, lineText, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) + threadSafeOp (fun () -> FSharpDeclarationListInfo.Empty) (fun scope -> + scope.GetDeclarations(parsedFileResults, line, lineText, partialName, getAllEntities)) - member __.GetDeclarationListSymbols(parsedFileResults, line, lineText, partialName, ?getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false) + member __.GetDeclarationListSymbols(parsedFileResults, line, lineText, partialName, ?getAllEntities) = let getAllEntities = defaultArg getAllEntities (fun() -> []) - reactorOp userOpName "GetDeclarationListSymbols" List.empty (fun ctok scope -> - scope.GetDeclarationListSymbols(ctok, parsedFileResults, line, lineText, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) + threadSafeOp (fun () -> []) (fun scope -> + scope.GetDeclarationListSymbols(parsedFileResults, line, lineText, partialName, getAllEntities)) /// Resolve the names at the given location to give a data tip - member __.GetStructuredToolTipText(line, colAtEndOfNames, lineText, names, tokenTag, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" + member __.GetStructuredToolTipText(line, colAtEndOfNames, lineText, names, tokenTag) = let dflt = FSharpToolTipText [] match tokenTagToTokenId tokenTag with | TOKEN_IDENT -> - reactorOp userOpName "GetStructuredToolTipText" dflt (fun ctok scope -> - scope.GetStructuredToolTipText(ctok, line, lineText, colAtEndOfNames, names)) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetStructuredToolTipText(line, lineText, 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 - member info.GetToolTipText(line, colAtEndOfNames, lineText, names, tokenTag, userOpName) = - info.GetStructuredToolTipText(line, colAtEndOfNames, lineText, names, tokenTag, ?userOpName=userOpName) - |> Tooltips.Map Tooltips.ToFSharpToolTipText + member info.GetToolTipText(line, colAtEndOfNames, lineText, names, tokenTag) = + info.GetStructuredToolTipText(line, colAtEndOfNames, lineText, names, tokenTag) + |> Tooltips.ToFSharpToolTipText - member __.GetF1Keyword (line, colAtEndOfNames, lineText, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetF1Keyword" None (fun ctok scope -> - scope.GetF1Keyword (ctok, line, lineText, colAtEndOfNames, names)) + member __.GetF1Keyword (line, colAtEndOfNames, lineText, names) = + threadSafeOp (fun () -> None) (fun scope -> + scope.GetF1Keyword (line, lineText, colAtEndOfNames, names)) // Resolve the names at the given location to a set of methods - member __.GetMethods(line, colAtEndOfNames, lineText, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" + member __.GetMethods(line, colAtEndOfNames, lineText, names) = let dflt = FSharpMethodGroup("",[| |]) - reactorOp userOpName "GetMethods" dflt (fun ctok scope -> - scope.GetMethods (ctok, line, lineText, colAtEndOfNames, names)) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetMethods (line, lineText, colAtEndOfNames, names)) - member __.GetDeclarationLocation (line, colAtEndOfNames, lineText, names, ?preferFlag, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" + member __.GetDeclarationLocation (line, colAtEndOfNames, lineText, names, ?preferFlag) = let dflt = FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "") - reactorOp userOpName "GetDeclarationLocation" dflt (fun ctok scope -> - scope.GetDeclarationLocation (ctok, line, lineText, colAtEndOfNames, names, preferFlag)) + threadSafeOp (fun () -> dflt) (fun scope -> + scope.GetDeclarationLocation (line, lineText, colAtEndOfNames, names, preferFlag)) - member __.GetSymbolUseAtLocation (line, colAtEndOfNames, lineText, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetSymbolUseAtLocation" None (fun ctok scope -> - scope.GetSymbolUseAtLocation (ctok, line, lineText, colAtEndOfNames, names) + member __.GetSymbolUseAtLocation (line, colAtEndOfNames, lineText, names) = + threadSafeOp (fun () -> None) (fun scope -> + scope.GetSymbolUseAtLocation (line, lineText, colAtEndOfNames, names) |> Option.map (fun (sym,denv,m) -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m))) - member __.GetMethodsAsSymbols (line, colAtEndOfNames, lineText, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetMethodsAsSymbols" None (fun ctok scope -> - scope.GetMethodsAsSymbols (ctok, line, lineText, colAtEndOfNames, names) + member __.GetMethodsAsSymbols (line, colAtEndOfNames, lineText, names) = + threadSafeOp (fun () -> None) (fun scope -> + 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)))) - member __.GetSymbolAtLocation (line, colAtEndOfNames, lineText, names, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "GetSymbolAtLocation" None (fun ctok scope -> - scope.GetSymbolUseAtLocation (ctok, line, lineText, colAtEndOfNames, names) + member __.GetSymbolAtLocation (line, colAtEndOfNames, lineStr, names) = + threadSafeOp (fun () -> None) (fun scope -> + scope.GetSymbolUseAtLocation (line, lineStr, colAtEndOfNames, names) |> Option.map (fun (sym,_,_) -> sym)) member info.GetFormatSpecifierLocations() = @@ -1914,49 +1871,42 @@ type FSharpCheckFileResults member __.DependencyFiles = dependencyFiles - member __.GetAllUsesOfAllSymbolsInFile() = + member __.GetAllUsesOfAllSymbolsInFile(?cancellationToken: CancellationToken ) = threadSafeOp (fun () -> [| |]) (fun scope -> let cenv = scope.SymbolEnv [| for symbolUseChunk in scope.ScopeSymbolUses.AllUsesOfSymbols do - for symbolUse in symbolUseChunk do - if symbolUse.ItemOccurence <> ItemOccurence.RelatedText then - let symbol = FSharpSymbol.Create(cenv, symbolUse.Item) - yield FSharpSymbolUse(scope.TcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range) |]) - |> async.Return + for symbolUse in symbolUseChunk do + cancellationToken |> Option.iter (fun ct -> ct.ThrowIfCancellationRequested()) + if symbolUse.ItemOccurence <> ItemOccurence.RelatedText then + let symbol = FSharpSymbol.Create(cenv, symbolUse.Item) + yield FSharpSymbolUse(scope.TcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range) |]) - member __.GetUsesOfSymbolInFile(symbol:FSharpSymbol) = + member __.GetUsesOfSymbolInFile(symbol:FSharpSymbol, ?cancellationToken: CancellationToken) = threadSafeOp (fun () -> [| |]) (fun scope -> [| for symbolUse in scope.ScopeSymbolUses.GetUsesOfSymbol(symbol.Item) |> Seq.distinctBy (fun symbolUse -> symbolUse.ItemOccurence, symbolUse.Range) do + cancellationToken |> Option.iter (fun ct -> ct.ThrowIfCancellationRequested()) if symbolUse.ItemOccurence <> ItemOccurence.RelatedText then yield FSharpSymbolUse(scope.TcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range) |]) - |> async.Return member __.GetVisibleNamespacesAndModulesAtPoint(pos: pos) = threadSafeOp (fun () -> [| |]) (fun scope -> scope.GetVisibleNamespacesAndModulesAtPosition(pos) |> List.toArray) - |> async.Return - member __.IsRelativeNameResolvable(cursorPos: pos, plid: string list, item: Item, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "IsRelativeNameResolvable" true (fun ctok scope -> - RequireCompilationThread ctok + member __.IsRelativeNameResolvable(cursorPos: pos, plid: string list, item: Item) = + threadSafeOp (fun () -> true) (fun scope -> scope.IsRelativeNameResolvable(cursorPos, plid, item)) - member __.IsRelativeNameResolvableFromSymbol(cursorPos: pos, plid: string list, symbol: FSharpSymbol, ?userOpName: string) = - let userOpName = defaultArg userOpName "Unknown" - reactorOp userOpName "IsRelativeNameResolvableFromSymbol" true (fun ctok scope -> - RequireCompilationThread ctok + member __.IsRelativeNameResolvableFromSymbol(cursorPos: pos, plid: string list, symbol: FSharpSymbol) = + threadSafeOp (fun () -> true) (fun scope -> scope.IsRelativeNameResolvableFromSymbol(cursorPos, plid, symbol)) - member __.GetDisplayContextForPos(cursorPos: pos) : Async = - let userOpName = "CodeLens" - reactorOp userOpName "GetDisplayContextAtPos" None (fun ctok scope -> - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok + member __.GetDisplayContextForPos(cursorPos: pos) = + threadSafeOp (fun () -> None) (fun scope -> let (nenv, _), _ = scope.GetBestDisplayEnvForPos cursorPos Some(FSharpDisplayContext(fun _ -> nenv.DisplayEnv))) @@ -1980,8 +1930,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[], @@ -2004,7 +1954,6 @@ type FSharpCheckFileResults creationErrors: FSharpErrorInfo[], parseErrors: FSharpErrorInfo[], tcErrors: FSharpErrorInfo[], - reactorOps, keepAssemblyContents, ccuSigForFile, thisCcu, tcImports, tcAccessRights, @@ -2016,11 +1965,11 @@ type FSharpCheckFileResults let tcFileInfo = TypeCheckInfo(tcConfig, tcGlobals, ccuSigForFile, thisCcu, tcImports, tcAccessRights, projectFileName, mainInputFileName, sResolutions, sSymbolUses, - sFallback, loadClosure, reactorOps, - None, implFileOpt, openDeclarations) + sFallback, loadClosure, + 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, @@ -2035,7 +1984,6 @@ type FSharpCheckFileResults loadClosure: LoadClosure option, backgroundDiagnostics: (PhasedDiagnostic * FSharpErrorSeverity)[], reactorOps: IReactorOperations, - textSnapshotInfo : obj option, userOpName: string, isIncompleteTypeCheckEnvironment: bool, builder: IncrementalBuilder, @@ -2049,13 +1997,13 @@ type FSharpCheckFileResults ParseAndCheckFile.CheckOneFile (parseResults, sourceText, mainInputFileName, projectFileName, tcConfig, tcGlobals, tcImports, tcState, moduleNamesDict, loadClosure, backgroundDiagnostics, reactorOps, - textSnapshotInfo, userOpName, suggestNamesForErrors) + userOpName, suggestNamesForErrors) match tcFileInfo with | Result.Error () -> 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) } @@ -2131,29 +2079,30 @@ type FSharpCheckProjectResults FSharpAssemblyContents(tcGlobals, thisCcu, Some ccuSig, tcImports, mimpls) // Not, this does not have to be a SyncOp, it can be called from any thread - member __.GetUsesOfSymbol(symbol:FSharpSymbol) = + member __.GetUsesOfSymbol(symbol:FSharpSymbol, ?cancellationToken: CancellationToken) = let (tcGlobals, _tcImports, _thisCcu, _ccuSig, tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, _ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() tcSymbolUses |> Seq.collect (fun r -> r.GetUsesOfSymbol symbol.Item) |> Seq.filter (fun symbolUse -> symbolUse.ItemOccurence <> ItemOccurence.RelatedText) |> Seq.distinctBy (fun symbolUse -> symbolUse.ItemOccurence, symbolUse.Range) - |> Seq.map (fun symbolUse -> FSharpSymbolUse(tcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range)) + |> Seq.map (fun symbolUse -> + cancellationToken |> Option.iter (fun ct -> ct.ThrowIfCancellationRequested()) + FSharpSymbolUse(tcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range)) |> Seq.toArray - |> async.Return // Not, this does not have to be a SyncOp, it can be called from any thread - member __.GetAllUsesOfAllSymbols() = + member __.GetAllUsesOfAllSymbols(?cancellationToken: CancellationToken) = let (tcGlobals, tcImports, thisCcu, ccuSig, tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, _ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() let cenv = SymbolEnv(tcGlobals, thisCcu, Some ccuSig, tcImports) [| for r in tcSymbolUses do for symbolUseChunk in r.AllUsesOfSymbols do for symbolUse in symbolUseChunk do + cancellationToken |> Option.iter (fun ct -> ct.ThrowIfCancellationRequested()) if symbolUse.ItemOccurence <> ItemOccurence.RelatedText then let symbol = FSharpSymbol.Create(cenv, symbolUse.Item) yield FSharpSymbolUse(tcGlobals, symbolUse.DisplayEnv, symbol, symbolUse.ItemOccurence, symbolUse.Range) |] - |> async.Return member __.ProjectContext = let (tcGlobals, tcImports, thisCcu, _ccuSig, _tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() @@ -2219,13 +2168,13 @@ type FsiInteractiveChecker(legacyReferenceResolver, (parseResults, sourceText, filename, "project", tcConfig, tcGlobals, tcImports, tcState, Map.empty, Some loadClosure, backgroundDiagnostics, - ops, None, userOpName, suggestNamesForErrors) + ops, userOpName, suggestNamesForErrors) return match tcFileInfo with | Result.Ok tcFileInfo -> let errors = Array.append parseErrors tcErrors - let typeCheckResults = FSharpCheckFileResults (filename, errors, Some tcFileInfo, dependencyFiles, None, ops, false) + let typeCheckResults = FSharpCheckFileResults (filename, errors, Some tcFileInfo, dependencyFiles, None, false) let projectResults = FSharpCheckProjectResults (filename, Some tcConfig, keepAssemblyContents, errors, diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index 52e241a61b1..023c23d3ac7 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -2,6 +2,8 @@ namespace FSharp.Compiler.SourceCodeServices + +open System.Threading open FSharp.Compiler open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library @@ -117,13 +119,7 @@ type public FSharpCheckFileResults = /// /// Function that returns all entities from current and referenced assemblies. /// - /// - /// If text has been used from a captured name resolution from the typecheck, then - /// callback to the client to check if the text has changed. If it has, then give up - /// 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 : parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async + member GetDeclarationListInfo: parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpDeclarationListInfo /// Get the items for a declaration list in FSharpSymbol format /// @@ -143,13 +139,7 @@ type public FSharpCheckFileResults = /// /// Function that returns all entities from current and referenced assemblies. /// - /// - /// If text has been used from a captured name resolution from the typecheck, then - /// callback to the client to check if the text has changed. If it has, then give up - /// 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 : parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async + member GetDeclarationListSymbols: parsedFileResults:FSharpParseFileResults option * line: int * lineText:string * partialName: PartialLongName * ?getAllEntities: (unit -> AssemblySymbol list) -> FSharpSymbolUse list list /// Compute a formatted tooltip for the given location /// @@ -158,8 +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. - /// 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 -> FSharpStructuredToolTipText /// Compute a formatted tooltip for the given location /// @@ -168,8 +157,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. - /// 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 -> FSharpToolTipText /// Compute the Visual Studio F1-help key identifier for the given location, based on name resolution results /// @@ -177,9 +165,7 @@ type public FSharpCheckFileResults = /// The column number at the end of the identifiers where the information is being requested. /// 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 -> string option /// Compute a set of method overloads to show in a dialog relevant to the given code location. /// @@ -187,16 +173,14 @@ type public FSharpCheckFileResults = /// The column number at the end of the identifiers where the information is being requested. /// 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 -> FSharpMethodGroup /// 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. /// The column number at the end of the identifiers where the information is being requested. /// 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 -> FSharpSymbolUse list option /// Resolve the names at the given location to the declaration location of the corresponding construct. /// @@ -205,8 +189,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. /// 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 -> FSharpFindDeclResult /// Resolve the names at the given location to a use of symbol. /// @@ -214,8 +197,7 @@ type public FSharpCheckFileResults = /// The column number at the end of the identifiers where the information is being requested. /// 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 -> FSharpSymbolUse option /// Get any extra colorization info that is available after the typecheck member GetSemanticClassification : range option -> struct (range * SemanticClassificationType)[] @@ -228,21 +210,21 @@ type public FSharpCheckFileResults = member GetFormatSpecifierLocationsAndArity : unit -> (range*int)[] /// Get all textual usages of all symbols throughout the file - member GetAllUsesOfAllSymbolsInFile : unit -> Async + member GetAllUsesOfAllSymbolsInFile : ?cancellationToken: CancellationToken -> FSharpSymbolUse[] /// Get the textual usages that resolved to the given symbol throughout the file - member GetUsesOfSymbolInFile : symbol:FSharpSymbol -> Async + member GetUsesOfSymbolInFile : symbol:FSharpSymbol * ?cancellationToken: CancellationToken -> FSharpSymbolUse[] - member internal GetVisibleNamespacesAndModulesAtPoint : pos -> Async + 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 * ?userOpName: string -> Async + member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item -> bool /// 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 -> bool /// Represents complete typechecked implementation file, including its typechecked signatures if any. member ImplementationFile: FSharpImplementationFileContents option @@ -254,7 +236,6 @@ type public FSharpCheckFileResults = static member internal MakeEmpty : filename: string * creationErrors: FSharpErrorInfo[] * - reactorOps: IReactorOperations * keepAssemblyContents: bool -> FSharpCheckFileResults @@ -270,7 +251,6 @@ type public FSharpCheckFileResults = creationErrors: FSharpErrorInfo[] * parseErrors: FSharpErrorInfo[] * tcErrors: FSharpErrorInfo[] * - reactorOps : IReactorOperations * keepAssemblyContents: bool * ccuSigForFile: ModuleOrNamespaceType * thisCcu: CcuThunk * @@ -298,7 +278,6 @@ type public FSharpCheckFileResults = loadClosure: LoadClosure option * backgroundDiagnostics: (PhasedDiagnostic * FSharpErrorSeverity)[] * reactorOps: IReactorOperations * - textSnapshotInfo : obj option * userOpName: string * isIncompleteTypeCheckEnvironment: bool * builder: IncrementalBuilder * @@ -337,10 +316,10 @@ type public FSharpCheckProjectResults = member ProjectContext: FSharpProjectContext /// Get the textual usages that resolved to the given symbol throughout the project - member GetUsesOfSymbol: symbol:FSharpSymbol -> Async + member GetUsesOfSymbol: symbol:FSharpSymbol * ?cancellationToken: CancellationToken -> FSharpSymbolUse[] /// Get all textual usages of all symbols throughout the project - member GetAllUsesOfAllSymbols: unit -> Async + member GetAllUsesOfAllSymbols: ?cancellationToken: CancellationToken -> FSharpSymbolUse[] /// Indicates if critical errors existed in the project options member HasCriticalErrors: bool diff --git a/src/fsharp/service/ServiceAnalysis.fs b/src/fsharp/service/ServiceAnalysis.fs index 69d2d774669..3eccf417a7b 100644 --- a/src/fsharp/service/ServiceAnalysis.fs +++ b/src/fsharp/service/ServiceAnalysis.fs @@ -224,7 +224,8 @@ module UnusedOpens = /// Async to allow cancellation. let getUnusedOpens (checkFileResults: FSharpCheckFileResults, getSourceLineStr: int -> string) : Async = async { - let! symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile() + let! ct = Async.CancellationToken + let symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile(ct) let symbolUses = filterSymbolUses getSourceLineStr symbolUses let symbolUses = splitSymbolUses symbolUses let openStatements = getOpenStatements checkFileResults.OpenDeclarations @@ -243,7 +244,8 @@ module SimplifyNames = let getSimplifiableNames (checkFileResults: FSharpCheckFileResults, getSourceLineStr: int -> string) : Async = async { let result = ResizeArray() - let! symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile() + let! ct = Async.CancellationToken + let symbolUses = checkFileResults.GetAllUsesOfAllSymbolsInFile(ct) let symbolUses = symbolUses |> Array.filter (fun symbolUse -> not symbolUse.IsFromOpenStatement) @@ -266,19 +268,17 @@ module SimplifyNames = if r.StartLine = r.EndLine then Range.mkPos r.StartLine (r.EndColumn - name.Length) else r.Start - let getNecessaryPlid (plid: string list) : Async = + let getNecessaryPlid (plid: string list) : string list = let rec loop (rest: string list) (current: string list) = - async { - match rest with - | [] -> return current - | headIdent :: restPlid -> - let! res = checkFileResults.IsRelativeNameResolvableFromSymbol(posAtStartOfName, current, symbolUse.Symbol) - if res then return current - else return! loop restPlid (headIdent :: current) - } + match rest with + | [] -> current + | headIdent :: restPlid -> + let res = checkFileResults.IsRelativeNameResolvableFromSymbol(posAtStartOfName, current, symbolUse.Symbol) + if res then current + else loop restPlid (headIdent :: current) loop (List.rev plid) [] - let! necessaryPlid = getNecessaryPlid plid + let necessaryPlid = getNecessaryPlid plid match necessaryPlid with | necessaryPlid when necessaryPlid = plid -> () @@ -342,7 +342,8 @@ module UnusedDeclarations = let getUnusedDeclarations(checkFileResults: FSharpCheckFileResults, isScriptFile: bool) : Async = async { - let! allSymbolUsesInFile = checkFileResults.GetAllUsesOfAllSymbolsInFile() + let! ct = Async.CancellationToken + let allSymbolUsesInFile = checkFileResults.GetAllUsesOfAllSymbolsInFile(ct) let unusedRanges = getUnusedDeclarationRanges allSymbolUsesInFile isScriptFile return unusedRanges } \ No newline at end of file diff --git a/src/fsharp/service/ServiceDeclarationLists.fs b/src/fsharp/service/ServiceDeclarationLists.fs index 3fd90b64ae7..587b31f1e41 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fs +++ b/src/fsharp/service/ServiceDeclarationLists.fs @@ -28,21 +28,21 @@ open FSharp.Compiler.TypedTreeOps type FSharpMethodGroupItemParameter(name: string, canonicalTypeTextForSorting: string, display: layout, isOptional: bool) = /// The name of the parameter. - member __.ParameterName = name + member _.ParameterName = name /// A key that can be used for sorting the parameters, used to help sort overloads. - member __.CanonicalTypeTextForSorting = canonicalTypeTextForSorting + member _.CanonicalTypeTextForSorting = canonicalTypeTextForSorting /// The structured representation for the parameter including its name, its type and visual indicators of other /// information such as whether it is optional. - member __.StructuredDisplay = display + member _.StructuredDisplay = display /// The text to display for the parameter including its name, its type and visual indicators of other /// information such as whether it is optional. - member __.Display = showL display + member _.Display = showL display /// Is the parameter optional - member __.IsOptional = isOptional + member _.IsOptional = isOptional [] module internal DescriptionListsImpl = @@ -475,45 +475,44 @@ module internal DescriptionListsImpl = [] type FSharpDeclarationListItem(name: string, nameInCode: string, fullName: string, glyph: FSharpGlyph, info, accessibility: FSharpAccessibility option, kind: CompletionItemKind, isOwnMember: bool, priority: int, isResolved: bool, namespaceToOpen: string option) = - member __.Name = name - member __.NameInCode = nameInCode + member _.Name = name + member _.NameInCode = nameInCode - member __.StructuredDescriptionTextAsync = - let userOpName = "ToolTip" + member decl.StructuredDescriptionTextAsync = decl.StructuredDescriptionText |> async.Return + + member _.StructuredDescriptionText = match info with - | Choice1Of2 (items: CompletionItem list, infoReader, m, denv, reactor:IReactorOperations) -> - // 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 - - member decl.DescriptionTextAsync = - decl.StructuredDescriptionTextAsync - |> Tooltips.Map Tooltips.ToFSharpToolTipText - - member __.Glyph = glyph - member __.Accessibility = accessibility - member __.Kind = kind - member __.IsOwnMember = isOwnMember - member __.MinorPriority = priority - member __.FullName = fullName - member __.IsResolved = isResolved - member __.NamespaceToOpen = namespaceToOpen + | Choice1Of2 (items: CompletionItem list, infoReader, m, denv) -> + FSharpToolTipText(items |> List.map (fun x -> SymbolHelpers.FormatStructuredDescriptionOfItem true infoReader m denv x.ItemWithInst)) + | Choice2Of2 result -> + result + + member x.DescriptionTextAsync = x.DescriptionText |> async.Return + + member decl.DescriptionText = + decl.StructuredDescriptionText + |> Tooltips.ToFSharpToolTipText + + member _.Glyph = glyph + member _.Accessibility = accessibility + member _.Kind = kind + member _.IsOwnMember = isOwnMember + member _.MinorPriority = priority + member _.FullName = fullName + member _.IsResolved = isResolved + member _.NamespaceToOpen = namespaceToOpen /// A table of declarations for Intellisense completion [] type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForType: bool, isError: bool) = static let fsharpNamespace = [|"Microsoft"; "FSharp"|] - member __.Items = declarations - member __.IsForType = isForType - member __.IsError = isError + member _.Items = declarations + member _.IsForType = isForType + member _.IsError = isError // Make a 'Declarations' object for a set of selected items - static member Create(infoReader:InfoReader, m: range, denv, getAccessibility, items: CompletionItem list, reactor, currentNamespace: string[] option, isAttributeApplicationContext: bool) = + static member Create(infoReader:InfoReader, m: range, denv, getAccessibility, items: CompletionItem list, currentNamespace: string[] option, isAttributeApplicationContext: bool) = let g = infoReader.g let isForType = items |> List.exists (fun x -> x.Type.IsSome) let items = items |> SymbolHelpers.RemoveExplicitlySuppressedCompletionItems g @@ -657,7 +656,7 @@ type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForT | ns -> Some (System.String.Join(".", ns))) FSharpDeclarationListItem( - name, nameInCode, fullName, glyph, Choice1Of2 (items, infoReader, m, denv, reactor), getAccessibility item.Item, + name, nameInCode, fullName, glyph, Choice1Of2 (items, infoReader, m, denv), getAccessibility item.Item, item.Kind, item.IsOwnMember, item.MinorPriority, item.Unresolved.IsNone, namespaceToOpen)) new FSharpDeclarationListInfo(Array.ofList decls, isForType, false) @@ -680,31 +679,31 @@ type FSharpMethodGroupItem(description: FSharpToolTipText, xmlDoc: FShar hasParameters: bool, hasParamArrayArg: bool, staticParameters: FSharpMethodGroupItemParameter[]) = /// The structured description representation for the method (or other item) - member __.StructuredDescription = description + member _.StructuredDescription = description /// The formatted description text for the method (or other item) - member __.Description = Tooltips.ToFSharpToolTipText description + member _.Description = Tooltips.ToFSharpToolTipText description /// The documentation for the item - member __.XmlDoc = xmlDoc + member _.XmlDoc = xmlDoc /// The The structured description representation for the method (or other item) - member __.StructuredReturnTypeText = returnType + member _.StructuredReturnTypeText = returnType /// The formatted type text for the method (or other item) - member __.ReturnTypeText = showL returnType + member _.ReturnTypeText = showL returnType /// The parameters of the method in the overload set - member __.Parameters = parameters + member _.Parameters = parameters /// Does the method support an arguments list? This is always true except for static type instantiations like TP<42, "foo">. - member __.HasParameters = hasParameters + member _.HasParameters = hasParameters /// Does the method support a params list arg? - member __.HasParamArrayArg = hasParamArrayArg + member _.HasParamArrayArg = hasParamArrayArg /// Does the type name or method support a static arguments list, like TP<42, "foo"> or conn.CreateCommand<42, "foo">(arg1, arg2)? - member __.StaticParameters = staticParameters + member _.StaticParameters = staticParameters /// A table of methods for Intellisense completion @@ -733,9 +732,9 @@ type FSharpMethodGroup( name: string, unsortedMethods: FSharpMethodGroupItem[] ) let parms = meth.Parameters parms.Length, (parms |> Array.map (fun p -> p.CanonicalTypeTextForSorting))) - member __.MethodName = name + member _.MethodName = name - member __.Methods = methods + member _.Methods = methods static member Create (infoReader: InfoReader, m, denv, items:ItemWithInst list) = let g = infoReader.g diff --git a/src/fsharp/service/ServiceDeclarationLists.fsi b/src/fsharp/service/ServiceDeclarationLists.fsi index 462f4d1fe6e..68a5093d6d3 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fsi +++ b/src/fsharp/service/ServiceDeclarationLists.fsi @@ -3,6 +3,7 @@ /// API for declaration lists and method overload lists namespace FSharp.Compiler.SourceCodeServices +open System open FSharp.Compiler.NameResolution open FSharp.Compiler.InfoReader open FSharp.Compiler.Range @@ -20,11 +21,17 @@ type public FSharpDeclarationListItem = /// Get the name for the declaration as it's presented in source code. member NameInCode : string - /// Get the description text, asynchronously. Never returns "Loading...". + [] member StructuredDescriptionTextAsync : Async + /// Get the description text. + member StructuredDescriptionText : FSharpStructuredToolTipText + + [] member DescriptionTextAsync : Async + member DescriptionText : FSharpToolTipText + member Glyph : FSharpGlyph member Accessibility : FSharpAccessibility option @@ -56,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 * reactor:IReactorOperations * currentNamespace:string[] option * isAttributeApplicationContext: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/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/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index a624afdadce..24c5cd08ea7 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,36 @@ 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 (AnyCallerThread, options) + + let tryGetSimilarBuilder options = + incrementalBuildersCache.TryGetSimilar (AnyCallerThread, options) + + let tryGetAnyBuilder options = + incrementalBuildersCache.TryGetAny (AnyCallerThread, 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 (AnyCallerThread, 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) @@ -389,7 +396,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) @@ -507,7 +513,6 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC sourceText: ISourceText, fileName: string, options: FSharpProjectOptions, - textSnapshotInfo: obj option, fileVersion: int, builder: IncrementalBuilder, tcConfig, @@ -536,7 +541,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, @@ -551,7 +556,6 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC loadClosure, prevTcErrors, reactorOps, - textSnapshotInfo, userOpName, options.IsIncompleteTypeCheckEnvironment, builder, @@ -578,7 +582,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC } /// Type-check the result obtained by parsing, but only if the antecedent type checking context is available. - member bc.CheckFileInProjectAllowingStaleCachedResults(parseResults: FSharpParseFileResults, filename, fileVersion, sourceText: ISourceText, options, textSnapshotInfo: obj option, userOpName) = + member bc.CheckFileInProjectAllowingStaleCachedResults(parseResults: FSharpParseFileResults, filename, fileVersion, sourceText: ISourceText, options, userOpName) = let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync(userOpName, "CheckFileInProjectAllowingStaleCachedResults ", filename, action) async { try @@ -590,7 +594,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)) @@ -617,7 +621,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC match tcPrior with | Some(tcPrior, tcInfo) -> - let! checkResults = bc.CheckOneFileImpl(parseResults, sourceText, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, tcInfo.tcDependencyFiles, tcPrior.TimeStamp, tcInfo.tcState, tcInfo.moduleNamesDict, tcInfo.TcErrors, creationErrors, userOpName) + let! checkResults = bc.CheckOneFileImpl(parseResults, sourceText, filename, options, fileVersion, builder, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, tcInfo.tcDependencyFiles, tcPrior.TimeStamp, tcInfo.tcState, tcInfo.moduleNamesDict, tcInfo.TcErrors, creationErrors, userOpName) return Some checkResults | None -> return None // the incremental builder was not up to date finally @@ -625,7 +629,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC } /// Type-check the result obtained by parsing. Force the evaluation of the antecedent type checking context if needed. - member bc.CheckFileInProject(parseResults: FSharpParseFileResults, filename, fileVersion, sourceText: ISourceText, options, textSnapshotInfo, userOpName) = + member bc.CheckFileInProject(parseResults: FSharpParseFileResults, filename, fileVersion, sourceText: ISourceText, options, userOpName) = let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync(userOpName, "CheckFileInProject", filename, action) async { try @@ -633,7 +637,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) @@ -648,14 +652,14 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC let! tcPrior = builder.GetCheckResultsBeforeFileInProject (ctok, filename) return (tcPrior, tcPrior.TcInfo ctok) } - let! checkAnswer = bc.CheckOneFileImpl(parseResults, sourceText, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, tcInfo.tcDependencyFiles, tcPrior.TimeStamp, tcInfo.tcState, tcInfo.moduleNamesDict, tcInfo.TcErrors, creationErrors, userOpName) + let! checkAnswer = bc.CheckOneFileImpl(parseResults, sourceText, filename, options, fileVersion, builder, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, tcInfo.tcDependencyFiles, tcPrior.TimeStamp, tcInfo.tcState, tcInfo.moduleNamesDict, tcInfo.TcErrors, creationErrors, userOpName) return checkAnswer finally bc.ImplicitlyStartCheckProjectInBackground(options, userOpName) } /// Parses and checks the source file and returns untyped AST and check results. - member bc.ParseAndCheckFileInProject (filename:string, fileVersion, sourceText: ISourceText, options:FSharpProjectOptions, textSnapshotInfo, userOpName) = + member bc.ParseAndCheckFileInProject (filename:string, fileVersion, sourceText: ISourceText, options:FSharpProjectOptions, userOpName) = let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync(userOpName, "ParseAndCheckFileInProject", filename, action) async { try @@ -697,7 +701,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC reactor.SetPreferredUILang tcPrior.TcConfig.preferredUiLang let parseErrors, parseTreeOpt, anyErrors = ParseAndCheckFile.parseFile (sourceText, filename, parsingOptions, userOpName, suggestNamesForErrors) let parseResults = FSharpParseFileResults(parseErrors, parseTreeOpt, anyErrors, builder.AllDependenciesDeprecated) - let! checkResults = bc.CheckOneFileImpl(parseResults, sourceText, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, tcInfo.tcDependencyFiles, tcPrior.TimeStamp, tcInfo.tcState, tcInfo.moduleNamesDict, tcInfo.TcErrors, creationErrors, userOpName) + let! checkResults = bc.CheckOneFileImpl(parseResults, sourceText, filename, options, fileVersion, builder, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, tcInfo.tcDependencyFiles, tcPrior.TimeStamp, tcInfo.tcState, tcInfo.moduleNamesDict, tcInfo.TcErrors, creationErrors, userOpName) Logger.LogBlockMessageStop (filename + strGuid + "-Successful") LogCompilerFunctionId.Service_ParseAndCheckFileInProject @@ -714,7 +718,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) @@ -735,7 +739,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, @@ -748,7 +752,6 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC creationErrors, parseResults.Errors, tcErrors, - reactorOps, keepAssemblyContents, Option.get latestCcuSigForFile, tcState.Ccu, @@ -794,13 +797,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) = @@ -914,45 +917,44 @@ 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 }) 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 + 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 - bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) + 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 -> + reactor.EnqueueOp(userOpName, "ClearCache", String.Empty, fun _ -> 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 -> - 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) - }) + 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 (AnyCallerThread, options) then + // We do not need to decrement here - it is done by disposal. + let! newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) + incrementalBuildersCache.Set(AnyCallerThread, options, newBuilderInfo) + }) member __.CheckProjectInBackground (options, userOpName) = reactor.SetBackgroundOp (Some (userOpName, "CheckProjectInBackground", options.ProjectFileName, (fun ctok ct -> @@ -997,9 +999,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) = @@ -1008,9 +1010,9 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC checkFileInProjectCachePossiblyStale.Resize(ltok, newKeepStrongly=1) checkFileInProjectCache.Resize(ltok, newKeepStrongly=1) parseFileCache.Resize(ltok, newKeepStrongly=1)) - incrementalBuildersCache.Resize(ctok, newKeepStrongly=1, newKeepMax=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 @@ -1041,7 +1043,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 +1080,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 +1211,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 +1227,7 @@ type FSharpChecker(legacyReferenceResolver, let userOpName = "MaxMemoryReached" backgroundCompiler.CompleteAllQueuedOps() maxMemoryReached <- true - braceMatchCache.Resize(AssumeAnyCallerThreadWithoutEvidence(), newKeepStrongly=10) + braceMatchCache.Resize(AnyCallerThread, newKeepStrongly=10) backgroundCompiler.DownsizeCaches(userOpName) |> Async.RunSynchronously maxMemEvent.Trigger( () ) @@ -1255,23 +1257,23 @@ type FSharpChecker(legacyReferenceResolver, /// Typecheck a source code file, returning a handle to the results of the /// parse including the reconstructed types in the file. - member __.CheckFileInProjectAllowingStaleCachedResults(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj, ?userOpName: string) = + member __.CheckFileInProjectAllowingStaleCachedResults(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" - backgroundCompiler.CheckFileInProjectAllowingStaleCachedResults(parseResults,filename,fileVersion,SourceText.ofString source,options,textSnapshotInfo, userOpName) + backgroundCompiler.CheckFileInProjectAllowingStaleCachedResults(parseResults,filename,fileVersion,SourceText.ofString source,options,userOpName) /// Typecheck a source code file, returning a handle to the results of the /// parse including the reconstructed types in the file. - member ic.CheckFileInProject(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, sourceText:ISourceText, options:FSharpProjectOptions, ?textSnapshotInfo:obj, ?userOpName: string) = + member ic.CheckFileInProject(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, sourceText:ISourceText, options:FSharpProjectOptions, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" ic.CheckMaxMemoryReached() - backgroundCompiler.CheckFileInProject(parseResults,filename,fileVersion,sourceText,options,textSnapshotInfo, userOpName) + backgroundCompiler.CheckFileInProject(parseResults,filename,fileVersion,sourceText,options,userOpName) /// Typecheck a source code file, returning a handle to the results of the /// parse including the reconstructed types in the file. - member ic.ParseAndCheckFileInProject(filename:string, fileVersion:int, sourceText:ISourceText, options:FSharpProjectOptions, ?textSnapshotInfo:obj, ?userOpName: string) = + member ic.ParseAndCheckFileInProject(filename:string, fileVersion:int, sourceText:ISourceText, options:FSharpProjectOptions, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" ic.CheckMaxMemoryReached() - backgroundCompiler.ParseAndCheckFileInProject(filename, fileVersion, sourceText, options, textSnapshotInfo, userOpName) + backgroundCompiler.ParseAndCheckFileInProject(filename, fileVersion, sourceText, options, userOpName) member ic.ParseAndCheckProject(options, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" diff --git a/src/fsharp/service/service.fsi b/src/fsharp/service/service.fsi index c1a284d658b..09d6469860f 100755 --- a/src/fsharp/service/service.fsi +++ b/src/fsharp/service/service.fsi @@ -155,14 +155,9 @@ type public FSharpChecker = /// An integer that can be used to indicate the version of the file. This will be returned by TryGetRecentCheckResultsForFile when looking up the file. /// The full source for the file. /// The options for the project or script. - /// - /// An item passed back to 'hasTextChangedSinceLastTypecheck' (from some calls made on 'FSharpCheckFileResults') to help determine if - /// an approximate intellisense resolution is inaccurate because a range of text has changed. This - /// can be used to marginally increase accuracy of intellisense results in some situations. - /// /// An optional string used for tracing compiler operations associated with this request. [] - member CheckFileInProjectAllowingStaleCachedResults : parseResults: FSharpParseFileResults * filename: string * fileVersion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj * ?userOpName: string -> Async + member CheckFileInProjectAllowingStaleCachedResults : parseResults: FSharpParseFileResults * filename: string * fileVersion: int * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async /// /// @@ -181,13 +176,8 @@ type public FSharpChecker = /// An integer that can be used to indicate the version of the file. This will be returned by TryGetRecentCheckResultsForFile when looking up the file. /// The full source for the file. /// The options for the project or script. - /// - /// An item passed back to 'hasTextChangedSinceLastTypecheck' (from some calls made on 'FSharpCheckFileResults') to help determine if - /// an approximate intellisense resolution is inaccurate because a range of text has changed. This - /// can be used to marginally increase accuracy of intellisense results in some situations. - /// /// An optional string used for tracing compiler operations associated with this request. - member CheckFileInProject : parseResults: FSharpParseFileResults * filename: string * fileVersion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?textSnapshotInfo: obj * ?userOpName: string -> Async + member CheckFileInProject : parseResults: FSharpParseFileResults * filename: string * fileVersion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?userOpName: string -> Async /// /// @@ -205,13 +195,8 @@ type public FSharpChecker = /// An integer that can be used to indicate the version of the file. This will be returned by TryGetRecentCheckResultsForFile when looking up the file. /// The source for the file. /// The options for the project or script. - /// - /// An item passed back to 'hasTextChangedSinceLastTypecheck' (from some calls made on 'FSharpCheckFileResults') to help determine if - /// an approximate intellisense resolution is inaccurate because a range of text has changed. This - /// can be used to marginally increase accuracy of intellisense results in some situations. - /// /// An optional string used for tracing compiler operations associated with this request. - member ParseAndCheckFileInProject : filename: string * fileVersion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?textSnapshotInfo: obj * ?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/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index f7593d8e0b8..5ae4c2cca64 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -288,7 +288,6 @@ module Tooltips = let ToFSharpToolTipText (FSharpStructuredToolTipText.FSharpToolTipText text) = FSharpToolTipText(List.map ToFSharpToolTipElement text) - let Map f a = async.Bind(a, f >> async.Return) [] type CompletionItemKind = diff --git a/src/fsharp/symbols/SymbolHelpers.fsi b/src/fsharp/symbols/SymbolHelpers.fsi index f5f345e4ef2..f7d0f0802d0 100755 --- a/src/fsharp/symbols/SymbolHelpers.fsi +++ b/src/fsharp/symbols/SymbolHelpers.fsi @@ -153,8 +153,6 @@ module public Tooltips = val ToFSharpToolTipText: FSharpStructuredToolTipText -> FSharpToolTipText - val Map: f: ('T1 -> 'T2) -> a: Async<'T1> -> Async<'T2> - // Implementation details used by other code in the compiler module internal SymbolHelpers = diff --git a/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs b/tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs index f5eebfdae42..dd6b41b43f2 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]) @@ -21442,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() @@ -21474,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() @@ -21496,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]) @@ -21562,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 @@ -25314,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) 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 24c44e12c40..57486501ecc 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"]); @@ -1032,7 +1032,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 ] @@ -1323,7 +1323,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)))]); @@ -1349,14 +1349,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 @@ -1378,7 +1378,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" @@ -1386,7 +1386,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) @@ -1396,13 +1396,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" @@ -1411,7 +1411,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) @@ -1476,7 +1476,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 @@ -1544,7 +1544,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" @@ -1560,7 +1560,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" @@ -1577,12 +1577,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 @@ -1604,7 +1604,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" @@ -1622,7 +1622,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 @@ -1632,7 +1632,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 @@ -1677,7 +1677,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 @@ -1733,16 +1733,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)), []); @@ -1794,7 +1794,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 @@ -1823,11 +1823,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 @@ -1874,7 +1874,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 @@ -1900,11 +1900,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 @@ -1953,7 +1953,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 @@ -1978,7 +1978,7 @@ let ``Test Project10 all symbols`` () = let querySymbolUseOpt = backgroundTypedParse1.GetSymbolUseAtLocation(7,23,"",["query"]) - |> Async.RunSynchronously + let querySymbolUse = querySymbolUseOpt.Value let querySymbol = querySymbolUse.Symbol @@ -1986,7 +1986,7 @@ let ``Test Project10 all symbols`` () = let querySymbolUse2Opt = backgroundTypedParse1.GetSymbolUseAtLocation(7,22,"",["query"]) - |> Async.RunSynchronously + let querySymbolUse2 = querySymbolUse2Opt.Value let querySymbol2 = querySymbolUse2.Symbol @@ -2033,7 +2033,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 @@ -2102,7 +2102,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 @@ -2169,7 +2169,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 @@ -2188,12 +2188,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 ] @@ -2320,7 +2320,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 @@ -2388,7 +2388,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 @@ -2475,7 +2475,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 @@ -2580,8 +2580,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). @@ -2629,7 +2629,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) @@ -2680,7 +2680,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(".") -> @@ -2745,7 +2745,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 @@ -2831,7 +2831,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)) @@ -2887,7 +2887,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 @@ -2959,14 +2959,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 @@ -3022,7 +3022,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 @@ -3097,7 +3097,7 @@ let ``Test Project22 IList contents`` () = let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() - |> Async.RunSynchronously + let ilistTypeUse = allUsesOfAllSymbols @@ -3179,7 +3179,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 @@ -3238,7 +3238,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 @@ -3305,11 +3305,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 @@ -3414,7 +3414,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 @@ -3521,7 +3521,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 @@ -3606,13 +3606,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)))|] @@ -3669,7 +3669,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 @@ -3705,13 +3705,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)))|] @@ -3728,13 +3728,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)))|] @@ -3748,13 +3748,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)))|] @@ -3800,11 +3800,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) = @@ -4031,7 +4031,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 = @@ -4088,7 +4088,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 = @@ -4102,7 +4102,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 = @@ -4151,7 +4151,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") @@ -4173,7 +4173,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 = @@ -4200,7 +4200,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") @@ -4217,7 +4217,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 = @@ -4275,11 +4275,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 @@ -4294,11 +4294,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 @@ -4338,7 +4338,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 @@ -4438,7 +4438,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) @@ -4590,7 +4590,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) @@ -4703,7 +4703,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 -> @@ -4757,7 +4757,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(".") -> @@ -4931,7 +4931,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 @@ -5006,7 +5006,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)), []); @@ -5076,7 +5076,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/CodeFix/ReplaceWithSuggestion.fs b/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs index 628508e76b6..0c62b1a884d 100644 --- a/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs +++ b/vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs @@ -45,7 +45,7 @@ type internal FSharpReplaceWithSuggestionCodeFixProvider let fcsCaretLineNumber = Line.fromZ caretLinePos.Line let partialName = QuickParse.GetPartialLongNameEx(caretLine.ToString(), caretLinePos.Character - 1) - let! declInfo = checkFileResults.GetDeclarationListInfo(Some parseFileResults, fcsCaretLineNumber, caretLine.ToString(), partialName, userOpName=userOpName) |> liftAsync + let declInfo = checkFileResults.GetDeclarationListInfo(Some parseFileResults, fcsCaretLineNumber, caretLine.ToString(), partialName) let addNames (addToBuffer:string -> unit) = for item in declInfo.Items do addToBuffer item.Name 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/CompletionProvider.fs b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs index acca943c970..312a7684427 100644 --- a/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs +++ b/vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs @@ -122,8 +122,8 @@ type internal FSharpCompletionProvider |> List.filter (fun assemblySymbol -> assemblySymbol.FullName.Contains "." && not (PrettyNaming.IsOperatorName assemblySymbol.Symbol.DisplayName)) - let! declarations = checkFileResults.GetDeclarationListInfo(Some(parseResults), fcsCaretLineNumber, caretLine.ToString(), - partialName, getAllSymbols, userOpName=userOpName) |> liftAsync + let declarations = checkFileResults.GetDeclarationListInfo(Some(parseResults), fcsCaretLineNumber, caretLine.ToString(), + partialName, getAllSymbols) let results = List() declarationItems <- 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..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 = @@ -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..76b3c7b36d0 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,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 @@ -453,7 +418,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 +453,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 +496,7 @@ 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() -> []), 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 +556,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 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)