Skip to content

Commit 3b4e1db

Browse files
plugin: stub ExtensionMode implementation
The commit stubs `ExtensionMode` in order not to fail on activation of popular extensions (ex: gitlens). The proper implementation should be done in future iterations. Signed-off-by: vince-fugnitto <[email protected]>
1 parent 1b333be commit 3b4e1db

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

packages/plugin-ext/src/plugin/plugin-context.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ import {
135135
ColorThemeKind,
136136
SourceControlInputBoxValidationType,
137137
URI,
138-
FileDecoration
138+
FileDecoration,
139+
ExtensionMode
139140
} from './types-impl';
140141
import { AuthenticationExtImpl } from './authentication-ext';
141142
import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -959,7 +960,8 @@ export function createAPIFactory(
959960
ColorThemeKind,
960961
SourceControlInputBoxValidationType,
961962
FileDecoration,
962-
CancellationError
963+
CancellationError,
964+
ExtensionMode
963965
};
964966
};
965967
}

packages/plugin-ext/src/plugin/plugin-manager.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
382382
secrets,
383383
globalStoragePath: globalStoragePath,
384384
globalStorageUri: Uri.file(globalStoragePath),
385-
environmentVariableCollection: this.terminalService.getEnvironmentVariableCollection(plugin.model.id)
385+
environmentVariableCollection: this.terminalService.getEnvironmentVariableCollection(plugin.model.id),
386+
extensionMode: 1 // @todo: implement proper `extensionMode`.
386387
};
387388
this.pluginContextsMap.set(plugin.model.id, pluginContext);
388389

packages/plugin-ext/src/plugin/types-impl.ts

+20
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,26 @@ export enum ColorThemeKind {
189189
HighContrast = 3
190190
}
191191

192+
export enum ExtensionMode {
193+
/**
194+
* The extension is installed normally (for example, from the marketplace
195+
* or VSIX) in the editor.
196+
*/
197+
Production = 1,
198+
199+
/**
200+
* The extension is running from an `--extensionDevelopmentPath` provided
201+
* when launching the editor.
202+
*/
203+
Development = 2,
204+
205+
/**
206+
* The extension is running from an `--extensionTestsPath` and
207+
* the extension host is running unit tests.
208+
*/
209+
Test = 3,
210+
}
211+
192212
/**
193213
* Represents the validation type of the Source Control input.
194214
*/

packages/plugin/src/theia.d.ts

+32
Original file line numberDiff line numberDiff line change
@@ -3039,6 +3039,31 @@ declare module '@theia/plugin' {
30393039
clear(): void;
30403040
}
30413041

3042+
/**
3043+
* The ExtensionMode is provided on the `ExtensionContext` and indicates the
3044+
* mode the specific extension is running in.
3045+
*/
3046+
export enum ExtensionMode {
3047+
3048+
/**
3049+
* The extension is installed normally (for example, from the marketplace
3050+
* or VSIX) in the editor.
3051+
*/
3052+
Production = 1,
3053+
3054+
/**
3055+
* The extension is running from an `--extensionDevelopmentPath` provided
3056+
* when launching the editor.
3057+
*/
3058+
Development = 2,
3059+
3060+
/**
3061+
* The extension is running from an `--extensionTestsPath` and
3062+
* the extension host is running unit tests.
3063+
*/
3064+
Test = 3,
3065+
}
3066+
30423067
/**
30433068
* A plug-in context is a collection of utilities private to a
30443069
* plug-in.
@@ -3165,6 +3190,13 @@ declare module '@theia/plugin' {
31653190
* the parent directory is guaranteed to be existent.
31663191
*/
31673192
readonly logPath: string;
3193+
3194+
/**
3195+
* The mode the extension is running in. This is specific to the current
3196+
* extension. One extension may be in `ExtensionMode.Development` while
3197+
* other extensions in the host run in `ExtensionMode.Release`.
3198+
*/
3199+
readonly extensionMode: ExtensionMode;
31683200
}
31693201

31703202
/**

0 commit comments

Comments
 (0)