Skip to content

Commit

Permalink
fix textDocument/documentSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
JJPro committed Apr 10, 2020
1 parent b283c2b commit 86b55b1
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions text-document.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

;; Hover request
;; Returns an object conforming to the Hover interface, to
;; be used as the result of the response message.
;; be used as the result of the response message.
(define (hover id params)
(match params
[(hash-table ['textDocument (DocIdentifier #:uri uri)]
Expand Down Expand Up @@ -239,25 +239,28 @@
(hash-ref open-docs (string->symbol uri)))
(define in (open-input-string (send doc-text get-text)))
(port-count-lines! in)
(define lexer (get-lexer in))
(define lexer (get-lexer in)) ;; lexer: token producer
(define after-define? (box #f))
(define results
(for/fold ([out empty])
([lst (in-port (lexer-wrap lexer) in)])
(match-define (list text type paren? start end) lst)
(cond [(set-member? '(constant string symbol) type)
(define kind (match type
['constant SymbolKind-Constant]
['string SymbolKind-String]
['symbol SymbolKind-Variable]))
(define range
(Range #:start (abs-pos->Pos doc-text start)
#:end (abs-pos->Pos doc-text end)))
(define sym-info
(SymbolInfo #:name text
#:kind kind
#:location (Location #:uri uri
#:range range)))
(cons sym-info out)]
(cond [(eq? 'symbol type)
(cond [(set-member? '("define" "define-type") text)
(set-box! after-define? #t)
out]
[(unbox after-define?)
(set-box! after-define? #f)
(define range
(Range #:start (abs-pos->Pos doc-text start)
#:end (abs-pos->Pos doc-text end)))
(define sym-info
(SymbolInfo #:name text
#:kind SymbolKind-Function
#:location (Location #:uri uri
#:range range)))
(cons sym-info out)]
[else out])]
[else out])))
(success-response id results)]
[_
Expand Down

0 comments on commit 86b55b1

Please sign in to comment.