Skip to content

Analysis: Introduce ProjectIndex as the front door to a project's indexes - #2185

Merged
marcoroth merged 1 commit into
language-service-view-rootfrom
analysis-project-index
Aug 11, 2026
Merged

Analysis: Introduce ProjectIndex as the front door to a project's indexes#2185
marcoroth merged 1 commit into
language-service-view-rootfrom
analysis-project-index

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 11, 2026

Copy link
Copy Markdown
Owner

This pull request gives a project's indexes a single owner, and deletes the two language server services that were standing in for one.

A project has two indexes, and the caller index is built from the partial index, so it has to be built second. Every caller had to know that. Keeping one file in step meant calling both services and combining the two answers, and the two places that did it used opposite orders:

session.ts, on an edit:

const callersChanged = project.partialCallerIndexService.updateFromSource(uri, text)
const partialsChanged = project.partialIndexService.updateFromSource(uri, text)

server.ts, on a watched file change:

const changed = partials.updateFromDisk(uri)
return callers.updateFromDisk(uri) || changed

Since call sites are resolved against the declarations, those two orders are not equivalent.

One owner

ProjectIndex owns both indexes and the ordering between them. indexAll builds them in sequence, handleChange brings both up to date for one file, and remove drops it from both. Each answers whether anything actually changed, which is what decides whether other open documents need revalidating.

await project.index.indexAll()

project.index.handleChange(uri, document.getText())
project.index.remove(uri)

project.index.partials
project.index.callers
project.index.viewRoot

handleChange takes the source when the caller already has the file in memory and reads from disk otherwise. That is one entry point instead of updateFromSource and updateFromDisk, so the file watcher no longer decides which pair of calls to make.

@github-actions github-actions Bot added language-server @herb-tools/language-server and Language Server Protocol support typescript TypeScript source across the javascript/ packages analysis labels Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 6331a51


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@2185
npx https://pkg.pr.new/@herb-tools/language-server@2185
npx https://pkg.pr.new/@herb-tools/linter@2185

commit: 6331a51

@marcoroth
marcoroth marked this pull request as ready for review August 11, 2026 17:45
@marcoroth
marcoroth merged commit 52a5f57 into main Aug 11, 2026
23 checks passed
@marcoroth
marcoroth deleted the analysis-project-index branch August 11, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analysis language-server @herb-tools/language-server and Language Server Protocol support typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant