fix(extraction): tolerate whitespace in MyBatis close tags and fix qualified include refid#1222
Open
fengshao1227 wants to merge 1 commit into
Open
Conversation
…alified include refid resolution Two bugs in the MyBatis mapper extractor: 1. A close tag with trailing whitespace (`</select >`, legal XML) was not matched by the statement regex, causing the non-greedy body to overshoot to the next close tag — silently swallowing the statement in between. Fix: add `\s*` before `>` in the close-tag pattern. 2. A fully-qualified `<include refid="com.example.M.base">` had every dot replaced with `::`, producing `com::example::M::base` — which never matched the fragment node's `qualifiedName` (`com.example.M::base`). Fix: split on the last dot only, matching `qualifyStatement`'s logic. Also fixes the include-offset calculation to derive from the opening tag length rather than subtracting the close tag, so it stays correct when the close tag carries trailing whitespace. Closes colbymchenry#1209
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
Fixes two bugs in the MyBatis/iBatis mapper extractor (
src/extraction/mybatis-extractor.ts), both reported and diagnosed in #1209:</select >, legal XML) was missed by the statement regex. The non-greedy body overshot to the next real close tag, silently swallowing the statement in between. Fixed by adding\s*before>in the close-tag pattern.<include refid="com.example.M.base">had every dot replaced with::, producingcom::example::M::basewhich never matched the fragment node'squalifiedName(com.example.M::base). Fixed by splitting on the last dot only, consistent withqualifyStatement's own logic.Also fixes the include-offset calculation to derive from the opening tag length rather than subtracting the close tag, so it stays correct when the close tag carries trailing whitespace.
Closes #1209
Test plan
mybatis-extractor-robustness.test.ts:<include>still resolves after a spaced close tagnpx vitest run __tests__/mybatis-extractor-robustness.test.ts)