Improve hover output
parent
02e1a5b8f5
commit
49f16f5c3e
|
@ -178,10 +178,6 @@ class TextDocument
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$contents = [];
|
$contents = [];
|
||||||
$docBlock = $def->getAttribute('docBlock');
|
|
||||||
if ($docBlock !== null) {
|
|
||||||
$contents[] = $docBlock->getSummary();
|
|
||||||
}
|
|
||||||
$defLine = clone $def;
|
$defLine = clone $def;
|
||||||
$defLine->setAttribute('comments', []);
|
$defLine->setAttribute('comments', []);
|
||||||
if (isset($defLine->stmts)) {
|
if (isset($defLine->stmts)) {
|
||||||
|
@ -190,7 +186,11 @@ class TextDocument
|
||||||
$defText = $this->prettyPrinter->prettyPrint([$defLine]);
|
$defText = $this->prettyPrinter->prettyPrint([$defLine]);
|
||||||
$lines = explode("\n", $defText);
|
$lines = explode("\n", $defText);
|
||||||
if (isset($lines[0])) {
|
if (isset($lines[0])) {
|
||||||
$contents[] = new MarkedString('php', $lines[0]);
|
$contents[] = new MarkedString('php', "<?php\n" . $lines[0]);
|
||||||
|
}
|
||||||
|
$docBlock = $def->getAttribute('docBlock');
|
||||||
|
if ($docBlock !== null) {
|
||||||
|
$contents[] = $docBlock->getSummary();
|
||||||
}
|
}
|
||||||
return new Hover($contents, Range::fromNode($node));
|
return new Hover($contents, Range::fromNode($node));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ class HoverTest extends ServerTestCase
|
||||||
$reference = $this->getReferenceLocations('TestClass')[0];
|
$reference = $this->getReferenceLocations('TestClass')[0];
|
||||||
$result = $this->textDocument->hover(new TextDocumentIdentifier($reference->uri), $reference->range->start);
|
$result = $this->textDocument->hover(new TextDocumentIdentifier($reference->uri), $reference->range->start);
|
||||||
$this->assertEquals(new Hover([
|
$this->assertEquals(new Hover([
|
||||||
'Pariatur ut laborum tempor voluptate consequat ea deserunt.',
|
new MarkedString('php', "<?php\nclass TestClass implements \\TestInterface"),
|
||||||
new MarkedString('php', 'class TestClass implements \\TestInterface')
|
'Pariatur ut laborum tempor voluptate consequat ea deserunt.'
|
||||||
], $reference->range), $result);
|
], $reference->range), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class HoverTest extends ServerTestCase
|
||||||
$uri = pathToUri(realpath(__DIR__ . '/../../../fixtures/references.php'));
|
$uri = pathToUri(realpath(__DIR__ . '/../../../fixtures/references.php'));
|
||||||
$result = $this->textDocument->hover(new TextDocumentIdentifier($uri), new Position(13, 7));
|
$result = $this->textDocument->hover(new TextDocumentIdentifier($uri), new Position(13, 7));
|
||||||
$this->assertEquals(new Hover(
|
$this->assertEquals(new Hover(
|
||||||
[new MarkedString('php', '$var = 123;')],
|
[new MarkedString('php', "<?php\n\$var = 123;")],
|
||||||
new Range(new Position(13, 5), new Position(13, 9))
|
new Range(new Position(13, 5), new Position(13, 9))
|
||||||
), $result);
|
), $result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue