|
5 | 5 |
|
6 | 6 | use LanguageServer\{LanguageClient, Project, PhpDocumentLoader}; |
7 | 7 | use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index}; |
8 | | -use LanguageServer\Protocol\{SymbolInformation, SymbolDescriptor, ReferenceInformation, DependencyReference, Location}; |
| 8 | +use LanguageServer\Protocol\{ |
| 9 | + FileChangeType, |
| 10 | + FileEvent, |
| 11 | + SymbolInformation, |
| 12 | + SymbolDescriptor, |
| 13 | + ReferenceInformation, |
| 14 | + DependencyReference, |
| 15 | + Location |
| 16 | +}; |
9 | 17 | use Sabre\Event\Promise; |
10 | 18 | use function Sabre\Event\coroutine; |
11 | 19 | use function LanguageServer\{waitForEvent, getPackageName}; |
|
15 | 23 | */ |
16 | 24 | class Workspace |
17 | 25 | { |
| 26 | + /** |
| 27 | + * @var LanguageClient |
| 28 | + */ |
| 29 | + public $client; |
| 30 | + |
18 | 31 | /** |
19 | 32 | * The symbol index for the workspace |
20 | 33 | * |
@@ -43,14 +56,16 @@ class Workspace |
43 | 56 | public $documentLoader; |
44 | 57 |
|
45 | 58 | /** |
| 59 | + * @param LanguageClient $client LanguageClient instance used to signal updated results |
46 | 60 | * @param ProjectIndex $index Index that is searched on a workspace/symbol request |
47 | 61 | * @param DependenciesIndex $dependenciesIndex Index that is used on a workspace/xreferences request |
48 | 62 | * @param DependenciesIndex $sourceIndex Index that is used on a workspace/xreferences request |
49 | 63 | * @param \stdClass $composerLock The parsed composer.lock of the project, if any |
50 | 64 | * @param PhpDocumentLoader $documentLoader PhpDocumentLoader instance to load documents |
51 | 65 | */ |
52 | | - public function __construct(ProjectIndex $index, DependenciesIndex $dependenciesIndex, Index $sourceIndex, \stdClass $composerLock = null, PhpDocumentLoader $documentLoader, \stdClass $composerJson = null) |
| 66 | + public function __construct(LanguageClient $client, ProjectIndex $index, DependenciesIndex $dependenciesIndex, Index $sourceIndex, \stdClass $composerLock = null, PhpDocumentLoader $documentLoader, \stdClass $composerJson = null) |
53 | 67 | { |
| 68 | + $this->client = $client; |
54 | 69 | $this->sourceIndex = $sourceIndex; |
55 | 70 | $this->index = $index; |
56 | 71 | $this->dependenciesIndex = $dependenciesIndex; |
@@ -82,6 +97,21 @@ public function symbol(string $query): Promise |
82 | 97 | }); |
83 | 98 | } |
84 | 99 |
|
| 100 | + /** |
| 101 | + * The watched files notification is sent from the client to the server when the client detects changes to files watched by the language client. |
| 102 | + * |
| 103 | + * @param FileEvent[] $changes |
| 104 | + * @return void |
| 105 | + */ |
| 106 | + public function didChangeWatchedFiles(array $changes) |
| 107 | + { |
| 108 | + foreach ($changes as $change) { |
| 109 | + if ($change->type === FileChangeType::DELETED) { |
| 110 | + $this->client->textDocument->publishDiagnostics($change->uri, []); |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + |
85 | 115 | /** |
86 | 116 | * The workspace references request is sent from the client to the server to locate project-wide references to a symbol given its description / metadata. |
87 | 117 | * |
|
0 commit comments