Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: stub setKeysForSync #10205

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ import {
ColorThemeKind,
SourceControlInputBoxValidationType,
URI,
FileDecoration
FileDecoration,
ExtensionMode
} from './types-impl';
import { AuthenticationExtImpl } from './authentication-ext';
import { SymbolKind } from '../common/plugin-api-rpc-model';
Expand Down Expand Up @@ -959,7 +960,8 @@ export function createAPIFactory(
ColorThemeKind,
SourceControlInputBoxValidationType,
FileDecoration,
CancellationError
CancellationError,
ExtensionMode
};
};
}
Expand Down
7 changes: 4 additions & 3 deletions packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import * as theia from '@theia/plugin';
import { join } from './path';
import { EnvExtImpl } from './env';
import { PreferenceRegistryExtImpl } from './preference-registry';
import { Memento, KeyValueStorageProxy } from './plugin-storage';
import { Memento, KeyValueStorageProxy, GlobalState } from './plugin-storage';
import { ExtPluginApi } from '../common/plugin-ext-api-contribution';
import { RPCProtocol } from '../common/rpc-protocol';
import { Emitter } from '@theia/core/lib/common/event';
Expand Down Expand Up @@ -372,7 +372,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
const pluginContext: theia.PluginContext = {
extensionPath: plugin.pluginFolder,
extensionUri: Uri.file(plugin.pluginFolder),
globalState: new Memento(plugin.model.id, true, this.storageProxy),
globalState: new GlobalState(plugin.model.id, true, this.storageProxy),
workspaceState: new Memento(plugin.model.id, false, this.storageProxy),
subscriptions: subscriptions,
asAbsolutePath: asAbsolutePath,
Expand All @@ -382,7 +382,8 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
secrets,
globalStoragePath: globalStoragePath,
globalStorageUri: Uri.file(globalStoragePath),
environmentVariableCollection: this.terminalService.getEnvironmentVariableCollection(plugin.model.id)
environmentVariableCollection: this.terminalService.getEnvironmentVariableCollection(plugin.model.id),
extensionMode: 1 // @todo: implement proper `extensionMode`.
};
this.pluginContextsMap.set(plugin.model.id, pluginContext);

Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export class Memento implements theia.Memento {
}
}

export class GlobalState extends Memento {

/** @todo: API is not yet implemented. */
setKeysForSync(keys: readonly string[]): void { }
}

/**
* Singleton.
* Is used to proxy storage requests to main side.
Expand Down
20 changes: 20 additions & 0 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ export enum ColorThemeKind {
HighContrast = 3
}

export enum ExtensionMode {
/**
* The extension is installed normally (for example, from the marketplace
* or VSIX) in the editor.
*/
Production = 1,

/**
* The extension is running from an `--extensionDevelopmentPath` provided
* when launching the editor.
*/
Development = 2,

/**
* The extension is running from an `--extensionTestsPath` and
* the extension host is running unit tests.
*/
Test = 3,
}

/**
* Represents the validation type of the Source Control input.
*/
Expand Down
49 changes: 48 additions & 1 deletion packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3039,6 +3039,31 @@ declare module '@theia/plugin' {
clear(): void;
}

/**
* The ExtensionMode is provided on the `ExtensionContext` and indicates the
* mode the specific extension is running in.
*/
export enum ExtensionMode {

/**
* The extension is installed normally (for example, from the marketplace
* or VSIX) in the editor.
*/
Production = 1,

/**
* The extension is running from an `--extensionDevelopmentPath` provided
* when launching the editor.
*/
Development = 2,

/**
* The extension is running from an `--extensionTestsPath` and
* the extension host is running unit tests.
*/
Test = 3,
}

/**
* A plug-in context is a collection of utilities private to a
* plug-in.
Expand All @@ -3064,7 +3089,22 @@ declare module '@theia/plugin' {
* A memento object that stores state independent
* of the current opened [workspace](#workspace.workspaceFolders).
*/
globalState: Memento;
globalState: Memento & {
/**
* Set the keys whose values should be synchronized across devices when synchronizing user-data
* like configuration, extensions, and mementos.
*
* Note that this function defines the whole set of keys whose values are synchronized:
* - calling it with an empty array stops synchronization for this memento
* - calling it with a non-empty array replaces all keys whose values are synchronized
*
* For any given set of keys this function needs to be called only once but there is no harm in
* repeatedly calling it.
*
* @param keys The set of keys whose values are synced.
*/
setKeysForSync(keys: readonly string[]): void;
};

/**
* A storage utility for secrets.
Expand Down Expand Up @@ -3150,6 +3190,13 @@ declare module '@theia/plugin' {
* the parent directory is guaranteed to be existent.
*/
readonly logPath: string;

/**
* The mode the extension is running in. This is specific to the current
* extension. One extension may be in `ExtensionMode.Development` while
* other extensions in the host run in `ExtensionMode.Release`.
*/
readonly extensionMode: ExtensionMode;
}

/**
Expand Down