Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add change tracking for projects #659

Merged
merged 1 commit into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -838,17 +838,17 @@ type Commands<'analyzer> (serialize : Serializer, backgroundServiceEnabled) =
return CoreResponse.Res d
}

member x.WorkspaceLoad onChange (files: string list) (disableInMemoryProjectReferences: bool) tfmForScripts (generateBinlog: bool) = async {
member x.WorkspaceLoad (files: string list) (disableInMemoryProjectReferences: bool) tfmForScripts (generateBinlog: bool) = async {
commandsLogger.info (Log.setMessage "Workspace loading started '{files}'" >> Log.addContextDestructured "files" files)
checker.DisableInMemoryProjectReferences <- disableInMemoryProjectReferences
let! res = state.ProjectController.LoadWorkspace onChange files tfmForScripts onProjectLoaded generateBinlog
let! res = state.ProjectController.LoadWorkspace files tfmForScripts onProjectLoaded generateBinlog
commandsLogger.info (Log.setMessage "Workspace loading finished ")
return CoreResponse.Res res
}

member x.Project onChange projectFileName tfmForScripts (generateBinlog: bool) = async {
member x.Project projectFileName tfmForScripts (generateBinlog: bool) = async {
commandsLogger.info (Log.setMessage "Project loading '{file}'" >> Log.addContextDestructured "file" projectFileName)
let! res = state.ProjectController.LoadProject onChange projectFileName tfmForScripts onProjectLoaded generateBinlog
let! res = state.ProjectController.LoadProject projectFileName tfmForScripts onProjectLoaded generateBinlog
return CoreResponse.Res res
}

Expand Down
8 changes: 4 additions & 4 deletions src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,15 @@ type FsharpLspServer(commands: Commands, lspClient: FSharpLspClient) =
match peeks with
| [] -> ()
| [CommandResponse.WorkspacePeekFound.Directory projs] ->
commands.WorkspaceLoad ignore projs.Fsprojs false config.ScriptTFM config.GenerateBinlog
commands.WorkspaceLoad projs.Fsprojs false config.ScriptTFM config.GenerateBinlog
|> Async.Ignore
|> Async.Start
| CommandResponse.WorkspacePeekFound.Solution sln::_ ->
let projs =
sln.Items
|> List.collect Workspace.foldFsproj
|> List.map fst
commands.WorkspaceLoad ignore projs false config.ScriptTFM config.GenerateBinlog
commands.WorkspaceLoad projs false config.ScriptTFM config.GenerateBinlog
|> Async.Ignore
|> Async.Start
| _ ->
Expand Down Expand Up @@ -1805,7 +1805,7 @@ type FsharpLspServer(commands: Commands, lspClient: FSharpLspClient) =
logger.info (Log.setMessage "FSharpWorkspaceLoad Request: {parms}" >> Log.addContextDestructured "parms" p )

let fns = p.TextDocuments |> Array.map (fun fn -> fn.GetFilePath() ) |> Array.toList
let! res = commands.WorkspaceLoad ignore fns config.DisableInMemoryProjectReferences config.ScriptTFM config.GenerateBinlog
let! res = commands.WorkspaceLoad fns config.DisableInMemoryProjectReferences config.ScriptTFM config.GenerateBinlog
let res =
match res with
| CoreResponse.InfoRes msg | CoreResponse.ErrorRes msg ->
Expand Down Expand Up @@ -1836,7 +1836,7 @@ type FsharpLspServer(commands: Commands, lspClient: FSharpLspClient) =
logger.info (Log.setMessage "FSharpProject Request: {parms}" >> Log.addContextDestructured "parms" p )

let fn = p.Project.GetFilePath()
let! res = commands.Project ignore fn config.ScriptTFM config.GenerateBinlog
let! res = commands.Project fn config.ScriptTFM config.GenerateBinlog
let res =
match res with
| CoreResponse.InfoRes msg | CoreResponse.ErrorRes msg ->
Expand Down
15 changes: 10 additions & 5 deletions src/ProjectSystem/ProjectSystem.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type ProjectController(checker : FSharpChecker) =

member private x.LoaderLoop = MailboxProcessor.Start(fun agent ->
let rec loop () = async {
let! ((oc, fn, tfm, ol, gb), reply : AsyncReplyChannel<_>) = agent.Receive()
let! ((fn, tfm, ol, gb), reply : AsyncReplyChannel<_>) = agent.Receive()
let mutable wasInvoked = false
let! x =
Async.FromContinuations( fun (succ, err, cancl) ->
Expand All @@ -85,7 +85,7 @@ type ProjectController(checker : FSharpChecker) =
else
wasInvoked <- true
succ ()
x.LoadWorkspace oc [fn] tfm opl gb |> Async.Ignore |> Async.Start
x.LoadWorkspace [fn] tfm opl gb |> Async.Ignore |> Async.Start
)

reply.Reply true
Expand Down Expand Up @@ -127,14 +127,19 @@ type ProjectController(checker : FSharpChecker) =
projects
|> Seq.map (|KeyValue|)

member x.LoadProject onChange projectFileName (tfmForScripts: FSIRefs.TFM) onProjectLoaded (generateBinlog: bool) =
x.LoaderLoop.PostAndAsyncReply(fun acr -> (onChange, projectFileName, tfmForScripts, onProjectLoaded, generateBinlog ), acr )
member x.LoadProject projectFileName (tfmForScripts: FSIRefs.TFM) onProjectLoaded (generateBinlog: bool) =
x.LoaderLoop.PostAndAsyncReply(fun acr -> (projectFileName, tfmForScripts, onProjectLoaded, generateBinlog ), acr )


member __.LoadWorkspace onChange (files: string list) (tfmForScripts: FSIRefs.TFM) onProjectLoaded (generateBinlog: bool) = async {
member x.LoadWorkspace (files: string list) (tfmForScripts: FSIRefs.TFM) onProjectLoaded (generateBinlog: bool) = async {
//TODO check full path
let projectFileNames = files |> List.map Path.GetFullPath

let onChange fn =
x.LoadProject fn tfmForScripts onProjectLoaded generateBinlog
|> Async.Ignore
|> Async.Start

let prjs =
projectFileNames
|> List.map (fun projectFileName -> projectFileName, new Project(projectFileName, onChange))
Expand Down