Skip to content

Commit 51814c2

Browse files
committed
Fix index building.
1 parent 2a8a788 commit 51814c2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/Tsufeki/Tenkawa/Server/Feature/Configuration/ConfigurationFeature.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ConfigurationFeature implements Feature, MethodProvider, OnInit
2323
private $registrationFeature;
2424

2525
/**
26-
* @var MappedJsonRpc
26+
* @var MappedJsonRpc|null
2727
*/
2828
private $rpc;
2929

@@ -78,7 +78,7 @@ class ConfigurationFeature implements Feature, MethodProvider, OnInit
7878
public function __construct(
7979
$serverDefaults,
8080
RegistrationFeature $registrationFeature,
81-
MappedJsonRpc $rpc,
81+
?MappedJsonRpc $rpc = null,
8282
LoggerInterface $logger
8383
) {
8484
$this->registrationFeature = $registrationFeature;
@@ -244,14 +244,14 @@ public function didChangeConfiguration($settings = null): \Generator
244244
*/
245245
private function getConfiguration(array $items): \Generator
246246
{
247-
if (!$this->supportsConfigurationRequest) {
247+
if (!$this->supportsConfigurationRequest || $this->rpc === null) {
248248
return [];
249249
}
250250

251251
$this->logger->debug('send: ' . __FUNCTION__);
252252

253253
try {
254-
return yield $this->rpc->call('workspace/configuration', compact('items'), 'mixed');
254+
return (yield $this->rpc->call('workspace/configuration', compact('items'), 'mixed')) ?? [];
255255
} catch (\Exception $e) {
256256
$this->logger->error('Failed to fetch configuration', ['exception' => $e]);
257257

src/Tsufeki/Tenkawa/Server/Feature/Registration/RegistrationFeature.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class RegistrationFeature implements Feature
1212
{
1313
/**
14-
* @var MappedJsonRpc
14+
* @var MappedJsonRpc|null
1515
*/
1616
private $rpc;
1717

@@ -21,7 +21,7 @@ class RegistrationFeature implements Feature
2121
private $logger;
2222

2323
public function __construct(
24-
MappedJsonRpc $rpc,
24+
?MappedJsonRpc $rpc = null,
2525
LoggerInterface $logger
2626
) {
2727
$this->rpc = $rpc;
@@ -50,6 +50,10 @@ public function initialize(ClientCapabilities $clientCapabilities, ServerCapabil
5050
*/
5151
public function registerCapability(array $registrations): \Generator
5252
{
53+
if ($this->rpc === null) {
54+
throw new \LogicException('Not connected');
55+
}
56+
5357
$unregistrations = [];
5458
foreach ($registrations as $registration) {
5559
$registration->id = $registration->id ?? $this->generateId();
@@ -73,6 +77,10 @@ public function registerCapability(array $registrations): \Generator
7377
*/
7478
public function unregisterCapability(array $unregisterations): \Generator
7579
{
80+
if ($this->rpc === null) {
81+
throw new \LogicException('Not connected');
82+
}
83+
7684
$this->logger->debug('send: ' . __FUNCTION__);
7785
yield $this->rpc->call('client/unregisterCapability', compact('unregisterations'));
7886
}

0 commit comments

Comments
 (0)