import { ExecuteCommandParams , createConnection } from "vscode-languageserver" ; import { commands } from "@ui5-language-assistant/user-facing-text" ; import { executeQuickFixStableIdCommand , executeQuickFixFileStableIdCommand , } from "./quick-fix" ; import { track } from "./swa" ; type LSPConnection = ReturnType < typeof createConnection > ; export function executeCommand ( connection , params ) { if ( params . arguments === undefined ) { return ; } switch ( params . command ) { case commands . QUICK_FIX_STABLE_ID_ERROR . name : { const change = executeQuickFixStableIdCommand ( { documentUri : params . arguments [ 0 ] , documentVersion : params . arguments [ 1 ] , quickFixReplaceRange : params . arguments [ 2 ] , quickFixNewText : params . arguments [ 3 ] , } ) ; connection . workspace . applyEdit ( { documentChanges : change , } ) ; track ( "MANIFEST_STABLE_ID" , "single" ) ; return ; } case commands . QUICK_FIX_STABLE_ID_FILE_ERRORS . name : { const change = executeQuickFixFileStableIdCommand ( { documentUri : params . arguments [ 1 ] , documentVersion : params . arguments [ 2 ] , nonStableIdIssues : params . arguments [ 3 ] , } ) ; connection . workspace . applyEdit ( { documentChanges : change , } ) ; track ( "MANIFEST_STABLE_ID" , "multiple" ) ; return ; } default : return undefined ; } }