Skip to content

Commit 86b55b1

Browse files
committed
fix textDocument/documentSymbol
1 parent b283c2b commit 86b55b1

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

text-document.rkt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129

130130
;; Hover request
131131
;; Returns an object conforming to the Hover interface, to
132-
;; be used as the result of the response message.
132+
;; be used as the result of the response message.
133133
(define (hover id params)
134134
(match params
135135
[(hash-table ['textDocument (DocIdentifier #:uri uri)]
@@ -239,25 +239,28 @@
239239
(hash-ref open-docs (string->symbol uri)))
240240
(define in (open-input-string (send doc-text get-text)))
241241
(port-count-lines! in)
242-
(define lexer (get-lexer in))
242+
(define lexer (get-lexer in)) ;; lexer: token producer
243+
(define after-define? (box #f))
243244
(define results
244245
(for/fold ([out empty])
245246
([lst (in-port (lexer-wrap lexer) in)])
246247
(match-define (list text type paren? start end) lst)
247-
(cond [(set-member? '(constant string symbol) type)
248-
(define kind (match type
249-
['constant SymbolKind-Constant]
250-
['string SymbolKind-String]
251-
['symbol SymbolKind-Variable]))
252-
(define range
253-
(Range #:start (abs-pos->Pos doc-text start)
254-
#:end (abs-pos->Pos doc-text end)))
255-
(define sym-info
256-
(SymbolInfo #:name text
257-
#:kind kind
258-
#:location (Location #:uri uri
259-
#:range range)))
260-
(cons sym-info out)]
248+
(cond [(eq? 'symbol type)
249+
(cond [(set-member? '("define" "define-type") text)
250+
(set-box! after-define? #t)
251+
out]
252+
[(unbox after-define?)
253+
(set-box! after-define? #f)
254+
(define range
255+
(Range #:start (abs-pos->Pos doc-text start)
256+
#:end (abs-pos->Pos doc-text end)))
257+
(define sym-info
258+
(SymbolInfo #:name text
259+
#:kind SymbolKind-Function
260+
#:location (Location #:uri uri
261+
#:range range)))
262+
(cons sym-info out)]
263+
[else out])]
261264
[else out])))
262265
(success-response id results)]
263266
[_

0 commit comments

Comments
 (0)