extensions/felixfbecker.php-intellisense-0.0.12/vendor/felixfbecker/language-server/src/Server/TextDocument.php
/**
     * The hover request is sent from the client to the server to request hover information at a given text document position.
     *
     * @param TextDocumentIdentifier $textDocument The text document
     * @param Position $position The position inside the text document
     * @return Promise <Hover>
     */
The hover request is sent from the client to the server to request hover information at a given text document position.
@param TextDocumentIdentifier $textDocument The text document
@param Position $position The position inside the text document
@return Promise 
The hover request is sent from the client to the server to request hover information at a given text document position . @param TextDocumentIdentifier $textDocument The text document @param Position $position The position inside the text document @return Promise
public function hover(TextDocumentIdentifier $textDocument, Position $position): Promise
    {
        return coroutine(function () use ($textDocument, $position) {
            $document = yield $this->project->getOrLoadDocument($textDocument->uri);
            $node = $document->getNodeAtPosition($position);
            if ($node === null) {
                return new Hover([]);
            }
            $range = Range::fromNode($node);
            $def = yield $document->getDefinitionByNode($node);
            if ($def === null) {
                return new Hover([], $range);
            }
            $contents = [];
            if ($def instanceof Node\Stmt\PropertyProperty || $def instanceof Node\Const_) {
                $child = $def;
                $def = $def->getAttribute('parentNode');
                $defLine = clone $def;
                $defLine->props = [$child];
            } else {
                $defLine = clone $def;
            }
            $defLine->setAttribute('comments', []);
            if (isset($defLine->stmts)) {
                $defLine->stmts = [];
            }
            $defText = $this->prettyPrinter->prettyPrint([$defLine]);
            $lines = explode("\n", $defText);
            if (isset($lines[0])) {
                $contents[] = new MarkedString('php', "<?php\n" . $lines[0]);
            }
            if ($def instanceof Node\Param) {
                $fn = $def->getAttribute('parentNode');
                $docBlock = $fn->getAttribute('docBlock');
                if ($docBlock !== null) {
                    $tags = $docBlock->getTagsByName('param');
                    foreach ($tags as $tag) {
                        if ($tag->getVariableName() === $def->name) {
                            $contents[] = $tag->getDescription()->render();
                            break;
                        }
                    }
                }
            } else {
                $docBlock = $def->getAttribute('docBlock');
                if ($docBlock !== null) {
                    $contents[] = $docBlock->getSummary();
                }
            }
            return new Hover($contents, $range);
        });
    }
public function hover ( TextDocumentIdentifier $ textDocument , Position $ position ) : Promise { return coroutine ( function ( ) use ( $ textDocument , $ position ) { $ document = yield $ this -> project -> getOrLoadDocument ( $ textDocument -> uri ) ; $ node = $ document -> getNodeAtPosition ( $ position ) ; if ( $ node === null ) { return new Hover ( [ ] ) ; } $ range = Range :: fromNode ( $ node ) ; $ def = yield $ document -> getDefinitionByNode ( $ node ) ; if ( $ def === null ) { return new Hover ( [ ] , $ range ) ; } $ contents = [ ] ; if ( $ def instanceof Node \ Stmt \ PropertyProperty || $ def instanceof Node \ Const_ ) { $ child = $ def ; $ def = $ def -> getAttribute ( 'parentNode' ) ; $ defLine = clone $ def ; $ defLine -> props = [ $ child ] ; } else { $ defLine = clone $ def ; } $ defLine -> setAttribute ( 'comments' , [ ] ) ; if ( isset ( $ defLine -> stmts ) ) { $ defLine -> stmts = [ ] ; } $ defText = $ this -> prettyPrinter -> prettyPrint ( [ $ defLine ] ) ; $ lines = explode ( " \n " , $ defText ) ; if ( isset ( $ lines [ 0 ] ) ) { $ contents [ ] = new MarkedString ( 'php' , " <?php \n " . $ lines [ 0 ] ) ; } if ( $ def instanceof Node \ Param ) { $ fn = $ def -> getAttribute ( 'parentNode' ) ; $ docBlock = $ fn -> getAttribute ( 'docBlock' ) ; if ( $ docBlock !== null ) { $ tags = $ docBlock -> getTagsByName ( 'param' ) ; foreach ( $ tags as $ tag ) { if ( $ tag -> getVariableName ( ) === $ def -> name ) { $ contents [ ] = $ tag -> getDescription ( ) -> render ( ) ; break ; } } } } else { $ docBlock = $ def -> getAttribute ( 'docBlock' ) ; if ( $ docBlock !== null ) { $ contents [ ] = $ docBlock -> getSummary ( ) ; } } return new Hover ( $ contents , $ range ) ; } ) ; }
The hover request is sent from the client to the server to request hover information at a given text document position.
The hover request is sent from the client to the server to request hover information at a given text document position .
// Find the node under the cursor // Get the definition node for whatever node is under the cursor // Build a declaration string // Properties and constants can have multiple declarations // Use the parent node (that includes the modifiers), but only render the requested declaration // Don't include the docblock in the declaration string // Get the documentation string