Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 15, 2025

Resyntax currently filters syntax objects during analysis by checking if their source locations fall within requested line ranges. As more of the codebase has moved to work with syntax paths, this line-based filtering has become a bottleneck.

Changes

  • Added source-syntax-paths function (private/source.rkt): Accepts a source? and optional range-set? of line numbers, returns a sorted-set? of syntax-path? values for all syntax objects that overlap with the specified lines.

  • Updated source-analyze signature (private/analysis.rkt): Changed from #:lines range-set? parameter to #:paths sorted-set?. The function now filters visited syntax objects by checking path membership instead of computing line overlaps during expansion observation.

  • Updated call sites (main.rkt): Convert line ranges to syntax paths via source-syntax-paths before passing to source-analyze.

Example

;; Before: source-analyze accepted line ranges
(source-analyze src 
  #:lines (range-set (closed-range 10 20 #:comparator natural<=>))
  #:analyzers analyzers
  #:timeout-ms 10000)

;; After: source-analyze accepts syntax paths
(define paths (source-syntax-paths src 
                 (range-set (closed-range 10 20 #:comparator natural<=>))))
(source-analyze src
  #:paths paths
  #:analyzers analyzers
  #:timeout-ms 10000)

This enables expansion analyzers to work directly with syntax paths, making it straightforward to limit analysis to specific subtrees of the expanded syntax.

Original prompt

This section details on the original issue you should resolve

<issue_title>Filtering by syntax paths</issue_title>
<issue_description>Resyntax can be asked to only make suggestions on specific lines and line ranges, as opposed to whole files. There are various places in Resyntax's core engine where this is used to filter out syntax objects based on whether their source location lies within the requested lines.

However, as more and more of Resyntax has changed to work in terms of syntax paths instead of source locations, this implementation is getting in the way. There should be a utility that takes a syntax object and a set of line ranges and returns a sorted set of the syntax paths within that syntax object that overlap with the line ranges. This would make it possible to ask expansion analyzers to only concern themselves with certain parts of the expanded syntax, instead of the entire expansion.</issue_description>

Comments on the Issue (you are @copilot in this section)

@jackfirth Proposed API: add a `source-syntax-paths` function that accepts a `source?` and an optional `range-set?` of line numbers, and returns an immutable `sorted-set?` of `syntax-path?` values. Any syntax objects which partially overlap with the line range should have their paths included. The `source-analyze` function should be changed to accept a sorted set of `syntax-path?` values instead of a range set of line numbers.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add utility to filter syntax paths by line ranges Refactor source-analyze to filter by syntax paths instead of line ranges Nov 15, 2025
Copilot AI requested a review from jackfirth November 15, 2025 17:27
Copilot finished work on behalf of jackfirth November 15, 2025 17:27
@jackfirth jackfirth marked this pull request as ready for review November 16, 2025 03:04
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resyntax analyzed 3 files in this pull request and found no issues.

@coveralls
Copy link

Coverage Status

coverage: 93.669% (+0.008%) from 93.661%
when pulling 599b9ef on copilot/add-syntax-path-filter-utility
into 43f5fc6 on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filtering by syntax paths

3 participants