Merge branch 'master' into no-fs
commit
745fec4d92
|
@ -199,7 +199,10 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
|
||||
$duration = (int)(microtime(true) - $startTime);
|
||||
$mem = (int)(memory_get_usage(true) / (1024 * 1024));
|
||||
$this->client->window->logMessage(MessageType::INFO, "All PHP files parsed in $duration seconds. $mem MiB allocated.");
|
||||
$this->client->window->logMessage(
|
||||
MessageType::INFO,
|
||||
"All $count PHP files parsed in $duration seconds. $mem MiB allocated."
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -226,7 +229,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
yield timeout();
|
||||
}
|
||||
});
|
||||
}, $patterns))->then(function () use ($textDocuments) {
|
||||
}, $patterns))->then(function () use (&$textDocuments) {
|
||||
return $textDocuments;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ function pathToUri(string $filepath): string
|
|||
if (substr($first, -1) !== ':') {
|
||||
$first = urlencode($first);
|
||||
}
|
||||
$parts = array_map('urlencode', $parts);
|
||||
$parts = array_map('rawurlencode', $parts);
|
||||
array_unshift($parts, $first);
|
||||
$filepath = implode('/', $parts);
|
||||
return 'file:///' . $filepath;
|
||||
|
|
|
@ -5,8 +5,10 @@ namespace LanguageServer\Tests;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use LanguageServer\LanguageServer;
|
||||
use LanguageServer\Protocol\{Message, ClientCapabilities, TextDocumentSyncKind};
|
||||
use LanguageServer\Protocol\{Message, ClientCapabilities, TextDocumentSyncKind, MessageType};
|
||||
use AdvancedJsonRpc;
|
||||
use Sabre\Event\Promise;
|
||||
use function LanguageServer\pathToUri;
|
||||
|
||||
class LanguageServerTest extends TestCase
|
||||
{
|
||||
|
@ -46,4 +48,24 @@ class LanguageServerTest extends TestCase
|
|||
]
|
||||
], $msg->body->result);
|
||||
}
|
||||
|
||||
public function testIndexing()
|
||||
{
|
||||
$promise = new Promise;
|
||||
$input = new MockProtocolStream;
|
||||
$output = new MockProtocolStream;
|
||||
$output->on('message', function (Message $msg) use ($promise) {
|
||||
if ($msg->body->method === 'window/logMessage') {
|
||||
if ($msg->body->params->type === MessageType::ERROR) {
|
||||
$promise->reject();
|
||||
} else if (strpos($msg->body->params->message, 'All 10 PHP files parsed') !== false) {
|
||||
$promise->fulfill();
|
||||
}
|
||||
}
|
||||
});
|
||||
$server = new LanguageServer($input, $output);
|
||||
$capabilities = new ClientCapabilities;
|
||||
$server->initialize(getmypid(), $capabilities, realpath(__DIR__ . '/../fixtures'));
|
||||
$promise->wait();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class FileUriTest extends TestCase
|
|||
|
||||
// special chars are escaped
|
||||
$uri = pathToUri('c:/path/to/file/dürüm döner.php');
|
||||
$this->assertEquals('file:///c:/path/to/file/d%C3%BCr%C3%BCm+d%C3%B6ner.php', $uri);
|
||||
$this->assertEquals('file:///c:/path/to/file/d%C3%BCr%C3%BCm%20d%C3%B6ner.php', $uri);
|
||||
|
||||
//backslashes are transformed
|
||||
$uri = pathToUri('c:\\foo\\bar.baz');
|
||||
|
|
Loading…
Reference in New Issue