55
66import { URI } from 'vs/base/common/uri' ;
77import { join , } from 'vs/base/common/path' ;
8- import { IProductService , IExeBasedExtensionTip } from 'vs/platform/product/common/productService' ;
8+ import { IProductService } from 'vs/platform/product/common/productService' ;
99import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
1010import { env as processEnv } from 'vs/base/common/process' ;
1111import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService' ;
1212import { IFileService } from 'vs/platform/files/common/files' ;
1313import { isWindows } from 'vs/base/common/platform' ;
1414import { isNonEmptyArray } from 'vs/base/common/arrays' ;
1515import { IExecutableBasedExtensionTip } from 'vs/platform/extensionManagement/common/extensionManagement' ;
16- import { IStringDictionary , forEach } from 'vs/base/common/collections' ;
16+ import { forEach } from 'vs/base/common/collections' ;
1717import { IRequestService } from 'vs/platform/request/common/request' ;
1818import { ILogService } from 'vs/platform/log/common/log' ;
1919import { ExtensionTipsService as BaseExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionTipsService' ;
2020
21+ type IExeBasedExtensionTips = {
22+ readonly exeFriendlyName : string ,
23+ readonly windowsPath ?: string ,
24+ readonly recommendations : { extensionId : string , extensionName : string } [ ] ;
25+ } ;
26+
2127export class ExtensionTipsService extends BaseExtensionTipsService {
2228
2329 _serviceBrand : any ;
2430
25- private readonly allImportantExecutableTips : IStringDictionary < IExeBasedExtensionTip > = { } ;
26- private readonly allOtherExecutableTips : IStringDictionary < IExeBasedExtensionTip > = { } ;
31+ private readonly allImportantExecutableTips : Map < string , IExeBasedExtensionTips > = new Map < string , IExeBasedExtensionTips > ( ) ;
32+ private readonly allOtherExecutableTips : Map < string , IExeBasedExtensionTips > = new Map < string , IExeBasedExtensionTips > ( ) ;
2733
2834 constructor (
2935 @IEnvironmentService private readonly environmentService : INativeEnvironmentService ,
@@ -35,10 +41,20 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
3541 super ( fileService , productService , requestService , logService ) ;
3642 if ( productService . exeBasedExtensionTips ) {
3743 forEach ( productService . exeBasedExtensionTips , ( { key, value } ) => {
38- if ( value . important ) {
39- this . allImportantExecutableTips [ key ] = value ;
40- } else {
41- this . allOtherExecutableTips [ key ] = value ;
44+ const importantRecommendations : { extensionId : string , extensionName : string } [ ] = [ ] ;
45+ const otherRecommendations : { extensionId : string , extensionName : string } [ ] = [ ] ;
46+ forEach ( value . recommendations , ( { key : extensionId , value } ) => {
47+ if ( value . important ) {
48+ importantRecommendations . push ( { extensionId, extensionName : value . name } ) ;
49+ } else {
50+ otherRecommendations . push ( { extensionId, extensionName : value . name } ) ;
51+ }
52+ } ) ;
53+ if ( importantRecommendations . length ) {
54+ this . allImportantExecutableTips . set ( key , { exeFriendlyName : value . friendlyName , windowsPath : value . windowsPath , recommendations : importantRecommendations } ) ;
55+ }
56+ if ( otherRecommendations . length ) {
57+ this . allOtherExecutableTips . set ( key , { exeFriendlyName : value . friendlyName , windowsPath : value . windowsPath , recommendations : otherRecommendations } ) ;
4258 }
4359 } ) ;
4460 }
@@ -52,13 +68,13 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
5268 return this . getValidExecutableBasedExtensionTips ( this . allOtherExecutableTips ) ;
5369 }
5470
55- private async getValidExecutableBasedExtensionTips ( executableTips : IStringDictionary < IExeBasedExtensionTip > ) : Promise < IExecutableBasedExtensionTip [ ] > {
71+ private async getValidExecutableBasedExtensionTips ( executableTips : Map < string , IExeBasedExtensionTips > ) : Promise < IExecutableBasedExtensionTip [ ] > {
5672 const result : IExecutableBasedExtensionTip [ ] = [ ] ;
5773
5874 const checkedExecutables : Map < string , boolean > = new Map < string , boolean > ( ) ;
59- for ( const exeName of Object . keys ( executableTips ) ) {
60- const extensionTip = executableTips [ exeName ] ;
61- if ( ! isNonEmptyArray ( extensionTip ? .recommendations ) ) {
75+ for ( const exeName of executableTips . keys ( ) ) {
76+ const extensionTip = executableTips . get ( exeName ) ;
77+ if ( ! extensionTip || ! isNonEmptyArray ( extensionTip . recommendations ) ) {
6278 continue ;
6379 }
6480
@@ -83,12 +99,14 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
8399 checkedExecutables . set ( exePath , exists ) ;
84100 }
85101 if ( exists ) {
86- extensionTip . recommendations . forEach ( recommendation => result . push ( {
87- extensionId : recommendation ,
88- friendlyName : extensionTip . friendlyName ,
89- exeFriendlyName : extensionTip . exeFriendlyName ,
90- windowsPath : extensionTip . windowsPath ,
91- } ) ) ;
102+ for ( const { extensionId, extensionName : friendlyName } of extensionTip . recommendations ) {
103+ result . push ( {
104+ extensionId,
105+ friendlyName,
106+ exeFriendlyName : extensionTip . exeFriendlyName ,
107+ windowsPath : extensionTip . windowsPath ,
108+ } ) ;
109+ }
92110 }
93111 }
94112 }
0 commit comments