Fixed hiding the tooltip too early, fixed tests
parent
b0f3952844
commit
1b68c73186
|
@ -4,6 +4,4 @@ function helpFunc2(int $count = 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = 1;
|
|
||||||
|
|
||||||
helpFunc2(
|
helpFunc2(
|
||||||
|
|
|
@ -7,6 +7,4 @@ class HelpClass4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpClass4::method(1, 2, 3
|
HelpClass4::method(1
|
||||||
|
|
||||||
HelpClass4::method(1, 2, 3
|
|
||||||
|
|
|
@ -72,8 +72,13 @@ class SignatureHelpProvider
|
||||||
$line = substr(fgets($handle), 0, $pos->character);
|
$line = substr(fgets($handle), 0, $pos->character);
|
||||||
fseek($handle, 0);
|
fseek($handle, 0);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$orig = null;
|
||||||
do {
|
do {
|
||||||
$node = $doc->getNodeAtPosition($pos);
|
$node = $doc->getNodeAtPosition($pos);
|
||||||
|
if ($node !== null) {
|
||||||
|
$orig = $node;
|
||||||
|
}
|
||||||
$pos->character--;
|
$pos->character--;
|
||||||
if ($pos->character < 0) {
|
if ($pos->character < 0) {
|
||||||
$pos->line --;
|
$pos->line --;
|
||||||
|
@ -82,22 +87,23 @@ class SignatureHelpProvider
|
||||||
}
|
}
|
||||||
$pos->character = $lines[$pos->line];
|
$pos->character = $lines[$pos->line];
|
||||||
}
|
}
|
||||||
} while ($node === null);
|
} while (!(
|
||||||
|
|
||||||
if ($node === null) {
|
|
||||||
fclose($handle);
|
|
||||||
return $help;
|
|
||||||
}
|
|
||||||
$i = 0;
|
|
||||||
while (!(
|
|
||||||
$node instanceof Node\Expr\PropertyFetch ||
|
$node instanceof Node\Expr\PropertyFetch ||
|
||||||
$node instanceof Node\Expr\MethodCall ||
|
$node instanceof Node\Expr\MethodCall ||
|
||||||
$node instanceof Node\Expr\FuncCall ||
|
$node instanceof Node\Expr\FuncCall ||
|
||||||
$node instanceof Node\Expr\ClassConstFetch ||
|
$node instanceof Node\Expr\ClassConstFetch ||
|
||||||
$node instanceof Node\Expr\StaticCall
|
$node instanceof Node\Expr\StaticCall
|
||||||
) && ++$i < 5 && $node !== null) {
|
) && ++$i < 120);
|
||||||
$node = $node->getAttribute('parentNode');
|
|
||||||
|
if ($node === null) {
|
||||||
|
$node = $orig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($node === null) {
|
||||||
|
fclose($handle);
|
||||||
|
return $help;
|
||||||
|
}
|
||||||
|
|
||||||
$params = '';
|
$params = '';
|
||||||
if ($node instanceof Node\Expr\PropertyFetch) {
|
if ($node instanceof Node\Expr\PropertyFetch) {
|
||||||
fseek($handle, $node->name->getAttribute('startFilePos'));
|
fseek($handle, $node->name->getAttribute('startFilePos'));
|
||||||
|
@ -142,7 +148,7 @@ class SignatureHelpProvider
|
||||||
$fqn = $this->definitionResolver->resolveReferenceNodeToFqn($node->class);
|
$fqn = $this->definitionResolver->resolveReferenceNodeToFqn($node->class);
|
||||||
$def = $this->index->getDefinition($fqn.'::'.$method.'()');
|
$def = $this->index->getDefinition($fqn.'::'.$method.'()');
|
||||||
} else {
|
} else {
|
||||||
if (!preg_match('(([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*\((.*)$)', $line, $method)) {
|
if (!preg_match('(([a-zA-Z_\x7f-\xff][:a-zA-Z0-9_\x7f-\xff]*)\s*\((.*)$)', $line, $method)) {
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return $help;
|
return $help;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,13 +132,13 @@ class SignatureHelpTest extends TestCase
|
||||||
$this->assertEquals($help, $result);
|
$this->assertEquals($help, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function funcClosed()
|
public function testFuncClosed()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/funcClosed.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/funcClosed.php');
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
$result = $this->textDocument->signatureHelp(
|
$result = $this->textDocument->signatureHelp(
|
||||||
new TextDocumentIdentifier($completionUri),
|
new TextDocumentIdentifier($completionUri),
|
||||||
new Position(5, 10)
|
new Position(6, 10)
|
||||||
)->wait();
|
)->wait();
|
||||||
|
|
||||||
$help = new SignatureHelp;
|
$help = new SignatureHelp;
|
||||||
|
@ -154,13 +154,13 @@ class SignatureHelpTest extends TestCase
|
||||||
$this->assertEquals($help, $result);
|
$this->assertEquals($help, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function funcNotClosed()
|
public function testFuncNotClosed()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/funcNotClosed.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/funcNotClosed.php');
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
$result = $this->textDocument->signatureHelp(
|
$result = $this->textDocument->signatureHelp(
|
||||||
new TextDocumentIdentifier($completionUri),
|
new TextDocumentIdentifier($completionUri),
|
||||||
new Position(5, 10)
|
new Position(6, 10)
|
||||||
)->wait();
|
)->wait();
|
||||||
|
|
||||||
$help = new SignatureHelp;
|
$help = new SignatureHelp;
|
||||||
|
@ -176,7 +176,7 @@ class SignatureHelpTest extends TestCase
|
||||||
$this->assertEquals($help, $result);
|
$this->assertEquals($help, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function staticClosed()
|
public function testStaticClosed()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/staticClosed.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/staticClosed.php');
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
|
@ -198,7 +198,7 @@ class SignatureHelpTest extends TestCase
|
||||||
$this->assertEquals($help, $result);
|
$this->assertEquals($help, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function staticNotClosed()
|
public function testStaticNotClosed()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/staticNotClosed.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/signatureHelp/staticNotClosed.php');
|
||||||
$this->loader->open($completionUri, file_get_contents($completionUri));
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
|
|
Loading…
Reference in New Issue