Handle case where $rootPath is null
parent
f2884c0e82
commit
0a0cd22a0a
|
@ -101,11 +101,10 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
{
|
{
|
||||||
$this->rootPath = $rootPath;
|
$this->rootPath = $rootPath;
|
||||||
|
|
||||||
$this->restoreCache();
|
|
||||||
|
|
||||||
// start building project index
|
// start building project index
|
||||||
if ($rootPath) {
|
if ($rootPath !== null) {
|
||||||
$this->indexProject($rootPath);
|
$this->restoreCache();
|
||||||
|
$this->indexProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverCapabilities = new ServerCapabilities();
|
$serverCapabilities = new ServerCapabilities();
|
||||||
|
@ -136,8 +135,10 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
*/
|
*/
|
||||||
public function shutdown()
|
public function shutdown()
|
||||||
{
|
{
|
||||||
|
if ($this->rootPath !== null) {
|
||||||
$this->saveCache();
|
$this->saveCache();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A notification to ask the server to exit its process.
|
* A notification to ask the server to exit its process.
|
||||||
|
@ -152,23 +153,23 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
/**
|
/**
|
||||||
* Parses workspace files, one at a time.
|
* Parses workspace files, one at a time.
|
||||||
*
|
*
|
||||||
* @param string $rootPath The rootPath of the workspace.
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function indexProject(string $rootPath)
|
private function indexProject()
|
||||||
{
|
{
|
||||||
$fileList = findFilesRecursive($rootPath, '/^.+\.php$/i');
|
$fileList = findFilesRecursive($this->rootPath, '/^.+\.php$/i');
|
||||||
$numTotalFiles = count($fileList);
|
$numTotalFiles = count($fileList);
|
||||||
|
|
||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
$fileNum = 0;
|
$fileNum = 0;
|
||||||
|
|
||||||
$processFile = function() use (&$fileList, &$fileNum, &$processFile, $rootPath, $numTotalFiles, $startTime) {
|
$processFile = function() use (&$fileList, &$fileNum, &$processFile, $numTotalFiles, $startTime) {
|
||||||
if ($fileNum < $numTotalFiles) {
|
if ($fileNum < $numTotalFiles) {
|
||||||
$file = $fileList[$fileNum];
|
$file = $fileList[$fileNum];
|
||||||
$uri = pathToUri($file);
|
$uri = pathToUri($file);
|
||||||
$fileNum++;
|
$fileNum++;
|
||||||
$shortName = substr($file, strlen($rootPath) + 1);
|
$shortName = substr($file, strlen($this->rootPath) + 1);
|
||||||
|
$this->client->window->logMessage(MessageType::INFO, "Parsing file $fileNum/$numTotalFiles: $shortName.");
|
||||||
|
|
||||||
if (filesize($file) > 500000) {
|
if (filesize($file) > 500000) {
|
||||||
$this->client->window->logMessage(MessageType::INFO, "Not parsing $shortName because it exceeds size limit of 0.5MB");
|
$this->client->window->logMessage(MessageType::INFO, "Not parsing $shortName because it exceeds size limit of 0.5MB");
|
||||||
|
|
Loading…
Reference in New Issue