diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 3f8e24bad78..a137d2a5b53 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -1536,6 +1536,18 @@ type internal TypeCheckInfo member scope.IsRelativeNameResolvableFromSymbol(cursorPos: pos, plid: string list, symbol: FSharpSymbol) : bool = scope.IsRelativeNameResolvable(cursorPos, plid, symbol.Item) + member scope.TryGetExpressionType(range) = + sResolutions.CapturedExpressionTypings + |> Seq.tryFindBack (fun (_, _, _, m) -> equals m range) + |> Option.map (fun (ty, _, _, _) -> FSharpType (cenv, ty)) + + member scope.GetExpressionDisplayContext(range) = + sResolutions.CapturedExpressionTypings + |> Seq.tryFindBack (fun (_, _, _, m) -> equals m range) + |> Option.map (fun (_, q, _, _) -> FSharpDisplayContext(fun _ -> q.DisplayEnv)) + + + /// Get the auto-complete items at a location member _.GetDeclarations(parseResultsOpt, line, lineStr, partialName, completionContextAtPos, getAllEntities) = let isSigFile = SourceFileImpl.IsSignatureFile mainInputFileName @@ -2887,6 +2899,16 @@ type FSharpCheckFileResults member _.DependencyFiles = dependencyFiles + member _.GetTypeOfExpression(range: range) = + match details with + | None -> None + | Some(scope, _) -> scope.TryGetExpressionType(range) + + member _.GetExpressionDisplayContext(range: range) = + match details with + | None -> None + | Some(scope, _) -> scope.GetExpressionDisplayContext(range) + member _.GetAllUsesOfAllSymbolsInFile(?cancellationToken: CancellationToken) = match details with | None -> Seq.empty diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index 3233fe0bece..c96b453f3c2 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -271,6 +271,9 @@ type public FSharpCheckFileResults = /// in the documentation for compiler service. member DependencyFiles: string[] + member GetTypeOfExpression: range -> FSharpType option + member GetExpressionDisplayContext: range -> FSharpDisplayContext option + /// Get the items for a declaration list /// ///