Skip to content

Commit

Permalink
Add TerminalQuickFixProvider API stubbing (#12532)
Browse files Browse the repository at this point in the history
The commit adds the stubbing for the proposed `TerminalQuickFixProvider` API which was necessary for the `vscode.npm` builtin to successfully activate at version `v1.77.0`.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto authored May 18, 2023
1 parent 22d5ef5 commit 39dfc8c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ import {
TerminalLocation,
TerminalExitReason,
TerminalProfile,
TerminalQuickFixType,
InlayHint,
InlayHintKind,
InlayHintLabelPart,
Expand Down Expand Up @@ -582,6 +583,10 @@ export function createAPIFactory(
/** @stubbed ProfileContentHandler */
registerProfileContentHandler(id: string, profileContentHandler: theia.ProfileContentHandler): theia.Disposable {
return Disposable.NULL;
},
/** @stubbed TerminalQuickFixProvider */
registerTerminalQuickFixProvider(id: string, provider: theia.TerminalQuickFixProvider): theia.Disposable {
return terminalExt.registerTerminalQuickFixProvider(id, provider);
}
};

Expand Down Expand Up @@ -1363,7 +1368,8 @@ export function createAPIFactory(
TerminalLocation,
TerminalExitReason,
DocumentPasteEdit,
ExternalUriOpenerPriority
ExternalUriOpenerPriority,
TerminalQuickFixType
};
};
}
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-ext/src/plugin/terminal-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
});
}

/** @stubbed */
registerTerminalQuickFixProvider(id: string, provider: theia.TerminalQuickFixProvider): theia.Disposable {
return Disposable.NULL;
}

protected isExtensionTerminalOptions(options: theia.TerminalOptions | theia.ExtensionTerminalOptions): options is theia.ExtensionTerminalOptions {
return 'pty' in options;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,11 @@ export enum TerminalExitReason {
Extension = 4,
}

export enum TerminalQuickFixType {
command = 'command',
opener = 'opener'
}

@es5ClassCompat
export class FileDecoration {

Expand Down
40 changes: 40 additions & 0 deletions packages/plugin/src/theia-proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,46 @@ export module '@theia/plugin' {
}

// #endregion ProfileContentHandler

// #region TerminalQuickFixProvider

export namespace window {
/**
* @param provider A terminal quick fix provider
* @return A {@link Disposable} that un-registers the provider when being disposed
*/
export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable;
}

export interface TerminalQuickFixProvider {
/**
* Provides terminal quick fixes
* @param commandMatchResult The command match result for which to provide quick fixes
* @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;
}

export interface TerminalCommandMatchResult {
commandLine: string;
commandLineMatch: RegExpMatchArray;
outputMatch?: {
regexMatch: RegExpMatchArray;
outputLines?: string[];
};
}

interface TerminalQuickFix {
type: TerminalQuickFixType;
}

enum TerminalQuickFixType {
command = 'command',
opener = 'opener'
}

// #endRegion TerminalQuickFixProvider
}

/**
Expand Down

0 comments on commit 39dfc8c

Please sign in to comment.