@@ -25,7 +25,6 @@ import {
2525 IConfigurationService ,
2626 IDisposableRegistry ,
2727 IExperimentsManager ,
28- IExtensionContext ,
2928 IFeatureDeprecationManager ,
3029 IOutputChannel
3130} from './common/types' ;
@@ -44,7 +43,6 @@ import {
4443 IInterpreterService
4544} from './interpreter/contracts' ;
4645import { registerTypes as interpretersRegisterTypes } from './interpreter/serviceRegistry' ;
47- import { IServiceContainer , IServiceManager } from './ioc/types' ;
4846import { getLanguageConfiguration } from './language/languageConfiguration' ;
4947import { LinterCommands } from './linters/linterCommands' ;
5048import { registerTypes as lintersRegisterTypes } from './linters/serviceRegistry' ;
@@ -65,14 +63,32 @@ import { ITestContextService } from './testing/common/types';
6563import { ITestCodeNavigatorCommandHandler , ITestExplorerCommandHandler } from './testing/navigation/types' ;
6664import { registerTypes as unitTestsRegisterTypes } from './testing/serviceRegistry' ;
6765
68- export async function activateComponents (
69- context : IExtensionContext ,
70- serviceManager : IServiceManager ,
71- serviceContainer : IServiceContainer
72- ) {
73- // We will be pulling code over from activateLegacy().
66+ // components
67+ import * as pythonEnvironments from './pythonEnvironments' ;
68+
69+ import { ActivationResult , ExtensionState } from './components' ;
70+ import { Components } from './extensionInit' ;
7471
75- return activateLegacy ( context , serviceManager , serviceContainer ) ;
72+ export async function activateComponents (
73+ // `ext` is passed to any extra activation funcs.
74+ ext : ExtensionState ,
75+ components : Components
76+ ) : Promise < ActivationResult [ ] > {
77+ // Note that each activation returns a promise that resolves
78+ // when that activation completes. However, it might have started
79+ // some non-critical background operations that do not block
80+ // extension activation but do block use of the extension "API".
81+ // Each component activation can't just resolve an "inner" promise
82+ // for those non-critical operations because `await` (and
83+ // `Promise.all()`, etc.) will flatten nested promises. Thus
84+ // activation resolves `ActivationResult`, which can safely wrap
85+ // the "inner" promise.
86+ const promises : Promise < ActivationResult > [ ] = [
87+ pythonEnvironments . activate ( components . pythonEnvs ) ,
88+ // These will go away eventually.
89+ activateLegacy ( ext )
90+ ] ;
91+ return Promise . all ( promises ) ;
7692}
7793
7894/////////////////////////////
@@ -85,11 +101,10 @@ export async function activateComponents(
85101// init and activation: move them to activateComponents().
86102// See https://github.com/microsoft/vscode-python/issues/10454.
87103
88- async function activateLegacy (
89- context : IExtensionContext ,
90- serviceManager : IServiceManager ,
91- serviceContainer : IServiceContainer
92- ) {
104+ async function activateLegacy ( ext : ExtensionState ) : Promise < ActivationResult > {
105+ const { context, legacyIOC } = ext ;
106+ const { serviceManager, serviceContainer } = legacyIOC ;
107+
93108 // register "services"
94109
95110 const standardOutputChannel = window . createOutputChannel ( OutputChannelNames . python ( ) ) ;
@@ -215,5 +230,5 @@ async function activateLegacy(
215230
216231 serviceContainer . get < IDebuggerBanner > ( IDebuggerBanner ) . initialize ( ) ;
217232
218- return { activationPromise } ;
233+ return { fullyReady : activationPromise } ;
219234}
0 commit comments