MCPcopy Create free account
hub / github.com/facebook/pyrefly / tryResolveProvider

Method tryResolveProvider

lsp/src/python-environment.ts:38–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 }
37
38 private async tryResolveProvider(): Promise<InterpreterProvider | undefined> {
39 // Prefer vscode-python-environments if available
40 try {
41 const api = await PythonEnvironments.api();
42 return {
43 async getPath(uri?: vscode.Uri) {
44 const env = await api.getEnvironment(uri);
45 return env?.execInfo?.run?.executable;
46 },
47 onDidChange(callback: () => void) {
48 return api.onDidChangeEnvironment(() => callback());
49 },
50 };
51 } catch {}
52
53 // Fall back to ms-python.python
54 try {
55 const ext = await PythonExtension.api();
56 return {
57 async getPath(uri?: vscode.Uri) {
58 const envPath =
59 await ext.environments.getActiveEnvironmentPath(uri);
60 return envPath.path.length > 0 ? envPath.path : undefined;
61 },
62 onDidChange(callback: () => void) {
63 return ext.environments.onDidChangeActiveEnvironmentPath(callback);
64 },
65 };
66 } catch {
67 return undefined;
68 }
69 }
70
71 private showInstallWarning() {
72 if (this.context.globalState.get(DISMISSED_KEY)) {

Callers 2

constructorMethod · 0.95
watchExtensionChangesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected