forked from fsprojects/fantomas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriviaTypes.fs
58 lines (44 loc) · 1.23 KB
/
TriviaTypes.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module Fantomas.TriviaTypes
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Range
type Token =
{ TokenInfo:FSharpTokenInfo
LineNumber: int
Content: string }
type Comment =
| LineCommentAfterSourceCode of comment:string
| LineCommentOnSingleLine of comment:string
| BlockComment of string * newlineBefore:bool * newlineAfter:bool
(* LineComment Examples
let a = 7 // b
=> LineCommentAfterSourceCode("// b", true)
// meh
let a = 7
=> LineCommentOnSingleLine("// meh", false)
*)
type TriviaContent =
| Keyword of Token
| Number of string
| StringContent of string
| IdentOperatorAsWord of string
| IdentBetweenTicks of string
| Comment of Comment
| Newline
| Directive of directive:string
| NewlineAfter
type Trivia =
{ Item: TriviaContent
Range: range }
with
static member Create item range : Trivia =
{ Item = item; Range = range }
type TriviaIndex = TriviaIndex of int * int
type TriviaNodeType =
| MainNode of ``type``:string
| Token of Token
type TriviaNode =
{ Type: TriviaNodeType
ContentBefore: TriviaContent list
ContentItself: TriviaContent option
ContentAfter: TriviaContent list
Range: range }