1
0
Fork 0

Add workspace/xGlob method

pull/136/head
Felix Becker 2016-10-30 23:14:45 +01:00
parent 04ef6c8adf
commit 6d1f1ff1d3
3 changed files with 54 additions and 1 deletions

View File

@ -29,7 +29,8 @@
"sabre/event": "^5.0", "sabre/event": "^5.0",
"felixfbecker/advanced-json-rpc": "^2.0", "felixfbecker/advanced-json-rpc": "^2.0",
"squizlabs/php_codesniffer" : "^2.7", "squizlabs/php_codesniffer" : "^2.7",
"symfony/debug": "^3.1" "symfony/debug": "^3.1",
"netresearch/jsonmapper": "^1.0"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,

44
src/Client/Workspace.php Normal file
View File

@ -0,0 +1,44 @@
<?php
declare(strict_types = 1);
namespace LanguageServer\Client;
use LanguageServer\ClientHandler;
use LanguageServer\Protocol\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 the workspace that match a glob pattern
*
* @param string $pattern A glob pattern
* @return Promise <TextDocumentIdentifier[]> Array of documents that match the glob pattern
*/
public function xGlob(string $pattern): Promise
{
return $this->handler->request('workspace/xGlob', ['pattern' => $pattern])->then(function ($textDocuments) {
return $this->mapper->mapArray($textDocuments, [], TextDocumentIdentifier::class);
});
}
}

View File

@ -19,11 +19,19 @@ class LanguageClient
*/ */
public $window; public $window;
/**
* Handles workspace/* methods
*
* @var Client\Workspace
*/
public $workspace;
public function __construct(ProtocolReader $reader, ProtocolWriter $writer) public function __construct(ProtocolReader $reader, ProtocolWriter $writer)
{ {
$handler = new ClientHandler($reader, $writer); $handler = new ClientHandler($reader, $writer);
$this->textDocument = new Client\TextDocument($handler); $this->textDocument = new Client\TextDocument($handler);
$this->window = new Client\Window($handler); $this->window = new Client\Window($handler);
$this->workspace = new Client\Workspace($handler, $mapper);
} }
} }