Skip to content

Commit

Permalink
add 'identifier-as-keyword property tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
rfindler committed Mar 21, 2024
1 parent d228209 commit 150f105
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
37 changes: 19 additions & 18 deletions drracket-tool-text-lib/drracket/private/syncheck/traversals.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1563,24 +1563,25 @@
;; add-id : id-set identifier -> void
(define (add-id mapping id level-of-enclosing-module #:mods [mods dont-add-binder+mods])
(when (original-enough? id)
(define shifted-id (syntax-shift-phase-level id level-of-enclosing-module))
(define old (free-id-table-ref mapping shifted-id '()))
(define no-span-id
(if (syntax-property shifted-id 'implicit-made-explicit)
(datum->syntax shifted-id
(syntax-e shifted-id)
(vector (syntax-source shifted-id)
(syntax-line shifted-id)
(syntax-column shifted-id)
(syntax-position shifted-id)
0)
shifted-id)
shifted-id))
(define with-binder+mods
(if (equal? mods dont-add-binder+mods)
no-span-id
(binder+mods no-span-id mods)))
(free-id-table-set! mapping shifted-id (cons with-binder+mods old))))
(unless (syntax-property id 'identifier-as-keyword)
(define shifted-id (syntax-shift-phase-level id level-of-enclosing-module))
(define old (free-id-table-ref mapping shifted-id '()))
(define no-span-id
(if (syntax-property shifted-id 'implicit-made-explicit)
(datum->syntax shifted-id
(syntax-e shifted-id)
(vector (syntax-source shifted-id)
(syntax-line shifted-id)
(syntax-column shifted-id)
(syntax-position shifted-id)
0)
shifted-id)
shifted-id))
(define with-binder+mods
(if (equal? mods dont-add-binder+mods)
no-span-id
(binder+mods no-span-id mods)))
(free-id-table-set! mapping shifted-id (cons with-binder+mods old)))))

(define (original-enough? x)
(or (syntax-original? x)
Expand Down
2 changes: 1 addition & 1 deletion drracket-tool-text-lib/info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

(define pkg-authors '(robby))

(define version "1.4")
(define version "1.5")

(define license
'(Apache-2.0 OR MIT))
15 changes: 12 additions & 3 deletions drracket/scribblings/tools/tools.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,14 @@ Check Syntax collects the values of the
@indexed-racket['disappeared-use],
@indexed-racket['disappeared-binding],
@indexed-racket['identifiers-as-disappeared-uses?],
@indexed-racket['identifer-as-keyword],
@indexed-racket['sub-range-binders], and
@indexed-racket['mouse-over-tooltips] and uses them to add
additional arrows to the program text. These properties are
control which arrows are added to the program text. These properties are
intended for use when a macro discards or manufactures identifiers that,
from the programmers perspective, should be binding each other.
from the programmers perspective, should be binding each other, or when
there are identifiers that are intended to be used more in the spirit of keywords,
and thus should be ignored.

For example, here is program with a macro that discards its arguments, but
adds properties to the result syntax object so that the two occurrences of @racket[_a]
Expand Down Expand Up @@ -821,9 +824,15 @@ For example, here's a macro that shows the span of itself in a tooltip on mouseo

(char-span (+ 1 2))}

If the syntax property @racket['identifier-as-keyword] is any value
except @racket[#f] and appears on an identifier, then Check Syntax
ignores the identifier, not drawing any arrows to it.

@history[#:changed "1.3" @list{
Looks for @racket['sub-range-binders]
on binding identifiers (not just in expression positions).}]
on binding identifiers (not just in expression positions).}
#:changed "1.5" @list{
Looks for @racket['identifier-as-keyword] on identifiers.}]

@section{Cooperating with Background Check Syntax}
@section-index["online-check-syntax logger"]
Expand Down

0 comments on commit 150f105

Please sign in to comment.