Skip to content

Conversation

@andrewbranch
Copy link
Member

I plan to add another one of these shared caches for parsed package.json files for the auto-imports work, so I went ahead and made the implementation generic, which required some fiddling with config file parsing to not pass a closure on every cache lookup so we don’t also pass a closure on every source file lookup. I also noticed a bug with the extended config caching, which is covered in a new test and fixed.

Copilot AI review requested due to automatic review settings December 10, 2025 00:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the reference counting cache implementations into a generic RefCountCache type and fixes a bug with extended config file caching. The key changes eliminate closure-based cache lookups, replacing them with direct function calls and structured arguments.

  • Introduces a generic RefCountCache implementation that can be specialized for different cache types
  • Fixes extended config cache bug where doubly-nested extended configs weren't being invalidated properly
  • Updates ParseCacheKey to include file hash as part of the key identity

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/project/refcountcache.go New generic reference counting cache implementation with support for expiration checks and configurable deletion
internal/project/parsecache.go Refactored to use generic RefCountCache; hash now part of cache key
internal/project/extendedconfigcache.go Refactored to use generic RefCountCache with hash-based expiration detection
internal/project/configfileregistrybuilder.go Fixed bug where oldCommandLine was not saved before reload, preventing proper extended config invalidation; updated GetExtendedConfig signature
internal/tsoptions/tsconfigparsing.go Exported ParseExtendedConfig function; updated ExtendedConfigCache interface to pass parameters directly instead of via closure; changed ExtendedSourceFiles to use InsertSorted for deterministic ordering
internal/tsoptions/tsconfigparsing_test.go Updated test mock to match new ExtendedConfigCache interface signature
internal/execute/tsc/extendedconfigcache.go Updated to match new ExtendedConfigCache interface signature
internal/project/compilerhost.go Updated to create ParseCacheKey with hash parameter
internal/project/project.go Updated Ref call to use NewParseCacheKey with hash
internal/project/snapshot.go Updated Deref call to use NewParseCacheKey with hash
internal/project/session.go Updated cache initialization to use new constructors; updated type annotations in cache stats logging
internal/project/refcountcache_test.go Updated test assertions to reflect new behavior where changed files create new cache entries
internal/project/configfilechanges_test.go Added new test for doubly-extended config file changes to verify bug fix
internal/fourslash/fourslash.go Updated ParseCache initialization to use new constructor
internal/ast/ast.go Added Hash field to SourceFile struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants