forked from fsprojects/fantomas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeFormatter.fs
35 lines (26 loc) · 1.57 KB
/
CodeFormatter.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace Fantomas
open Fantomas
[<Sealed>]
type CodeFormatter =
static member ParseAsync(fileName, source, parsingOptions, checker) =
CodeFormatterImpl.createFormatContext fileName source
|> CodeFormatterImpl.parse checker parsingOptions
static member FormatASTAsync(ast, fileName, defines, source, config) =
let formatContext = CodeFormatterImpl.createFormatContext fileName (Option.defaultValue (SourceOrigin.SourceString "") source)
CodeFormatterImpl.formatAST ast defines formatContext config
|> async.Return
static member FormatDocumentAsync(fileName, source, config, parsingOptions, checker) =
CodeFormatterImpl.createFormatContext fileName source
|> CodeFormatterImpl.formatDocument checker parsingOptions config
static member FormatSelectionAsync(fileName, selection, source, config, parsingOptions, checker) =
CodeFormatterImpl.createFormatContext fileName source
|> CodeFormatterImpl.formatSelection checker parsingOptions selection config
static member IsValidFSharpCodeAsync(fileName, source, parsingOptions, checker) =
CodeFormatterImpl.createFormatContext fileName source
|> CodeFormatterImpl.isValidFSharpCode checker parsingOptions
static member IsValidASTAsync ast =
async { return CodeFormatterImpl.isValidAST ast }
static member MakePos(line, col) =
CodeFormatterImpl.makePos line col
static member MakeRange(fileName, startLine, startCol, endLine, endCol) =
CodeFormatterImpl.makeRange fileName startLine startCol endLine endCol