1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT License.
3
3
import { inject , injectable } from 'inversify' ;
4
- import { Disposable , extensions } from 'vscode' ;
5
- import { IConfigurationService , IDisposableRegistry } from '../../common/types' ;
6
- import { sendTelemetryEvent } from '../../telemetry' ;
7
- import { EventName } from '../../telemetry/constants' ;
8
- import { JUPYTER_EXTENSION_ID , PYLANCE_EXTENSION_ID } from '../../common/constants' ;
9
- import { IExtensionSingleActivationService , LanguageServerType } from '../types' ;
10
- import { traceLog , traceVerbose } from '../../logging' ;
4
+ import { IExtensionSingleActivationService } from '../types' ;
5
+ import { traceVerbose } from '../../logging' ;
11
6
import { IJupyterExtensionDependencyManager } from '../../common/application/types' ;
12
7
import { IServiceContainer } from '../../ioc/types' ;
13
8
import { sleep } from '../../common/utils/async' ;
@@ -17,28 +12,18 @@ import { JupyterExtensionIntegration } from '../../jupyter/jupyterIntegration';
17
12
export class LspNotebooksExperiment implements IExtensionSingleActivationService {
18
13
public readonly supportedWorkspaceTypes = { untrustedWorkspace : true , virtualWorkspace : true } ;
19
14
20
- private pylanceExtensionChangeHandler : Disposable | undefined ;
21
-
22
15
private isJupyterInstalled = false ;
23
16
24
- private isUsingPylance : boolean | undefined ;
25
-
26
17
constructor (
27
18
@inject ( IServiceContainer ) private readonly serviceContainer : IServiceContainer ,
28
- @inject ( IConfigurationService ) private readonly configurationService : IConfigurationService ,
29
- @inject ( IDisposableRegistry ) private readonly disposables : IDisposableRegistry ,
30
19
@inject ( IJupyterExtensionDependencyManager ) jupyterDependencyManager : IJupyterExtensionDependencyManager ,
31
20
) {
32
21
this . isJupyterInstalled = jupyterDependencyManager . isJupyterExtensionInstalled ;
33
22
}
34
23
35
- public async activate ( ) : Promise < void > {
36
- if ( ! LspNotebooksExperiment . isPylanceInstalled ( ) ) {
37
- this . pylanceExtensionChangeHandler = extensions . onDidChange ( this . pylanceExtensionsChangeHandler . bind ( this ) ) ;
38
- this . disposables . push ( this . pylanceExtensionChangeHandler ) ;
39
- }
40
-
41
- this . updateExperimentSupport ( ) ;
24
+ // eslint-disable-next-line class-methods-use-this
25
+ public activate ( ) : Promise < void > {
26
+ return Promise . resolve ( ) ;
42
27
}
43
28
44
29
public async onJupyterInstalled ( ) : Promise < void > {
@@ -47,34 +32,10 @@ export class LspNotebooksExperiment implements IExtensionSingleActivationService
47
32
}
48
33
49
34
await this . waitForJupyterToRegisterPythonPathFunction ( ) ;
50
- this . updateExperimentSupport ( ) ;
51
35
52
36
this . isJupyterInstalled = true ;
53
37
}
54
38
55
- private updateExperimentSupport ( ) : void {
56
- const languageServerType = this . configurationService . getSettings ( ) . languageServer ;
57
-
58
- this . isUsingPylance = false ;
59
- if ( languageServerType !== LanguageServerType . Node ) {
60
- traceLog ( `LSP Notebooks is disabled -- not using Pylance` ) ;
61
- } else if ( ! LspNotebooksExperiment . isJupyterInstalled ( ) ) {
62
- traceLog ( `LSP Notebooks is disabled -- Jupyter disabled or not installed` ) ;
63
- } else if ( ! LspNotebooksExperiment . isPylanceInstalled ( ) ) {
64
- traceLog ( `LSP Notebooks is disabled -- Pylance disabled or not installed` ) ;
65
- } else {
66
- this . isUsingPylance = true ;
67
- traceLog ( `LSP Notebooks is enabled` ) ;
68
- sendTelemetryEvent ( EventName . PYTHON_EXPERIMENTS_LSP_NOTEBOOKS ) ;
69
- }
70
-
71
- if ( ! this . isUsingPylance ) {
72
- traceLog ( `LSP Notebooks interactive window support is disabled -- not using Pylance` ) ;
73
- } else {
74
- traceLog ( `LSP Notebooks interactive window support is enabled` ) ;
75
- }
76
- }
77
-
78
39
private async waitForJupyterToRegisterPythonPathFunction ( ) : Promise < void > {
79
40
const jupyterExtensionIntegration = this . serviceContainer . get < JupyterExtensionIntegration > (
80
41
JupyterExtensionIntegration ,
@@ -96,21 +57,4 @@ export class LspNotebooksExperiment implements IExtensionSingleActivationService
96
57
traceVerbose ( `Timed out waiting for Jupyter to call registerJupyterPythonPathFunction` ) ;
97
58
}
98
59
}
99
-
100
- private static isPylanceInstalled ( ) : boolean {
101
- return ! ! extensions . getExtension ( PYLANCE_EXTENSION_ID ) ;
102
- }
103
-
104
- private static isJupyterInstalled ( ) : boolean {
105
- return ! ! extensions . getExtension ( JUPYTER_EXTENSION_ID ) ;
106
- }
107
-
108
- private async pylanceExtensionsChangeHandler ( ) : Promise < void > {
109
- if ( LspNotebooksExperiment . isPylanceInstalled ( ) && this . pylanceExtensionChangeHandler ) {
110
- this . pylanceExtensionChangeHandler . dispose ( ) ;
111
- this . pylanceExtensionChangeHandler = undefined ;
112
-
113
- this . updateExperimentSupport ( ) ;
114
- }
115
- }
116
60
}
0 commit comments