From 0e29092597243ce0c86f7abea672afa983053d5f Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Wed, 1 Feb 2017 16:32:24 +0100 Subject: [PATCH] Remove CompletionItem.textEdit --- src/CompletionProvider.php | 10 ---------- src/Protocol/CompletionItem.php | 19 +++++++++++-------- src/utils.php | 22 ---------------------- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/CompletionProvider.php b/src/CompletionProvider.php index 99a5d57..020ffcb 100644 --- a/src/CompletionProvider.php +++ b/src/CompletionProvider.php @@ -6,8 +6,6 @@ namespace LanguageServer; use PhpParser\Node; use LanguageServer\Index\ReadableIndex; use LanguageServer\Protocol\{ - TextEdit, - Range, Position, CompletionList, CompletionItem, @@ -272,18 +270,10 @@ class CompletionProvider $item->label = '$' . ($var instanceof Node\Expr\ClosureUse ? $var->var : $var->name); $item->documentation = $this->definitionResolver->getDocumentationFromNode($var); $item->detail = (string)$this->definitionResolver->getTypeFromNode($var); - $item->textEdit = new TextEdit( - new Range($pos, $pos), - stripStringOverlap($doc->getRange(new Range(new Position(0, 0), $pos)), $item->label) - ); $list->items[] = $item; } } else if ($node instanceof Node\Stmt\InlineHTML || $pos == new Position(0, 0)) { $item = new CompletionItem('textEdit = new TextEdit( - new Range($pos, $pos), - stripStringOverlap($doc->getRange(new Range(new Position(0, 0), $pos)), 'items[] = $item; } diff --git a/src/Protocol/CompletionItem.php b/src/Protocol/CompletionItem.php index 64bc69d..e883582 100644 --- a/src/Protocol/CompletionItem.php +++ b/src/Protocol/CompletionItem.php @@ -64,13 +64,16 @@ class CompletionItem public $insertText; /** - * An edit which is applied to a document when selecting - * this completion. When an edit is provided the value of - * insertText is ignored. + * A range of text that should be replaced by this completion item. * - * @var TextEdit|null + * Defaults to a range from the start of the current word to the current position. + * + * *Note:* The range must be a single line range and it must contain the position at which completion + * has been requested. + * + * @var Range|null */ - public $textEdit; + public $range; /** * An optional array of additional text edits that are applied when @@ -106,7 +109,7 @@ class CompletionItem * @param string|null $sortText * @param string|null $filterText * @param string|null $insertText - * @param TextEdit|null $textEdit + * @param Range|null $range * @param TextEdit[]|null $additionalTextEdits * @param Command|null $command * @param mixed|null $data @@ -119,7 +122,7 @@ class CompletionItem string $sortText = null, string $filterText = null, string $insertText = null, - TextEdit $textEdit = null, + Range $range = null, array $additionalTextEdits = null, Command $command = null, $data = null @@ -131,7 +134,7 @@ class CompletionItem $this->sortText = $sortText; $this->filterText = $filterText; $this->insertText = $insertText; - $this->textEdit = $textEdit; + $this->range = $range; $this->additionalTextEdits = $additionalTextEdits; $this->command = $command; $this->data = $data; diff --git a/src/utils.php b/src/utils.php index 8ab7beb..92c4c48 100644 --- a/src/utils.php +++ b/src/utils.php @@ -109,25 +109,3 @@ function getClosestNode(Node $node, string $type) } } } - -/** - * Returns the part of $b that is not overlapped by $a - * Example: - * - * stripStringOverlap('whatever