* Fetch a project's state, creating it if new, and mark it most-recently-used. * Evicts the LRU project past the bound — dropping a project entirely (rather * than its detail) is right here: a session that has moved on to four other * repos is not about to re-ask the first one.
(key: string, projectRoot: string)
| 287 | * repos is not about to re-ask the first one. |
| 288 | */ |
| 289 | private touch(key: string, projectRoot: string): MutableProjectState { |
| 290 | const existing = this.projects.get(key); |
| 291 | if (existing) { |
| 292 | this.projects.delete(key); |
| 293 | this.projects.set(key, existing); |
| 294 | return existing; |
| 295 | } |
| 296 | const created: MutableProjectState = { projectRoot, callCount: 0, responseBytes: 0, calls: [] }; |
| 297 | this.projects.set(key, created); |
| 298 | while (this.projects.size > EXPLORE_SESSION_LIMITS.MAX_PROJECTS) { |
| 299 | const lru = this.projects.keys().next().value as string | undefined; |
| 300 | if (lru === undefined) break; |
| 301 | this.projects.delete(lru); |
| 302 | } |
| 303 | return created; |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Normalize + bound one call's files: coalesce each file's ranges, then keep |