|
4 | 4 | namespace LanguageServer\Server;
|
5 | 5 |
|
6 | 6 | use LanguageServer\{
|
7 |
| - CompletionProvider, LanguageClient, PhpDocument, PhpDocumentLoader, DefinitionResolver |
| 7 | + CompletionProvider, SignatureHelpProvider, LanguageClient, PhpDocument, PhpDocumentLoader, DefinitionResolver |
8 | 8 | };
|
9 | 9 | use LanguageServer\Index\ReadableIndex;
|
10 | 10 | use LanguageServer\Protocol\{
|
@@ -59,6 +59,11 @@ class TextDocument
|
59 | 59 | */
|
60 | 60 | protected $completionProvider;
|
61 | 61 |
|
| 62 | + /** |
| 63 | + * @var SignatureHelpProvider |
| 64 | + */ |
| 65 | + protected $signatureHelpProvider; |
| 66 | + |
62 | 67 | /**
|
63 | 68 | * @var ReadableIndex
|
64 | 69 | */
|
@@ -94,6 +99,7 @@ public function __construct(
|
94 | 99 | $this->client = $client;
|
95 | 100 | $this->definitionResolver = $definitionResolver;
|
96 | 101 | $this->completionProvider = new CompletionProvider($this->definitionResolver, $index);
|
| 102 | + $this->signatureHelpProvider = new SignatureHelpProvider($this->definitionResolver, $index, $documentLoader); |
97 | 103 | $this->index = $index;
|
98 | 104 | $this->composerJson = $composerJson;
|
99 | 105 | $this->composerLock = $composerLock;
|
@@ -237,6 +243,23 @@ public function references(
|
237 | 243 | });
|
238 | 244 | }
|
239 | 245 |
|
| 246 | + /** |
| 247 | + * The signature help request is sent from the client to the server to request signature information at a given |
| 248 | + * cursor position. |
| 249 | + * |
| 250 | + * @param TextDocumentIdentifier $textDocument The text document |
| 251 | + * @param Position $position The position inside the text document |
| 252 | + * |
| 253 | + * @return Promise <SignatureHelp> |
| 254 | + */ |
| 255 | + public function signatureHelp(TextDocumentIdentifier $textDocument, Position $position): Promise |
| 256 | + { |
| 257 | + return coroutine(function () use ($textDocument, $position) { |
| 258 | + $document = yield $this->documentLoader->getOrLoad($textDocument->uri); |
| 259 | + return $this->signatureHelpProvider->getSignatureHelp($document, $position); |
| 260 | + }); |
| 261 | + } |
| 262 | + |
240 | 263 | /**
|
241 | 264 | * The goto definition request is sent from the client to the server to resolve the definition location of a symbol
|
242 | 265 | * at a given text document position.
|
|
0 commit comments