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

Method watchExtensionChanges

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

Source from the content-addressed store, hash-verified

93 }
94
95 private watchExtensionChanges() {
96 let hadPyEnvs = !!vscode.extensions.getExtension(
97 'ms-python.vscode-python-envs',
98 );
99 let hadMsPython = !!vscode.extensions.getExtension('ms-python.python');
100
101 this.context.subscriptions.push(
102 vscode.extensions.onDidChange(() => {
103 const hasPyEnvs = !!vscode.extensions.getExtension(
104 'ms-python.vscode-python-envs',
105 );
106 const hasMsPython = !!vscode.extensions.getExtension(
107 'ms-python.python',
108 );
109
110 if (hasPyEnvs === hadPyEnvs && hasMsPython === hadMsPython) {
111 return;
112 }
113 hadPyEnvs = hasPyEnvs;
114 hadMsPython = hasMsPython;
115
116 this.tryResolveProvider()
117 .then(provider => {
118 for (const d of this.listenerDisposables) {
119 d.dispose();
120 }
121 this.listenerDisposables = [];
122
123 this.provider = Promise.resolve(provider);
124
125 if (provider) {
126 for (const listener of this.listeners) {
127 listener();
128 this.listenerDisposables.push(
129 provider.onDidChange(listener),
130 );
131 }
132 }
133 })
134 .catch(() => {});
135 }),
136 );
137 }
138
139 async getInterpreterPath(uri?: vscode.Uri): Promise<string | undefined> {
140 const provider = await this.provider;

Callers 1

constructorMethod · 0.95

Calls 4

tryResolveProviderMethod · 0.95
onDidChangeMethod · 0.65
pushMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected