Skip to content

Commit fe85613

Browse files
authored
Remove SafeNotebookDocument API compat wrapper class (microsoft#16570)
1 parent 846eee8 commit fe85613

3 files changed

Lines changed: 8 additions & 103 deletions

File tree

src/client/jupyter/languageserver/notebookConcatDocument.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ import { NotebookConcatTextDocument, NotebookCell, NotebookDocument } from 'vsco
2121
import { IVSCodeNotebook } from '../../common/application/types';
2222
import { IDisposable } from '../../common/types';
2323
import { PYTHON_LANGUAGE } from '../../common/constants';
24-
import { SafeNotebookDocument } from './safeNotebookDocument';
2524

2625
const NotebookConcatPrefix = '_NotebookConcat_';
2726

2827
/**
2928
* This helper class is used to present a converted document to an LS
3029
*/
3130
export class NotebookConcatDocument implements TextDocument, IDisposable {
32-
public get notebook(): SafeNotebookDocument {
31+
public get notebook(): NotebookDocument {
3332
return this._notebook;
3433
}
3534

@@ -118,14 +117,14 @@ export class NotebookConcatDocument implements TextDocument, IDisposable {
118117

119118
private onCellsChangedEmitter = new EventEmitter<TextDocumentChangeEvent>();
120119

121-
private _notebook: SafeNotebookDocument;
120+
private _notebook: NotebookDocument;
122121

123122
constructor(notebook: NotebookDocument, notebookApi: IVSCodeNotebook, selector: DocumentSelector) {
124123
const dir = path.dirname(notebook.uri.fsPath);
125124
// Create a safe notebook document so that we can handle both >= 1.56 vscode API and < 1.56
126125
// when vscode stable is 1.56 and both Python release and insiders can update to that engine version we
127126
// can remove this and just use NotebookDocument directly
128-
this._notebook = new SafeNotebookDocument(notebook);
127+
this._notebook = notebook;
129128
// Note: Has to be different than the prefix for old notebook editor (HiddenFileFormat) so
130129
// that the caller doesn't remove diagnostics for this document.
131130
this.dummyFilePath = path.join(dir, `${NotebookConcatPrefix}${uuid().replace(/-/g, '')}.py`);

src/client/jupyter/languageserver/notebookConverter.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { NotebookCell, NotebookConcatTextDocument, NotebookDocument } from 'vsco
3434
import { IVSCodeNotebook } from '../../common/application/types';
3535
import { IFileSystem } from '../../common/platform/types';
3636
import { NotebookConcatDocument } from './notebookConcatDocument';
37-
import { SafeNotebookDocument } from './safeNotebookDocument';
3837

3938
/* Used by code actions. Disabled for now.
4039
function toRange(rangeLike: Range): Range {
@@ -649,17 +648,15 @@ export class NotebookConverter implements Disposable {
649648
}
650649

651650
private onDidOpenNotebook(doc: NotebookDocument) {
652-
const safeDoc = new SafeNotebookDocument(doc);
653-
if (this.notebookFilter.test(safeDoc.fileName)) {
654-
this.getTextDocumentWrapper(safeDoc.uri);
651+
if (this.notebookFilter.test(doc.uri.fsPath)) {
652+
this.getTextDocumentWrapper(doc.uri);
655653
}
656654
}
657655

658656
private onDidCloseNotebook(doc: NotebookDocument) {
659-
const safeDoc = new SafeNotebookDocument(doc);
660-
if (this.notebookFilter.test(safeDoc.fileName)) {
661-
const key = NotebookConverter.getDocumentKey(safeDoc.uri);
662-
const wrapper = this.getTextDocumentWrapper(safeDoc.uri);
657+
if (this.notebookFilter.test(doc.uri.fsPath)) {
658+
const key = NotebookConverter.getDocumentKey(doc.uri);
659+
const wrapper = this.getTextDocumentWrapper(doc.uri);
663660
this.activeDocuments.delete(key);
664661
this.activeDocumentsOutgoingMap.delete(NotebookConverter.getDocumentKey(wrapper.uri));
665662
}

src/client/jupyter/languageserver/safeNotebookDocument.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)