1
0
Fork 0

Improve hover output

pull/50/head
Felix Becker 2016-10-19 03:39:28 +02:00
parent 02e1a5b8f5
commit 49f16f5c3e
2 changed files with 8 additions and 8 deletions

View File

@ -178,10 +178,6 @@ class TextDocument
return null;
}
$contents = [];
$docBlock = $def->getAttribute('docBlock');
if ($docBlock !== null) {
$contents[] = $docBlock->getSummary();
}
$defLine = clone $def;
$defLine->setAttribute('comments', []);
if (isset($defLine->stmts)) {
@ -190,7 +186,11 @@ class TextDocument
$defText = $this->prettyPrinter->prettyPrint([$defLine]);
$lines = explode("\n", $defText);
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));
}

View File

@ -18,8 +18,8 @@ class HoverTest extends ServerTestCase
$reference = $this->getReferenceLocations('TestClass')[0];
$result = $this->textDocument->hover(new TextDocumentIdentifier($reference->uri), $reference->range->start);
$this->assertEquals(new Hover([
'Pariatur ut laborum tempor voluptate consequat ea deserunt.',
new MarkedString('php', 'class TestClass implements \\TestInterface')
new MarkedString('php', "<?php\nclass TestClass implements \\TestInterface"),
'Pariatur ut laborum tempor voluptate consequat ea deserunt.'
], $reference->range), $result);
}
@ -30,7 +30,7 @@ class HoverTest extends ServerTestCase
$uri = pathToUri(realpath(__DIR__ . '/../../../fixtures/references.php'));
$result = $this->textDocument->hover(new TextDocumentIdentifier($uri), new Position(13, 7));
$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))
), $result);
}