Ignore errors from dependencies
parent
03bbf5f4ba
commit
0e67baca55
|
@ -19,6 +19,7 @@ use phpDocumentor\Reflection\DocBlockFactory;
|
|||
use function LanguageServer\Fqn\{getDefinedFqn, getVariableDefinition, getReferencedFqn};
|
||||
use Sabre\Event\Promise;
|
||||
use function Sabre\Event\coroutine;
|
||||
use Sabre\Uri;
|
||||
|
||||
class PhpDocument
|
||||
{
|
||||
|
@ -208,8 +209,21 @@ class PhpDocument
|
|||
$this->stmts = $stmts;
|
||||
}
|
||||
|
||||
if (!$this->isVendored()) {
|
||||
$this->client->textDocument->publishDiagnostics($this->uri, $diagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the document is a dependency
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVendored(): bool
|
||||
{
|
||||
$path = Uri\parse($this->uri)['path'];
|
||||
return strpos($path, '/vendor/') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of TextEdit changes to format this document.
|
||||
|
|
|
@ -37,4 +37,22 @@ class PhpDocumentTest extends TestCase
|
|||
$this->assertInstanceOf(Node\Name\FullyQualified::class, $node);
|
||||
$this->assertEquals('SomeClass', (string)$node);
|
||||
}
|
||||
|
||||
public function testIsVendored()
|
||||
{
|
||||
$document = $this->project->openDocument('file:///dir/vendor/x.php', "<?php\n$\$a = new SomeClass;");
|
||||
$this->assertEquals(true, $document->isVendored());
|
||||
|
||||
$document = $this->project->openDocument('file:///c:/dir/vendor/x.php', "<?php\n$\$a = new SomeClass;");
|
||||
$this->assertEquals(true, $document->isVendored());
|
||||
|
||||
$document = $this->project->openDocument('file:///vendor/x.php', "<?php\n$\$a = new SomeClass;");
|
||||
$this->assertEquals(true, $document->isVendored());
|
||||
|
||||
$document = $this->project->openDocument('file:///dir/vendor.php', "<?php\n$\$a = new SomeClass;");
|
||||
$this->assertEquals(false, $document->isVendored());
|
||||
|
||||
$document = $this->project->openDocument('file:///dir/x.php', "<?php\n$\$a = new SomeClass;");
|
||||
$this->assertEquals(false, $document->isVendored());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue