From ff2c177a6d0d805cf0981bfe568f05a94be7c6d4 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Fri, 15 Jul 2016 19:29:33 +0300 Subject: [PATCH 1/5] add FSharp.Editing.Messages project --- FSharpVSPowerTools.sln | 6 + src/FSharp.Editing.Messages/AssemblyInfo.fs | 41 ++++++ .../FSharp.Editing.Messages.fsproj | 135 ++++++++++++++++++ src/FSharp.Editing.Messages/Messages.fs | 46 ++++++ src/FSharp.Editing.Messages/paket.references | 1 + 5 files changed, 229 insertions(+) create mode 100644 src/FSharp.Editing.Messages/AssemblyInfo.fs create mode 100644 src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj create mode 100644 src/FSharp.Editing.Messages/Messages.fs create mode 100644 src/FSharp.Editing.Messages/paket.references diff --git a/FSharpVSPowerTools.sln b/FSharpVSPowerTools.sln index fd44e1a5..fa3e7ec7 100644 --- a/FSharpVSPowerTools.sln +++ b/FSharpVSPowerTools.sln @@ -60,6 +60,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editing.VisualStudio EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editing.VisualStudio.Tests", "tests\FSharp.Editing.VisualStudio.Tests\FSharp.Editing.VisualStudio.Tests.fsproj", "{CA2902E0-5E1C-46EE-963D-D72BC3B6EFAA}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editing.Messages", "src\FSharp.Editing.Messages\FSharp.Editing.Messages.fsproj", "{90B29F03-2CD0-4265-B06D-851DC045D62B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -94,6 +96,10 @@ Global {CA2902E0-5E1C-46EE-963D-D72BC3B6EFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {CA2902E0-5E1C-46EE-963D-D72BC3B6EFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {CA2902E0-5E1C-46EE-963D-D72BC3B6EFAA}.Release|Any CPU.Build.0 = Release|Any CPU + {90B29F03-2CD0-4265-B06D-851DC045D62B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90B29F03-2CD0-4265-B06D-851DC045D62B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90B29F03-2CD0-4265-B06D-851DC045D62B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90B29F03-2CD0-4265-B06D-851DC045D62B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/FSharp.Editing.Messages/AssemblyInfo.fs b/src/FSharp.Editing.Messages/AssemblyInfo.fs new file mode 100644 index 00000000..f0081c7d --- /dev/null +++ b/src/FSharp.Editing.Messages/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace FSharp.Editing.Messages.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj b/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj new file mode 100644 index 00000000..dab5b67d --- /dev/null +++ b/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj @@ -0,0 +1,135 @@ + + + + + Debug + AnyCPU + 2.0 + 90b29f03-2cd0-4265-b06d-851dc045d62b + Library + FSharp.Editing.Messages + FSharp.Editing.Messages + v4.5 + 4.4.0.0 + true + FSharp.Editing.Messages + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\FSharp.Editing.Messages.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\FSharp.Editing.Messages.XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + + + + + + + + ..\..\packages\FSharp.Core\lib\net20\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\net40\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+netcore45\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wp8\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + True + True + + + + + + \ No newline at end of file diff --git a/src/FSharp.Editing.Messages/Messages.fs b/src/FSharp.Editing.Messages/Messages.fs new file mode 100644 index 00000000..4cb41a02 --- /dev/null +++ b/src/FSharp.Editing.Messages/Messages.fs @@ -0,0 +1,46 @@ +namespace FSharp.Editing.Messages + +type [] requestId +type RequestId = int64 +type FilePath = string +type DocumentContent = string + +type Project = + { FileName: FilePath + Files: FilePath list + ReferencedProjects: FilePath list + CompilerOptions: string list } + +type ServerCapability = + | SyntaxHighlighting + | HighlighIdentifier + | ImplementInterface + +type ClientNotification = + /// New solution loaded or new folder opened. All server state should be discarded. + | Cleanup + /// A new project loaded or a known project changed in any way (name, file list, references, etc.) + | ProjectLoaded of Project + /// Previously loaded project was unloaded from IDE or deleted from disk so it should not be part of solution anymore. + | ProjectUnloaded + /// Document opened in an IDE for the first time. No need to send its content since server can read it from disk. + | DocumentOpened of file: FilePath + /// Document closed. Server can stop tracking its content in a special way and just read it from disk. + | DocumentClosed of file: FilePath + | DocumentRenamed of oldFile: FilePath * newFile: FilePath + /// Opened document changed in IDE without saving to disk. Full new content should be sent + /// (for now. Later we can add incremental changes support). + | DocumentChanged of file: FilePath * content: DocumentContent + | Subscribe of ServerCapability Set + +type SyntaxHighlightingInfo = + { ClassificationRanges: unit list } + +type ServerNotification = + | SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo + +type RequestMessage = + { RequestId: RequestId } + +type ResponseMessage = + { RequestId: RequestId } \ No newline at end of file diff --git a/src/FSharp.Editing.Messages/paket.references b/src/FSharp.Editing.Messages/paket.references new file mode 100644 index 00000000..3a01785e --- /dev/null +++ b/src/FSharp.Editing.Messages/paket.references @@ -0,0 +1 @@ +FSharp.Core \ No newline at end of file From baff136337dcb6053393e83a505e0db846500942 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Fri, 15 Jul 2016 21:16:13 +0300 Subject: [PATCH 2/5] cosmetics --- src/FSharp.Editing.Messages/Messages.fs | 33 ++++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/FSharp.Editing.Messages/Messages.fs b/src/FSharp.Editing.Messages/Messages.fs index 4cb41a02..1493a18a 100644 --- a/src/FSharp.Editing.Messages/Messages.fs +++ b/src/FSharp.Editing.Messages/Messages.fs @@ -16,31 +16,34 @@ type ServerCapability = | HighlighIdentifier | ImplementInterface +type SyntaxHighlightingInfo = + { ClassificationRanges: unit list } + +type ServerNotification = + | SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo + +type ClientCallbackAddress = string + type ClientNotification = - /// New solution loaded or new folder opened. All server state should be discarded. - | Cleanup + /// Reset all server state. + | Reset /// A new project loaded or a known project changed in any way (name, file list, references, etc.) | ProjectLoaded of Project /// Previously loaded project was unloaded from IDE or deleted from disk so it should not be part of solution anymore. - | ProjectUnloaded + | ProjectUnloaded of FilePath /// Document opened in an IDE for the first time. No need to send its content since server can read it from disk. - | DocumentOpened of file: FilePath + | DocumentOpened of FilePath /// Document closed. Server can stop tracking its content in a special way and just read it from disk. - | DocumentClosed of file: FilePath + | DocumentClosed of FilePath | DocumentRenamed of oldFile: FilePath * newFile: FilePath /// Opened document changed in IDE without saving to disk. Full new content should be sent /// (for now. Later we can add incremental changes support). - | DocumentChanged of file: FilePath * content: DocumentContent - | Subscribe of ServerCapability Set - -type SyntaxHighlightingInfo = - { ClassificationRanges: unit list } - -type ServerNotification = - | SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo + | DocumentChanged of FilePath * DocumentContent + /// Client subscribing on a set of server notifications, passing an address to which them should be sent. + | Subscribe of Set * ClientCallbackAddress -type RequestMessage = +type ClientRequest = { RequestId: RequestId } -type ResponseMessage = +type ServerResponse = { RequestId: RequestId } \ No newline at end of file From 110e73dd249b45e5a3bd78c4039fe097ae185921 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Fri, 15 Jul 2016 21:46:16 +0300 Subject: [PATCH 3/5] add FSharp.Editing.Server project --- FSharpVSPowerTools.sln | 6 + .../FSharp.Editing.Messages.fsproj | 21 +-- src/FSharp.Editing.Messages/Messages.fs | 3 +- src/FSharp.Editing.Server/AssemblyInfo.fs | 41 +++++ .../FSharp.Editing.Server.fsproj | 141 ++++++++++++++++++ src/FSharp.Editing.Server/Library1.fs | 4 + src/FSharp.Editing.Server/paket.references | 1 + 7 files changed, 206 insertions(+), 11 deletions(-) create mode 100644 src/FSharp.Editing.Server/AssemblyInfo.fs create mode 100644 src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj create mode 100644 src/FSharp.Editing.Server/Library1.fs create mode 100644 src/FSharp.Editing.Server/paket.references diff --git a/FSharpVSPowerTools.sln b/FSharpVSPowerTools.sln index fa3e7ec7..1a45cf2d 100644 --- a/FSharpVSPowerTools.sln +++ b/FSharpVSPowerTools.sln @@ -62,6 +62,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editing.VisualStudio EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editing.Messages", "src\FSharp.Editing.Messages\FSharp.Editing.Messages.fsproj", "{90B29F03-2CD0-4265-B06D-851DC045D62B}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editing.Server", "src\FSharp.Editing.Server\FSharp.Editing.Server.fsproj", "{E086BE6B-6187-4288-9EE4-DC98D8A16742}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -100,6 +102,10 @@ Global {90B29F03-2CD0-4265-B06D-851DC045D62B}.Debug|Any CPU.Build.0 = Debug|Any CPU {90B29F03-2CD0-4265-B06D-851DC045D62B}.Release|Any CPU.ActiveCfg = Release|Any CPU {90B29F03-2CD0-4265-B06D-851DC045D62B}.Release|Any CPU.Build.0 = Release|Any CPU + {E086BE6B-6187-4288-9EE4-DC98D8A16742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E086BE6B-6187-4288-9EE4-DC98D8A16742}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E086BE6B-6187-4288-9EE4-DC98D8A16742}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E086BE6B-6187-4288-9EE4-DC98D8A16742}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj b/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj index dab5b67d..243334a3 100644 --- a/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj +++ b/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj @@ -21,7 +21,7 @@ false bin\Debug\ DEBUG;TRACE - 3 + 5 bin\Debug\FSharp.Editing.Messages.XML @@ -30,8 +30,11 @@ true bin\Release\ TRACE - 3 + 5 bin\Release\FSharp.Editing.Messages.XML + true + + --warnon:1182 11 @@ -60,6 +63,13 @@ + @@ -125,11 +135,4 @@ - \ No newline at end of file diff --git a/src/FSharp.Editing.Messages/Messages.fs b/src/FSharp.Editing.Messages/Messages.fs index 1493a18a..bf0f4f1c 100644 --- a/src/FSharp.Editing.Messages/Messages.fs +++ b/src/FSharp.Editing.Messages/Messages.fs @@ -1,7 +1,6 @@ namespace FSharp.Editing.Messages -type [] requestId -type RequestId = int64 +type RequestId = Guid type FilePath = string type DocumentContent = string diff --git a/src/FSharp.Editing.Server/AssemblyInfo.fs b/src/FSharp.Editing.Server/AssemblyInfo.fs new file mode 100644 index 00000000..0901a1c7 --- /dev/null +++ b/src/FSharp.Editing.Server/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace FSharp.Editing.Server.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj new file mode 100644 index 00000000..335d61e9 --- /dev/null +++ b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj @@ -0,0 +1,141 @@ + + + + + Debug + AnyCPU + 2.0 + e086be6b-6187-4288-9ee4-dc98d8a16742 + Library + FSharp.Editing.Server + FSharp.Editing.Server + v4.5 + 4.4.0.0 + true + FSharp.Editing.Server + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 5 + + + --warnon:1182 + + + pdbonly + true + true + bin\Release\ + TRACE + 5 + + + true + + --warnon:1182 + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + + + + + + + + ..\..\packages\FSharp.Core\lib\net20\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\net40\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+netcore45\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wp8\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll + True + True + + + + + + + ..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + True + True + + + + + + \ No newline at end of file diff --git a/src/FSharp.Editing.Server/Library1.fs b/src/FSharp.Editing.Server/Library1.fs new file mode 100644 index 00000000..0fa51057 --- /dev/null +++ b/src/FSharp.Editing.Server/Library1.fs @@ -0,0 +1,4 @@ +namespace FSharp.Editing.Server + +type Class1() = + member this.X = "F#" diff --git a/src/FSharp.Editing.Server/paket.references b/src/FSharp.Editing.Server/paket.references new file mode 100644 index 00000000..e0b951f0 --- /dev/null +++ b/src/FSharp.Editing.Server/paket.references @@ -0,0 +1 @@ +FSharp.Core From 894fb0139eca2dec167323f321a1acb1a52b4668 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Fri, 15 Jul 2016 22:16:02 +0300 Subject: [PATCH 4/5] MessageRouter --- src/FSharp.Editing.Messages/Messages.fs | 27 ++++++++---- .../FSharp.Editing.Server.fsproj | 41 +++++++++++++++---- src/FSharp.Editing.Server/Library1.fs | 4 -- src/FSharp.Editing.Server/MessageRouter.fs | 23 +++++++++++ src/FSharp.Editing.Server/ProjectSystem.fs | 9 ++++ src/FSharp.Editing.Server/Utilites.fs | 11 +++++ src/FSharp.Editing.Server/paket.references | 1 + 7 files changed, 97 insertions(+), 19 deletions(-) delete mode 100644 src/FSharp.Editing.Server/Library1.fs create mode 100644 src/FSharp.Editing.Server/MessageRouter.fs create mode 100644 src/FSharp.Editing.Server/ProjectSystem.fs create mode 100644 src/FSharp.Editing.Server/Utilites.fs diff --git a/src/FSharp.Editing.Messages/Messages.fs b/src/FSharp.Editing.Messages/Messages.fs index bf0f4f1c..3b6fc958 100644 --- a/src/FSharp.Editing.Messages/Messages.fs +++ b/src/FSharp.Editing.Messages/Messages.fs @@ -10,19 +10,15 @@ type Project = ReferencedProjects: FilePath list CompilerOptions: string list } +[] type ServerCapability = | SyntaxHighlighting | HighlighIdentifier | ImplementInterface -type SyntaxHighlightingInfo = - { ClassificationRanges: unit list } - -type ServerNotification = - | SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo - type ClientCallbackAddress = string +[] type ClientNotification = /// Reset all server state. | Reset @@ -45,4 +41,21 @@ type ClientRequest = { RequestId: RequestId } type ServerResponse = - { RequestId: RequestId } \ No newline at end of file + { RequestId: RequestId } + +[] +type ClientMessage = + | Request of ClientRequest + | Notification of ClientNotification + +type SyntaxHighlightingInfo = + { ClassificationRanges: unit list } + +[] +type ServerNotification = + | SyntaxHighlightingChanged of file: FilePath * SyntaxHighlightingInfo + +[] +type ServerMessage = + | Response of ServerResponse + | Notification of ServerNotification \ No newline at end of file diff --git a/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj index 335d61e9..ca36c96c 100644 --- a/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj +++ b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj @@ -57,7 +57,9 @@ - + + + @@ -66,6 +68,36 @@ + + + FSharp.Editing.Messages + {90b29f03-2cd0-4265-b06d-851dc045d62b} + True + + + FSharp.Editing + {f3d0b372-3af7-49d9-98ed-5a78e9416098} + True + + + + + + + + ..\..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll + True + True + + + + @@ -131,11 +163,4 @@ - \ No newline at end of file diff --git a/src/FSharp.Editing.Server/Library1.fs b/src/FSharp.Editing.Server/Library1.fs deleted file mode 100644 index 0fa51057..00000000 --- a/src/FSharp.Editing.Server/Library1.fs +++ /dev/null @@ -1,4 +0,0 @@ -namespace FSharp.Editing.Server - -type Class1() = - member this.X = "F#" diff --git a/src/FSharp.Editing.Server/MessageRouter.fs b/src/FSharp.Editing.Server/MessageRouter.fs new file mode 100644 index 00000000..b7381aad --- /dev/null +++ b/src/FSharp.Editing.Server/MessageRouter.fs @@ -0,0 +1,23 @@ +namespace FSharp.Editing.Server + +open FSharp.Editing.Messages + +module MessageRouter = + let start() = + let agent = MailboxProcessor.Start <| fun mb -> + let rec loop() = + async { + let! message = mb.Receive() + match message with + | ClientMessage.Notification _x -> + //dispatchClientNotification x + return! loop() + | ClientMessage.Request _x -> + //dispatchClientRequest x + return! loop() + + } + loop() + + agent.Error.Add <| fun e -> Logger.error "%O" e + agent.Post \ No newline at end of file diff --git a/src/FSharp.Editing.Server/ProjectSystem.fs b/src/FSharp.Editing.Server/ProjectSystem.fs new file mode 100644 index 00000000..0fe63b99 --- /dev/null +++ b/src/FSharp.Editing.Server/ProjectSystem.fs @@ -0,0 +1,9 @@ +namespace FSharp.Editing.Server + +open FSharp.Editing + +type Project = + { FilePath: FilePath } + +type Solution = + { Projects: Map } \ No newline at end of file diff --git a/src/FSharp.Editing.Server/Utilites.fs b/src/FSharp.Editing.Server/Utilites.fs new file mode 100644 index 00000000..c086f928 --- /dev/null +++ b/src/FSharp.Editing.Server/Utilites.fs @@ -0,0 +1,11 @@ +[] +module FSharp.Editing.Server.Utilites + +open System + +module Logger = + open Microsoft.FSharp.Core.Printf + + let debug msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [DEBUG] " + x)) msg + let info msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [INFO] " + x)) msg + let error msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [ERROR] " + x)) msg diff --git a/src/FSharp.Editing.Server/paket.references b/src/FSharp.Editing.Server/paket.references index e0b951f0..24bacaf5 100644 --- a/src/FSharp.Editing.Server/paket.references +++ b/src/FSharp.Editing.Server/paket.references @@ -1 +1,2 @@ FSharp.Core +FSharp.Compiler.Service \ No newline at end of file From 7ff9da5ef3f4e982689ba63924885f1255482960 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Sun, 17 Jul 2016 17:40:30 +0300 Subject: [PATCH 5/5] Context --- src/FSharp.Editing.Messages/Messages.fs | 1 + src/FSharp.Editing.Server/Context.fs | 9 +++++++ .../FSharp.Editing.Server.fsproj | 1 + src/FSharp.Editing.Server/MessageRouter.fs | 24 ++++++++++++------- src/FSharp.Editing.Server/ProjectSystem.fs | 14 +++++++++-- src/FSharp.Editing.Server/Utilites.fs | 7 ++++++ 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 src/FSharp.Editing.Server/Context.fs diff --git a/src/FSharp.Editing.Messages/Messages.fs b/src/FSharp.Editing.Messages/Messages.fs index 3b6fc958..69beb523 100644 --- a/src/FSharp.Editing.Messages/Messages.fs +++ b/src/FSharp.Editing.Messages/Messages.fs @@ -36,6 +36,7 @@ type ClientNotification = | DocumentChanged of FilePath * DocumentContent /// Client subscribing on a set of server notifications, passing an address to which them should be sent. | Subscribe of Set * ClientCallbackAddress + | CancelRequest of RequestId type ClientRequest = { RequestId: RequestId } diff --git a/src/FSharp.Editing.Server/Context.fs b/src/FSharp.Editing.Server/Context.fs new file mode 100644 index 00000000..d7018e09 --- /dev/null +++ b/src/FSharp.Editing.Server/Context.fs @@ -0,0 +1,9 @@ +namespace FSharp.Editing.Server + +open FSharp.Editing + +[] +type Context = + { Solution: Solution + LanguageService: LanguageService } + diff --git a/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj index ca36c96c..eed32f12 100644 --- a/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj +++ b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj @@ -59,6 +59,7 @@ + diff --git a/src/FSharp.Editing.Server/MessageRouter.fs b/src/FSharp.Editing.Server/MessageRouter.fs index b7381aad..1ac53146 100644 --- a/src/FSharp.Editing.Server/MessageRouter.fs +++ b/src/FSharp.Editing.Server/MessageRouter.fs @@ -5,19 +5,25 @@ open FSharp.Editing.Messages module MessageRouter = let start() = let agent = MailboxProcessor.Start <| fun mb -> - let rec loop() = + let rec loop ctx = async { let! message = mb.Receive() - match message with - | ClientMessage.Notification _x -> - //dispatchClientNotification x - return! loop() - | ClientMessage.Request _x -> - //dispatchClientRequest x - return! loop() + match ctx with + | Some ctx -> + match message with + | ClientMessage.Notification _x -> + //match x with + //| ClientNotification.ProjectLoaded project -> + // return! loop (Some { ctx with Solution = ctx.Solution |> Solution.addOrUpdateProject project }) + //dispatchClientNotification x + return! loop (Some ctx) + | ClientMessage.Request _x -> + //dispatchClientRequest x + return! loop (Some ctx) + | None -> failwith "No solution opened." } - loop() + loop None agent.Error.Add <| fun e -> Logger.error "%O" e agent.Post \ No newline at end of file diff --git a/src/FSharp.Editing.Server/ProjectSystem.fs b/src/FSharp.Editing.Server/ProjectSystem.fs index 0fe63b99..72ca376f 100644 --- a/src/FSharp.Editing.Server/ProjectSystem.fs +++ b/src/FSharp.Editing.Server/ProjectSystem.fs @@ -1,9 +1,19 @@ namespace FSharp.Editing.Server open FSharp.Editing +open Microsoft.FSharp.Compiler.SourceCodeServices +[] type Project = - { FilePath: FilePath } + { FilePath: FilePath + CompilerOptions: FSharpProjectOptions } +[] type Solution = - { Projects: Map } \ No newline at end of file + { FileName: FileName option + Projects: Map } + +//[] +//module Solution = + //let addOrUpdateProject project solution = + //{ solution with Projects = solution.Projects |> Map.add project } \ No newline at end of file diff --git a/src/FSharp.Editing.Server/Utilites.fs b/src/FSharp.Editing.Server/Utilites.fs index c086f928..ab6ed28c 100644 --- a/src/FSharp.Editing.Server/Utilites.fs +++ b/src/FSharp.Editing.Server/Utilites.fs @@ -9,3 +9,10 @@ module Logger = let debug msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [DEBUG] " + x)) msg let info msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [INFO] " + x)) msg let error msg = kprintf (fun x -> Console.WriteLine ((string DateTime.Now) + " [ERROR] " + x)) msg + +module Map = + let addOrUpdate (key: 'k) (newValue: unit -> 'v) (update: 'v -> 'v) (m: Map<'k, 'v>) = + match m |> Map.tryFind key with + | Some oldV -> m |> Map.add key (update oldV) + | None -> m |> Map.add key (newValue()) + \ No newline at end of file