Repository navigation
Conversation
findAndPushMatches wrapped each needle in word-boundary groups that only
accepted whitespace or a parenthesis after the match. String-literal
needles such as "Network.dataReceived" start and end with a quote, so a
call like jsonNotification("Network.dataReceived", params) never matched.
The legacy Hermes model used plain \b, which can only match a quoted
needle when a word character touches both quotes.
Move the regex into a shared buildNeedleRegExp helper that applies \b
only at needle edges that are word characters, and add tests.
Against jsinspector-modern this finds all 67 CDP names referenced as
string literals (previously 57), and 353 references instead of 204.
|
Hi @kirawth! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
findAndPushMatcheswraps each needle in(\b|(?<=\s|[()]))…(\b|(?=\s|[()])). String-literal needles like"Network.dataReceived"start and end with a quote, which is not a word character, so a match needs whitespace or a parenthesis right after the closing quote.React Native emits events as
cdp::jsonNotification("Network.dataReceived", params). A comma follows the quote, so these references were never found:HermesLegacyImplementationModelused plain\b"…"\b. That only matches when a word character touches both quotes, so its string-literal needle effectively never matched.Changes
data/needleRegExp.tsxwithbuildNeedleRegExp(needles). It applies\bonly at needle edges that are word characters. Quoted needles are already delimited by their quotes.escapeRegExp.data/needleRegExp.test.tsx.Matching identifiers is unchanged:
\bis still applied to both edges.Impact
Running old vs. new against
packages/react-native/ReactCommon/jsinspector-modernat currentmain:Test plan
,;:)}, rejection of longer literals, whole-word identifier matching, and multiple needles.