diff --git a/FsAutoComplete.Core/CommandResponse.fs b/FsAutoComplete.Core/CommandResponse.fs index 02d14f740..9673431cb 100644 --- a/FsAutoComplete.Core/CommandResponse.fs +++ b/FsAutoComplete.Core/CommandResponse.fs @@ -74,6 +74,7 @@ module CommandResponse = Files: List Output: string References: List + Logs: Map } type OverloadSignature = @@ -202,12 +203,13 @@ module CommandResponse = let data = TipFormatter.formatTip tip |> List.map(List.map(fun (n,m) -> {Signature = n; Comment = m} )) serialize { Kind = "helptext"; Data = { HelpTextResponse.Name = name; Overloads = data } } - let project (serialize : obj -> string) (projectFileName, projectFiles, outFileOpt, references) = + let project (serialize : obj -> string) (projectFileName, projectFiles, outFileOpt, references, logMap) = let projectData = { Project = projectFileName Files = projectFiles Output = match outFileOpt with Some x -> x | None -> "null" - References = List.sortBy IO.Path.GetFileName references } + References = List.sortBy IO.Path.GetFileName references + Logs = logMap } serialize { Kind = "project"; Data = projectData } let completion (serialize : obj -> string) (decls: FSharpDeclarationListItem[]) = diff --git a/FsAutoComplete.Core/CompilerServiceInterface.fs b/FsAutoComplete.Core/CompilerServiceInterface.fs index 3788deab7..023794d07 100644 --- a/FsAutoComplete.Core/CompilerServiceInterface.fs +++ b/FsAutoComplete.Core/CompilerServiceInterface.fs @@ -139,19 +139,19 @@ type FSharpCompilerServiceChecker() = |> Async.RunSynchronously parseResult.GetNavigationItems().Declarations - member x.TryGetProjectOptions (file: string) : Result<_> = + member x.TryGetProjectOptions (file: string, verbose: bool) : Result<_> = if not (File.Exists file) then Failure (sprintf "File '%s' does not exist" file) else try - let po = - let p = checker.GetProjectOptionsFromProjectFile(file) + let po, logMap = + let p, logMap = ProjectCracker.GetProjectOptionsFromProjectFileLogged(file, enableLogging=verbose) let opts = if not (Seq.exists (fun (s: string) -> s.Contains "FSharp.Core.dll") p.OtherOptions) then ensureCorrectFSharpCore p.OtherOptions else p.OtherOptions - { p with OtherOptions = opts } + { p with OtherOptions = opts }, logMap let chooseByPrefix prefix (s: string) = if s.StartsWith(prefix) then Some (s.Substring(prefix.Length)) @@ -161,20 +161,6 @@ type FSharpCompilerServiceChecker() = let outputFile = Seq.tryPick (chooseByPrefix "--out:") po.OtherOptions let references = Seq.choose (chooseByPrefix "-r:") po.OtherOptions - Success (po, Seq.toList compileFiles, outputFile, Seq.toList references) + Success (po, Seq.toList compileFiles, outputFile, Seq.toList references, logMap) with e -> Failure e.Message - -open System.Reflection -module CompilerServiceInterface = - let addMSBuildv14BackupResolution () = - let onResolveEvent = new ResolveEventHandler( fun sender evArgs -> - let requestedAssembly = AssemblyName(evArgs.Name) - if requestedAssembly.Name.StartsWith("Microsoft.Build") && - not (requestedAssembly.Name.EndsWith(".resources")) then - requestedAssembly.Version <- Version("14.0.0.0") - Assembly.Load (requestedAssembly) - else - null - ) - AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent) diff --git a/FsAutoComplete.Core/FsAutoComplete.Core.fs b/FsAutoComplete.Core/FsAutoComplete.Core.fs index 3955d49ed..54c15ce36 100644 --- a/FsAutoComplete.Core/FsAutoComplete.Core.fs +++ b/FsAutoComplete.Core/FsAutoComplete.Core.fs @@ -38,7 +38,7 @@ module Commands = - let project (serialize : obj -> string) (state : State) (checker : FSharpCompilerServiceChecker) file time = async { + let project (serialize : obj -> string) (state : State) (checker : FSharpCompilerServiceChecker) file time verbose = async { let file = Path.GetFullPath file // The FileSystemWatcher often triggers multiple times for @@ -49,10 +49,10 @@ module Commands = | Some oldtime when time - oldtime < TimeSpan.FromSeconds(1.0) -> [],state | _ -> - match checker.TryGetProjectOptions(file) with + match checker.TryGetProjectOptions(file, verbose) with | Result.Failure s -> [Response.error serialize s],state - | Result.Success(po, projectFiles, outFileOpt, references) -> - let res = Response.project serialize (file, projectFiles, outFileOpt, references) + | Result.Success(po, projectFiles, outFileOpt, references, logMap) -> + let res = Response.project serialize (file, projectFiles, outFileOpt, references, logMap) let checkOptions = projectFiles |> List.fold (fun s f -> Map.add f po s) state.FileCheckOptions diff --git a/FsAutoComplete.Core/FsAutoComplete.Core.fsproj b/FsAutoComplete.Core/FsAutoComplete.Core.fsproj index 86bbf2230..2634859bc 100644 --- a/FsAutoComplete.Core/FsAutoComplete.Core.fsproj +++ b/FsAutoComplete.Core/FsAutoComplete.Core.fsproj @@ -77,7 +77,16 @@ - + + + + ..\packages\FSharp.Compiler.Service\lib\net40\FSharp.Compiler.Service.dll + True + True + + + + ..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll @@ -87,6 +96,22 @@ + + + + + ..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCracker.dll + True + True + + + ..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCrackerTool.exe + True + True + + + + ..\packages\FSharpLint.Core\lib\FParsec.dll diff --git a/FsAutoComplete.Core/paket.references b/FsAutoComplete.Core/paket.references index 529148dc3..1d118e954 100644 --- a/FsAutoComplete.Core/paket.references +++ b/FsAutoComplete.Core/paket.references @@ -1,2 +1,3 @@ FSharp.Compiler.Service +FSharp.Compiler.Service.ProjectCracker FSharpLint.Core diff --git a/FsAutoComplete.Suave/App.config b/FsAutoComplete.Suave/App.config index dd6c7e6e2..ddb9d1ed0 100644 --- a/FsAutoComplete.Suave/App.config +++ b/FsAutoComplete.Suave/App.config @@ -1,30 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/FsAutoComplete.Suave/FsAutoComplete.Suave.fs b/FsAutoComplete.Suave/FsAutoComplete.Suave.fs index 4e9f9dbf5..06b1c8a75 100644 --- a/FsAutoComplete.Suave/FsAutoComplete.Suave.fs +++ b/FsAutoComplete.Suave/FsAutoComplete.Suave.fs @@ -77,7 +77,7 @@ let main argv = choose [ path "/parse" >>= handler (fun (data : ParseRequest) -> Commands.parse writeJson !state checker data.FileName data.Lines) //TODO: Add filewatcher - path "/project" >>= handler (fun (data : ProjectRequest) -> Commands.project writeJson !state checker data.FileName DateTime.Now) + path "/project" >>= handler (fun (data : ProjectRequest) -> Commands.project writeJson !state checker data.FileName DateTime.Now false) path "/declarations" >>= handler (fun (data : DeclarationsRequest) -> Commands.declarations writeJson !state checker data.FileName) path "/helptext" >>= handler (fun (data : HelptextRequest) -> Commands.helptext writeJson !state checker data.Symbol) path "/completion" >>= positionHandler (fun data tyRes lineStr _ -> Commands.completion writeJson !state checker tyRes data.Line data.Column lineStr None (Some data.Filter) ) diff --git a/FsAutoComplete.Suave/FsAutoComplete.Suave.fsproj b/FsAutoComplete.Suave/FsAutoComplete.Suave.fsproj index 2f08424a0..d632a33c1 100644 --- a/FsAutoComplete.Suave/FsAutoComplete.Suave.fsproj +++ b/FsAutoComplete.Suave/FsAutoComplete.Suave.fsproj @@ -82,7 +82,16 @@ --> - + + + + ..\packages\FSharp.Compiler.Service\lib\net40\FSharp.Compiler.Service.dll + True + True + + + + ..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll @@ -120,7 +129,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -149,7 +158,7 @@ - + ..\packages\Suave\lib\net40\Suave.dll @@ -159,4 +168,8 @@ + + + + diff --git a/FsAutoComplete.Tests/App.config b/FsAutoComplete.Tests/App.config index dd6c7e6e2..ddb9d1ed0 100644 --- a/FsAutoComplete.Tests/App.config +++ b/FsAutoComplete.Tests/App.config @@ -1,30 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/FsAutoComplete/App.config b/FsAutoComplete/App.config index 0e333fb28..b067e2f0a 100644 --- a/FsAutoComplete/App.config +++ b/FsAutoComplete/App.config @@ -3,19 +3,8 @@ - - - - - - - - - - - - - + + diff --git a/FsAutoComplete/CommandInput.fs b/FsAutoComplete/CommandInput.fs index a045defce..0a4922712 100644 --- a/FsAutoComplete/CommandInput.fs +++ b/FsAutoComplete/CommandInput.fs @@ -23,7 +23,7 @@ type Command = | Parse of string * ParseKind * string[] | Error of string | Lint of string - | Project of string * DateTime + | Project of string * DateTime * bool | Colorization of bool | CompilerLocation | Quit @@ -56,7 +56,11 @@ module CommandInput = let! _ = char '"' let! filename = some (sat ((<>) '"')) |> Parser.map String.ofSeq let! _ = char '"' - return Project(filename,DateTime.Now) } + let! verbose = + (parser { let! _ = some (string " verbose") + return true }) <|> + (parser { return false }) + return Project(filename,DateTime.Now,verbose) } /// Parse 'lint' command let lint = parser { diff --git a/FsAutoComplete/FsAutoComplete.fsproj b/FsAutoComplete/FsAutoComplete.fsproj index 93597be09..3f57c1473 100644 --- a/FsAutoComplete/FsAutoComplete.fsproj +++ b/FsAutoComplete/FsAutoComplete.fsproj @@ -75,12 +75,6 @@ True - @@ -89,8 +83,21 @@ True + + + + - + + + + ..\packages\FSharp.Compiler.Service\lib\net40\FSharp.Compiler.Service.dll + True + True + + + + ..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll @@ -135,7 +142,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll diff --git a/FsAutoComplete/Program.fs b/FsAutoComplete/Program.fs index cd2621c07..7355c5c77 100644 --- a/FsAutoComplete/Program.fs +++ b/FsAutoComplete/Program.fs @@ -40,15 +40,15 @@ module internal Main = return [r] @res,state } - | Project (file,time) -> + | Project (file,time,verbose) -> //THIS SHOULD BE INITIALIZED SOMEWHERE ELSE ? let fp = Path.GetFullPath file let fsw = new FileSystemWatcher() fsw.Path <- Path.GetDirectoryName fp fsw.Filter <- Path.GetFileName fp - fsw.Changed.Add(fun _ -> commandQueue.Add(Project (fp, DateTime.Now))) + fsw.Changed.Add(fun _ -> commandQueue.Add(Project (fp, DateTime.Now, verbose))) fsw.EnableRaisingEvents <- true - Commands.project writeJson !state checker file time + Commands.project writeJson !state checker file time verbose | Declarations file -> Commands.declarations writeJson !state checker file @@ -118,7 +118,6 @@ module internal Main = 1 else try - CompilerServiceInterface.addMSBuildv14BackupResolution() async { while true do let cmd = CommandInput.parseCommand(Console.ReadLine()) diff --git a/FsAutoComplete/test/integration/ErrorTestsJson/output.json b/FsAutoComplete/test/integration/ErrorTestsJson/output.json index 03959d5f0..9760afcb2 100644 --- a/FsAutoComplete/test/integration/ErrorTestsJson/output.json +++ b/FsAutoComplete/test/integration/ErrorTestsJson/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/ErrorTestsJson/Test1.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/FindDeclarations/output.json b/FsAutoComplete/test/integration/FindDeclarations/output.json index 0498c8e6d..064c337af 100644 --- a/FsAutoComplete/test/integration/FindDeclarations/output.json +++ b/FsAutoComplete/test/integration/FindDeclarations/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/FindDeclarations/FindDecl.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/MultiProj/output.json b/FsAutoComplete/test/integration/MultiProj/output.json index 4e565385d..10b0561b0 100644 --- a/FsAutoComplete/test/integration/MultiProj/output.json +++ b/FsAutoComplete/test/integration/MultiProj/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/MultiProj/Proj1/Proj1.fsproj": "" + } } } { @@ -229,7 +232,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/MultiProj/Proj2/Proj2.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/MultipleUnsavedFiles/output.json b/FsAutoComplete/test/integration/MultipleUnsavedFiles/output.json index 4de0653e9..3f40da409 100644 --- a/FsAutoComplete/test/integration/MultipleUnsavedFiles/output.json +++ b/FsAutoComplete/test/integration/MultipleUnsavedFiles/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/MultipleUnsavedFiles/multunsaved.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/NoFSharpCoreReference/output.json b/FsAutoComplete/test/integration/NoFSharpCoreReference/output.json index 427a7a9ee..a77253147 100644 --- a/FsAutoComplete/test/integration/NoFSharpCoreReference/output.json +++ b/FsAutoComplete/test/integration/NoFSharpCoreReference/output.json @@ -12,6 +12,9 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/NoFSharpCoreReference/Test1.fsproj": "" + } } } diff --git a/FsAutoComplete/test/integration/ParamCompletion/output.json b/FsAutoComplete/test/integration/ParamCompletion/output.json index 63253805a..e9d41b7a5 100644 --- a/FsAutoComplete/test/integration/ParamCompletion/output.json +++ b/FsAutoComplete/test/integration/ParamCompletion/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/ParamCompletion/Test1.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/ProjectReload/output.json b/FsAutoComplete/test/integration/ProjectReload/output.json index dc74595d0..b1cd8b655 100644 --- a/FsAutoComplete/test/integration/ProjectReload/output.json +++ b/FsAutoComplete/test/integration/ProjectReload/output.json @@ -11,7 +11,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/ProjectReload/Test1.fsproj": "" + } } } { @@ -27,6 +30,9 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/ProjectReload/Test1.fsproj": "" + } } } diff --git a/FsAutoComplete/test/integration/RobustCommands/completebadposition.json b/FsAutoComplete/test/integration/RobustCommands/completebadposition.json index 1d04f38b8..112636aa5 100644 --- a/FsAutoComplete/test/integration/RobustCommands/completebadposition.json +++ b/FsAutoComplete/test/integration/RobustCommands/completebadposition.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/RobustCommands/Project/Test1.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/RobustCommands/completenosuchfile.json b/FsAutoComplete/test/integration/RobustCommands/completenosuchfile.json index 233d20ac9..1abeb6bb7 100644 --- a/FsAutoComplete/test/integration/RobustCommands/completenosuchfile.json +++ b/FsAutoComplete/test/integration/RobustCommands/completenosuchfile.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/RobustCommands/Project/Test1.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/RobustCommands/parsenosuchfile.json b/FsAutoComplete/test/integration/RobustCommands/parsenosuchfile.json index d71ebbbc9..6ce2d5db3 100644 --- a/FsAutoComplete/test/integration/RobustCommands/parsenosuchfile.json +++ b/FsAutoComplete/test/integration/RobustCommands/parsenosuchfile.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/RobustCommands/Project/Test1.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/SymbolUse/output.json b/FsAutoComplete/test/integration/SymbolUse/output.json index 2f185ac4e..29f85476f 100644 --- a/FsAutoComplete/test/integration/SymbolUse/output.json +++ b/FsAutoComplete/test/integration/SymbolUse/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/SymbolUse/SymbolUse.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/Test1Json/output.json b/FsAutoComplete/test/integration/Test1Json/output.json index 6c0062525..d3e848119 100644 --- a/FsAutoComplete/test/integration/Test1Json/output.json +++ b/FsAutoComplete/test/integration/Test1Json/output.json @@ -12,7 +12,10 @@ "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/Test1Json/Test1.fsproj": "" + } } } { diff --git a/FsAutoComplete/test/integration/TestHelpers.fsx b/FsAutoComplete/test/integration/TestHelpers.fsx index 93bec5f46..2d2ef0a10 100644 --- a/FsAutoComplete/test/integration/TestHelpers.fsx +++ b/FsAutoComplete/test/integration/TestHelpers.fsx @@ -81,6 +81,9 @@ let formatJson json = let writeNormalizedOutput (fn: string) (s: string) = let lines = s.TrimEnd().Split('\n') for i in [ 0 .. lines.Length - 1 ] do + if Path.GetExtension fn = ".json" then + lines.[i] <- formatJson lines.[i] + if Path.DirectorySeparatorChar = '/' then lines.[i] <- Regex.Replace(lines.[i], "/.*?FsAutoComplete/test/(.*?(\"|$))", @@ -101,8 +104,6 @@ let writeNormalizedOutput (fn: string) (s: string) = "[a-zA-Z]:/.*?FsAutoComplete/test/(.*?(\"|$))", "/test/$1") - if Path.GetExtension fn = ".json" then - lines.[i] <- formatJson lines.[i] lines.[i] <- lines.[i].Replace("\r", "") diff --git a/FsAutoComplete/test/integration/UncompiledReferencedProjects/output.json b/FsAutoComplete/test/integration/UncompiledReferencedProjects/output.json index 7d7ee72a2..2081ec787 100644 --- a/FsAutoComplete/test/integration/UncompiledReferencedProjects/output.json +++ b/FsAutoComplete/test/integration/UncompiledReferencedProjects/output.json @@ -7,12 +7,18 @@ ], "Output": "/test/integration/UncompiledReferencedProjects/bin/Debug/MultiProject1.exe", "References": [ + "/FSharp.Core.dll", "/test/integration/UncompiledReferencedProjects/bin/Debug/Project1A.dll", "/test/integration/UncompiledReferencedProjects/bin/Debug/Project1B.exe", "/System.Core.dll", "/System.dll", "/mscorlib.dll" - ] + ], + "Logs": { + "/test/integration/UncompiledReferencedProjects/MultiProject1.fsproj": "", + "/test/integration/UncompiledReferencedProjects/Project1A.fsproj": "", + "/test/integration/UncompiledReferencedProjects/Project1B.fsproj": "" + } } } { diff --git a/paket.dependencies b/paket.dependencies index 20c22da6e..b0db0edb6 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -1,13 +1,14 @@ source https://www.nuget.org/api/v2/ -nuget FSharp.Compiler.Service framework: >= net45 +nuget FSharp.Compiler.Service 2.0.0.0-beta framework: >= net45 +nuget FSharp.Compiler.Service.ProjectCracker 2.0.0.0-beta framework: >= net45 nuget Mono.Cecil nuget NDesk.Options nuget Newtonsoft.Json nuget FAKE nuget FSharp.Core 3.1.2.5 -nuget NUnit -nuget NUnit.Runners +nuget NUnit 2.6.4 +nuget NUnit.Runners 2.6.4 nuget Octokit nuget Suave nuget FSharpLint.Core prerelease diff --git a/paket.lock b/paket.lock index 08255d0ee..2ff152ee6 100644 --- a/paket.lock +++ b/paket.lock @@ -1,11 +1,12 @@ NUGET remote: https://nuget.org/api/v2 specs: - FAKE (4.7.2) - FSharp.Compiler.Service (1.4.2.1) - framework: >= net45 + FAKE (4.10.3) + FSharp.Compiler.Service (2.0.0-beta) + FSharp.Compiler.Service.ProjectCracker (2.0.0-beta) - framework: >= net45 FSharp.Core (3.1.2.5) - FSharpLint.Core (0.0.13-beta) - FSharp.Compiler.Service (>= 1.4.0.6) + FSharpLint.Core (0.0.13) + FSharp.Compiler.Service (>= 1.4.2.1) Microsoft.Bcl (1.1.10) Microsoft.Bcl.Build (>= 1.0.14) Microsoft.Bcl.Build (1.0.21) - import_targets: false @@ -19,5 +20,5 @@ NUGET NUnit.Runners (2.6.4) Octokit (0.16.0) Microsoft.Net.Http - Suave (0.32.1) + Suave (0.33.0) FSharp.Core (>= 3.1.2.5)