perf: reduce ValidScopedCSSClass save latency on large themes#1181
Merged
perf: reduce ValidScopedCSSClass save latency on large themes#1181
Conversation
ddd51bf to
daeab3d
Compare
aswamy
commented
Apr 20, 2026
99126a6 to
0a2bb7c
Compare
stephanie-shopify
approved these changes
Apr 22, 2026
tgeselle
reviewed
Apr 22, 2026
Moves per-file CSS class extraction onto the language server's AugmentedLiquidSourceCode so it is memoized per file version and invalidated automatically when a document changes. Eliminates the full-theme rescan that ran on every save. Also skips syntax-tree parsing for Liquid files with no stylesheet tag, cutting first-save and CLI-run costs. Re-enables ValidScopedCSSClass in the recommended config, reversing the temporary opt-out from #1180. Fixes #1179.
0a2bb7c to
597a3c5
Compare
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 the save-lag reported in #1179 and re-enables
ValidScopedCSSClassin the recommended config (reversing the temporary opt-out from #1180).What was happening
The check needed to know every CSS class declared anywhere in the theme to avoid false positives on CDN/utility classes. The language server was rebuilding that information from scratch on every save — re-reading and re-parsing every Liquid file with a stylesheet tag, even though the language server already holds the parsed syntax tree for every file in memory.
What this PR changes
Two architectural changes, no change to the check's output or public API:
CSS class extraction is now a memoized derivation on the language server's document model — alongside schema and doc-definition extraction, following the same pattern. When a document changes, the model replaces the cached extraction automatically, so invalidation is implicit. The expensive parse work is shared across every consumer of a file's CSS classes and across every save within a session.
Early exit for files with no stylesheet tag — cheap source-level scan avoids invoking the syntax-tree parser for files that cannot declare CSS classes.
Impact (measured on a 240-file theme)
Test plan
main; subsequent saves sub-second (see logs)🤖 Generated with Claude Code