Skip to content

Commit

Permalink
removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
heejaechang committed Mar 10, 2023
1 parent ab2dcf2 commit 00717e8
Showing 1 changed file with 5 additions and 61 deletions.
66 changes: 5 additions & 61 deletions src/client/activation/node/lspNotebooksExperiment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { inject, injectable } from 'inversify';
import { Disposable, extensions } from 'vscode';
import { IConfigurationService, IDisposableRegistry } from '../../common/types';
import { sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { JUPYTER_EXTENSION_ID, PYLANCE_EXTENSION_ID } from '../../common/constants';
import { IExtensionSingleActivationService, LanguageServerType } from '../types';
import { traceLog, traceVerbose } from '../../logging';
import { IExtensionSingleActivationService } from '../types';
import { traceVerbose } from '../../logging';
import { IJupyterExtensionDependencyManager } from '../../common/application/types';
import { IServiceContainer } from '../../ioc/types';
import { sleep } from '../../common/utils/async';
Expand All @@ -17,28 +12,18 @@ import { JupyterExtensionIntegration } from '../../jupyter/jupyterIntegration';
export class LspNotebooksExperiment implements IExtensionSingleActivationService {
public readonly supportedWorkspaceTypes = { untrustedWorkspace: true, virtualWorkspace: true };

private pylanceExtensionChangeHandler: Disposable | undefined;

private isJupyterInstalled = false;

private isUsingPylance: boolean | undefined;

constructor(
@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer,
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
@inject(IJupyterExtensionDependencyManager) jupyterDependencyManager: IJupyterExtensionDependencyManager,
) {
this.isJupyterInstalled = jupyterDependencyManager.isJupyterExtensionInstalled;
}

public async activate(): Promise<void> {
if (!LspNotebooksExperiment.isPylanceInstalled()) {
this.pylanceExtensionChangeHandler = extensions.onDidChange(this.pylanceExtensionsChangeHandler.bind(this));
this.disposables.push(this.pylanceExtensionChangeHandler);
}

this.updateExperimentSupport();
// eslint-disable-next-line class-methods-use-this
public activate(): Promise<void> {
return Promise.resolve();
}

public async onJupyterInstalled(): Promise<void> {
Expand All @@ -47,34 +32,10 @@ export class LspNotebooksExperiment implements IExtensionSingleActivationService
}

await this.waitForJupyterToRegisterPythonPathFunction();
this.updateExperimentSupport();

this.isJupyterInstalled = true;
}

private updateExperimentSupport(): void {
const languageServerType = this.configurationService.getSettings().languageServer;

this.isUsingPylance = false;
if (languageServerType !== LanguageServerType.Node) {
traceLog(`LSP Notebooks is disabled -- not using Pylance`);
} else if (!LspNotebooksExperiment.isJupyterInstalled()) {
traceLog(`LSP Notebooks is disabled -- Jupyter disabled or not installed`);
} else if (!LspNotebooksExperiment.isPylanceInstalled()) {
traceLog(`LSP Notebooks is disabled -- Pylance disabled or not installed`);
} else {
this.isUsingPylance = true;
traceLog(`LSP Notebooks is enabled`);
sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_LSP_NOTEBOOKS);
}

if (!this.isUsingPylance) {
traceLog(`LSP Notebooks interactive window support is disabled -- not using Pylance`);
} else {
traceLog(`LSP Notebooks interactive window support is enabled`);
}
}

private async waitForJupyterToRegisterPythonPathFunction(): Promise<void> {
const jupyterExtensionIntegration = this.serviceContainer.get<JupyterExtensionIntegration>(
JupyterExtensionIntegration,
Expand All @@ -96,21 +57,4 @@ export class LspNotebooksExperiment implements IExtensionSingleActivationService
traceVerbose(`Timed out waiting for Jupyter to call registerJupyterPythonPathFunction`);
}
}

private static isPylanceInstalled(): boolean {
return !!extensions.getExtension(PYLANCE_EXTENSION_ID);
}

private static isJupyterInstalled(): boolean {
return !!extensions.getExtension(JUPYTER_EXTENSION_ID);
}

private async pylanceExtensionsChangeHandler(): Promise<void> {
if (LspNotebooksExperiment.isPylanceInstalled() && this.pylanceExtensionChangeHandler) {
this.pylanceExtensionChangeHandler.dispose();
this.pylanceExtensionChangeHandler = undefined;

this.updateExperimentSupport();
}
}
}

0 comments on commit 00717e8

Please sign in to comment.