2016-09-02 19:13:30 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace LanguageServer\Client;
|
|
|
|
|
|
|
|
use AdvancedJsonRpc\Notification as NotificationBody;
|
|
|
|
use LanguageServer\ProtocolWriter;
|
2016-10-11 13:28:53 +00:00
|
|
|
use LanguageServer\Protocol\Message;
|
2016-09-02 19:13:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides method handlers for all textDocument/* methods
|
|
|
|
*/
|
|
|
|
class TextDocument
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ProtocolWriter
|
|
|
|
*/
|
|
|
|
private $protocolWriter;
|
|
|
|
|
|
|
|
public function __construct(ProtocolWriter $protocolWriter)
|
|
|
|
{
|
|
|
|
$this->protocolWriter = $protocolWriter;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Diagnostics notification are sent from the server to the client to signal results of validation runs.
|
|
|
|
*
|
|
|
|
* @param string $uri
|
|
|
|
* @param Diagnostic[] $diagnostics
|
|
|
|
*/
|
|
|
|
public function publishDiagnostics(string $uri, array $diagnostics)
|
|
|
|
{
|
|
|
|
$this->protocolWriter->write(new Message(new NotificationBody(
|
|
|
|
'textDocument/publishDiagnostics',
|
|
|
|
(object)[
|
|
|
|
'uri' => $uri,
|
|
|
|
'diagnostics' => $diagnostics
|
|
|
|
]
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|