add/utilise constructors
parent
a1347dbfee
commit
5ba7724a5c
|
@ -23,4 +23,17 @@ class ParameterInformation
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $documentation;
|
public $documentation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create ParameterInformation
|
||||||
|
*
|
||||||
|
* @param string $label The label of this signature. Will be shown in the UI.
|
||||||
|
* @param string $documentation The human-readable doc-comment of this signature. Will be shown in the UI but can
|
||||||
|
* be omitted.
|
||||||
|
*/
|
||||||
|
public function __construct(string $label, string $documentation = null)
|
||||||
|
{
|
||||||
|
$this->label = $label;
|
||||||
|
$this->documentation = $documentation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,18 @@ class SignatureHelp
|
||||||
* @var int|null
|
* @var int|null
|
||||||
*/
|
*/
|
||||||
public $activeParameter;
|
public $activeParameter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SignatureHelp
|
||||||
|
*
|
||||||
|
* @param SignatureInformation[] $signatures List of signature information
|
||||||
|
* @param int|null $activeSignature The active signature, zero based
|
||||||
|
* @param int|null $activeParameter The active parameter, zero based
|
||||||
|
*/
|
||||||
|
public function __construct(array $signatures = [], $activeSignature = null, int $activeParameter = null)
|
||||||
|
{
|
||||||
|
$this->signatures = $signatures;
|
||||||
|
$this->activeSignature = $activeSignature;
|
||||||
|
$this->activeParameter = $activeParameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,19 @@ class SignatureInformation
|
||||||
* @var ParameterInformation[]|null
|
* @var ParameterInformation[]|null
|
||||||
*/
|
*/
|
||||||
public $parameters;
|
public $parameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a SignatureInformation
|
||||||
|
*
|
||||||
|
* @param string $label The label of this signature. Will be shown in the UI.
|
||||||
|
* @param ParameterInformation[]|null The parameters of this signature
|
||||||
|
* @param string|null The human-readable doc-comment of this signature. Will be shown in the UI
|
||||||
|
* but can be omitted.
|
||||||
|
*/
|
||||||
|
public function __construct(string $label, array $parameters = null, string $documentation = null)
|
||||||
|
{
|
||||||
|
$this->label = $label;
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
$this->documentation = $documentation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,14 +72,13 @@ class SignatureHelpProvider
|
||||||
$params = $this->getParameters($calledNode, $calledDoc);
|
$params = $this->getParameters($calledNode, $calledDoc);
|
||||||
$label = $this->getLabel($calledNode, $params, $calledDoc);
|
$label = $this->getLabel($calledNode, $params, $calledDoc);
|
||||||
|
|
||||||
$signatureInformation = new SignatureInformation();
|
$signatureInformation = new SignatureInformation(
|
||||||
$signatureInformation->label = $label;
|
$label,
|
||||||
$signatureInformation->parameters = $params;
|
$params,
|
||||||
$signatureInformation->documentation = $this->definitionResolver->getDocumentationFromNode($calledNode);
|
$this->definitionResolver->getDocumentationFromNode($calledNode)
|
||||||
$signatureHelp = new SignatureHelp();
|
);
|
||||||
$signatureHelp->signatures = [$signatureInformation];
|
$signatureHelp = new SignatureHelp([$signatureInformation], 0, $activeParam);
|
||||||
$signatureHelp->activeSignature = 0;
|
|
||||||
$signatureHelp->activeParameter = $activeParam;
|
|
||||||
return $signatureHelp;
|
return $signatureHelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,10 +190,10 @@ class SignatureHelpProvider
|
||||||
if ($element->default) {
|
if ($element->default) {
|
||||||
$param .= ' = ' . $element->default->getText($doc->getContent());
|
$param .= ' = ' . $element->default->getText($doc->getContent());
|
||||||
}
|
}
|
||||||
$info = new ParameterInformation();
|
$params[] = new ParameterInformation(
|
||||||
$info->label = $param;
|
$param,
|
||||||
$info->documentation = $this->definitionResolver->getDocumentationFromNode($element);
|
$this->definitionResolver->getDocumentationFromNode($element)
|
||||||
$params[] = $info;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $params;
|
return $params;
|
||||||
|
|
|
@ -192,19 +192,12 @@ class SignatureHelpTest extends TestCase
|
||||||
{
|
{
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach ($info['parameters'] as $param) {
|
foreach ($info['parameters'] as $param) {
|
||||||
$paramInfo = new ParameterInformation();
|
$paramInfo = new ParameterInformation($param['label'], $param['documentation']);
|
||||||
$paramInfo->label = $param['label'];
|
|
||||||
$paramInfo->documentation = $param['documentation'];
|
|
||||||
$params[] = $paramInfo;
|
$params[] = $paramInfo;
|
||||||
}
|
}
|
||||||
$signature = new SignatureInformation();
|
$signature = new SignatureInformation($info['label'], $params, $info['documentation']);
|
||||||
$signature->label = $info['label'];
|
$help = new SignatureHelp([$signature], $info['activeSignature'], $info['activeParameter']);
|
||||||
$signature->documentation = $info['documentation'];
|
|
||||||
$signature->parameters = $params;
|
|
||||||
$help = new SignatureHelp();
|
|
||||||
$help->signatures = [$signature];
|
|
||||||
$help->activeSignature = $info['activeSignature'];
|
|
||||||
$help->activeParameter = $info['activeParameter'];
|
|
||||||
return $help;
|
return $help;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue