1
0
Fork 0

Use file stat

pull/161/head
Felix Becker 2016-11-18 13:12:40 +01:00
parent fcc9ac714b
commit ccd97ce377
1 changed files with 11 additions and 6 deletions

View File

@ -103,17 +103,22 @@ class Project
public function loadDocument(string $uri): Promise
{
return coroutine(function () use ($uri) {
$limit = 150000;
if ($this->clientCapabilities->xcontentProvider) {
$content = (yield $this->client->textDocument->xcontent(new TextDocumentIdentifier($uri)))->text;
$size = strlen($content);
if ($size > $limit) {
throw new ContentTooLargeException($uri, $size, $limit);
}
} else {
$content = file_get_contents(uriToPath($uri));
$path = uriToPath($uri);
$size = filesize($path);
if ($size > $limit) {
throw new ContentTooLargeException($uri, $size, $limit);
}
$content = file_get_contents($path);
}
// Don't parse large files
$size = strlen($content);
$limit = 150000;
if ($size > $limit) {
throw new ContentTooLargeException($uri, $size, $limit);
}
if (isset($this->documents[$uri])) {
$document = $this->documents[$uri];
$document->updateContent($content);