@@ -443,7 +443,7 @@ private void RunVisualStudioFormatDocument(TextDocument textDocument)
443443 {
444444 if ( ! Settings . Default . Cleaning_RunVisualStudioFormatDocumentCommand ) return ;
445445
446- ExecuteCommand ( textDocument , "Edit.FormatDocument" ) ;
446+ _commandHelper . ExecuteCommand ( textDocument , "Edit.FormatDocument" ) ;
447447 }
448448
449449 /// <summary>
@@ -456,8 +456,7 @@ private void RunJetBrainsReSharperCleanup(TextDocument textDocument)
456456
457457 // This command changed to include the leading 'ReSharper.' in version 2016.1.
458458 // Execute both commands for backwards compatibility.
459- ExecuteCommand ( textDocument , "ReSharper_SilentCleanupCode" ) ;
460- ExecuteCommand ( textDocument , "ReSharper.ReSharper_SilentCleanupCode" ) ;
459+ _commandHelper . ExecuteCommand ( textDocument , "ReSharper_SilentCleanupCode" , "ReSharper.ReSharper_SilentCleanupCode" ) ;
461460 }
462461
463462 /// <summary>
@@ -468,7 +467,7 @@ private void RunTelerikJustCodeCleanup(TextDocument textDocument)
468467 {
469468 if ( ! Settings . Default . ThirdParty_UseTelerikJustCodeCleanup ) return ;
470469
471- ExecuteCommand ( textDocument , "JustCode.JustCode_CleanCodeWithDefaultProfile" ) ;
470+ _commandHelper . ExecuteCommand ( textDocument , "JustCode.JustCode_CleanCodeWithDefaultProfile" ) ;
472471 }
473472
474473 /// <summary>
@@ -479,7 +478,7 @@ private void RunXAMLStylerCleanup(TextDocument textDocument)
479478 {
480479 if ( ! Settings . Default . ThirdParty_UseXAMLStylerCleanup ) return ;
481480
482- ExecuteCommand ( textDocument , "EditorContextMenus.XAMLEditor.BeautifyXaml" , "EditorContextMenus.XAMLEditor.FormatXAML" ) ;
481+ _commandHelper . ExecuteCommand ( textDocument , "EditorContextMenus.XAMLEditor.BeautifyXaml" , "EditorContextMenus.XAMLEditor.FormatXAML" ) ;
483482 }
484483
485484 /// <summary>
@@ -492,31 +491,7 @@ private void RunOtherCleanupCommands(TextDocument textDocument)
492491
493492 foreach ( var commandName in _otherCleaningCommands . Value )
494493 {
495- ExecuteCommand ( textDocument , commandName ) ;
496- }
497- }
498-
499- /// <summary>
500- /// Executes the specified cleanup command when available against the specified text document.
501- /// </summary>
502- /// <param name="textDocument">The text document to cleanup.</param>
503- /// <param name="commandNames">The cleanup command name(s).</param>
504- private void ExecuteCommand ( TextDocument textDocument , params string [ ] commandNames )
505- {
506- try
507- {
508- var command = _commandHelper . FindCommand ( commandNames ) ;
509- if ( command != null && command . IsAvailable )
510- {
511- using ( new CursorPositionRestorer ( textDocument ) )
512- {
513- _package . IDE . ExecuteCommand ( command . Name , string . Empty ) ;
514- }
515- }
516- }
517- catch
518- {
519- // OK if fails, not available for some file types.
494+ _commandHelper . ExecuteCommand ( textDocument , commandName ) ;
520495 }
521496 }
522497
0 commit comments