Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all dependencies in a multi-root project are cached #641

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/LanguageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,18 @@ public function initialize(ClientCapabilities $capabilities, string $rootPath =
sortUrisLevelOrder($composerLockFiles);

if (!empty($composerLockFiles)) {
$this->composerLock = json_decode(yield $this->contentRetriever->retrieve($composerLockFiles[0]));
$packages = [];
$packagesDev = [];
foreach ($composerLockFiles as $composerLockFile) {
$composerLock = json_decode(yield $this->contentRetriever->retrieve($composerLockFile));
$packages = array_merge($packages, $composerLock->packages);
$packagesDev = array_merge($packagesDev, $composerLock->{'packages-dev'});
}
$this->composerLock = $composerLock;
$this->composerLock->packages = $packages;
$this->composerLock->{'packages-dev'} = $packagesDev;
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, are you sure aggregating all packages work? What if the same package appears with different versions, and then the cache key that is used for the index is not actually the package version that was indexed?

}
}

$cache = $capabilities->xcacheProvider ? new ClientCache($this->client) : new FileSystemCache;

// Index in background
Expand Down