Index twice to collect dynamic references (#206)
parent
a7d77d844e
commit
d7fc9e0425
|
@ -238,42 +238,43 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
|
||||
$startTime = microtime(true);
|
||||
|
||||
// Parse PHP files
|
||||
foreach ($uris as $i => $uri) {
|
||||
if ($this->documentLoader->isOpen($uri)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Give LS to the chance to handle requests while indexing
|
||||
yield timeout();
|
||||
$this->client->window->logMessage(
|
||||
MessageType::LOG,
|
||||
"Parsing file $i/$count: {$uri}"
|
||||
);
|
||||
try {
|
||||
$document = yield $this->documentLoader->load($uri);
|
||||
if (!$document->isVendored()) {
|
||||
$this->client->textDocument->publishDiagnostics($uri, $document->getDiagnostics());
|
||||
foreach (['Collecting definitions and static references', 'Collecting dynamic references'] as $run) {
|
||||
$this->client->window->logMessage(MessageType::INFO, $run);
|
||||
foreach ($uris as $i => $uri) {
|
||||
if ($this->documentLoader->isOpen($uri)) {
|
||||
continue;
|
||||
}
|
||||
} catch (ContentTooLargeException $e) {
|
||||
$this->client->window->logMessage(
|
||||
MessageType::INFO,
|
||||
"Ignoring file {$uri} because it exceeds size limit of {$e->limit} bytes ({$e->size})"
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->client->window->logMessage(
|
||||
MessageType::ERROR,
|
||||
"Error parsing file {$uri}: " . (string)$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$duration = (int)(microtime(true) - $startTime);
|
||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
||||
$this->client->window->logMessage(
|
||||
MessageType::INFO,
|
||||
"All $count PHP files parsed in $duration seconds. $mem MiB allocated."
|
||||
);
|
||||
// Give LS to the chance to handle requests while indexing
|
||||
yield timeout();
|
||||
$this->client->window->logMessage(
|
||||
MessageType::LOG,
|
||||
"Parsing file $i/$count: {$uri}"
|
||||
);
|
||||
try {
|
||||
$document = yield $this->documentLoader->load($uri);
|
||||
if (!$document->isVendored()) {
|
||||
$this->client->textDocument->publishDiagnostics($uri, $document->getDiagnostics());
|
||||
}
|
||||
} catch (ContentTooLargeException $e) {
|
||||
$this->client->window->logMessage(
|
||||
MessageType::INFO,
|
||||
"Ignoring file {$uri} because it exceeds size limit of {$e->limit} bytes ({$e->size})"
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->client->window->logMessage(
|
||||
MessageType::ERROR,
|
||||
"Error parsing file {$uri}: " . (string)$e
|
||||
);
|
||||
}
|
||||
}
|
||||
$duration = (int)(microtime(true) - $startTime);
|
||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
||||
$this->client->window->logMessage(
|
||||
MessageType::INFO,
|
||||
"All $count PHP files parsed in $duration seconds. $mem MiB allocated."
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,8 @@ class LanguageServerTest extends TestCase
|
|||
$rootPath = realpath(__DIR__ . '/../fixtures');
|
||||
$input = new MockProtocolStream;
|
||||
$output = new MockProtocolStream;
|
||||
$output->on('message', function (Message $msg) use ($promise, $input, $rootPath, &$filesCalled, &$contentCalled) {
|
||||
$run = 1;
|
||||
$output->on('message', function (Message $msg) use ($promise, $input, $rootPath, &$filesCalled, &$contentCalled, &$run) {
|
||||
if ($msg->body->method === 'textDocument/xcontent') {
|
||||
// Document content requested
|
||||
$contentCalled = true;
|
||||
|
@ -100,8 +101,11 @@ class LanguageServerTest extends TestCase
|
|||
$promise->reject(new Exception($msg->body->params->message));
|
||||
}
|
||||
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) {
|
||||
// Indexing finished
|
||||
$promise->fulfill();
|
||||
if ($run === 1) {
|
||||
$run++;
|
||||
} else {
|
||||
$promise->fulfill();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue