Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Aug 31, 2023
1 parent 2e5d936 commit de40978
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function __construct(
self::$instance = $this;

if ($threads > 1) {
$this->pool = new Pool($threads);
$this->pool = new Pool($threads, $this);
}
}

Expand Down Expand Up @@ -401,7 +401,7 @@ public function serverMode(LanguageServer $server): void

if ($usable_cpus > 1) {
$this->threads = $usable_cpus;
$this->pool = new Pool($usable_cpus);
$this->pool = new Pool($usable_cpus, $this);
}

$server->logInfo("Initializing: Initialize Plugins...");
Expand Down
8 changes: 2 additions & 6 deletions src/Psalm/Internal/Fork/InitStartupTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@

final class InitStartupTask implements Task
{
private readonly ProjectAnalyzer $analyzer;
private readonly Config $config;
private readonly string $memoryLimit;
private readonly array $server;
private readonly ?string $processTitle;
final public function __construct()
final public function __construct(private ProjectAnalyzer $analyzer)
{
$this->analyzer = ProjectAnalyzer::getInstance();
$this->config = Config::getInstance();
$this->memoryLimit = ini_get('memory_limit');
$this->server = IssueBuffer::getServer();
if (function_exists('cli_get_process_title')) {
Expand All @@ -62,7 +58,7 @@ final public function run(Channel $channel, Cancellation $cancellation): mixed
// More initialization is needed but doing just this for now...

ProjectAnalyzer::$instance = $this->analyzer;
Config::setInstance($this->config);
Config::setInstance($this->analyzer->getConfig());

if (function_exists('cli_set_process_title') && $this->processTitle !== null) {
@cli_set_process_title($this->processTitle);
Expand Down
5 changes: 3 additions & 2 deletions src/Psalm/Internal/Fork/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Amp\Parallel\Worker\WorkerPool;
use AssertionError;
use Closure;
use Psalm\Internal\Analyzer\ProjectAnalyzer;

use function Amp\Future\await;
use function array_map;
Expand All @@ -36,7 +37,7 @@ final class Pool
/**
* @param int<2, max> $threads
*/
public function __construct(private readonly int $threads)
public function __construct(private readonly int $threads, ProjectAnalyzer $project_analyzer)
{
// TODO: disable xdebug
$additional_options = [];
Expand All @@ -55,7 +56,7 @@ public function __construct(private readonly int $threads)
),
);

$this->runAll(new InitStartupTask);
$this->runAll(new InitStartupTask($project_analyzer));
}
/**
* @template TFinalResult
Expand Down

0 comments on commit de40978

Please sign in to comment.