forked from fsprojects/fantomas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeFormatter.fsi
106 lines (83 loc) · 6.5 KB
/
CodeFormatter.fsi
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
namespace Fantomas
open System
open Fantomas.FormatConfig
open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.Range
open Microsoft.FSharp.Compiler.SourceCodeServices
[<Sealed>]
type CodeFormatter =
/// Parse a source string using given config
static member Parse : fileName:string * source:string -> ParsedInput
/// Parse a source string using given config
static member ParseAsync : fileName:string * source:string * projectOptions:FSharpParsingOptions * checker:FSharpChecker -> Async<ParsedInput>
/// Format an abstract syntax tree using an optional source for looking up literals
static member FormatAST : ast:ParsedInput * fileName:string * source:string option * config:FormatConfig -> string
/// Infer selection around cursor by looking for a pair of '[' and ']', '{' and '}' or '(' and ')'.
static member InferSelectionFromCursorPos : fileName:string * cursorPos:pos * source:string -> range
/// Format around cursor delimited by '[' and ']', '{' and '}' or '(' and ')' using given config; keep other parts unchanged.
/// (Only use in testing.)
static member internal FormatAroundCursorAsync :
fileName:string * cursorPos:pos * source:string * config:FormatConfig * projectOptions:FSharpParsingOptions * checker:FSharpChecker -> Async<string>
/// Format a source string using given config
static member FormatDocument :
fileName:string * source:string * config:FormatConfig -> string
/// Format a source string using given config
static member FormatDocumentAsync :
fileName:string * source:string * config:FormatConfig * projectOptions:FSharpParsingOptions * checker:FSharpChecker -> Async<string>
/// Format a part of source string using given config, and return the (formatted) selected part only.
/// Beware that the range argument is inclusive. If the range has a trailing newline, it will appear in the formatted result.
static member FormatSelection :
fileName:string * selection:range * source:string * config:FormatConfig -> string
/// Format a part of source string using given config, and return the (formatted) selected part only.
/// Beware that the range argument is inclusive. If the range has a trailing newline, it will appear in the formatted result.
static member FormatSelectionAsync :
fileName:string * selection:range * source:string * config:FormatConfig * projectOptions:FSharpParsingOptions * checker:FSharpChecker -> Async<string>
/// Format a selected part of source string using given config; keep other parts unchanged.
/// (Only use in testing.)
static member internal FormatSelectionInDocumentAsync :
fileName:string * selection:range * source:string * config:FormatConfig * projectOptions:FSharpParsingOptions * checker:FSharpChecker -> Async<string>
/// Check whether an AST consists of parsing errors
static member IsValidAST : ast:ParsedInput -> bool
/// Check whether an input string is invalid in F# by looking for erroneous nodes in ASTs
static member IsValidFSharpCode : fileName:string * source:string -> bool
/// Check whether an input string is invalid in F# by looking for erroneous nodes in ASTs
static member IsValidFSharpCodeAsync : fileName:string * source:string * projectOptions:FSharpParsingOptions * checker:FSharpChecker -> Async<bool>
static member MakePos : line:int * col:int -> pos
static member MakeRange : fileName:string * startLine:int * startCol:int * endLine:int * endCol:int -> range
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module CodeFormatter =
/// Parse a source code string
[<Obsolete("Please use 'CodeFormatter.ParseAsync' instead.")>]
val parse : isFsiFile:bool -> sourceCode:string -> ParsedInput
[<Obsolete("Please use 'CodeFormatter.MakePos' instead.")>]
val makePos : line:int -> col:int -> pos
[<Obsolete("Please use 'CodeFormatter.MakeRange' instead.")>]
val makeRange : startLine:int -> startCol:int -> endLine:int -> endCol:int -> range
/// Check whether an AST consists of parsing errors
[<Obsolete("Please use 'CodeFormatter.IsValidAST' instead.")>]
val isValidAST : ast:ParsedInput -> bool
/// Check whether an input string is invalid in F# by looking for erroneous nodes in ASTs
[<Obsolete("Please use 'CodeFormatter.IsValidFSharpCodeAsync' instead.")>]
val isValidFSharpCode : isFsiFile:bool -> sourceCode:string -> bool
/// Format a source string using given config
[<Obsolete("Please use 'CodeFormatter.FormatDocumentAsync' instead.")>]
val formatSourceString : isFsiFile:bool -> sourceCode:string -> config:FormatConfig -> string
/// Format an abstract syntax tree using given config
[<Obsolete("Please use 'CodeFormatter.FormatAST' instead.")>]
val formatAST : ast:ParsedInput -> formatContext: CodeFormatterImpl.FormatContext-> config:FormatConfig -> string
/// Format a part of source string using given config, and return the (formatted) selected part only.
/// Beware that the range argument is inclusive. If the range has a trailing newline, it will appear in the formatted result.
[<Obsolete("Please use 'CodeFormatter.FormatSelectionAsync' instead.")>]
val formatSelectionOnly : isFsiFile:bool -> range:range -> sourceCode:string -> config:FormatConfig -> string
/// Format a selected part of source string using given config; expanded selected ranges to parsable ranges.
[<Obsolete("Please use 'CodeFormatter.FormatSelectionAsync' instead.")>]
val formatSelectionExpanded : isFsiFile:bool -> range:range -> sourceCode:string -> config:FormatConfig -> string * range
/// Format a selected part of source string using given config; keep other parts unchanged.
[<Obsolete("Please use 'CodeFormatter.FormatSelectionAsync' instead.")>]
val formatSelectionFromString : isFsiFile:bool -> range:range -> sourceCode:string -> config:FormatConfig -> string
/// Format around cursor delimited by '[' and ']', '{' and '}' or '(' and ')' using given config; keep other parts unchanged.
[<Obsolete("Please use 'CodeFormatter.FormatSelectionAsync' instead.")>]
val formatAroundCursor : isFsiFile:bool -> cursorPos:pos -> sourceCode:string -> config:FormatConfig -> string
/// Infer selection around cursor by looking for a pair of '[' and ']', '{' and '}' or '(' and ')'.
[<Obsolete("Please use 'CodeFormatter.InferSelectionFromCursorPos' instead.")>]
val inferSelectionFromCursorPos : cursorPos:pos -> sourceCode:string -> range