diff --git a/packages/core/src/browser/frontend-application-module.ts b/packages/core/src/browser/frontend-application-module.ts index 676130f3ffd9e..4372221050224 100644 --- a/packages/core/src/browser/frontend-application-module.ts +++ b/packages/core/src/browser/frontend-application-module.ts @@ -226,6 +226,7 @@ export const frontendApplicationModule = new ContainerModule((bind, unbind, isBo bindContributionProvider(bind, LabelProviderContribution); bind(LabelProvider).toSelf().inSingletonScope(); + bind(FrontendApplicationContribution).toService(LabelProvider); bind(LabelProviderContribution).to(DefaultUriLabelProviderContribution).inSingletonScope(); bind(LabelProviderContribution).to(DiffUriLabelProviderContribution).inSingletonScope(); diff --git a/packages/core/src/browser/label-provider.ts b/packages/core/src/browser/label-provider.ts index b9f85c792bcb4..621fa286c0135 100644 --- a/packages/core/src/browser/label-provider.ts +++ b/packages/core/src/browser/label-provider.ts @@ -20,6 +20,7 @@ import URI from '../common/uri'; import { ContributionProvider } from '../common/contribution-provider'; import { Prioritizeable, MaybePromise } from '../common/types'; import { Event, Emitter } from '../common'; +import { FrontendApplicationContribution } from './frontend-application'; export const FOLDER_ICON = 'fa fa-folder'; export const FILE_ICON = 'fa fa-file'; @@ -98,14 +99,20 @@ export class DefaultUriLabelProviderContribution implements LabelProviderContrib } @injectable() -export class LabelProvider { +export class LabelProvider implements FrontendApplicationContribution { protected readonly onDidChangeEmitter = new Emitter(); - constructor( - @inject(ContributionProvider) @named(LabelProviderContribution) - protected readonly contributionProvider: ContributionProvider - ) { + @inject(ContributionProvider) @named(LabelProviderContribution) + protected readonly contributionProvider: ContributionProvider; + + /** + * Start listening to contributions. + * + * Don't call this method directly! + * It's called by the frontend application during initialization. + */ + initialize(): void { const contributions = this.contributionProvider.getContributions(); for (const contribution of contributions) { if (contribution.onDidChange) {