This repository was archived by the owner on Oct 31, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +45
-11
lines changed Expand file tree Collapse file tree 6 files changed +45
-11
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ type ClientNotification =
3636 | DocumentChanged of FilePath * DocumentContent
3737 /// Client subscribing on a set of server notifications, passing an address to which them should be sent.
3838 | Subscribe of Set < ServerCapability > * ClientCallbackAddress
39+ | CancelRequest of RequestId
3940
4041type ClientRequest =
4142 { RequestId: RequestId }
Original file line number Diff line number Diff line change 1+ namespace FSharp.Editing.Server
2+
3+ open FSharp.Editing
4+
5+ [<NoComparison>]
6+ type Context =
7+ { Solution: Solution
8+ LanguageService: LanguageService }
9+
Original file line number Diff line number Diff line change 5959 <Compile Include =" AssemblyInfo.fs" />
6060 <Compile Include =" Utilites.fs" />
6161 <Compile Include =" ProjectSystem.fs" />
62+ <Compile Include =" Context.fs" />
6263 <Compile Include =" MessageRouter.fs" />
6364 <None Include =" paket.references" />
6465 </ItemGroup >
Original file line number Diff line number Diff line change @@ -5,19 +5,25 @@ open FSharp.Editing.Messages
55module MessageRouter =
66 let start () =
77 let agent = MailboxProcessor.Start <| fun mb ->
8- let rec loop () =
8+ let rec loop ctx =
99 async {
1010 let! message = mb.Receive()
11- match message with
12- | ClientMessage.Notification _ x ->
13- //dispatchClientNotification x
14- return ! loop()
15- | ClientMessage.Request _ x ->
16- //dispatchClientRequest x
17- return ! loop()
11+ match ctx with
12+ | Some ctx ->
13+ match message with
14+ | ClientMessage.Notification _ x ->
15+ //match x with
16+ //| ClientNotification.ProjectLoaded project ->
17+ // return! loop (Some { ctx with Solution = ctx.Solution |> Solution.addOrUpdateProject project })
18+ //dispatchClientNotification x
19+ return ! loop ( Some ctx)
20+ | ClientMessage.Request _ x ->
21+ //dispatchClientRequest x
22+ return ! loop ( Some ctx)
23+ | None -> failwith " No solution opened."
1824
1925 }
20- loop()
26+ loop None
2127
2228 agent.Error.Add <| fun e -> Logger.error " %O " e
2329 agent.Post
Original file line number Diff line number Diff line change 11namespace FSharp.Editing.Server
22
33open FSharp.Editing
4+ open Microsoft.FSharp .Compiler .SourceCodeServices
45
6+ [<NoComparison>]
57type Project =
6- { FilePath: FilePath }
8+ { FilePath: FilePath
9+ CompilerOptions: FSharpProjectOptions }
710
11+ [<NoComparison>]
812type Solution =
9- { Projects: Map < FilePath , Project > }
13+ { FileName: FileName option
14+ Projects: Map < FilePath , Project > }
15+
16+ //[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
17+ //module Solution =
18+ //let addOrUpdateProject project solution =
19+ //{ solution with Projects = solution.Projects |> Map.add project }
Original file line number Diff line number Diff line change @@ -9,3 +9,10 @@ module Logger =
99 let debug msg = kprintf ( fun x -> Console.WriteLine (( string DateTime.Now) + " [DEBUG] " + x)) msg
1010 let info msg = kprintf ( fun x -> Console.WriteLine (( string DateTime.Now) + " [INFO] " + x)) msg
1111 let error msg = kprintf ( fun x -> Console.WriteLine (( string DateTime.Now) + " [ERROR] " + x)) msg
12+
13+ module Map =
14+ let addOrUpdate ( key : 'k ) ( newValue : unit -> 'v ) ( update : 'v -> 'v ) ( m : Map < 'k , 'v >) =
15+ match m |> Map.tryFind key with
16+ | Some oldV -> m |> Map.add key ( update oldV)
17+ | None -> m |> Map.add key ( newValue())
18+
You can’t perform that action at this time.
0 commit comments