From 71608b1f459e8faffaeba48e9b5ba08038b5ab00 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Thu, 17 Nov 2016 22:04:53 +0100 Subject: [PATCH] Index files serially again --- src/LanguageServer.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/LanguageServer.php b/src/LanguageServer.php index 9a89066..c94f2bc 100644 --- a/src/LanguageServer.php +++ b/src/LanguageServer.php @@ -179,24 +179,22 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher $startTime = microtime(true); - yield Promise\all(array_map(function ($textDocument, $i) use ($count) { - return coroutine(function () use ($textDocument, $i, $count) { - // Give LS to the chance to handle requests while indexing - yield timeout(); + foreach ($textDocuments as $i => $textDocument) { + // Give LS to the chance to handle requests while indexing + yield timeout(); + $this->client->window->logMessage( + MessageType::INFO, + "Parsing file $i/$count: {$textDocument->uri}" + ); + try { + yield $this->project->loadDocument($textDocument->uri); + } catch (Exception $e) { $this->client->window->logMessage( - MessageType::INFO, - "Parsing file $i/$count: {$textDocument->uri}" + MessageType::ERROR, + "Error parsing file {$textDocument->uri}: " . (string)$e ); - try { - yield $this->project->loadDocument($textDocument->uri); - } catch (Exception $e) { - $this->client->window->logMessage( - MessageType::ERROR, - "Error parsing file {$textDocument->uri}: " . (string)$e - ); - } - }); - }, $textDocuments, array_keys($textDocuments))); + } + } $duration = (int)(microtime(true) - $startTime); $mem = (int)(memory_get_usage(true) / (1024 * 1024));