Conversation
Implements #46 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85c141e565
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds a new stateful, streaming match-and-replace API to reggie-runtime via MatchCursor, analogous to java.util.regex.Matcher.appendReplacement/appendTail, and introduces named-group support hooks (NamedGroupResult, MatchResult.hasNamedGroups()).
Changes:
- Introduces
MatchCursor(iterator-style cursor withfindNext(),appendReplacement(),appendTail(),reset(),close()). - Adds named-group result support via
NamedGroupResultand extendsMatchResult/MatchResultImplaccordingly. - Adds
MatchCursorTestcovering streaming replacement behaviors.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/MatchCursor.java | New streaming cursor implementation (iteration, replacement expansion, named-group parsing). |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/ReggieMatcher.java | Adds cursor(String) factory method to create a MatchCursor. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/NamedGroupResult.java | New sub-interface for named-group lookup (group(String)). |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/MatchResultImpl.java | Extends result implementation with optional named-group index support. |
| reggie-runtime/src/main/java/com/datadoghq/reggie/runtime/MatchResult.java | Adds hasNamedGroups() default method for capability checks. |
| reggie-runtime/src/test/java/com/datadoghq/reggie/runtime/MatchCursorTest.java | New test suite validating cursor iteration/replacement semantics and state transitions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- MatchCursor.java:211 — fix digit-greedy loop in expandReplacement to stop before a digit that would push group number past groupCount (JDK appendReplacement semantics), so $12 with 1 group emits group(1) + literal '2' - MatchCursor.java:88 — findNext() now consumes the peeked buffer from hasNext() to avoid skipping matches when caller mixes hasNext() with findNext() - MatchResultImpl.java — revert to implements MatchResult only; remove nameIndex field - NamedMatchResultImpl.java — new package-private class extends MatchResultImpl implements NamedGroupResult; only instantiated when pattern has named groups; requireNonNull guard on nameIndex - MatchCursor.java:125 — appendTail() clears lastMatch/peeked references after tail is appended - MatchCursorTest.java:191 — add ready.await() before start.countDown() so all threads reach barrier before race starts Co-Authored-By: muse <muse@noreply>
|
@copilot review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb5297eebf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Google Java Format requires the parameters to fit on one line when within the 100-char limit; put all 5 params on the same continuation line to satisfy the spotlessJavaCheck CI task. Agent-Logs-Url: https://github.com/DataDog/java-reggie/sessions/f4a2f7a8-d99e-4c39-9666-25404e355f5d Co-authored-by: jbachorik <738413+jbachorik@users.noreply.github.com>
Fixed the CI failure (commit e844992): the |
|
@copilot resolve the merge conflicts in this pull request |
…h-limit, self-ref backrefs) Main added: - Named group extraction directly into MatchResult/MatchResultImpl (group/start/end by name) - split(String, int) with JDK semantics - Self-referencing backreference support in RECURSIVE_DESCENT - NameEnrichingMatcher for enriching results with named groups Conflict resolution in MatchResult.java: - Dropped hasNamedGroups() (our addition) in favour of main's group/start/end(String) defaults - NamedGroupResult simplified to a marker interface (named group methods now in MatchResult) - NamedMatchResultImpl delegates named-group storage to MatchResultImpl's 5-arg constructor Co-authored-by: jbachorik <738413+jbachorik@users.noreply.github.com>
Resolved in commit 7fc4118. The only true conflict was in
|
(?|...) resets group numbering per-alternative; the previous monotonic scan mapped named groups in later alternatives to wrong indices. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b52f400a06
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- MatchCursor uses matcher.nameToIndex (authoritative, handles branch-reset) instead of re-parsing the pattern — removes parseNamedGroups() entirely - expandReplacement throws IllegalArgumentException for $<non-digit> per JDK - reset()/cursor() validate input is non-null via Objects.requireNonNull - MatchResult.hasNamedGroups() default false; NamedGroupResult overrides true - Add hasNext()/next() and mixed-iteration tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot review |
CI is green on the latest commit ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 646b615304
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…onstruction paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot please review |
|
@codex please review |
The PR is in good shape. Here's what I found after reviewing the full diff, including the two newest commits (
Tests — good coverage: the new CI is in progress on |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c64ee8f08d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot please review |
|
@codex please review |
CI is green on the latest commit (
Tests — 35 tests covering all acceptance criteria including iterator mixing, peeked buffer semantics, and edge cases. The PR is clean and ready for merge.
CI is green on the latest commit (
CI is green on the latest commit (
CI is green on the latest commit ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 625918ce8f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot please review |
|
@codex please review |
CI is green on the latest commit (
The PR is clean and ready for merge.
CI is green on the latest commit ( |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What does this PR do?
Adds
MatchCursor— a stateful streaming cursor for incremental match-and-replace, analogous to JDKMatcher.appendReplacement/appendTail. Also introduces theNamedGroupResultsub-interface and extendsMatchResultImplwith optional named-group support.Motivation
Implements #46.
ReggieMatcher.replaceAll(Function)covers the common case, but callers that need to accumulate aStringBuilderincrementally across matches (e.g. interleaving non-match content with per-match computed replacements) have no equivalent API today.Related Issue(s)
Closes #46
Change Type
Checklist
./gradlew build)Performance Impact
MatchCursor.findNext()returnsMatchResultdirectly (notOptional) to stay allocation-free on the hot path. Named-group index is parsed once at cursor construction from the pattern string.Additional Notes
New public API:
ReggieMatcher.cursor(String)— factory methodMatchCursor— implementsIterator<MatchResult>andAutoCloseablefindNext()→MatchResultornull(exhausted / closed)appendReplacement(StringBuilder, String)→MatchCursor(fluent)appendTail(StringBuilder)→StringBuilderreset(String)— restarts cursor on new input, safe to call at any pointclose()— resets all stateNamedGroupResult— extendsMatchResultwithgroup(String name)MatchResult.hasNamedGroups()— defaultfalse;MatchResultImploverrides totruewhen named groups are presentAcceptance criteria satisfied:
MatchCursorimplementsIterator<MatchResult>andAutoCloseable✓findNext()advances cursor;nullsignals exhaustion ✓reset(String)may be called at any point, including mid-iteration ✓$1,$2) and named (${name}) backreferences ✓Matcher.appendReplacementbehavior ✓appendReplacementreturnsMatchCursor(fluent) ✓appendTailreturnsStringBuilder✓ReggieMatcherand cursor (documented) ✓IllegalStateException/NullPointerExceptionas appropriate ✓findNext()may be called withoutappendReplacement()to skip a match ✓findNext()afterappendTail()returnsnull(not an error) ✓close()resets all fields ✓replaceAll(Function)✓20 tests covering all behaviours added in
MatchCursorTest.🤖 Generated with Claude Code via muse implement