-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
102 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
module Fable.Compiler.Service.Compiler | ||
|
||
open FSharp.Compiler.SourceCodeServices | ||
open Fable | ||
open Fable.Compiler.Service.Util | ||
open Fable.Compiler.Service.ProjectCracker | ||
|
||
val mkCompilerForFile: cliArgs: CliArgs -> crackerResponse: CrackerResponse -> currentFile: string -> Async<Compiler> | ||
val compileFile: com: Compiler -> pathResolver: PathResolver -> outPath: string -> Async<string * string array> | ||
val mkCompilerForFile: | ||
checker: InteractiveChecker -> | ||
cliArgs: CliArgs -> | ||
crackerResponse: CrackerResponse -> | ||
currentFile: string -> | ||
Async<Compiler> | ||
|
||
val compileFile: | ||
com: Compiler -> | ||
pathResolver: PathResolver -> | ||
outPath: string -> | ||
Async<string * string array> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace Fable.Transforms | ||
|
||
open System.IO | ||
|
||
// TODO: Check the path is actually normalized? | ||
type File(normalizedFullPath: string) = | ||
let mutable sourceHash = None | ||
|
||
let readAllTextNonBlocking (path: string) = | ||
if File.Exists(path) then | ||
use fileStream = | ||
new FileStream( | ||
path, | ||
FileMode.Open, | ||
FileAccess.Read, | ||
FileShare.ReadWrite | ||
) | ||
|
||
use textReader = new StreamReader(fileStream) | ||
textReader.ReadToEnd() | ||
else | ||
// Log.always("File does not exist: " + path) | ||
"" | ||
|
||
member _.NormalizedFullPath = normalizedFullPath | ||
|
||
member _.ReadSource() = | ||
match sourceHash with | ||
| Some h -> h, lazy readAllTextNonBlocking normalizedFullPath | ||
| _ -> | ||
let source = readAllTextNonBlocking normalizedFullPath | ||
let h = hash source | ||
sourceHash <- Some h | ||
h, lazy source | ||
|
||
static member MakeSourceReader(files: File array) = | ||
let fileDic = | ||
files |> Seq.map (fun f -> f.NormalizedFullPath, f) |> dict | ||
|
||
let sourceReader f = fileDic[f].ReadSource() | ||
files |> Array.map (fun file -> file.NormalizedFullPath), sourceReader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters