-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
interfaces.rkt
56 lines (49 loc) · 1.25 KB
/
interfaces.rkt
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
#lang racket/base
(require (for-syntax racket/base
syntax/parse)
racket/class
racket/contract/base
racket/match
"json-util.rkt")
(provide WorkspaceEdit
TextEdit
CodeAction
Diagnostic
Pos
Range
abs-pos->Pos)
(define-json-expander WorkspaceEdit
[changes any/c])
(define-json-expander TextEdit
[range any/c]
[newText string?])
(define-json-expander CodeAction
[title string?]
[kind string?]
[diagnostics any/c]
[isPreferred boolean?]
[edit any/c])
(define-json-expander Diagnostic
[range any/c]
[severity (or/c 1 2 3 4)]
[source string?]
[message string?])
(define-match-expander Pos
(λ (stx)
(syntax-parse stx
[(_ #:line l #:char c)
(syntax/loc stx
(hash-table ['line (? exact-nonnegative-integer? l)]
['character (? exact-nonnegative-integer? c)]))]))
(λ (stx)
(syntax-parse stx
[(_ #:line l #:char c)
(syntax/loc stx
(hasheq 'line l
'character c))])))
(define-json-expander Range
[start any/c]
[end any/c])
(define (abs-pos->Pos editor pos)
(match-define (list line char) (send editor pos->line/char pos))
(Pos #:line line #:char char))