Skip to content

Service and plugin lookups in files open at startup - #569

Merged
AJenbo merged 3 commits into
PHPantom-dev:mainfrom
giuseppe-esposito-87:fix-container-lookups-before-index
Nov 12, 2026
Merged

AJenbo merged 3 commits into
PHPantom-dev:mainfrom
giuseppe-esposito-87:fix-container-lookups-before-index

Conversation

@giuseppe-esposito-87

Copy link
Copy Markdown
Contributor

🤖 This was written by an AI agent on behalf of @giuseppe-esposito-87 (claude-code/claude-opus-5-5).

Fixes service and plugin lookups in files the editor opened before indexing ended. A lookup such as \Drupal::service('entity_type.manager')->getStorage('node') or \Drupal::service('plugin.manager.block')->createInstance('…') in a restored tab stayed unresolved until the file was edited, so go to definition on the ID found nothing.

// Open in the editor at startup, before the project is indexed:
\Drupal::service('plugin.manager.block')->createInstance('acme_greeting_block');  // now goes to the block class once indexing ends
  • Lookups recompute when the service container, the plugin managers or a service provider's alter() change, so they follow these files as they are read or edited.
  • No stale answer is kept when one of these changes lands while a lookup is being worked out.

On Drupal core 11.4 and on the redirect and flag modules, analyze reports exactly what main reports, and the Drupal and Symfony completion benchmarks pass.

How to test: run composer install in examples/drupal and open web/modules/custom/acme/src/Controller/GreetingController.php with this branch's build. Restart the editor with that tab open, wait for indexing to end, and go to the definition of 'acme_greeting_block' in block() without editing the file: it lands on the block class.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, examples/). Not applicable: no documented behaviour changes.
  • I have updated the config schema (config-schema.json). Not applicable: this PR adds or changes no setting.
  • I have added/updated tests to cover my changes
  • If I used AI tools, I have reviewed what they produced and can explain
    the changes and why they are needed.
  • I have read through any AI-generated text, especially documentation,
    the changelog, and other user-facing content, and removed or corrected
    anything inaccurate, unclear, or unnecessary.

@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.84946% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/drupal/service_providers.rs 84.61% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@AJenbo AJenbo added this to the Sprint 8 milestone Nov 12, 2026
giuseppe-esposito-87 and others added 3 commits November 12, 2026 20:55
A file the editor has open before the workspace index runs confirms its
typed receivers against a container nothing has filled yet, and kept
that answer until the file was edited. Clear the confirmed spans when
the container's declarations change.

Assisted-by: claude-code/claude-opus-5-5
A file's typed receivers confirmed against the old container or the old
signatures, and cached after the change cleared the cache, kept that
answer. Stamp each file's confirmed spans with an epoch read before
confirming, and keep them only if the epoch has not moved since. The
epoch moves wherever the cache was cleared, whenever the container index
is retired, and when the plugin managers or a service provider's class
replacements change, so an answer that predates a change is never
served. A declaring file is now noted in the container after joining the
set of declaring files, so a lookup that reads the new generation builds
the index from it.

Assisted-by: claude-code/claude-opus-5-5
Confirming a receiver as a plugin manager reads only the managers, but
the confirmed spans were retired whenever a file's plugin sources
changed. Those include the plugin declarations and their offsets, so
indexing or editing any plugin class threw away every file's confirmed
lookups. Retire them only when the file's managers change, and say why
signature changes retire them before the container index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AJenbo
AJenbo force-pushed the fix-container-lookups-before-index branch from 191dd17 to 0251826 Compare November 12, 2026 20:12
@AJenbo
AJenbo merged commit d49e1dd into PHPantom-dev:main Nov 12, 2026
15 checks passed
@AJenbo

AJenbo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

thanks

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.

3 participants