fix: parse string interpolations as code via interpolated_fragments()#409
Draft
toddr-bot wants to merge 2 commits into
Draft
fix: parse string interpolations as code via interpolated_fragments()#409toddr-bot wants to merge 2 commits into
toddr-bot wants to merge 2 commits into
Conversation
Add test file exercising the new interpolated_fragments() method on PPI::Token::Quote::Double, PPI::Token::Quote::Interpolate, and PPI::Token::HereDoc. Tests cover simple variables, arrays, escaped sigils, hash/array subscripts, arrow derefs, braced forms, complex expressions, magic variables, namespaced variables, and heredocs. All assertions are wrapped in $TODO blocks since the method is not yet implemented. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tions as code Add interpolated_fragments() method to PPI::Token::Quote::Double, PPI::Token::Quote::Interpolate, and PPI::Token::HereDoc. Each interpolation within a double-quoted string is extracted and parsed into a PPI::Document::Fragment, giving callers structured access to the variables and expressions embedded in interpolating strings. The extraction algorithm in the new PPI::Token::_Interpolations private module handles: simple variables ($x, @x), namespaced variables ($Foo::bar), subscripts ($h{k}, $a[0]), arrow dereferences ($r->{k}), braced forms (${expr}, @{[expr]}), magic variables ($$, $!, $^W), capture variables ($1, $12), and array-index expressions ($#arr). Fixes #107 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an
interpolated_fragments()method toPPI::Token::Quote::Double,PPI::Token::Quote::Interpolate, andPPI::Token::HereDocthat extracts each interpolated expression from the string and parses it into aPPI::Document::Fragment. This gives callers structured, queryable access to the variables and expressions embedded in interpolating strings — enabling static analysis tools like Perl::Critic to inspect interpolations as parsed code rather than opaque text.Fixes #107
Changes
PPI::Token::_Interpolationswith the shared extraction algorithm that handles: simple variables ($x,@x), namespaced variables ($Foo::bar), subscripts ($h{k},$a[0]), arrow dereferences ($r->{k}), braced forms (${expr},@{[expr]}), magic variables ($$,$!,$^W), capture variables ($1,$12), and array-index expressions ($#arr)interpolated_fragments()method onQuote::Double,Quote::Interpolate, andHereDocTest plan
Generated by Kōan /fix
Quality Report
Changes: 5 files changed, 494 insertions(+), 4 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline