From 07914c98cba13df35ac8a307c57a2efb5c08bda5 Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Tue, 13 Sep 2016 20:47:25 +0300 Subject: [PATCH] Completion Request should return CompletionList As discussed in https://github.com/Microsoft/language-server-protocol/issues/39 statically typed languages like Java do not support mixed return types, which in the case of Completion Request is `CompletionItem[] | CompletionList`. Thus Typefox - the Java client of the language server protocol - accepts only `CompletionList`, which contains `CompletionItem[]`. In order to work with Eclipse Che and other IDEs using the Typefox client, the Completion Request handler in the PHP language server should return `CompletionList` instead of `CompletionItems[]`. --- src/Server/TextDocument.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Server/TextDocument.php b/src/Server/TextDocument.php index a5367caf..f014be61 100644 --- a/src/Server/TextDocument.php +++ b/src/Server/TextDocument.php @@ -17,7 +17,8 @@ FormattingOptions, TextEdit, CompletionItem, - CompletionItemKind + CompletionItemKind, + CompletionList }; use LanguageServer\Server\Completion\PHPKeywords; @@ -166,7 +167,9 @@ public function formatting(TextDocumentIdentifier $textDocument, FormattingOptio public function completion(TextDocumentIdentifier $textDocument, Position $position) { - $items = []; + $list = new CompletionList(); + $list->isIncomplete = false; + $list->items = []; $keywords = new PHPKeywords(); foreach ($keywords->getKeywords() as $keyword){ $item = new CompletionItem(); @@ -174,9 +177,9 @@ public function completion(TextDocumentIdentifier $textDocument, Position $posit $item->kind = CompletionItemKind::KEYWORD; $item->insertText = $keyword->getInsertText(); $item->detail = "PHP Language Server"; - $items[] = $item; + $list->items[] = $item; } - return $items; + return $list; } }