import * as vscode from 'vscode' ; import { Extension } from '../extension' ; export class HoverProvider implements vscode . HoverProvider { extension : Extension ; constructor ( extension ) { this . extension = extension ; } public async provideHover ( document , position , token ) { const keyRange = document . getWordRangeAtPosition ( position , /(?<=@)\w+/ ) ; if ( keyRange ) { const citeKey = document . getText ( keyRange ) ; const cite = this . extension . completer . citation . getEntry ( citeKey ) ; if ( cite ) { let hoverMarkdownText = cite . documentation || cite . detail ; hoverMarkdownText = hoverMarkdownText . replace ( /\n/g , '  \n' ) ; if ( hoverMarkdownText ) { return new vscode . Hover ( hoverMarkdownText ) ; } } } } }