Skip to content
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
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors));
const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors, extHostLogService));
const extHostDocumentSaveParticipant = rpcProtocol.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostLogService, extHostDocuments, rpcProtocol.getProxy(MainContext.MainThreadBulkEdits)));
const extHostNotebook = rpcProtocol.set(ExtHostContext.ExtHostNotebook, new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extHostConsumerFileSystem, extHostSearch));
const extHostNotebook = rpcProtocol.set(ExtHostContext.ExtHostNotebook, new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extHostConsumerFileSystem, extHostSearch, extHostLogService));
const extHostNotebookDocuments = rpcProtocol.set(ExtHostContext.ExtHostNotebookDocuments, new ExtHostNotebookDocuments(extHostNotebook));
const extHostNotebookEditors = rpcProtocol.set(ExtHostContext.ExtHostNotebookEditors, new ExtHostNotebookEditors(extHostLogService, extHostNotebook));
const extHostNotebookKernels = rpcProtocol.set(ExtHostContext.ExtHostNotebookKernels, new ExtHostNotebookKernels(rpcProtocol, initData, extHostNotebook, extHostCommands, extHostLogService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export class ExtHostDocumentContentProvider implements ExtHostDocumentContentPro
throw new Error(`scheme '${scheme}' already registered`);
}

this._logService.warn('TEST WARNING');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, yes

this._logService.error('TEST ERROR');
this._logService.info('TEST INFO');
this._logService.trace('TEST TRACE');

const handle = ExtHostDocumentContentProvider._handlePool++;

this._documentContentProviders.set(handle, provider);
Expand Down
13 changes: 12 additions & 1 deletion src/vs/workbench/api/common/extHostNotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { CellSearchModel } from 'vs/workbench/contrib/search/common/cellSearchMo
import { INotebookCellMatchNoModel, INotebookFileMatchNoModel, IRawClosedNotebookFileMatch, genericCellMatchesToTextSearchMatches } from 'vs/workbench/contrib/search/common/searchNotebookHelpers';
import { NotebookPriorityInfo } from 'vs/workbench/contrib/search/common/search';
import { globMatchesResource } from 'vs/workbench/services/editor/common/editorResolverService';
import { ILogService } from 'vs/platform/log/common/log';

export class ExtHostNotebookController implements ExtHostNotebookShape {
private static _notebookStatusBarItemProviderHandlePool: number = 0;
Expand Down Expand Up @@ -78,7 +79,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
private _textDocumentsAndEditors: ExtHostDocumentsAndEditors,
private _textDocuments: ExtHostDocuments,
private _extHostFileSystem: IExtHostConsumerFileSystem,
private _extHostSearch: IExtHostSearch
private _extHostSearch: IExtHostSearch,
private _logService: ILogService
) {
this._notebookProxy = mainContext.getProxy(MainContext.MainThreadNotebook);
this._notebookDocumentsProxy = mainContext.getProxy(MainContext.MainThreadNotebookDocuments);
Expand Down Expand Up @@ -314,6 +316,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
async $saveNotebook(handle: number, uriComponents: UriComponents, versionId: number, options: files.IWriteFileOptions, token: CancellationToken): Promise<INotebookPartialFileStatsWithMetadata> {
const uri = URI.revive(uriComponents);
const serializer = this._notebookSerializer.get(handle);
this.trace(`enter saveNotebook(versionId: ${versionId}, ${uri.toString()})`);

if (!serializer) {
throw new Error('NO serializer found');
}
Expand Down Expand Up @@ -357,7 +361,9 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
await this._validateWriteFile(uri, options);

const bytes = await serializer.serializer.serializeNotebook(data, token);
this.trace(`serialized versionId: ${versionId} ${uri.toString()}`);
await this._extHostFileSystem.value.writeFile(uri, bytes);
this.trace(`Finished write versionId: ${versionId} ${uri.toString()}`);
const providerExtUri = this._extHostFileSystem.getFileSystemProviderExtUri(uri.scheme);
const stat = await this._extHostFileSystem.value.stat(uri);

Expand All @@ -375,6 +381,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
children: undefined
};

this.trace(`exit saveNotebook(versionId: ${versionId}, ${uri.toString()})`);
return fileStats;
}

Expand Down Expand Up @@ -718,4 +725,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape {
extHostCommands.registerApiCommand(commandDataToNotebook);
extHostCommands.registerApiCommand(commandNotebookToData);
}

private trace(msg: string): void {
this._logService.trace(`[Extension Host Notebook] ${msg}`);
}
}
2 changes: 1 addition & 1 deletion src/vs/workbench/api/test/browser/extHostNotebook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ suite('NotebookCell#Document', function () {
override onExtensionError(): boolean {
return true;
}
}), extHostDocumentsAndEditors, extHostDocuments, extHostConsumerFileSystem, extHostSearch);
}), extHostDocumentsAndEditors, extHostDocuments, extHostConsumerFileSystem, extHostSearch, new NullLogService());
extHostNotebookDocuments = new ExtHostNotebookDocuments(extHostNotebooks);

const reg = extHostNotebooks.registerNotebookSerializer(nullExtensionDescription, 'test', new class extends mock<vscode.NotebookSerializer>() { });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ suite('NotebookKernel', function () {
});
extHostConsumerFileSystem = new ExtHostConsumerFileSystem(rpcProtocol, new ExtHostFileSystemInfo());
extHostSearch = new ExtHostSearch(rpcProtocol, new URITransformerService(null), new NullLogService());
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extHostConsumerFileSystem, extHostSearch);
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extHostConsumerFileSystem, extHostSearch, new NullLogService());

extHostNotebookDocuments = new ExtHostNotebookDocuments(extHostNotebooks);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,17 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
if (!token.isCancellationRequested) {
type notebookSaveErrorData = {
isRemote: boolean;
versionMismatch: boolean;
error: Error;
};
type notebookSaveErrorClassification = {
owner: 'amunger';
comment: 'Detect if we are having issues saving a notebook on the Extension Host';
isRemote: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Whether the save is happening on a remote file system' };
versionMismatch: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'If the error was because of a version mismatch' };
error: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Info about the error that occurred' };
};
this._telemetryService.publicLogError2<notebookSaveErrorData, notebookSaveErrorClassification>('notebook/SaveError', {
isRemote: this._notebookModel.uri.scheme === Schemas.vscodeRemote,
versionMismatch: error instanceof Error && error.message === 'Document version mismatch'
error: error
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ import { IMarkdownString } from 'vs/base/common/htmlContent';
*/
export interface IStoredFileWorkingCopyModelFactory<M extends IStoredFileWorkingCopyModel> extends IFileWorkingCopyModelFactory<M> { }

export async function createOptionalResult<T>(callback: (token: CancellationToken) => Promise<T | undefined>, token: CancellationToken): Promise<T | undefined> {
const result = await callback(token);
if (result === undefined && token.isCancellationRequested) {
return undefined;
}
else {
return assertIsDefined(result);
}
}

/**
* The underlying model of a stored file working copy provides some
* methods for the stored file working copy to function. The model is
Expand Down