Source file reason_comment.ml
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
type category =
| EndOfLine
| SingleLine
| Regular
type t =
{ location : Location.t
; category : category
; text : string
}
let category t = t.category
let location t = t.location
let wrap t =
match t.text with
| "" | "*" -> "/***/"
| txt when Reason_syntax_util.isLineComment txt ->
"//"
^ String.sub txt ~pos:0 ~len:(String.length txt - 1)
^ Reason_syntax_util.EOLMarker.string
| txt when txt.[0] = '*' && txt.[1] <> '*' ->
"/**" ^ txt ^ "*/"
| txt -> "/*" ^ txt ^ "*/"
let make ~location category text = { text; category; location }
let { category; text; _ } =
match category with
| SingleLine -> Reason_syntax_util.isLineComment text
| EndOfLine | Regular -> false