label = $label; $this->kind = $kind; $this->detail = $detail; $this->documentation = $documentation; $this->sortText = $sortText; $this->filterText = $filterText; $this->insertText = $insertText; $this->textEdit = $textEdit; $this->additionalTextEdits = $additionalTextEdits; $this->command = $command; $this->data = $data; } /** * Creates a CompletionItem for a Definition * * @param Definition $def * @return self */ public static function fromDefinition(Definition $def): self { $item = new CompletionItem; $item->label = $def->symbolInformation->name; $item->kind = CompletionItemKind::fromSymbolKind($def->symbolInformation->kind); if ($def->type) { $item->detail = (string)$def->type; } else if ($def->symbolInformation->containerName) { $item->detail = $def->symbolInformation->containerName; } if ($def->documentation) { $item->documentation = $def->documentation; } if ($def->isStatic && $def->symbolInformation->kind === SymbolKind::PROPERTY) { $item->insertText = '$' . $def->symbolInformation->name; } return $item; } }