Skip to content

Commit

Permalink
Completion Request should return CompletionList
Browse files Browse the repository at this point in the history
As discussed in
microsoft/language-server-protocol#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[]`.
  • Loading branch information
kaloyan-raev committed Sep 13, 2016
1 parent 5d85e4d commit 07914c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Server/TextDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
FormattingOptions,
TextEdit,
CompletionItem,
CompletionItemKind
CompletionItemKind,
CompletionList
};
use LanguageServer\Server\Completion\PHPKeywords;

Expand Down Expand Up @@ -166,17 +167,19 @@ 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();
$item->label = $keyword->getLabel();
$item->kind = CompletionItemKind::KEYWORD;
$item->insertText = $keyword->getInsertText();
$item->detail = "PHP Language Server";
$items[] = $item;
$list->items[] = $item;
}
return $items;
return $list;
}

}

0 comments on commit 07914c9

Please sign in to comment.