|
| 1 | +namespace CSharpLanguageServer.State |
| 2 | + |
| 3 | +open System |
| 4 | +open System.IO |
| 5 | +open System.Threading |
| 6 | +open System.Collections.Generic |
| 7 | +open System.Text.RegularExpressions |
| 8 | + |
| 9 | +open Ionide.LanguageServerProtocol |
| 10 | +open Ionide.LanguageServerProtocol.Types |
| 11 | +open Microsoft.Build.Construction |
| 12 | +open Microsoft.Build.Exceptions |
| 13 | +open Microsoft.Build.Locator |
| 14 | +open Microsoft.CodeAnalysis |
| 15 | +open Microsoft.CodeAnalysis.MSBuild |
| 16 | +open Microsoft.CodeAnalysis.Text |
| 17 | +open Microsoft.Extensions.Logging |
| 18 | + |
| 19 | +open CSharpLanguageServer |
| 20 | +open CSharpLanguageServer.Lsp |
| 21 | +open CSharpLanguageServer.Logging |
| 22 | +open CSharpLanguageServer.Util |
| 23 | +open CSharpLanguageServer.Roslyn.Conversions |
| 24 | +open CSharpLanguageServer.Roslyn.WorkspaceServices |
| 25 | +open CSharpLanguageServer.Roslyn.Solution |
| 26 | +open CSharpLanguageServer.Types |
| 27 | + |
| 28 | + |
| 29 | +type DecompiledMetadataDocument = |
| 30 | + { Metadata: CSharpMetadataInformation |
| 31 | + Document: Document } |
| 32 | + |
| 33 | + |
| 34 | +/// Codebase wraps roslyn Solution and encapsulates extra metadata |
| 35 | +/// that goes along |
| 36 | +type Codebase = |
| 37 | + { Solution: Solution |
| 38 | + DecompiledMetadata: Map<string, DecompiledMetadataDocument> } |
| 39 | + |
| 40 | + static member LoadWithPathOrOnCwd(lspClient: ILspClient, solutionPathMaybe: string option, cwd: string) = async { |
| 41 | + let! solution = async { |
| 42 | + match solutionPathMaybe with |
| 43 | + | Some solutionPath -> |
| 44 | + let rootedSolutionPath = |
| 45 | + match Path.IsPathRooted solutionPath with |
| 46 | + | true -> solutionPath |
| 47 | + | false -> Path.Combine(cwd, solutionPath) |
| 48 | + |
| 49 | + return! solutionTryLoadOnPath lspClient rootedSolutionPath |
| 50 | + |
| 51 | + | None -> |
| 52 | + let logMessage: LogMessageParams = |
| 53 | + { Type = MessageType.Info |
| 54 | + Message = sprintf "csharp-ls: attempting to find and load solution based on cwd (\"%s\").." cwd } |
| 55 | + |
| 56 | + do! lspClient.WindowLogMessage logMessage |
| 57 | + return! solutionFindAndLoadOnDir lspClient cwd |
| 58 | + } |
| 59 | + |
| 60 | + return |
| 61 | + { Solution = solution |
| 62 | + DecompiledMetadata = Map.empty } |
| 63 | + } |
0 commit comments