mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
pass progress higher up
This commit is contained in:
parent
81d37311d5
commit
a697c79a37
@ -140,10 +140,13 @@ class LanguageServer extends Dispatcher
|
||||
ProtocolReader $reader,
|
||||
ProtocolWriter $writer,
|
||||
ProjectAnalyzer $project_analyzer,
|
||||
ClientConfiguration $clientConfiguration
|
||||
ClientConfiguration $clientConfiguration,
|
||||
Progress $progress
|
||||
) {
|
||||
parent::__construct($this, '/');
|
||||
|
||||
$progress->setServer($this);
|
||||
|
||||
$this->project_analyzer = $project_analyzer;
|
||||
|
||||
$this->protocolWriter = $writer;
|
||||
@ -229,8 +232,6 @@ class LanguageServer extends Dispatcher
|
||||
|
||||
$this->client = new LanguageClient($reader, $writer, $this, $clientConfiguration);
|
||||
|
||||
$this->project_analyzer->progress = new Progress($this);
|
||||
|
||||
$this->logInfo("Psalm Language Server ".PSALM_VERSION." has started.");
|
||||
}
|
||||
|
||||
@ -239,6 +240,7 @@ class LanguageServer extends Dispatcher
|
||||
*/
|
||||
public static function run(Config $config, ClientConfiguration $clientConfiguration, string $base_dir): void
|
||||
{
|
||||
$progress = new Progress();
|
||||
//no-cache mode does not work in the LSP
|
||||
$providers = new Providers(
|
||||
new FileProvider,
|
||||
@ -251,7 +253,11 @@ class LanguageServer extends Dispatcher
|
||||
|
||||
$project_analyzer = new ProjectAnalyzer(
|
||||
$config,
|
||||
$providers
|
||||
$providers,
|
||||
null,
|
||||
[],
|
||||
1,
|
||||
$progress
|
||||
);
|
||||
|
||||
if ($config->find_unused_variables) {
|
||||
@ -283,7 +289,8 @@ class LanguageServer extends Dispatcher
|
||||
new ProtocolStreamReader($socket),
|
||||
new ProtocolStreamWriter($socket),
|
||||
$project_analyzer,
|
||||
$clientConfiguration
|
||||
$clientConfiguration,
|
||||
$progress
|
||||
);
|
||||
Loop::run();
|
||||
} elseif ($clientConfiguration->TCPServerMode && $clientConfiguration->TCPServerAddress) {
|
||||
@ -336,7 +343,8 @@ class LanguageServer extends Dispatcher
|
||||
$reader,
|
||||
new ProtocolStreamWriter($socket),
|
||||
$project_analyzer,
|
||||
$clientConfiguration
|
||||
$clientConfiguration,
|
||||
$progress
|
||||
);
|
||||
// Just for safety
|
||||
exit(0);
|
||||
@ -348,7 +356,8 @@ class LanguageServer extends Dispatcher
|
||||
new ProtocolStreamReader($socket),
|
||||
new ProtocolStreamWriter($socket),
|
||||
$project_analyzer,
|
||||
$clientConfiguration
|
||||
$clientConfiguration,
|
||||
$progress
|
||||
);
|
||||
Loop::run();
|
||||
}
|
||||
@ -360,7 +369,8 @@ class LanguageServer extends Dispatcher
|
||||
new ProtocolStreamReader(STDIN),
|
||||
new ProtocolStreamWriter(STDOUT),
|
||||
$project_analyzer,
|
||||
$clientConfiguration
|
||||
$clientConfiguration,
|
||||
$progress
|
||||
);
|
||||
Loop::run();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Psalm\Internal\LanguageServer;
|
||||
|
||||
use Psalm\Progress\Progress as Base;
|
||||
use function str_replace;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -11,22 +12,31 @@ class Progress extends Base
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LanguageServer
|
||||
* @var LanguageServer|null
|
||||
*/
|
||||
private $server;
|
||||
|
||||
public function __construct(LanguageServer $server)
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function setServer(LanguageServer $server): void
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
public function debug(string $message): void
|
||||
{
|
||||
$this->server->logDebug($message);
|
||||
if ($this->server) {
|
||||
$this->server->logDebug(str_replace("\n", "", $message));
|
||||
}
|
||||
}
|
||||
|
||||
public function write(string $message): void
|
||||
{
|
||||
$this->server->logInfo($message);
|
||||
if ($this->server) {
|
||||
$this->server->logInfo(str_replace("\n", "", $message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user