import { HoverProvider , TextDocument , Position , CancellationToken , ProviderResult , Hover , workspace , commands , Location } from 'vscode' ; export class SystemVerilogHoverProvider implements HoverProvider { provideHover ( document , position , token ) { return new Promise ( ( resolve , _reject ) => { const lookupRange = document . getWordRangeAtPosition ( position ) ; if ( ! lookupRange ) { return resolve ( undefined ) ; } resolve ( commands . executeCommand ( 'vscode.executeDefinitionProvider' , document . uri , position , token ) . then ( ( loc ) : Thenable < string > => { if ( loc . length === 0 ) { return undefined ; } return workspace . openTextDocument ( loc [ 0 ] . uri ) . then ( ( doc ) => doc . lineAt ( loc [ 0 ] . range . start . line ) . text . trim ( ) ) ; } ) . then ( ( str ) : Hover => new Hover ( [ { language : 'systemverilog' , value : str } ] ) ) ) ; } ) ; } }