Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

The source-code-analysis object stored a list of enriched syntax objects for each visited form, causing duplicated data and redundant work for nested syntax.

Changes

  • Record structure: Store enriched-syntax (entire source, enriched once) and visited-paths (list of syntax-path) instead of visited-forms
  • Backward compatibility: Add computed accessor source-code-analysis-visited-forms that uses syntax-ref on enriched syntax with each path
  • Property preservation: Extract expander-added properties (e.g., 'class-body) from visits and merge with analyzer properties before enrichment
  • Single enrichment pass: Enrich the complete source once instead of per-visit

Usage

Clients can now iterate paths and inspect forms:

(define analysis (source-analyze code #:analyzers analyzers))
(define stx (source-code-analysis-enriched-syntax analysis))
(define paths (source-code-analysis-visited-paths analysis))

;; Inspect visited forms
(for ([path (in-list paths)])
  (define form (syntax-ref stx path))
  ...)

;; Or use backward-compatible accessor
(for ([form (in-list (source-code-analysis-visited-forms analysis))])
  ...)

Reduces memory usage and eliminates duplicated enrichment/logging for nested syntax.

Original prompt

This section details on the original issue you should resolve

<issue_title>Store visited paths instead of syntaxes</issue_title>
<issue_description>The source-code-analysis object represents the set of visits as a list of syntax objects, each of which is enriched with context and properties from the fully expanded syntax and any expansion analyzers. This results in a lot of duplicated data, especially duplicated logging, as visits of nested syntax objects redo work done by visits of parent syntax objects.

It would be more efficient for the analysis to enrich only the syntax object representing the entire unexpanded source, and separately store a list of visited syntax paths. This would also be conceptually easier to understand. Clients would iterate through the paths and use syntax-ref on the enriched unexpanded syntax to inspect each visited syntax object.</issue_description>

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


💡 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 self-assigned this Nov 4, 2025
Copilot AI and others added 3 commits November 4, 2025 01:10
- Change source-code-analysis record to store enriched-syntax and visited-paths
- Add backward-compatible accessor for visited-forms that uses syntax-ref
- Update source-analyze to compute paths and enrich syntax once
- Extract and preserve expander-added properties (like 'class-body')
- Combine expander and analyzer properties before enrichment
- This reduces duplication by enriching the source once instead of per-visit

Co-authored-by: jackfirth <8175575+jackfirth@users.noreply.github.com>
Explain why we need to manually extract and preserve expander-added
properties like 'class-body, which affect refactoring rule matching.

Co-authored-by: jackfirth <8175575+jackfirth@users.noreply.github.com>
Add a comment explaining how to add new expander properties to the
preservation list when needed.

Co-authored-by: jackfirth <8175575+jackfirth@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor source code analysis to store visited paths Store visited paths instead of syntaxes in source-code-analysis Nov 4, 2025
Copilot AI requested a review from jackfirth November 4, 2025 01:16
@jackfirth jackfirth marked this pull request as ready for review November 4, 2025 01:28
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 1 file in this pull request and found no issues.

@coveralls
Copy link

Pull Request Test Coverage Report for Build #177

Details

  • 30 of 31 (96.77%) changed or added relevant lines in 1 file are covered.
  • 10 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 92.881%

Changes Missing Coverage Covered Lines Changed/Added Lines %
private/analysis.rkt 30 31 96.77%
Files with Coverage Reduction New Missed Lines %
private/syntax-property-bundle.rkt 10 87.63%
Totals Coverage Status
Change from base Build #172: -0.03%
Covered Lines: 14664
Relevant Lines: 15788

💛 - Coveralls

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 1 file in this pull request and found no issues.

@jackfirth jackfirth enabled auto-merge (squash) November 4, 2025 03:41
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 1 file in this pull request and found no issues.

@jackfirth jackfirth merged commit e05681a into master Nov 4, 2025
5 checks passed
@jackfirth jackfirth deleted the copilot/store-visited-paths branch November 4, 2025 03:44
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.

Store visited paths instead of syntaxes

3 participants