Skip to content

Commit

Permalink
plugin: stub setKeysForSync
Browse files Browse the repository at this point in the history
The commit stubs the method `setKeysForSync` as it is currently not
supported by the framework and likely uses vscode online services to
store data across machines.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Sep 30, 2021
1 parent 6abc784 commit 4c2b3d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 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 Down
8 changes: 8 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,14 @@ export class Memento implements theia.Memento {
}
}

export class GlobalState extends Memento {

setKeysForSync(keys: readonly string[]): void {
/** no-op. */
}

}

/**
* Singleton.
* Is used to proxy storage requests to main side.
Expand Down
17 changes: 16 additions & 1 deletion packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3064,7 +3064,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

0 comments on commit 4c2b3d9

Please sign in to comment.