Add expansion context analyzer for refactoring rules #782
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactoring rules need to know the expansion context (
'module,'expression,'internal-definition) of forms to determine valid transformations. This adds an expansion analyzer that labels each form with its context based on its position in the expanded syntax tree.Implementation
New analyzer:
expansion-context-analyzer.rkttraverses expanded syntax usingsyntax-searchto annotate forms based on structural position#%module-begin→'modulecontext#%plain-app→'expressioncontext'internal-definitioncontextTest suite:
expansion-context-analyzer-test.rktvalidates context labeling per the issue specStatus
Core analyzer structure is in place but patterns aren't matching as expected. The
#%module-beginpattern should annotate forms at paths like/3/1, but currently only wrapper-level paths (/1,/2,/3) are being annotated. Likely cause:syntax-searchrecursion semantics or phase handling in pattern matching.Test output shows properties are being created but filtered out due to "multiple expanded forms claim to originate from that path" - suggesting the analyzer is annotating expanded paths that map ambiguously to original code positions.
Needs further debugging of pattern matching behavior and the relationship between expanded syntax paths and original syntax paths in the analysis infrastructure.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.