import * as vscode from 'vscode' ; import { PositionContext } from '../documents/positionContexts/PositionContext' ; import { TemplatePositionContext } from '../documents/positionContexts/TemplatePositionContext' ; import { getRenameError } from '../util/getRenameError' ; const command = 'editor.action.rename' ; export class RenameCodeActionProvider implements vscode . CodeActionProvider { constructor ( private action ) { } public async provideCodeActions ( document , range ) { let pc = await this . action ( document , range . start ) as TemplatePositionContext | undefined ; const referenceSiteInfo = pc && pc . getReferenceSiteInfo ( true ) ; if ( ! referenceSiteInfo || getRenameError ( referenceSiteInfo ) ) { return ; } return [ this . createCommand ( ) ] ; } private createCommand ( ) { const action = new vscode . CodeAction ( 'Rename...' , vscode . CodeActionKind . RefactorRewrite ) ; action . command = { command : command , title : '' } ; return action ; } }