Skip to content

Commit 3488313

Browse files
committed
Rename load to get
1 parent c5aac6d commit 3488313

File tree

13 files changed

+39
-39
lines changed

13 files changed

+39
-39
lines changed

src/client/datascience/export/exportUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ExportUtil {
6363
await this.jupyterExporter.exportToFile(cells, tempFile.filePath, false);
6464
const newPath = path.join(tempDir.path, '.ipynb');
6565
await this.fileSystem.copyFile(tempFile.filePath, newPath);
66-
model = await this.notebookStorage.load(Uri.file(newPath));
66+
model = await this.notebookStorage.get(Uri.file(newPath));
6767
} finally {
6868
tempFile.dispose();
6969
tempDir.dispose();
@@ -73,7 +73,7 @@ export class ExportUtil {
7373
}
7474

7575
public async removeSvgs(source: Uri) {
76-
const model = await this.notebookStorage.load(source);
76+
const model = await this.notebookStorage.get(source);
7777

7878
const newCells: ICell[] = [];
7979
for (const cell of model.cells) {

src/client/datascience/interactive-ipynb/nativeEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
151151
private startupTimer: StopWatch = new StopWatch();
152152
private loadedAllCells: boolean = false;
153153
private executeCancelTokens = new Set<CancellationTokenSource>();
154-
private previouslyNotTrusted:boolean = false;
154+
private previouslyNotTrusted: boolean = false;
155155

156156
constructor(
157157
@multiInject(IInteractiveWindowListener) listeners: IInteractiveWindowListener[],
@@ -809,4 +809,4 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
809809
}
810810
}
811811
}
812-
812+
}

src/client/datascience/interactive-ipynb/nativeEditorProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class NativeEditorProvider implements INotebookEditorProvider, CustomEdit
184184
this.untitledCounter = getNextUntitledCounter(file, this.untitledCounter);
185185

186186
// Load our model from our storage object.
187-
const model = await this.storage.load(file, contents, options);
187+
const model = await this.storage.get(file, contents, options);
188188

189189
// Make sure to listen to events on the model
190190
this.trackModel(model);

src/client/datascience/interactive-ipynb/nativeEditorStorage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,20 @@ export class NativeEditorStorage implements INotebookStorage {
7474
return `${path.basename(model.file.fsPath)}-${uuid()}`;
7575
}
7676

77-
public load(
77+
public get(
7878
file: Uri,
7979
possibleContents?: string,
8080
backupId?: string,
8181
forVSCodeNotebook?: boolean
8282
): Promise<INotebookModel>;
83-
public load(
83+
public get(
8484
file: Uri,
8585
possibleContents?: string,
8686
// tslint:disable-next-line: unified-signatures
8787
skipDirtyContents?: boolean,
8888
forVSCodeNotebook?: boolean
8989
): Promise<INotebookModel>;
90-
public load(
90+
public get(
9191
file: Uri,
9292
possibleContents?: string,
9393
// tslint:disable-next-line: no-any

src/client/datascience/interactive-ipynb/notebookStorageProvider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export class NotebookStorageProvider implements INotebookStorageProvider {
5656
public deleteBackup(model: INotebookModel, backupId?: string) {
5757
return this.storage.deleteBackup(model, backupId);
5858
}
59-
public load(file: Uri, contents?: string, backupId?: string, forVSCodeNotebook?: boolean): Promise<INotebookModel>;
60-
public load(
59+
public get(file: Uri, contents?: string, backupId?: string, forVSCodeNotebook?: boolean): Promise<INotebookModel>;
60+
public get(
6161
file: Uri,
6262
contents?: string,
6363
// tslint:disable-next-line: unified-signatures
@@ -66,15 +66,15 @@ export class NotebookStorageProvider implements INotebookStorageProvider {
6666
): Promise<INotebookModel>;
6767

6868
// tslint:disable-next-line: no-any
69-
public load(file: Uri, contents?: string, options?: any, forVSCodeNotebook?: boolean): Promise<INotebookModel> {
69+
public get(file: Uri, contents?: string, options?: any, forVSCodeNotebook?: boolean): Promise<INotebookModel> {
7070
const key = file.toString();
7171
if (!this.storageAndModels.has(key)) {
7272
// Every time we load a new untitled file, up the counter past the max value for this counter
7373
NotebookStorageProvider.untitledCounter = getNextUntitledCounter(
7474
file,
7575
NotebookStorageProvider.untitledCounter
7676
);
77-
const promise = this.storage.load(file, contents, options, forVSCodeNotebook);
77+
const promise = this.storage.get(file, contents, options, forVSCodeNotebook);
7878
this.storageAndModels.set(key, promise.then(this.trackModel.bind(this)));
7979
}
8080
return this.storageAndModels.get(key)!;
@@ -90,7 +90,7 @@ export class NotebookStorageProvider implements INotebookStorageProvider {
9090
const uri = this.getNextNewNotebookUri(forVSCodeNotebooks);
9191

9292
// Always skip loading from the hot exit file. When creating a new file we want a new file.
93-
return this.load(uri, contents, true);
93+
return this.get(uri, contents, true);
9494
}
9595

9696
private getNextNewNotebookUri(forVSCodeNotebooks?: boolean): Uri {

src/client/datascience/notebook/contentProvider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ export class NotebookContentProvider implements INotebookContentProvider {
7272
}
7373
// If there's no backup id, then skip loading dirty contents.
7474
const model = await (openContext.backupId
75-
? this.notebookStorage.load(uri, undefined, openContext.backupId, true)
76-
: this.notebookStorage.load(uri, undefined, true, true));
75+
? this.notebookStorage.get(uri, undefined, openContext.backupId, true)
76+
: this.notebookStorage.get(uri, undefined, true, true));
7777

7878
setSharedProperty('ds_notebookeditor', 'native');
7979
sendTelemetryEvent(Telemetry.CellCount, undefined, { count: model.cells.length });
8080
return notebookModelToVSCNotebookData(model);
8181
}
8282
@captureTelemetry(Telemetry.Save, undefined, true)
8383
public async saveNotebook(document: NotebookDocument, cancellation: CancellationToken) {
84-
const model = await this.notebookStorage.load(document.uri, undefined, undefined, true);
84+
const model = await this.notebookStorage.get(document.uri, undefined, undefined, true);
8585
if (cancellation.isCancellationRequested) {
8686
return;
8787
}
@@ -97,7 +97,7 @@ export class NotebookContentProvider implements INotebookContentProvider {
9797
document: NotebookDocument,
9898
cancellation: CancellationToken
9999
): Promise<void> {
100-
const model = await this.notebookStorage.load(document.uri, undefined, undefined, true);
100+
const model = await this.notebookStorage.get(document.uri, undefined, undefined, true);
101101
if (!cancellation.isCancellationRequested) {
102102
await this.notebookStorage.saveAs(model, targetResource);
103103
}
@@ -107,7 +107,7 @@ export class NotebookContentProvider implements INotebookContentProvider {
107107
_context: NotebookDocumentBackupContext,
108108
cancellation: CancellationToken
109109
): Promise<NotebookDocumentBackup> {
110-
const model = await this.notebookStorage.load(document.uri, undefined, undefined, true);
110+
const model = await this.notebookStorage.get(document.uri, undefined, undefined, true);
111111
const id = this.notebookStorage.generateBackupId(model);
112112
await this.notebookStorage.backup(model, cancellation, id);
113113
return {

src/client/datascience/notebook/executionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class NotebookExecutionService implements INotebookExecutionService {
144144
private async getNotebookAndModel(
145145
document: NotebookDocument
146146
): Promise<{ model: VSCodeNotebookModel; nb: INotebook }> {
147-
const model = await this.notebookStorage.load(document.uri, undefined, undefined, true);
147+
const model = await this.notebookStorage.get(document.uri, undefined, undefined, true);
148148
const nb = await this.notebookProvider.getOrCreateNotebook({
149149
identity: document.uri,
150150
resource: document.uri,

src/client/datascience/notebook/notebookEditorProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class NotebookEditorProvider implements INotebookEditorProvider {
160160
return;
161161
}
162162
const uri = doc.uri;
163-
const model = await this.storage.load(uri, undefined, undefined, true);
163+
const model = await this.storage.get(uri, undefined, undefined, true);
164164
mapVSCNotebookCellsToNotebookCellModels(doc, model);
165165
// In open method we might be waiting.
166166
let editor = this.notebookEditorsByUri.get(uri.toString());
@@ -237,7 +237,7 @@ export class NotebookEditorProvider implements INotebookEditorProvider {
237237
if (!isJupyterNotebook(e.document)) {
238238
return;
239239
}
240-
const model = await this.storage.load(e.document.uri, undefined, undefined, true);
240+
const model = await this.storage.get(e.document.uri, undefined, undefined, true);
241241
if (!(model instanceof VSCodeNotebookModel)) {
242242
throw new Error('NotebookModel not of type VSCodeNotebookModel');
243243
}

src/client/datascience/notebook/notebookTrustHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class NotebookTrustHandler implements IExtensionSingleActivationService {
5353
if (!uri) {
5454
return;
5555
}
56-
const model = await this.storageProvider.load(uri);
56+
const model = await this.storageProvider.get(uri);
5757
if (model.isTrusted) {
5858
return;
5959
}
@@ -66,8 +66,6 @@ export class NotebookTrustHandler implements IExtensionSingleActivationService {
6666
if (selection !== DataScience.trustNotebook() || model.isTrusted) {
6767
return;
6868
}
69-
const contents = model.getContent();
70-
await this.trustService.trustNotebook(model.file, contents);
7169
// Update model trust
7270
model.update({
7371
source: 'user',
@@ -76,5 +74,7 @@ export class NotebookTrustHandler implements IExtensionSingleActivationService {
7674
newDirty: model.isDirty,
7775
isNotebookTrusted: true
7876
});
77+
const contents = model.getContent();
78+
await this.trustService.trustNotebook(model.file, contents);
7979
}
8080
}

src/client/datascience/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ export interface INotebookStorage {
10431043
save(model: INotebookModel, cancellation: CancellationToken): Promise<void>;
10441044
saveAs(model: INotebookModel, targetResource: Uri): Promise<void>;
10451045
backup(model: INotebookModel, cancellation: CancellationToken, backupId?: string): Promise<void>;
1046-
load(file: Uri, contents?: string, backupId?: string, forVSCodeNotebook?: boolean): Promise<INotebookModel>;
1047-
load(
1046+
get(file: Uri, contents?: string, backupId?: string, forVSCodeNotebook?: boolean): Promise<INotebookModel>;
1047+
get(
10481048
file: Uri,
10491049
contents?: string,
10501050
// tslint:disable-next-line: unified-signatures

src/test/datascience/export/exportUtil.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ suite('DataScience - Export Util', () => {
3737
);
3838

3939
await exportUtil.removeSvgs(file);
40-
const model = await notebookStorage.load(file);
40+
const model = await notebookStorage.get(file);
4141

4242
// make sure no svg exists in model
4343
const SVG = 'image/svg+xml';

src/test/datascience/interactive-ipynb/nativeEditorStorage.unit.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ suite('DataScience - Native Editor Storage', () => {
409409
}
410410

411411
test('Create new editor and add some cells', async () => {
412-
model = await storage.load(baseUri);
412+
model = await storage.get(baseUri);
413413
insertCell(0, '1');
414414
const cells = model.cells;
415415
expect(cells).to.be.lengthOf(4);
@@ -418,7 +418,7 @@ suite('DataScience - Native Editor Storage', () => {
418418
});
419419

420420
test('Move cells around', async () => {
421-
model = await storage.load(baseUri);
421+
model = await storage.get(baseUri);
422422
swapCells('NotebookImport#0', 'NotebookImport#1');
423423
const cells = model.cells;
424424
expect(cells).to.be.lengthOf(3);
@@ -427,7 +427,7 @@ suite('DataScience - Native Editor Storage', () => {
427427
});
428428

429429
test('Edit/delete cells', async () => {
430-
model = await storage.load(baseUri);
430+
model = await storage.get(baseUri);
431431
expect(model.isDirty).to.be.equal(false, 'Editor should not be dirty');
432432
editCell(
433433
[
@@ -467,7 +467,7 @@ suite('DataScience - Native Editor Storage', () => {
467467
test('Editing a file and closing will keep contents', async () => {
468468
await filesConfig?.update('autoSave', 'off');
469469

470-
model = await storage.load(baseUri);
470+
model = await storage.get(baseUri);
471471
expect(model.isDirty).to.be.equal(false, 'Editor should not be dirty');
472472
editCell(
473473
[
@@ -496,7 +496,7 @@ suite('DataScience - Native Editor Storage', () => {
496496

497497
// Recreate
498498
storage = createStorage();
499-
model = await storage.load(baseUri);
499+
model = await storage.get(baseUri);
500500

501501
const cells = model.cells;
502502
expect(cells).to.be.lengthOf(3);
@@ -506,7 +506,7 @@ suite('DataScience - Native Editor Storage', () => {
506506
});
507507

508508
test('Editing a new file and closing will keep contents', async () => {
509-
model = await storage.load(untiledUri, undefined, true);
509+
model = await storage.get(untiledUri, undefined, true);
510510
expect(model.isDirty).to.be.equal(false, 'Editor should not be dirty');
511511
insertCell(0, 'a=1');
512512

@@ -515,7 +515,7 @@ suite('DataScience - Native Editor Storage', () => {
515515

516516
// Recreate
517517
storage = createStorage();
518-
model = await storage.load(untiledUri);
518+
model = await storage.get(untiledUri);
519519

520520
const cells = model.cells;
521521
expect(cells).to.be.lengthOf(2);
@@ -534,7 +534,7 @@ suite('DataScience - Native Editor Storage', () => {
534534

535535
// Put the regular file into the local storage
536536
await localMemento.update(`notebook-storage-${file.toString()}`, differentFile);
537-
model = await storage.load(file);
537+
model = await storage.get(file);
538538

539539
// It should load with that value
540540
const cells = model.cells;
@@ -555,7 +555,7 @@ suite('DataScience - Native Editor Storage', () => {
555555
contents: differentFile,
556556
lastModifiedTimeMs: Date.now()
557557
});
558-
model = await storage.load(file);
558+
model = await storage.get(file);
559559

560560
// It should load with that value
561561
const cells = model.cells;
@@ -585,7 +585,7 @@ suite('DataScience - Native Editor Storage', () => {
585585
lastModifiedTimeMs: Date.now()
586586
});
587587

588-
model = await storage.load(file);
588+
model = await storage.get(file);
589589

590590
// It should load with that value
591591
const cells = model.cells;

src/test/datascience/notebook/contentProvider.unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ suite('Data Science - NativeNotebook ContentProvider', () => {
6565
state: CellState.init
6666
}
6767
],
68-
isTrusted: isNotebookTrusted
68+
isTrustedgetNotebookTrusted
6969
};
7070
when(storageProvider.load(anything(), anything(), anything(), anything())).thenResolve(
7171
(model as unknown) as INotebookModel
@@ -143,7 +143,7 @@ suite('Data Science - NativeNotebook ContentProvider', () => {
143143
source: '# HEAD',
144144
metadata: {}
145145
},
146-
file: 'a.ipynb',
146+
fget 'a.ipynb',
147147
id: 'MyCellId2',
148148
line: 0,
149149
state: CellState.init

0 commit comments

Comments
 (0)