From 9c6537538571e221a2d3e63a4c1d79be5b21d706 Mon Sep 17 00:00:00 2001
From: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
Date: Wed, 18 Oct 2023 16:25:42 +0200
Subject: [PATCH] API evolution for TerminalQuickFixProvider

note the API is still stubbed in the tool.

Fixes #12969

Contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
---
 CHANGELOG.md                                  |  1 +
 .../plugin-ext/src/plugin/plugin-context.ts   |  8 +++--
 packages/plugin-ext/src/plugin/types-impl.ts  | 29 +++++++++++++++----
 ...eia.proposed.terminalQuickFixProvider.d.ts | 23 ++++++++++-----
 4 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ec00510584bef..13db2748b19d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
 ## v1.43.0 - Unreleased
 
 - [vsode] evolve proposed API for dropDocument [#13009](https://github.com/eclipse-theia/theia/pull/13009) - contributed on behalf of STMicroelectronics
+- [vsode] evolve proposed API for terminalQuickFixProvider [#13006](https://github.com/eclipse-theia/theia/pull/13006) - contributed on behalf of STMicroelectronics
 
 <a name="breaking_changes_1.43.0">[Breaking Changes:](#breaking_changes_1.43.0)</a>
 
diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts
index 0f44efee200fa..504d5b5955210 100644
--- a/packages/plugin-ext/src/plugin/plugin-context.ts
+++ b/packages/plugin-ext/src/plugin/plugin-context.ts
@@ -161,7 +161,6 @@ import {
     TerminalLocation,
     TerminalExitReason,
     TerminalProfile,
-    TerminalQuickFixType,
     InlayHint,
     InlayHintKind,
     InlayHintLabelPart,
@@ -199,7 +198,9 @@ import {
     DocumentPasteEdit,
     ExternalUriOpenerPriority,
     EditSessionIdentityMatch,
-    TerminalOutputAnchor
+    TerminalOutputAnchor,
+    TerminalQuickFixExecuteTerminalCommand,
+    TerminalQuickFixOpener
 } from './types-impl';
 import { AuthenticationExtImpl } from './authentication-ext';
 import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -1391,7 +1392,8 @@ export function createAPIFactory(
             TerminalExitReason,
             DocumentPasteEdit,
             ExternalUriOpenerPriority,
-            TerminalQuickFixType,
+            TerminalQuickFixExecuteTerminalCommand,
+            TerminalQuickFixOpener,
             EditSessionIdentityMatch
         };
     };
diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts
index 99be4c26625a9..b653620464f90 100644
--- a/packages/plugin-ext/src/plugin/types-impl.ts
+++ b/packages/plugin-ext/src/plugin/types-impl.ts
@@ -2183,11 +2183,6 @@ export enum TerminalExitReason {
     Extension = 4,
 }
 
-export enum TerminalQuickFixType {
-    command = 'command',
-    opener = 'opener'
-}
-
 @es5ClassCompat
 export class FileDecoration {
 
@@ -3630,3 +3625,27 @@ export enum EditSessionIdentityMatch {
     None = 0
 }
 // #endregion
+
+// #region terminalQuickFixProvider
+export class TerminalQuickFixExecuteTerminalCommand {
+    /**
+     * The terminal command to run
+     */
+    terminalCommand: string;
+    /**
+     * @stubbed
+     */
+    constructor(terminalCommand: string) { }
+}
+export class TerminalQuickFixOpener {
+    /**
+     * The uri to open
+     */
+    uri: theia.Uri;
+    /**
+     * @stubbed
+     */
+    constructor(uri: theia.Uri) { }
+}
+
+// #endregion
diff --git a/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts b/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts
index c04280b8d8529..60d86230880c4 100644
--- a/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts
+++ b/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts
@@ -22,6 +22,8 @@
 
 export module '@theia/plugin' {
 
+    export type SingleOrMany<T> = T[] | T;
+
     export namespace window {
         /**
          * @param provider A terminal quick fix provider
@@ -37,7 +39,8 @@ export module '@theia/plugin' {
          * @param token A cancellation token indicating the result is no longer needed
          * @return Terminal quick fix(es) if any
          */
-        provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): TerminalQuickFix[] | TerminalQuickFix | undefined;
+        provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken):
+            ProviderResult<SingleOrMany<TerminalQuickFixExecuteTerminalCommand | TerminalQuickFixOpener | Command>>;
     }
 
     export interface TerminalCommandMatchResult {
@@ -49,13 +52,19 @@ export module '@theia/plugin' {
         };
     }
 
-    interface TerminalQuickFix {
-        type: TerminalQuickFixType;
+    export class TerminalQuickFixExecuteTerminalCommand {
+        /**
+         * The terminal command to run
+         */
+        terminalCommand: string;
+        constructor(terminalCommand: string);
     }
-
-    enum TerminalQuickFixType {
-        command = 'command',
-        opener = 'opener'
+    export class TerminalQuickFixOpener {
+        /**
+         * The uri to open
+         */
+        uri: Uri;
+        constructor(uri: Uri);
     }
 
     /**