import * as vscode from 'vscode' ; import { commandIds , isSupportedLanguage } from './const' ; import langService from './services/langService' ; import { isSelection } from './utils/isSelection' ; export class CodeModCodeActionProvider implements vscode . CodeActionProvider { public async provideCodeActions ( document , selection , context , token ) { if ( ! isSupportedLanguage ( document . languageId ) ) { return [ ] ; } if ( ! isSelection ( selection ) ) { return [ ] ; } const result = await langService . requestCodeActions ( document . uri . toString ( ) , selection ) ; return result . codeMods . map ( ( mod ) => ( { title : mod . title , tooltip : mod . tooltip , command : commandIds . _executeCodeAction , arguments : [ mod . id , result . textDocument , selection ] , } as vscode . Command ) ) ; } }