add/utilise constructors
parent
a1347dbfee
commit
5ba7724a5c
|
@ -23,4 +23,17 @@ class ParameterInformation
|
|||
* @var string|null
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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);
|
||||
$label = $this->getLabel($calledNode, $params, $calledDoc);
|
||||
|
||||
$signatureInformation = new SignatureInformation();
|
||||
$signatureInformation->label = $label;
|
||||
$signatureInformation->parameters = $params;
|
||||
$signatureInformation->documentation = $this->definitionResolver->getDocumentationFromNode($calledNode);
|
||||
$signatureHelp = new SignatureHelp();
|
||||
$signatureHelp->signatures = [$signatureInformation];
|
||||
$signatureHelp->activeSignature = 0;
|
||||
$signatureHelp->activeParameter = $activeParam;
|
||||
$signatureInformation = new SignatureInformation(
|
||||
$label,
|
||||
$params,
|
||||
$this->definitionResolver->getDocumentationFromNode($calledNode)
|
||||
);
|
||||
$signatureHelp = new SignatureHelp([$signatureInformation], 0, $activeParam);
|
||||
|
||||
return $signatureHelp;
|
||||
}
|
||||
|
||||
|
@ -191,10 +190,10 @@ class SignatureHelpProvider
|
|||
if ($element->default) {
|
||||
$param .= ' = ' . $element->default->getText($doc->getContent());
|
||||
}
|
||||
$info = new ParameterInformation();
|
||||
$info->label = $param;
|
||||
$info->documentation = $this->definitionResolver->getDocumentationFromNode($element);
|
||||
$params[] = $info;
|
||||
$params[] = new ParameterInformation(
|
||||
$param,
|
||||
$this->definitionResolver->getDocumentationFromNode($element)
|
||||
);
|
||||
}
|
||||
}
|
||||
return $params;
|
||||
|
|
|
@ -192,19 +192,12 @@ class SignatureHelpTest extends TestCase
|
|||
{
|
||||
$params = [];
|
||||
foreach ($info['parameters'] as $param) {
|
||||
$paramInfo = new ParameterInformation();
|
||||
$paramInfo->label = $param['label'];
|
||||
$paramInfo->documentation = $param['documentation'];
|
||||
$paramInfo = new ParameterInformation($param['label'], $param['documentation']);
|
||||
$params[] = $paramInfo;
|
||||
}
|
||||
$signature = new SignatureInformation();
|
||||
$signature->label = $info['label'];
|
||||
$signature->documentation = $info['documentation'];
|
||||
$signature->parameters = $params;
|
||||
$help = new SignatureHelp();
|
||||
$help->signatures = [$signature];
|
||||
$help->activeSignature = $info['activeSignature'];
|
||||
$help->activeParameter = $info['activeParameter'];
|
||||
$signature = new SignatureInformation($info['label'], $params, $info['documentation']);
|
||||
$help = new SignatureHelp([$signature], $info['activeSignature'], $info['activeParameter']);
|
||||
|
||||
return $help;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue