macro-stepper: removed unnecessary partition code
downgraded secondary "partition" to simple binary predicate original commit: f6f480053eefb840bf723a4c55fa96729d4c4c00
This commit is contained in:
parent
bc306a09bd
commit
803cc3ec82
|
@ -48,26 +48,20 @@
|
||||||
(define/public-final (reset-primary-partition)
|
(define/public-final (reset-primary-partition)
|
||||||
(set! primary-partition (new-bound-partition)))))
|
(set! primary-partition (new-bound-partition)))))
|
||||||
|
|
||||||
;; secondary-partition-mixin
|
;; secondary-relation-mixin
|
||||||
(define secondary-partition-mixin
|
(define secondary-relation-mixin
|
||||||
(mixin (displays-manager<%>) (secondary-partition<%>)
|
(mixin (displays-manager<%>) (secondary-relation<%>)
|
||||||
(inherit-field displays)
|
(inherit-field displays)
|
||||||
(define-notify identifier=? (new notify-box% (value #f)))
|
(define-notify identifier=? (new notify-box% (value #f)))
|
||||||
(define-notify secondary-partition (new notify-box% (value #f)))
|
|
||||||
|
|
||||||
(listen-identifier=?
|
(listen-identifier=?
|
||||||
(lambda (name+proc)
|
(lambda (name+proc)
|
||||||
(set-secondary-partition
|
(for ([d (in-list displays)])
|
||||||
(and name+proc
|
|
||||||
(new partition% (relation (cdr name+proc)))))))
|
|
||||||
(listen-secondary-partition
|
|
||||||
(lambda (p)
|
|
||||||
(for ([d displays])
|
|
||||||
(send/i d display<%> refresh))))
|
(send/i d display<%> refresh))))
|
||||||
(super-new)))
|
(super-new)))
|
||||||
|
|
||||||
(define controller%
|
(define controller%
|
||||||
(class* (secondary-partition-mixin
|
(class* (secondary-relation-mixin
|
||||||
(selection-manager-mixin
|
(selection-manager-mixin
|
||||||
(mark-manager-mixin
|
(mark-manager-mixin
|
||||||
(displays-manager-mixin
|
(displays-manager-mixin
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
(let ([selected-syntax
|
(let ([selected-syntax
|
||||||
(send/i controller selection-manager<%>
|
(send/i controller selection-manager<%>
|
||||||
get-selected-syntax)])
|
get-selected-syntax)])
|
||||||
(apply-secondary-partition-styles selected-syntax)
|
(apply-secondary-relation-styles selected-syntax)
|
||||||
(apply-selection-styles selected-syntax))
|
(apply-selection-styles selected-syntax))
|
||||||
(send* text
|
(send* text
|
||||||
(end-edit-sequence))))
|
(end-edit-sequence))))
|
||||||
|
@ -199,18 +199,18 @@
|
||||||
(for ([style-delta style-deltas])
|
(for ([style-delta style-deltas])
|
||||||
(restyle-range r style-delta)))))
|
(restyle-range r style-delta)))))
|
||||||
|
|
||||||
;; apply-secondary-partition-styles : selected-syntax -> void
|
;; apply-secondary-relation-styles : selected-syntax -> void
|
||||||
;; If the selected syntax is an identifier, then styles all identifiers
|
;; If the selected syntax is an identifier, then styles all identifiers
|
||||||
;; in the same partition in blue.
|
;; in the relation with it.
|
||||||
(define/private (apply-secondary-partition-styles selected-syntax)
|
(define/private (apply-secondary-relation-styles selected-syntax)
|
||||||
(when (identifier? selected-syntax)
|
(when (identifier? selected-syntax)
|
||||||
(let ([partition
|
(let* ([name+relation
|
||||||
(send/i controller secondary-partition<%>
|
(send/i controller secondary-relation<%>
|
||||||
get-secondary-partition)])
|
get-identifier=?)]
|
||||||
(when partition
|
[relation (and name+relation (cdr name+relation))])
|
||||||
|
(when relation
|
||||||
(for ([id (send/i range range<%> get-identifier-list)])
|
(for ([id (send/i range range<%> get-identifier-list)])
|
||||||
(when (send/i partition partition<%>
|
(when (relation selected-syntax id)
|
||||||
same-partition? selected-syntax id)
|
|
||||||
(draw-secondary-connection id)))))))
|
(draw-secondary-connection id)))))))
|
||||||
|
|
||||||
;; apply-selection-styles : syntax -> void
|
;; apply-selection-styles : syntax -> void
|
||||||
|
|
|
@ -61,18 +61,16 @@
|
||||||
;; reset-primary-partition : -> void
|
;; reset-primary-partition : -> void
|
||||||
reset-primary-partition))
|
reset-primary-partition))
|
||||||
|
|
||||||
;; secondary-partition<%>
|
;; secondary-relation<%>
|
||||||
(define-interface secondary-partition<%> ()
|
(define-interface secondary-relation<%> ()
|
||||||
(;; secondary-partition : notify-box of partition<%>
|
(;; identifier=? : notify-box of (cons string (U #f (id id -> bool)))
|
||||||
;; identifier=? : notify-box of (cons string procedure)
|
(methods:notify identifier=?)))
|
||||||
(methods:notify secondary-partition
|
|
||||||
identifier=?)))
|
|
||||||
|
|
||||||
;; controller<%>
|
;; controller<%>
|
||||||
(define-interface controller<%> (displays-manager<%>
|
(define-interface controller<%> (displays-manager<%>
|
||||||
selection-manager<%>
|
selection-manager<%>
|
||||||
mark-manager<%>
|
mark-manager<%>
|
||||||
secondary-partition<%>)
|
secondary-relation<%>)
|
||||||
())
|
())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,77 +4,11 @@
|
||||||
"interfaces.rkt"
|
"interfaces.rkt"
|
||||||
"../util/stxobj.rkt")
|
"../util/stxobj.rkt")
|
||||||
(provide new-bound-partition
|
(provide new-bound-partition
|
||||||
partition%
|
|
||||||
identifier=-choices)
|
identifier=-choices)
|
||||||
|
|
||||||
(define (new-bound-partition)
|
(define (new-bound-partition)
|
||||||
(new bound-partition%))
|
(new bound-partition%))
|
||||||
|
|
||||||
;; representative-symbol : symbol
|
|
||||||
;; Must be fresh---otherwise, using it could detect rename wraps
|
|
||||||
;; instead of only marks.
|
|
||||||
;; For example, in (lambda (representative) representative)
|
|
||||||
(define representative-symbol
|
|
||||||
(gensym 'representative))
|
|
||||||
|
|
||||||
;; unmarked-syntax : identifier
|
|
||||||
;; Has no marks---used to initialize bound partition so that
|
|
||||||
;; unmarked syntax always gets colored "black"
|
|
||||||
(define unmarked-syntax
|
|
||||||
(datum->syntax #f representative-symbol))
|
|
||||||
|
|
||||||
(define partition%
|
|
||||||
(class* object% (partition<%>)
|
|
||||||
(init relation)
|
|
||||||
|
|
||||||
(define related? (or relation (lambda (a b) #f)))
|
|
||||||
(field (rep=>num (make-hasheq)))
|
|
||||||
(field (obj=>rep (make-weak-hasheq)))
|
|
||||||
(field (reps null))
|
|
||||||
(field (next-num 0))
|
|
||||||
|
|
||||||
(define/public (get-partition obj)
|
|
||||||
(rep->partition (obj->rep obj)))
|
|
||||||
|
|
||||||
(define/public (same-partition? A B)
|
|
||||||
(= (get-partition A) (get-partition B)))
|
|
||||||
|
|
||||||
(define/private (obj->rep obj)
|
|
||||||
(hash-ref obj=>rep obj (lambda () (obj->rep* obj))))
|
|
||||||
|
|
||||||
(define/public (count)
|
|
||||||
next-num)
|
|
||||||
|
|
||||||
(define/private (obj->rep* obj)
|
|
||||||
(let loop ([reps reps])
|
|
||||||
(cond [(null? reps)
|
|
||||||
(new-rep obj)]
|
|
||||||
[(related? obj (car reps))
|
|
||||||
(hash-set! obj=>rep obj (car reps))
|
|
||||||
(car reps)]
|
|
||||||
[else
|
|
||||||
(loop (cdr reps))])))
|
|
||||||
|
|
||||||
(define/private (new-rep rep)
|
|
||||||
(hash-set! rep=>num rep next-num)
|
|
||||||
(set! next-num (add1 next-num))
|
|
||||||
(set! reps (cons rep reps))
|
|
||||||
rep)
|
|
||||||
|
|
||||||
(define/private (rep->partition rep)
|
|
||||||
(hash-ref rep=>num rep))
|
|
||||||
|
|
||||||
;; Nearly useless as it stands
|
|
||||||
(define/public (dump)
|
|
||||||
(hash-for-each
|
|
||||||
rep=>num
|
|
||||||
(lambda (k v)
|
|
||||||
(printf "~s => ~s~n" k v))))
|
|
||||||
|
|
||||||
(get-partition unmarked-syntax)
|
|
||||||
(super-new)
|
|
||||||
))
|
|
||||||
|
|
||||||
;; bound-partition%
|
;; bound-partition%
|
||||||
(define bound-partition%
|
(define bound-partition%
|
||||||
(class* object% (partition<%>)
|
(class* object% (partition<%>)
|
||||||
|
@ -99,57 +33,13 @@
|
||||||
(define/public (count)
|
(define/public (count)
|
||||||
next-number)
|
next-number)
|
||||||
|
|
||||||
(get-partition unmarked-syntax)
|
(get-partition (datum->syntax #f 'nowhere))
|
||||||
(super-new)))
|
(super-new)))
|
||||||
|
|
||||||
;; Different identifier relations for highlighting.
|
;; ==== Identifier relations ====
|
||||||
|
|
||||||
(define (lift/rep id=?)
|
|
||||||
(lambda (A B)
|
|
||||||
(let ([ra (datum->syntax A representative-symbol)]
|
|
||||||
[rb (datum->syntax B representative-symbol)])
|
|
||||||
(id=? ra rb))))
|
|
||||||
|
|
||||||
(define (lift id=?)
|
|
||||||
(lambda (A B)
|
|
||||||
(and (identifier? A) (identifier? B) (id=? A B))))
|
|
||||||
|
|
||||||
;; id:same-marks? : syntax syntax -> boolean
|
|
||||||
(define id:same-marks?
|
|
||||||
(lift/rep bound-identifier=?))
|
|
||||||
|
|
||||||
;; id:X-module=? : identifier identifier -> boolean
|
|
||||||
;; If both module-imported, do they come from the same module?
|
|
||||||
;; If both top-bound, then same source.
|
|
||||||
(define (id:source-module=? a b)
|
|
||||||
(let ([ba (identifier-binding a)]
|
|
||||||
[bb (identifier-binding b)])
|
|
||||||
(cond [(or (eq? 'lexical ba) (eq? 'lexical bb))
|
|
||||||
(free-identifier=? a b)]
|
|
||||||
[(and (not ba) (not bb))
|
|
||||||
#t]
|
|
||||||
[(or (not ba) (not bb))
|
|
||||||
#f]
|
|
||||||
[else
|
|
||||||
(eq? (car ba) (car bb))])))
|
|
||||||
(define (id:nominal-module=? A B)
|
|
||||||
(let ([ba (identifier-binding A)]
|
|
||||||
[bb (identifier-binding B)])
|
|
||||||
(cond [(or (eq? 'lexical ba) (eq? 'lexical bb))
|
|
||||||
(free-identifier=? A B)]
|
|
||||||
[(or (not ba) (not bb))
|
|
||||||
(and (not ba) (not bb))]
|
|
||||||
[else (eq? (caddr ba) (caddr bb))])))
|
|
||||||
|
|
||||||
(define (symbolic-identifier=? A B)
|
|
||||||
(eq? (syntax-e A) (syntax-e B)))
|
|
||||||
|
|
||||||
(define identifier=-choices
|
(define identifier=-choices
|
||||||
(make-parameter
|
(make-parameter
|
||||||
`(("<nothing>" . #f)
|
`(("<nothing>" . #f)
|
||||||
("bound-identifier=?" . ,bound-identifier=?)
|
("bound-identifier=?" . ,bound-identifier=?)
|
||||||
("free-identifier=?" . ,free-identifier=?)
|
("free-identifier=?" . ,free-identifier=?))))
|
||||||
("module-or-top-identifier=?" . ,module-or-top-identifier=?)
|
|
||||||
("symbolic-identifier=?" . ,symbolic-identifier=?)
|
|
||||||
("same source module" . ,id:source-module=?)
|
|
||||||
("same nominal module" . ,id:nominal-module=?))))
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user