-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathWorkspace.php
More file actions
46 lines (40 loc) Β· 1.05 KB
/
Workspace.php
File metadata and controls
46 lines (40 loc) Β· 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace LanguageServer\Client;
use LanguageServer\ClientHandler;
use LanguageServerProtocol\TextDocumentIdentifier;
use Sabre\Event\Promise;
use JsonMapper;
/**
* Provides method handlers for all workspace/* methods
*/
class Workspace
{
/**
* @var ClientHandler
*/
private $handler;
/**
* @var JsonMapper
*/
private $mapper;
public function __construct(ClientHandler $handler, JsonMapper $mapper)
{
$this->handler = $handler;
$this->mapper = $mapper;
}
/**
* Returns a list of all files in a directory
*
* @param string $base The base directory (defaults to the workspace)
* @return Promise <TextDocumentIdentifier[]> Array of documents
*/
public function xfiles(string $base = null): \Generator
{
$textDocuments = yield from $this->handler->request(
'workspace/xfiles',
['base' => $base]
);
return $this->mapper->mapArray($textDocuments, [], TextDocumentIdentifier::class);
}
}