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

Remove old Python API code #15465

Merged
merged 1 commit into from
Apr 2, 2024
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
8 changes: 0 additions & 8 deletions src/platform/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,4 @@ export interface PythonApi {
* @param func : The function that Python should call when requesting the Python path.
*/
registerJupyterPythonPathFunction(func: (uri: Uri) => Promise<string | undefined>): void;

/**
* Call to provide a function that the Python extension can call to request the notebook
* document URI related to a particular text document URI, or undefined if there is no
* associated notebook.
* @param func : The function that Python should call when requesting the notebook URI.
*/
registerGetNotebookUriForTextDocumentUriFunction(func: (textDocumentUri: Uri) => Uri | undefined): void;
}
31 changes: 2 additions & 29 deletions src/standalone/intellisense/notebookPythonPathService.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import { Disposable, extensions, Uri, window } from 'vscode';
import { Disposable, extensions, Uri } from 'vscode';
import { INotebookEditorProvider } from '../../notebooks/types';
import { IExtensionSyncActivationService } from '../../platform/activation/types';
import { IPythonApiProvider, IPythonExtensionChecker } from '../../platform/api/types';
import { PylanceExtension } from '../../platform/common/constants';
import { getDisplayPath, getFilePath } from '../../platform/common/platform/fs-paths';
import { traceInfo } from '../../platform/logging';
import { IControllerRegistration } from '../../notebooks/controllers/types';
import { isInteractiveInputTab } from '../../interactive-window/helpers';
import { IKernelProvider, isRemoteConnection } from '../../kernels/types';
import { noop } from '../../platform/common/utils/misc';
import { raceTimeout } from '../../platform/common/utils/async';
import * as fs from 'fs-extra';
import { getNotebookUriFromInputBoxUri, isUsingPylance } from './notebookPythonPathService';
import { isUsingPylance } from './notebookPythonPathService';

/**
* Manages use of the Python extension's registerJupyterPythonPathFunction API which
Expand Down Expand Up @@ -51,11 +50,6 @@ export class NotebookPythonPathService implements IExtensionSyncActivationServic
if (api.registerJupyterPythonPathFunction !== undefined) {
api.registerJupyterPythonPathFunction((uri) => this._jupyterPythonPathFunction(uri));
}
if (api.registerGetNotebookUriForTextDocumentUriFunction !== undefined) {
api.registerGetNotebookUriForTextDocumentUriFunction((uri) =>
this._getNotebookUriForTextDocumentUri(uri)
);
}
})
.catch(noop);
}
Expand Down Expand Up @@ -151,25 +145,4 @@ del _VSCODE_os, _VSCODE_sys, _VSCODE_builtins
}
return getFilePath(interpreter.uri);
}

private _getNotebookUriForTextDocumentUri(textDocumentUri: Uri): Uri | undefined {
const notebookUri = getNotebookUriFromInputBoxUri(textDocumentUri);
if (!notebookUri) {
return undefined;
}

let result: string | undefined = undefined;
window.tabGroups.all.find((group) => {
group.tabs.find((tab) => {
if (isInteractiveInputTab(tab)) {
const tabUri = tab.input.uri.toString();
// the interactive resource URI was altered to start with `/`, this will account for both URI formats
if (tab.input.uri.toString().endsWith(notebookUri.path)) {
result = tabUri;
}
}
});
});
return result;
}
}
Loading