Skip to content
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
13 changes: 2 additions & 11 deletions src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import { CodeActionKind, debug, DebugConfigurationProvider, languages, OutputChannel, window } from 'vscode';

import { registerTypes as activationRegisterTypes } from './activation/serviceRegistry';
import {
IExtensionActivationManager,
IExtensionSingleActivationService,
ILanguageServerExtension,
} from './activation/types';
import { IExtensionActivationManager, ILanguageServerExtension } from './activation/types';
import { registerTypes as appRegisterTypes } from './application/serviceRegistry';
import { IApplicationDiagnostics } from './application/types';
import { DebugService } from './common/application/debugService';
Expand All @@ -35,7 +31,7 @@ import { IDebugSessionEventHandlers } from './debugger/extension/hooks/types';
import { registerTypes as debugConfigurationRegisterTypes } from './debugger/extension/serviceRegistry';
import { IDebugConfigurationService, IDebuggerBanner } from './debugger/extension/types';
import { registerTypes as formattersRegisterTypes } from './formatters/serviceRegistry';
import { IComponentAdapter, IInterpreterService } from './interpreter/contracts';
import { IInterpreterService } from './interpreter/contracts';
import { getLanguageConfiguration } from './language/languageConfiguration';
import { LinterCommands } from './linters/linterCommands';
import { registerTypes as lintersRegisterTypes } from './linters/serviceRegistry';
Expand Down Expand Up @@ -151,11 +147,6 @@ async function activateLegacy(ext: ExtensionState): Promise<ActivationResult> {

// "initialize" "services"

// There's a bug now due to which IExtensionSingleActivationService is only activated in background.
// However for some cases particularly IComponentAdapter we need to block on activation before rest
// of the extension is activated. Hence explicitly activate it for now.
await serviceContainer.get<IExtensionSingleActivationService>(IComponentAdapter).activate();

const interpreterManager = serviceContainer.get<IInterpreterService>(IInterpreterService);
interpreterManager.initialize();

Expand Down
1 change: 0 additions & 1 deletion src/client/pythonEnvironments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export async function initialize(ext: ExtensionState): Promise<PythonEnvironment
ext.legacyIOC.serviceManager,
api,
environmentsSecurity,
ext.disposables,
);
// Deal with legacy IOC.
await registerLegacyDiscoveryForIOC(ext.legacyIOC.serviceManager);
Expand Down
25 changes: 4 additions & 21 deletions src/client/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import { injectable } from 'inversify';
import { intersection } from 'lodash';
import * as vscode from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { DiscoveryVariants } from '../common/experiments/groups';
import { traceError } from '../common/logger';
import { FileChangeType } from '../common/platform/fileSystemWatcher';
import { IDisposableRegistry, Resource } from '../common/types';
import { Resource } from '../common/types';
import {
CONDA_ENV_FILE_SERVICE,
CONDA_ENV_SERVICE,
Expand Down Expand Up @@ -69,6 +68,7 @@ import { EnvironmentType, PythonEnvironment } from './info';
import { EnvironmentsSecurity, IEnvironmentsSecurity } from './security';
import { toSemverLikeVersion } from './base/info/pythonVersion';
import { PythonVersion } from './info/pythonVersion';
import { IExtensionSingleActivationService } from '../activation/types';

const convertedKinds = new Map(
Object.entries({
Expand Down Expand Up @@ -136,7 +136,7 @@ export async function isComponentEnabled(): Promise<boolean> {
interface IPythonEnvironments extends ILocator {}

@injectable()
class ComponentAdapter implements IComponentAdapter, IExtensionSingleActivationService {
class ComponentAdapter implements IComponentAdapter {
private readonly refreshing = new vscode.EventEmitter<void>();

private readonly refreshed = new vscode.EventEmitter<void>();
Expand All @@ -147,23 +147,8 @@ class ComponentAdapter implements IComponentAdapter, IExtensionSingleActivationS
// The adapter only wraps one thing: the component API.
private readonly api: IPythonEnvironments,
private readonly environmentsSecurity: IEnvironmentsSecurity,
private readonly disposables: IDisposableRegistry,
) {}

public async activate(): Promise<void> {
this.disposables.push(
this.api.onChanged((e) => {
const query = {
kinds: e.kind ? [e.kind] : undefined,
searchLocations: e.searchLocation ? { roots: [e.searchLocation] } : undefined,
ignoreCache: true,
};
// Trigger a background refresh of the environments.
getEnvs(this.api.iterEnvs(query)).ignoreErrors();
}),
);
}

// For use in VirtualEnvironmentPrompt.activate()

// Call callback if an environment gets created within the resource provided.
Expand Down Expand Up @@ -437,11 +422,9 @@ export function registerNewDiscoveryForIOC(
serviceManager: IServiceManager,
api: IPythonEnvironments,
environmentsSecurity: EnvironmentsSecurity,
disposables: IDisposableRegistry,
): void {
serviceManager.addSingletonInstance<IComponentAdapter>(
IComponentAdapter,
new ComponentAdapter(api, environmentsSecurity, disposables),
new ComponentAdapter(api, environmentsSecurity),
);
serviceManager.addBinding(IComponentAdapter, IExtensionSingleActivationService);
}
1 change: 0 additions & 1 deletion src/test/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function registerForIOC(
serviceManager,
instance(mock(PythonEnvironments)),
instance(mock(EnvironmentsSecurity)),
[],
);
await registerLegacyDiscoveryForIOC(serviceManager);
}