Skip to content

Commit 599b9ef

Browse files
Copilotjackfirth
andcommitted
Update source-analyze to accept syntax paths instead of line ranges
Co-authored-by: jackfirth <[email protected]>
1 parent 7c8a399 commit 599b9ef

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

main.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@
209209

210210
(define results
211211
(with-handlers ([exn:fail? skip])
212+
(define paths (source-syntax-paths source lines))
212213
(define analysis (source-analyze source
213-
#:lines lines
214+
#:paths paths
214215
#:analyzers (refactoring-suite-analyzers effective-suite)
215216
#:timeout-ms timeout-ms))
216217
(refactor-visited-forms

private/analysis.rkt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(provide
88
(contract-out
99
[source-analyze (->* (source? #:analyzers (sequence/c expansion-analyzer?) #:timeout-ms exact-nonnegative-integer?)
10-
(#:lines range-set?)
10+
(#:paths sorted-set?)
1111
source-code-analysis?)]
1212
[source-code-analysis? (-> any/c boolean?)]
1313
[source-code-analysis-code (-> source-code-analysis? source?)]
@@ -117,7 +117,7 @@
117117

118118

119119
(define (source-analyze code
120-
#:lines [lines (range-set (unbounded-range #:comparator natural<=>))]
120+
#:paths [paths (sorted-set #:comparator syntax-path<=>)]
121121
#:analyzers analyzers
122122
#:timeout-ms timeout-ms)
123123
(define ns (make-base-namespace))
@@ -141,18 +141,22 @@
141141
(define/guard (resyntax-should-analyze-syntax? stx #:as-visit? [as-visit? #true])
142142
(guard (syntax-original-and-from-source? stx program-source-name) #:else #false)
143143
(guard as-visit? #:else #true)
144-
(define stx-lines (syntax-line-range stx #:linemap code-linemap))
145-
(define overlaps? (range-set-overlaps? lines stx-lines))
146-
(unless overlaps?
144+
;; If no paths were specified (empty set), analyze everything
145+
(guard (not (sorted-set-empty? paths)) #:else #true)
146+
(define stx-path (syntax-original-path stx))
147+
(define should-analyze?
148+
(and stx-path
149+
(sorted-set-contains? paths stx-path)))
150+
(unless should-analyze?
147151
(log-resyntax-debug
148-
(string-append "ignoring visited syntax object because it's outside analyzed lines\n"
149-
" analyzed lines: ~a\n"
150-
" syntax lines: ~a\n"
152+
(string-append "ignoring visited syntax object because it's not in analyzed paths\n"
153+
" analyzed paths: ~a\n"
154+
" syntax path: ~a\n"
151155
" syntax: ~a")
152-
lines
153-
stx-lines
156+
paths
157+
stx-path
154158
stx))
155-
overlaps?)
159+
should-analyze?)
156160

157161
(define/match (observe-event! sig val)
158162
[('visit (? syntax? visited))

0 commit comments

Comments
 (0)