Skip to content

Commit

Permalink
Merge pull request #86 from rneatherway/fcs-2.0.0
Browse files Browse the repository at this point in the history
Update to FCS 2.0.0.0-beta (new project cracking)
  • Loading branch information
rneatherway committed Dec 8, 2015
2 parents 2ba128e + 0114183 commit 137acef
Show file tree
Hide file tree
Showing 29 changed files with 203 additions and 142 deletions.
6 changes: 4 additions & 2 deletions FsAutoComplete.Core/CommandResponse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module CommandResponse =
Files: List<string>
Output: string
References: List<string>
Logs: Map<string, string>
}

type OverloadSignature =
Expand Down Expand Up @@ -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[]) =
Expand Down
24 changes: 5 additions & 19 deletions FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
8 changes: 4 additions & 4 deletions FsAutoComplete.Core/FsAutoComplete.Core.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
27 changes: 26 additions & 1 deletion FsAutoComplete.Core/FsAutoComplete.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@
<Reference Include="System.Numerics" />
</ItemGroup>
<Choose>
<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')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net40\FSharp.Compiler.Service.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<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')">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath>
Expand All @@ -87,6 +96,22 @@
</ItemGroup>
</When>
</Choose>
<Choose>
<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')">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service.ProjectCracker">
<HintPath>..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCracker.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="FSharp.Compiler.Service.ProjectCrackerTool">
<HintPath>..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCrackerTool.exe</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Reference Include="FParsec">
<HintPath>..\packages\FSharpLint.Core\lib\FParsec.dll</HintPath>
Expand Down
1 change: 1 addition & 0 deletions FsAutoComplete.Core/paket.references
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FSharp.Compiler.Service
FSharp.Compiler.Service.ProjectCracker
FSharpLint.Core
52 changes: 22 additions & 30 deletions FsAutoComplete.Suave/App.config
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.6.4.14350" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.6.4.14350" />
</dependentAssembly>
</assemblyBinding></runtime>
</configuration>
2 changes: 1 addition & 1 deletion FsAutoComplete.Suave/FsAutoComplete.Suave.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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) )
Expand Down
19 changes: 16 additions & 3 deletions FsAutoComplete.Suave/FsAutoComplete.Suave.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@
</Target>
-->
<Choose>
<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')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net40\FSharp.Compiler.Service.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<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')">
<ItemGroup>
<Reference Include="FSharp.Compiler.Service">
<HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath>
Expand Down Expand Up @@ -120,7 +129,7 @@
</Reference>
</ItemGroup>
</When>
<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')">
<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')">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -149,7 +158,7 @@
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(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')">
<ItemGroup>
<Reference Include="Suave">
<HintPath>..\packages\Suave\lib\net40\Suave.dll</HintPath>
Expand All @@ -159,4 +168,8 @@
</ItemGroup>
</When>
</Choose>
<Target Name="AfterBuild">
<Copy SourceFiles="..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCrackerTool.exe" DestinationFolder="$(OutputPath)" />
<Copy SourceFiles="..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCrackerTool.exe.config" DestinationFolder="$(OutputPath)" />
</Target>
</Project>
52 changes: 22 additions & 30 deletions FsAutoComplete.Tests/App.config
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.6.4.14350" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.6.4.14350" />
</dependentAssembly>
</assemblyBinding></runtime>
</configuration>
15 changes: 2 additions & 13 deletions FsAutoComplete/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,8 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>



<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.3.1.0" />
Expand Down
8 changes: 6 additions & 2 deletions FsAutoComplete/CommandInput.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 137acef

Please sign in to comment.