diff options
author | nosami <jasonimison@gmail.com> | 2019-06-05 14:15:19 +0300 |
---|---|---|
committer | nosami <jasonimison@gmail.com> | 2019-06-05 14:15:19 +0300 |
commit | 57a86f52a7c8ecefa2e9a3f51aaef4dfd38fe364 (patch) | |
tree | dfb15e127d64555e1e51f9afe7a8fb7b98252e2d /main/external/fsharpbinding | |
parent | 8930618531b2091a02040a342185473e4ab3bc42 (diff) |
Remove usage of GetTypedParseResultWithTimeout
Fixes VSTS #904300
Diffstat (limited to 'main/external/fsharpbinding')
-rw-r--r-- | main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs | 14 | ||||
-rw-r--r-- | main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs | 24 |
2 files changed, 22 insertions, 16 deletions
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs index 3cac905401..14a63bd70e 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs @@ -27,11 +27,14 @@ type HighlightUsagesExtension() = LoggingService.logDebug "HighlightUsagesExtension: ResolveAsync starting on %s" (x.DocumentContext.Name |> IO.Path.GetFileName ) try let line, col, lineStr = x.Editor.GetLineInfoByCaretOffset () - let currentFile = x.DocumentContext.Name - let source = x.Editor.Text - let projectFile = x.DocumentContext.Project |> function null -> currentFile | project -> project.FileName.ToString() - let! symbolReferences = languageService.GetUsesOfSymbolAtLocationInFile (projectFile, currentFile, 0, source, line, col, lineStr) - return symbolReferences + let parseAndCheckResults = x.DocumentContext.TryGetAst() + + match parseAndCheckResults with + | Some results -> + let currentFile = x.DocumentContext.Name + return! results.GetUsesOfSymbolAtLocationInFile (currentFile, line, col, lineStr) + | None -> + return None with | :? TaskCanceledException -> return None | exn -> LoggingService.LogError("Unhandled Exception in F# HighlightingUsagesExtension", exn) @@ -56,6 +59,7 @@ type HighlightUsagesExtension() = let start, finish = Symbol.trimSymbolRegion symbolUse fsSymbolName let startOffset = snapshot.LocationToOffset (start.Line, start.Column+1) let endOffset = snapshot.LocationToOffset (finish.Line, finish.Column+1) + let referenceType = if symbolUse.IsFromDefinition then ReferenceUsageType.Declaration diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs index ecb23511cc..474bcb0645 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs @@ -171,6 +171,19 @@ type ParseAndCheckResults (infoOpt : FSharpCheckFileResults option, parseResults | Some checkResults -> Some(checkResults.GetFormatSpecifierLocationsAndArity()) | None -> None + /// Get all the uses of a symbol in the given file + member x.GetUsesOfSymbolAtLocationInFile(fileName, line, col, lineStr) = + asyncMaybe { + LoggingService.logDebug "LanguageService: GetUsesOfSymbolAtLocationInFile: file:%s, line:%i, col:%i" (Path.GetFileName(fileName)) line col + let! colu, identIsland = MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent |> async.Return + let! results = infoOpt |> async.Return + let! symbolUse = results.GetSymbolUseAtLocation(line, colu, lineStr, identIsland) + let! symbolUse = x.GetSymbolAtLocation(line, col, lineStr) + let lastIdent = Seq.last identIsland + let! refs = results.GetUsesOfSymbolInFile(symbolUse.Symbol) |> Async.map Some + return (lastIdent, refs) + } + [<RequireQualifiedAccess>] type AllowStaleResults = // Allow checker results where the source doesn't even match @@ -499,17 +512,6 @@ type LanguageService(dirtyNotify, _extraProjectInfo) as x = LoggingService.logDebug "LanguageService: GetTypedParseResultIfAvailable: file=%s" (Path.GetFileName(fileName)) options |> Option.bind(fun opts -> x.TryGetStaleTypedParseResult(fileName, opts, src, stale)) - /// Get all the uses of a symbol in the given file (using 'source' as the source for the file) - member x.GetUsesOfSymbolAtLocationInFile(projectFilename, fileName, version, source, line:int, col, lineStr) = - asyncMaybe { - LoggingService.logDebug "LanguageService: GetUsesOfSymbolAtLocationInFile: file:%s, line:%i, col:%i" (Path.GetFileName(fileName)) line col - let! _colu, identIsland = MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent |> async.Return - let! results = x.GetTypedParseResultWithTimeout(projectFilename, fileName, version, source, AllowStaleResults.MatchingSource) - let! symbolUse = results.GetSymbolAtLocation(line, col, lineStr) - let lastIdent = Seq.last identIsland - let! refs = results.GetUsesOfSymbolInFile(symbolUse.Symbol) |> Async.map Some - return (lastIdent, refs) } - member x.GetSymbolAtLocationInFile(projectFilename, fileName, version, source, line:int, col, lineStr) = asyncMaybe { LoggingService.logDebug "LanguageService: GetUsesOfSymbolAtLocationInFile: file:%s, line:%i, col:%i" (Path.GetFileName(fileName)) line col |