From 6d1f1ff1d3e1e5d73f9d24554b07fdac35e6fd15 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Sun, 30 Oct 2016 23:14:45 +0100 Subject: [PATCH] Add workspace/xGlob method --- composer.json | 3 ++- src/Client/Workspace.php | 44 ++++++++++++++++++++++++++++++++++++++++ src/LanguageClient.php | 8 ++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/Client/Workspace.php diff --git a/composer.json b/composer.json index 6d9159b..ffb4776 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "sabre/event": "^5.0", "felixfbecker/advanced-json-rpc": "^2.0", "squizlabs/php_codesniffer" : "^2.7", - "symfony/debug": "^3.1" + "symfony/debug": "^3.1", + "netresearch/jsonmapper": "^1.0" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/src/Client/Workspace.php b/src/Client/Workspace.php new file mode 100644 index 0000000..567cceb --- /dev/null +++ b/src/Client/Workspace.php @@ -0,0 +1,44 @@ +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 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); + }); + } +} diff --git a/src/LanguageClient.php b/src/LanguageClient.php index 1f3c42a..70ff952 100644 --- a/src/LanguageClient.php +++ b/src/LanguageClient.php @@ -19,11 +19,19 @@ class LanguageClient */ public $window; + /** + * Handles workspace/* methods + * + * @var Client\Workspace + */ + public $workspace; + public function __construct(ProtocolReader $reader, ProtocolWriter $writer) { $handler = new ClientHandler($reader, $writer); $this->textDocument = new Client\TextDocument($handler); $this->window = new Client\Window($handler); + $this->workspace = new Client\Workspace($handler, $mapper); } }