fix(vscode-graphql-syntax): don't highlight .graphql() member calls as embedded GraphQL#4415
fix(vscode-graphql-syntax): don't highlight .graphql() member calls as embedded GraphQL#4415mvanhorn wants to merge 4 commits into
Conversation
…s embedded GraphQL The function-call injection regex matched a bare `graphql`/`gql` identifier even when it appeared as a member access, so `client.graphql<Response>(...)` and `foo.graphql()` were swallowed as embedded GraphQL blocks and broke downstream JS/TS scoping (regression from graphql#3540, v1.3.5). Add a negative lookbehind so the keyword only triggers when it is not preceded by `.`, `$`, or a word character, and make the generic-arguments matcher non-greedy. Closes graphql#3810
Preserve quoted angle brackets in generic arguments, exclude private #graphql member calls, and handle cross-line member dots; regenerate snapshots and add coverage.
🦋 Changeset detectedLatest commit: e38d5c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The syntax-highlighting fixtures deliberately contain unformatted constructs (multiline member access, space and comment between the dot and method name) that the grammar tests assert against; formatting them would erase what they test. cspell flagged the POSIX class [:alnum:] in the grammar fixture.
|
Fixed the CSpell and Format checks in e38d5c8. CSpell was flagging |
Summary
The
vscode-graphql-syntaxTextMate grammar treated a baregraphql/gqlidentifier as an embedded-GraphQL trigger even when it appeared as a member access, soclient.graphql<Response>(...)andfoo.graphql()were highlighted as embedded GraphQL and broke downstream JS/TS scoping (regression from #3540). This restricts the trigger to genuine tagged-template / helper calls.Why
The injection regex now requires the keyword not to be preceded by a member/identifier boundary, so member calls (
.graphql(), private#graphql()) are excluded, and it preserves quoted angle brackets inside generic arguments (graphql<Result<User>>(...)). Cross-line member access is handled as far as a single-line TextMate grammar can. The bulk of the diff is regenerated tokenizer snapshots reflecting the corrected scoping.Testing
vitest run tests/js-grammar.spec.tsinpackages/vscode-graphql-syntax-- passes, with fixtures added for member calls, private-member calls, and generic arguments.Closes #3810