| 41 | */ |
| 42 | @injectable() |
| 43 | export class FeatureManager implements IFeaturesManager { |
| 44 | private _onDidChangeFeatures = new EventEmitter<void>(); |
| 45 | readonly onDidChangeFeatures = this._onDidChangeFeatures.event; |
| 46 | private _features: IFeatureSet = {}; |
| 47 | get features(): IFeatureSet { |
| 48 | return this._features; |
| 49 | } |
| 50 | |
| 51 | set features(newFeatures: IFeatureSet) { |
| 52 | this._features = newFeatures; |
| 53 | this._onDidChangeFeatures.fire(); |
| 54 | } |
| 55 | |
| 56 | private disposables: Disposable[] = []; |
| 57 | constructor(@inject(IPersistentStateFactory) private persistentStateFactory: IPersistentStateFactory) { |
| 58 | this._updateFeatures(); |
| 59 | |
| 60 | this.disposables.push( |
| 61 | workspace.onDidChangeConfiguration(() => { |
| 62 | this._updateFeatures(); |
| 63 | }) |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | private _updateFeatures() { |
| 68 | this.features = {}; |
| 69 | } |
| 70 | |
| 71 | public dispose() { |
| 72 | this.disposables.forEach((disposable) => disposable.dispose()); |
| 73 | } |
| 74 | |
| 75 | public initialize() { |
| 76 | deprecatedFeatures.forEach(this.registerDeprecation.bind(this)); |
| 77 | } |
| 78 | |
| 79 | public registerDeprecation(deprecatedInfo: DeprecatedFeatureInfo): void { |
| 80 | if (Array.isArray(deprecatedInfo.commands)) { |
| 81 | deprecatedInfo.commands.forEach((cmd) => { |
| 82 | this.disposables.push( |
| 83 | commands.registerCommand(cmd, () => this.notifyDeprecation(deprecatedInfo), this) |
| 84 | ); |
| 85 | }); |
| 86 | } |
| 87 | if (deprecatedInfo.setting) { |
| 88 | this.checkAndNotifyDeprecatedSetting(deprecatedInfo); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | public async notifyDeprecation(deprecatedInfo: DeprecatedFeatureInfo): Promise<void> { |
| 93 | const notificationPromptEnabled = this.persistentStateFactory.createGlobalPersistentState( |
| 94 | deprecatedInfo.doNotDisplayPromptStateKey, |
| 95 | true |
| 96 | ); |
| 97 | if (!notificationPromptEnabled.value) { |
| 98 | return; |
| 99 | } |
| 100 | const moreInfo = 'Learn more'; |
nothing calls this directly
no outgoing calls
no test coverage detected