Skip to content

Commit

Permalink
Fixing incoming call typechecks
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Oct 4, 2023
1 parent 43f3fce commit 0d51159
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type LoadedProject =

member x.SourceFiles = x.FSharpProjectOptions.SourceFiles
member x.ProjectFileName = x.FSharpProjectOptions.ProjectFileName
static member op_Implicit(x : LoadedProject) = x.FSharpProjectOptions


type AdaptiveFSharpLspServer
Expand Down Expand Up @@ -1336,7 +1337,7 @@ type AdaptiveFSharpLspServer

/// Bypass Adaptive checking and tell the checker to check a file
let bypassAdaptiveTypeCheck (filePath: string<LocalPath>) opts =
async {
asyncResult {
try
logger.info (
Log.setMessage "Forced Check : {file}"
Expand All @@ -1345,17 +1346,18 @@ type AdaptiveFSharpLspServer

let checker = checker |> AVal.force

match! forceFindOpenFileOrRead filePath with
let! fileInfo = forceFindOpenFileOrRead filePath
// Don't cache for autocompletions as we really only want to cache "Opened" files.
| Ok(fileInfo) -> return! parseAndCheckFile checker fileInfo opts false |> Async.Ignore
| _ -> ()
return! parseAndCheckFile checker fileInfo opts false

with e ->

logger.warn (
Log.setMessage "Forced Check error : {file}"
>> Log.addContextDestructured "file" filePath
>> Log.addExn e
)
return! Error (e.ToString())
}


Expand Down Expand Up @@ -4018,7 +4020,9 @@ type AdaptiveFSharpLspServer
let pos = protocolPosToPos p.Item.SelectionRange.Start
let! volatileFile = forceFindOpenFileOrRead filePath |> AsyncResult.ofStringErr
let! lineStr = tryGetLineStr pos volatileFile.Source |> Result.ofStringErr
and! tyRes = forceGetTypeCheckResults filePath |> AsyncResult.ofStringErr
and! opts = forceGetProjectOptions filePath |> AsyncResult.ofStringErr
// Incoming file may not be "Opened" so we need to force a typecheck
let! tyRes = bypassAdaptiveTypeCheck filePath opts |> AsyncResult.ofStringErr


let! usages =
Expand Down Expand Up @@ -4051,7 +4055,7 @@ type AdaptiveFSharpLspServer
{ Name = name
Kind = (AVal.force glyphToSymbolKind) glyph |> Option.defaultValue SymbolKind.Method
Tags = None
Detail = None
Detail = Some (sprintf $"From {Path.GetFileName (UMX.untag fn)}")
Uri = loc.Uri
Range = fcsRangeToLsp fullBindingRange
SelectionRange = fcsRangeToLsp endRange.idRange
Expand Down
4 changes: 2 additions & 2 deletions test/FsAutoComplete.Tests.Lsp/CallHierarchyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let incomingTests createServer =
|]
From = {
Data = None
Detail = None
Detail = Some "From Example1.fsx"
Kind = SymbolKind.Function
Name = "foo"
Range = LspRange.create 6 12 8 18
Expand All @@ -91,6 +91,6 @@ let incomingTests createServer =


let tests createServer =
testList "CallHierarchy" [
ftestList "CallHierarchy" [
incomingTests createServer
]

0 comments on commit 0d51159

Please sign in to comment.