Merge branch 'master' into master
commit
82bc3e8b20
|
@ -179,24 +179,22 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
|
|
||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
|
|
||||||
yield Promise\all(array_map(function ($textDocument, $i) use ($count) {
|
foreach ($textDocuments as $i => $textDocument) {
|
||||||
return coroutine(function () use ($textDocument, $i, $count) {
|
// Give LS to the chance to handle requests while indexing
|
||||||
// Give LS to the chance to handle requests while indexing
|
yield timeout();
|
||||||
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(
|
$this->client->window->logMessage(
|
||||||
MessageType::INFO,
|
MessageType::ERROR,
|
||||||
"Parsing file $i/$count: {$textDocument->uri}"
|
"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);
|
$duration = (int)(microtime(true) - $startTime);
|
||||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
||||||
|
|
|
@ -58,9 +58,9 @@ class LanguageServerTest extends TestCase
|
||||||
$input = new MockProtocolStream;
|
$input = new MockProtocolStream;
|
||||||
$output = new MockProtocolStream;
|
$output = new MockProtocolStream;
|
||||||
$output->on('message', function (Message $msg) use ($promise) {
|
$output->on('message', function (Message $msg) use ($promise) {
|
||||||
if ($msg->body->method === 'window/logMessage') {
|
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
|
||||||
if ($msg->body->params->type === MessageType::ERROR) {
|
if ($msg->body->params->type === MessageType::ERROR) {
|
||||||
$promise->reject();
|
$promise->reject(new Exception($msg->body->params->message));
|
||||||
} else if (strpos($msg->body->params->message, 'All 10 PHP files parsed') !== false) {
|
} else if (strpos($msg->body->params->message, 'All 10 PHP files parsed') !== false) {
|
||||||
$promise->fulfill();
|
$promise->fulfill();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue