Skip to content
This repository was archived by the owner on Oct 31, 2021. It is now read-only.

Commit 822253d

Browse files
MessageRouter
1 parent 5d838e4 commit 822253d

File tree

7 files changed

+97
-19
lines changed

7 files changed

+97
-19
lines changed

src/FSharp.Editing.Messages/Messages.fs

+20-7
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@ type Project =
1010
ReferencedProjects: FilePath list
1111
CompilerOptions: string list }
1212

13+
[<RequireQualifiedAccess>]
1314
type ServerCapability =
1415
| SyntaxHighlighting
1516
| HighlighIdentifier
1617
| ImplementInterface
1718

18-
type SyntaxHighlightingInfo =
19-
{ ClassificationRanges: unit list }
20-
21-
type ServerNotification =
22-
| SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo
23-
2419
type ClientCallbackAddress = string
2520

21+
[<RequireQualifiedAccess>]
2622
type ClientNotification =
2723
/// Reset all server state.
2824
| Reset
@@ -45,4 +41,21 @@ type ClientRequest =
4541
{ RequestId: RequestId }
4642

4743
type ServerResponse =
48-
{ RequestId: RequestId }
44+
{ RequestId: RequestId }
45+
46+
[<RequireQualifiedAccess>]
47+
type ClientMessage =
48+
| Request of ClientRequest
49+
| Notification of ClientNotification
50+
51+
type SyntaxHighlightingInfo =
52+
{ ClassificationRanges: unit list }
53+
54+
[<RequireQualifiedAccess>]
55+
type ServerNotification =
56+
| SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo
57+
58+
[<RequireQualifiedAccess>]
59+
type ServerMessage =
60+
| Response of ServerResponse
61+
| Notification of ServerNotification

src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj

+33-8
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
<Import Project="$(FSharpTargetsPath)" />
5858
<ItemGroup>
5959
<Compile Include="AssemblyInfo.fs" />
60-
<Compile Include="Library1.fs" />
60+
<Compile Include="Utilites.fs" />
61+
<Compile Include="ProjectSystem.fs" />
62+
<Compile Include="MessageRouter.fs" />
6163
<None Include="paket.references" />
6264
</ItemGroup>
6365
<ItemGroup>
@@ -66,6 +68,36 @@
6668
<Reference Include="System.Core" />
6769
<Reference Include="System.Numerics" />
6870
</ItemGroup>
71+
<ItemGroup>
72+
<ProjectReference Include="..\FSharp.Editing.Messages\FSharp.Editing.Messages.fsproj">
73+
<Name>FSharp.Editing.Messages</Name>
74+
<Project>{90b29f03-2cd0-4265-b06d-851dc045d62b}</Project>
75+
<Private>True</Private>
76+
</ProjectReference>
77+
<ProjectReference Include="..\FSharp.Editing\FSharp.Editing.fsproj">
78+
<Name>FSharp.Editing</Name>
79+
<Project>{f3d0b372-3af7-49d9-98ed-5a78e9416098}</Project>
80+
<Private>True</Private>
81+
</ProjectReference>
82+
</ItemGroup>
83+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
84+
Other similar extension points exist, see Microsoft.Common.targets.
85+
<Target Name="BeforeBuild">
86+
</Target>
87+
<Target Name="AfterBuild">
88+
</Target>
89+
-->
90+
<Choose>
91+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
92+
<ItemGroup>
93+
<Reference Include="FSharp.Compiler.Service">
94+
<HintPath>..\..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath>
95+
<Private>True</Private>
96+
<Paket>True</Paket>
97+
</Reference>
98+
</ItemGroup>
99+
</When>
100+
</Choose>
69101
<Choose>
70102
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v3.0' Or $(TargetFrameworkVersion) == 'v3.5')">
71103
<ItemGroup>
@@ -131,11 +163,4 @@
131163
</ItemGroup>
132164
</When>
133165
</Choose>
134-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
135-
Other similar extension points exist, see Microsoft.Common.targets.
136-
<Target Name="BeforeBuild">
137-
</Target>
138-
<Target Name="AfterBuild">
139-
</Target>
140-
-->
141166
</Project>

src/FSharp.Editing.Server/Library1.fs

-4
This file was deleted.
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace FSharp.Editing.Server
2+
3+
open FSharp.Editing.Messages
4+
5+
module MessageRouter =
6+
let start() =
7+
let agent = MailboxProcessor.Start <| fun mb ->
8+
let rec loop() =
9+
async {
10+
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()
18+
19+
}
20+
loop()
21+
22+
agent.Error.Add <| fun e -> Logger.error "%O" e
23+
agent.Post
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FSharp.Editing.Server
2+
3+
open FSharp.Editing
4+
5+
type Project =
6+
{ FilePath: FilePath }
7+
8+
type Solution =
9+
{ Projects: Map<FilePath, Project> }

src/FSharp.Editing.Server/Utilites.fs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[<AutoOpen>]
2+
module FSharp.Editing.Server.Utilites
3+
4+
open System
5+
6+
module Logger =
7+
open Microsoft.FSharp.Core.Printf
8+
9+
let debug msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [DEBUG] " + x)) msg
10+
let info msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [INFO] " + x)) msg
11+
let error msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [ERROR] " + x)) msg
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
FSharp.Core
2+
FSharp.Compiler.Service

0 commit comments

Comments
 (0)