diff --git a/FSharpVSPowerTools.sln b/FSharpVSPowerTools.sln index fd44e1a5..1a45cf2d 100644 --- a/FSharpVSPowerTools.sln +++ b/FSharpVSPowerTools.sln @@ -60,6 +60,10 @@ 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 +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 @@ -94,6 +98,14 @@ 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 + {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/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..243334a3 --- /dev/null +++ b/src/FSharp.Editing.Messages/FSharp.Editing.Messages.fsproj @@ -0,0 +1,138 @@ + + + + + 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 + 5 + bin\Debug\FSharp.Editing.Messages.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 5 + bin\Release\FSharp.Editing.Messages.XML + 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.Messages/Messages.fs b/src/FSharp.Editing.Messages/Messages.fs new file mode 100644 index 00000000..69beb523 --- /dev/null +++ b/src/FSharp.Editing.Messages/Messages.fs @@ -0,0 +1,62 @@ +namespace FSharp.Editing.Messages + +type RequestId = Guid +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 ClientCallbackAddress = string + +[] +type ClientNotification = + /// 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 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 FilePath + /// Document closed. Server can stop tracking its content in a special way and just read it from disk. + | 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 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 } + +type ServerResponse = + { 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.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 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/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 new file mode 100644 index 00000000..eed32f12 --- /dev/null +++ b/src/FSharp.Editing.Server/FSharp.Editing.Server.fsproj @@ -0,0 +1,167 @@ + + + + + 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 + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + ..\..\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/MessageRouter.fs b/src/FSharp.Editing.Server/MessageRouter.fs new file mode 100644 index 00000000..1ac53146 --- /dev/null +++ b/src/FSharp.Editing.Server/MessageRouter.fs @@ -0,0 +1,29 @@ +namespace FSharp.Editing.Server + +open FSharp.Editing.Messages + +module MessageRouter = + let start() = + let agent = MailboxProcessor.Start <| fun mb -> + let rec loop ctx = + async { + let! message = mb.Receive() + 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 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 new file mode 100644 index 00000000..72ca376f --- /dev/null +++ b/src/FSharp.Editing.Server/ProjectSystem.fs @@ -0,0 +1,19 @@ +namespace FSharp.Editing.Server + +open FSharp.Editing +open Microsoft.FSharp.Compiler.SourceCodeServices + +[] +type Project = + { FilePath: FilePath + CompilerOptions: FSharpProjectOptions } + +[] +type Solution = + { 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 new file mode 100644 index 00000000..ab6ed28c --- /dev/null +++ b/src/FSharp.Editing.Server/Utilites.fs @@ -0,0 +1,18 @@ +[] +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 + +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 diff --git a/src/FSharp.Editing.Server/paket.references b/src/FSharp.Editing.Server/paket.references new file mode 100644 index 00000000..24bacaf5 --- /dev/null +++ b/src/FSharp.Editing.Server/paket.references @@ -0,0 +1,2 @@ +FSharp.Core +FSharp.Compiler.Service \ No newline at end of file