adjust the interaction between online check syntax and the documentation
system to guarantee that killing online check syntax doesn't wedge the docs information lookup process
This commit is contained in:
parent
0ba3a8ef7c
commit
d6f54435b7
|
@ -1,7 +1,5 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(require racket/class
|
(require racket/class
|
||||||
racket/promise
|
|
||||||
setup/xref
|
|
||||||
"local-member-names.rkt")
|
"local-member-names.rkt")
|
||||||
|
|
||||||
(define syncheck-annotations<%>
|
(define syncheck-annotations<%>
|
||||||
|
@ -33,17 +31,6 @@
|
||||||
;; parameters to all of the functions
|
;; parameters to all of the functions
|
||||||
(define current-annotations (make-parameter #f))
|
(define current-annotations (make-parameter #f))
|
||||||
|
|
||||||
(define xref (if (getenv "PLTDRXREFDELAY")
|
|
||||||
(begin
|
|
||||||
(printf "PLTDRXREFDELAY: using plain delay\n")
|
|
||||||
(delay (begin
|
|
||||||
(printf "PLTDRXREFDELAY: loading xref\n")
|
|
||||||
(begin0
|
|
||||||
(load-collections-xref)
|
|
||||||
(printf "PLTDRXREFDELAY: loaded xref\n")))))
|
|
||||||
(delay/idle (load-collections-xref))))
|
|
||||||
(define (get-xref) (force xref))
|
|
||||||
|
|
||||||
(define annotations-mixin
|
(define annotations-mixin
|
||||||
(mixin () (syncheck-annotations<%>)
|
(mixin () (syncheck-annotations<%>)
|
||||||
(define/public (syncheck:find-source-object stx) #f)
|
(define/public (syncheck:find-source-object stx) #f)
|
||||||
|
@ -64,5 +51,4 @@
|
||||||
(provide syncheck-text<%>
|
(provide syncheck-text<%>
|
||||||
syncheck-annotations<%>
|
syncheck-annotations<%>
|
||||||
current-annotations
|
current-annotations
|
||||||
annotations-mixin
|
annotations-mixin)
|
||||||
get-xref)
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"traversals.rkt"
|
"traversals.rkt"
|
||||||
"local-member-names.rkt"
|
"local-member-names.rkt"
|
||||||
"intf.rkt"
|
"intf.rkt"
|
||||||
|
"xref.rkt"
|
||||||
framework/preferences)
|
framework/preferences)
|
||||||
|
|
||||||
(preferences:set-default 'framework:white-on-black? #f boolean?)
|
(preferences:set-default 'framework:white-on-black? #f boolean?)
|
||||||
|
@ -52,9 +53,8 @@
|
||||||
(define/public (get-trace) (reverse trace))
|
(define/public (get-trace) (reverse trace))
|
||||||
(super-new)))
|
(super-new)))
|
||||||
|
|
||||||
(void (get-xref)) ;; do this now so that it doesn't get killed during a call to 'go'
|
|
||||||
|
|
||||||
(define (go expanded path the-source)
|
(define (go expanded path the-source)
|
||||||
|
(time
|
||||||
(with-handlers ((exn:fail? (λ (x)
|
(with-handlers ((exn:fail? (λ (x)
|
||||||
(printf "~a\n" (exn-message x))
|
(printf "~a\n" (exn-message x))
|
||||||
(printf "---\n")
|
(printf "---\n")
|
||||||
|
@ -75,4 +75,4 @@
|
||||||
(parameterize ([current-annotations obj])
|
(parameterize ([current-annotations obj])
|
||||||
(expanded-expression expanded)
|
(expanded-expression expanded)
|
||||||
(expansion-completed))
|
(expansion-completed))
|
||||||
(send obj get-trace)))
|
(send obj get-trace))))
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
"local-member-names.rkt"
|
"local-member-names.rkt"
|
||||||
"annotate.rkt"
|
"annotate.rkt"
|
||||||
"contract-traversal.rkt"
|
"contract-traversal.rkt"
|
||||||
|
"xref.rkt"
|
||||||
string-constants
|
string-constants
|
||||||
racket/unit
|
racket/unit
|
||||||
racket/set
|
racket/set
|
||||||
racket/class
|
racket/class
|
||||||
racket/list
|
racket/list
|
||||||
syntax/boundmap
|
syntax/boundmap
|
||||||
scribble/xref
|
framework/preferences
|
||||||
scribble/manual-struct
|
scribble/manual-struct)
|
||||||
framework/preferences)
|
|
||||||
|
|
||||||
(provide make-traversal)
|
(provide make-traversal)
|
||||||
|
|
||||||
|
@ -1038,24 +1038,19 @@
|
||||||
|
|
||||||
;; document-variable : stx[identifier,original] phase-level -> void
|
;; document-variable : stx[identifier,original] phase-level -> void
|
||||||
(define (document-variable stx phase-level)
|
(define (document-variable stx phase-level)
|
||||||
(let ([defs-text (current-annotations)])
|
(define defs-text (current-annotations))
|
||||||
(when defs-text
|
(when defs-text
|
||||||
(let ([binding-info (identifier-binding stx phase-level)])
|
(define binding-info (identifier-binding stx phase-level))
|
||||||
(when (and (pair? binding-info)
|
(when (and (pair? binding-info)
|
||||||
(syntax-position stx)
|
(syntax-position stx)
|
||||||
(syntax-span stx))
|
(syntax-span stx))
|
||||||
(let* ([start (- (syntax-position stx) 1)]
|
(define start (- (syntax-position stx) 1))
|
||||||
[fin (+ start (syntax-span stx))]
|
(define fin (+ start (syntax-span stx)))
|
||||||
[source-editor (find-source-editor stx)])
|
(define source-editor (find-source-editor stx))
|
||||||
(when source-editor
|
(when source-editor
|
||||||
(let ([xref (get-xref)])
|
(define info (get-index-entry-info binding-info))
|
||||||
(when xref
|
(when info
|
||||||
(let ([definition-tag (xref-binding->definition-tag xref binding-info #f)])
|
(define-values (entry-desc path tag) (apply values info))
|
||||||
(when definition-tag
|
|
||||||
(let-values ([(path tag) (xref-tag->path+anchor xref definition-tag)])
|
|
||||||
(when path
|
|
||||||
(let ([index-entry (xref-tag->index-entry xref definition-tag)])
|
|
||||||
(when index-entry
|
|
||||||
(send defs-text syncheck:add-background-color
|
(send defs-text syncheck:add-background-color
|
||||||
source-editor start fin
|
source-editor start fin
|
||||||
(if (preferences:get 'framework:white-on-black?)
|
(if (preferences:get 'framework:white-on-black?)
|
||||||
|
@ -1066,23 +1061,23 @@
|
||||||
start
|
start
|
||||||
fin
|
fin
|
||||||
(syntax-e stx)
|
(syntax-e stx)
|
||||||
(build-docs-label (entry-desc index-entry))
|
(build-docs-label entry-desc)
|
||||||
path
|
path
|
||||||
tag))))))))))))))))
|
tag))))))
|
||||||
|
|
||||||
(define (build-docs-label desc)
|
(define (build-docs-label entry-desc)
|
||||||
(let ([libs (exported-index-desc-from-libs desc)])
|
(let ([libs (exported-index-desc-from-libs entry-desc)])
|
||||||
(cond
|
(cond
|
||||||
[(null? libs)
|
[(null? libs)
|
||||||
(format
|
(format
|
||||||
(string-constant cs-view-docs)
|
(string-constant cs-view-docs)
|
||||||
(exported-index-desc-name desc))]
|
(exported-index-desc-name entry-desc))]
|
||||||
[else
|
[else
|
||||||
(format
|
(format
|
||||||
(string-constant cs-view-docs-from)
|
(string-constant cs-view-docs-from)
|
||||||
(format
|
(format
|
||||||
(string-constant cs-view-docs)
|
(string-constant cs-view-docs)
|
||||||
(exported-index-desc-name desc))
|
(exported-index-desc-name entry-desc))
|
||||||
(apply string-append
|
(apply string-append
|
||||||
(add-between
|
(add-between
|
||||||
(map (λ (x) (format "~s" x)) libs)
|
(map (λ (x) (format "~s" x)) libs)
|
||||||
|
|
51
collects/drracket/private/syncheck/xref.rkt
Normal file
51
collects/drracket/private/syncheck/xref.rkt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#lang racket/base
|
||||||
|
(require setup/xref
|
||||||
|
racket/promise
|
||||||
|
scribble/xref
|
||||||
|
scribble/manual-struct)
|
||||||
|
(provide get-index-entry-info)
|
||||||
|
|
||||||
|
(define delayed-xref
|
||||||
|
(if (getenv "PLTDRXREFDELAY")
|
||||||
|
(begin
|
||||||
|
(printf "PLTDRXREFDELAY: using plain delay\n")
|
||||||
|
(delay (begin
|
||||||
|
(printf "PLTDRXREFDELAY: loading xref\n")
|
||||||
|
(begin0
|
||||||
|
(load-collections-xref)
|
||||||
|
(printf "PLTDRXREFDELAY: loaded xref\n")))))
|
||||||
|
(delay/idle (load-collections-xref))))
|
||||||
|
|
||||||
|
(define req-chan (make-channel))
|
||||||
|
|
||||||
|
(define thd
|
||||||
|
(thread
|
||||||
|
(λ ()
|
||||||
|
(let loop ()
|
||||||
|
(define-values (binding-info resp-chan nack-evt) (apply values (channel-get req-chan)))
|
||||||
|
(define xref (force delayed-xref))
|
||||||
|
(define resp
|
||||||
|
(and xref
|
||||||
|
(let ([definition-tag (xref-binding->definition-tag xref binding-info #f)])
|
||||||
|
(and definition-tag
|
||||||
|
(let-values ([(path tag) (xref-tag->path+anchor xref definition-tag)])
|
||||||
|
(and path
|
||||||
|
(let ([index-entry (xref-tag->index-entry xref definition-tag)])
|
||||||
|
(and index-entry
|
||||||
|
(list (entry-desc index-entry)
|
||||||
|
path
|
||||||
|
tag)))))))))
|
||||||
|
(sync (channel-put-evt resp-chan resp)
|
||||||
|
nack-evt)
|
||||||
|
(loop)))))
|
||||||
|
|
||||||
|
;; this function is called from a thread that might be killed
|
||||||
|
;; (but the body of this module is run in a context where it is
|
||||||
|
;; guaranteed that that custodian doesn't get shut down)
|
||||||
|
(define (get-index-entry-info binding-info)
|
||||||
|
(sync
|
||||||
|
(nack-guard-evt
|
||||||
|
(λ (nack-evt)
|
||||||
|
(define resp-chan (make-channel))
|
||||||
|
(channel-put req-chan (list binding-info resp-chan nack-evt))
|
||||||
|
resp-chan))))
|
Loading…
Reference in New Issue
Block a user