Index twice to collect dynamic references (#206)
parent
a7d77d844e
commit
d7fc9e0425
|
@ -238,42 +238,43 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
|
|
||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
|
|
||||||
// Parse PHP files
|
foreach (['Collecting definitions and static references', 'Collecting dynamic references'] as $run) {
|
||||||
foreach ($uris as $i => $uri) {
|
$this->client->window->logMessage(MessageType::INFO, $run);
|
||||||
if ($this->documentLoader->isOpen($uri)) {
|
foreach ($uris as $i => $uri) {
|
||||||
continue;
|
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());
|
|
||||||
}
|
}
|
||||||
} 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);
|
// Give LS to the chance to handle requests while indexing
|
||||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
yield timeout();
|
||||||
$this->client->window->logMessage(
|
$this->client->window->logMessage(
|
||||||
MessageType::INFO,
|
MessageType::LOG,
|
||||||
"All $count PHP files parsed in $duration seconds. $mem MiB allocated."
|
"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');
|
$rootPath = realpath(__DIR__ . '/../fixtures');
|
||||||
$input = new MockProtocolStream;
|
$input = new MockProtocolStream;
|
||||||
$output = 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') {
|
if ($msg->body->method === 'textDocument/xcontent') {
|
||||||
// Document content requested
|
// Document content requested
|
||||||
$contentCalled = true;
|
$contentCalled = true;
|
||||||
|
@ -100,8 +101,11 @@ class LanguageServerTest extends TestCase
|
||||||
$promise->reject(new Exception($msg->body->params->message));
|
$promise->reject(new Exception($msg->body->params->message));
|
||||||
}
|
}
|
||||||
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) {
|
} else if (strpos($msg->body->params->message, 'All 25 PHP files parsed') !== false) {
|
||||||
// Indexing finished
|
if ($run === 1) {
|
||||||
$promise->fulfill();
|
$run++;
|
||||||
|
} else {
|
||||||
|
$promise->fulfill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue