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

Use _ for privates in webview code #165183

Merged
merged 1 commit into from
Nov 1, 2022
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
18 changes: 9 additions & 9 deletions src/vs/workbench/contrib/webview/browser/overlayWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
const oldOwner = this._owner;

this._owner = owner;
this.show();
this._show();

if (oldOwner !== owner) {
const contextKeyService = (scopedContextKeyService || this._baseContextKeyService);
Expand Down Expand Up @@ -184,7 +184,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
}
}

private show() {
private _show() {
if (this._isDisposed) {
throw new Error('Webview overlay is disposed');
}
Expand Down Expand Up @@ -259,25 +259,25 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
public get html(): string { return this._html; }
public set html(value: string) {
this._html = value;
this.withWebview(webview => webview.html = value);
this._withWebview(webview => webview.html = value);
}

public get initialScrollProgress(): number { return this._initialScrollProgress; }
public set initialScrollProgress(value: number) {
this._initialScrollProgress = value;
this.withWebview(webview => webview.initialScrollProgress = value);
this._withWebview(webview => webview.initialScrollProgress = value);
}

public get state(): string | undefined { return this._state; }
public set state(value: string | undefined) {
this._state = value;
this.withWebview(webview => webview.state = value);
this._withWebview(webview => webview.state = value);
}

public get extension(): WebviewExtensionDescription | undefined { return this._extension; }
public set extension(value: WebviewExtensionDescription | undefined) {
this._extension = value;
this.withWebview(webview => webview.extension = value);
this._withWebview(webview => webview.extension = value);
}

public get options(): WebviewOptions { return this._options; }
Expand All @@ -286,11 +286,11 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
public get contentOptions(): WebviewContentOptions { return this._contentOptions; }
public set contentOptions(value: WebviewContentOptions) {
this._contentOptions = value;
this.withWebview(webview => webview.contentOptions = value);
this._withWebview(webview => webview.contentOptions = value);
}

public set localResourcesRoot(resources: URI[]) {
this.withWebview(webview => webview.localResourcesRoot = resources);
this._withWebview(webview => webview.localResourcesRoot = resources);
}

private readonly _onDidFocus = this._register(new Emitter<void>());
Expand Down Expand Up @@ -355,7 +355,7 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {

runFindAction(previous: boolean): void { this._webview.value?.runFindAction(previous); }

private withWebview(f: (webview: IWebview) => void): void {
private _withWebview(f: (webview: IWebview) => void): void {
if (this._webview.value) {
f(this._webview.value);
}
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/webview/browser/themeing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export class WebviewThemeDataProvider extends Disposable {
super();

this._register(this._themeService.onDidColorThemeChange(() => {
this.reset();
this._reset();
}));

const webviewConfigurationKeys = ['editor.fontFamily', 'editor.fontWeight', 'editor.fontSize'];
this._register(this._configurationService.onDidChangeConfiguration(e => {
if (webviewConfigurationKeys.some(key => e.affectsConfiguration(key))) {
this.reset();
this._reset();
}
}));
}
Expand Down Expand Up @@ -82,7 +82,7 @@ export class WebviewThemeDataProvider extends Disposable {
return this._cachedWebViewThemeData;
}

private reset() {
private _reset() {
this._cachedWebViewThemeData = undefined;
this._onThemeDataChanged.fire();
}
Expand Down
24 changes: 12 additions & 12 deletions src/vs/workbench/contrib/webview/browser/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,32 +299,32 @@ export interface IOverlayWebview extends IWebview {
*/
export class WebviewOriginStore {

private readonly memento: Memento;
private readonly state: MementoObject;
private readonly _memento: Memento;
private readonly _state: MementoObject;

constructor(
rootStorageKey: string,
@IStorageService storageService: IStorageService,
) {
this.memento = new Memento(rootStorageKey, storageService);
this.state = this.memento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE);
this._memento = new Memento(rootStorageKey, storageService);
this._state = this._memento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE);
}

public getOrigin(viewType: string, additionalKey: string | undefined): string {
const key = this.getKey(viewType, additionalKey);
const key = this._getKey(viewType, additionalKey);

const existing = this.state[key];
const existing = this._state[key];
if (existing && typeof existing === 'string') {
return existing;
}

const newOrigin = generateUuid();
this.state[key] = newOrigin;
this.memento.saveMemento();
this._state[key] = newOrigin;
this._memento.saveMemento();
return newOrigin;
}

private getKey(viewType: string, additionalKey: string | undefined): string {
private _getKey(viewType: string, additionalKey: string | undefined): string {
return JSON.stringify({ viewType, key: additionalKey });
}
}
Expand All @@ -336,16 +336,16 @@ export class WebviewOriginStore {
*/
export class ExtensionKeyedWebviewOriginStore {

private readonly store: WebviewOriginStore;
private readonly _store: WebviewOriginStore;

constructor(
rootStorageKey: string,
@IStorageService storageService: IStorageService,
) {
this.store = new WebviewOriginStore(rootStorageKey, storageService);
this._store = new WebviewOriginStore(rootStorageKey, storageService);
}

public getOrigin(viewType: string, extId: ExtensionIdentifier): string {
return this.store.getOrigin(viewType, extId.value);
return this._store.getOrigin(viewType, extId.value);
}
}
Loading