progress...
parent
8ac5d72fdc
commit
f79fbf8235
|
@ -9,14 +9,17 @@ namespace HELLO {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
\HELLO;
|
\HE
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lorem ipsum dolor sit amet.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
define('HELLO', true);
|
define('HELLO', true);
|
||||||
|
|
||||||
HELLO;
|
|
||||||
|
|
||||||
HELLO\world();
|
HELLO\world();
|
||||||
}
|
}
|
|
@ -98,3 +98,12 @@ new class {
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChildClass extends TestClass {}
|
class ChildClass extends TestClass {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lorem ipsum dolor sit amet, consectetur.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
define('TEST_PROPERTY', false);
|
||||||
|
|
||||||
|
print TEST_PROPERTY ? 'true' : 'false';
|
||||||
|
|
|
@ -84,9 +84,8 @@ class SymbolInformation
|
||||||
$symbol->name = $node->var;
|
$symbol->name = $node->var;
|
||||||
} else if (isset($node->name)) {
|
} else if (isset($node->name)) {
|
||||||
$symbol->name = (string)$node->name;
|
$symbol->name = (string)$node->name;
|
||||||
} else if
|
} else if (
|
||||||
(
|
$node instanceof Node\Expr\FuncCall
|
||||||
$node instanceof Node\Expr\FuncCall
|
|
||||||
&& $node->name instanceof Node\Name
|
&& $node->name instanceof Node\Name
|
||||||
&& (string)$node->name === 'define'
|
&& (string)$node->name === 'define'
|
||||||
&& isset($node->args[0])
|
&& isset($node->args[0])
|
||||||
|
|
|
@ -57,7 +57,7 @@ class LanguageServerTest extends TestCase
|
||||||
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
|
if ($msg->body->method === 'window/logMessage' && $promise->state === Promise::PENDING) {
|
||||||
if ($msg->body->params->type === MessageType::ERROR) {
|
if ($msg->body->params->type === MessageType::ERROR) {
|
||||||
$promise->reject(new Exception($msg->body->params->message));
|
$promise->reject(new Exception($msg->body->params->message));
|
||||||
} else if (strpos($msg->body->params->message, 'All 26 PHP files parsed') !== false) {
|
} else if (strpos($msg->body->params->message, 'All 27 PHP files parsed') !== false) {
|
||||||
$promise->fulfill();
|
$promise->fulfill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class LanguageServerTest extends TestCase
|
||||||
if ($promise->state === Promise::PENDING) {
|
if ($promise->state === Promise::PENDING) {
|
||||||
$promise->reject(new Exception($msg->body->params->message));
|
$promise->reject(new Exception($msg->body->params->message));
|
||||||
}
|
}
|
||||||
} else if (strpos($msg->body->params->message, 'All 26 PHP files parsed') !== false) {
|
} else if (strpos($msg->body->params->message, 'All 27 PHP files parsed') !== false) {
|
||||||
$promise->fulfill();
|
$promise->fulfill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ abstract class ServerTestCase extends TestCase
|
||||||
$this->definitionLocations = [
|
$this->definitionLocations = [
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
|
'TEST_PROPERTY' => new Location($globalSymbolsUri, new Range(new Position(106, 4), new Position(106, 31))),
|
||||||
'TEST_CONST' => new Location($globalSymbolsUri, new Range(new Position( 9, 6), new Position( 9, 22))),
|
'TEST_CONST' => new Location($globalSymbolsUri, new Range(new Position( 9, 6), new Position( 9, 22))),
|
||||||
'TestClass' => new Location($globalSymbolsUri, new Range(new Position(20, 0), new Position(61, 1))),
|
'TestClass' => new Location($globalSymbolsUri, new Range(new Position(20, 0), new Position(61, 1))),
|
||||||
'ChildClass' => new Location($globalSymbolsUri, new Range(new Position(99, 0), new Position(99, 37))),
|
'ChildClass' => new Location($globalSymbolsUri, new Range(new Position(99, 0), new Position(99, 37))),
|
||||||
|
@ -160,6 +161,9 @@ abstract class ServerTestCase extends TestCase
|
||||||
],
|
],
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
|
'TEST_PROPERTY' => [
|
||||||
|
0 => new Location($globalSymbolsUri, new Range(new Position(108, 6), new Position(108, 19)))
|
||||||
|
],
|
||||||
'TEST_CONST' => [
|
'TEST_CONST' => [
|
||||||
0 => new Location($referencesUri, new Range(new Position(29, 5), new Position(29, 15))),
|
0 => new Location($referencesUri, new Range(new Position(29, 5), new Position(29, 15))),
|
||||||
1 => new Location($globalReferencesUri, new Range(new Position(29, 5), new Position(29, 15)))
|
1 => new Location($globalReferencesUri, new Range(new Position(29, 5), new Position(29, 15)))
|
||||||
|
|
|
@ -229,6 +229,23 @@ class CompletionTest extends TestCase
|
||||||
], true), $items);
|
], true), $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGlobalConstant() {
|
||||||
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/constant_with_namespace.php');
|
||||||
|
$this->loader->open($completionUri, file_get_contents($completionUri));
|
||||||
|
$items = $this->textDocument->completion(
|
||||||
|
new TextDocumentIdentifier($completionUri),
|
||||||
|
new Position(11, 7)
|
||||||
|
)->wait();
|
||||||
|
|
||||||
|
var_dump($items);
|
||||||
|
$this->assertEquals(new CompletionList([
|
||||||
|
new CompletionItem(
|
||||||
|
'HELLO',
|
||||||
|
CompletionItemKind::VARIABLE
|
||||||
|
)
|
||||||
|
], true), $items);
|
||||||
|
}
|
||||||
|
|
||||||
public function testStaticPropertyWithPrefix()
|
public function testStaticPropertyWithPrefix()
|
||||||
{
|
{
|
||||||
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_property_with_prefix.php');
|
$completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/static_property_with_prefix.php');
|
||||||
|
|
|
@ -156,6 +156,20 @@ class HoverTest extends ServerTestCase
|
||||||
], $reference->range), $result);
|
], $reference->range), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHoverForGlobalConstant() {
|
||||||
|
// HELLO;
|
||||||
|
// Get hover for HELLO
|
||||||
|
$reference = $this->getReferenceLocations('TEST_PROPERTY')[0];
|
||||||
|
$result = $this->textDocument->hover(
|
||||||
|
new TextDocumentIdentifier($reference->uri),
|
||||||
|
$reference->range->end
|
||||||
|
)->wait();
|
||||||
|
$this->assertEquals(new Hover([
|
||||||
|
new MarkedString('php', "<?php\n\\define('TEST_PROPERTY', \\false);"),
|
||||||
|
'Lorem ipsum dolor sit amet, consectetur.'
|
||||||
|
], $reference->range), $result);
|
||||||
|
}
|
||||||
|
|
||||||
public function testHoverForVariable()
|
public function testHoverForVariable()
|
||||||
{
|
{
|
||||||
// echo $var;
|
// echo $var;
|
||||||
|
|
|
@ -55,6 +55,7 @@ class SymbolTest extends ServerTestCase
|
||||||
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestInterface'), ''),
|
new SymbolInformation('TestInterface', SymbolKind::INTERFACE, $this->getDefinitionLocation('TestInterface'), ''),
|
||||||
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('test_function()'), ''),
|
new SymbolInformation('test_function', SymbolKind::FUNCTION, $this->getDefinitionLocation('test_function()'), ''),
|
||||||
new SymbolInformation('ChildClass', SymbolKind::CLASS_, $this->getDefinitionLocation('ChildClass'), ''),
|
new SymbolInformation('ChildClass', SymbolKind::CLASS_, $this->getDefinitionLocation('ChildClass'), ''),
|
||||||
|
new SymbolInformation('TEST_PROPERTY', SymbolKind::VARIABLE, $this->getDefinitionLocation('TEST_PROPERTY'), ''),
|
||||||
new SymbolInformation('whatever', SymbolKind::FUNCTION, $this->getDefinitionLocation('whatever()'), ''),
|
new SymbolInformation('whatever', SymbolKind::FUNCTION, $this->getDefinitionLocation('whatever()'), ''),
|
||||||
|
|
||||||
new SymbolInformation('SecondTestNamespace', SymbolKind::NAMESPACE, $this->getDefinitionLocation('SecondTestNamespace'), '')
|
new SymbolInformation('SecondTestNamespace', SymbolKind::NAMESPACE, $this->getDefinitionLocation('SecondTestNamespace'), '')
|
||||||
|
|
Loading…
Reference in New Issue