Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/extensions/browser/extensionRecommendations.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable } from '../../../../base/common/lifecycle.js';
7
import { URI } from '../../../../base/common/uri.js';
8
import { IExtensionRecommendationReason } from '../../../services/extensionRecommendations/common/extensionRecommendations.js';
9
10
export type GalleryExtensionRecommendation = {
11
readonly extension: string;
12
readonly reason: IExtensionRecommendationReason;
13
};
14
15
export type ResourceExtensionRecommendation = {
16
readonly extension: URI;
17
readonly reason: IExtensionRecommendationReason;
18
};
19
20
export type ExtensionRecommendation = GalleryExtensionRecommendation | ResourceExtensionRecommendation;
21
22
export abstract class ExtensionRecommendations extends Disposable {
23
24
readonly abstract recommendations: ReadonlyArray<ExtensionRecommendation>;
25
protected abstract doActivate(): Promise<void>;
26
27
private _activationPromise: Promise<void> | null = null;
28
get activated(): boolean { return this._activationPromise !== null; }
29
activate(): Promise<void> {
30
if (!this._activationPromise) {
31
this._activationPromise = this.doActivate();
32
}
33
return this._activationPromise;
34
}
35
36
}
37
38