@@ -16,7 +16,7 @@ import { URI } from 'vs/base/common/uri';
1616import { IHeaders , IRequestContext , IRequestOptions } from 'vs/base/parts/request/common/request' ;
1717import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
1818import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
19- import { DefaultIconPath , getFallbackTargetPlarforms , getTargetPlatform , IExtensionGalleryService , IExtensionIdentifier , IExtensionIdentifierWithVersion , IGalleryExtension , IGalleryExtensionAsset , IGalleryExtensionAssets , IGalleryExtensionVersion , InstallOperation , IQueryOptions , IExtensionsControlManifest , isIExtensionIdentifier , isNotWebExtensionInWebTargetPlatform , isTargetPlatformCompatible , ITranslation , SortBy , SortOrder , StatisticType , TargetPlatform , toTargetPlatform , WEB_EXTENSION_TAG , IExtensionIdentifierWithPreRelease } from 'vs/platform/extensionManagement/common/extensionManagement' ;
19+ import { DefaultIconPath , getFallbackTargetPlarforms , getTargetPlatform , IExtensionGalleryService , IExtensionIdentifier , IExtensionIdentifierWithVersion , IGalleryExtension , IGalleryExtensionAsset , IGalleryExtensionAssets , IGalleryExtensionVersion , InstallOperation , IQueryOptions , IExtensionsControlManifest , isIExtensionIdentifier , isNotWebExtensionInWebTargetPlatform , isTargetPlatformCompatible , ITranslation , SortBy , SortOrder , StatisticType , TargetPlatform , toTargetPlatform , WEB_EXTENSION_TAG } from 'vs/platform/extensionManagement/common/extensionManagement' ;
2020import { adoptToGalleryExtensionId , areSameExtensions , getGalleryExtensionId , getGalleryExtensionTelemetryData } from 'vs/platform/extensionManagement/common/extensionManagementUtil' ;
2121import { IExtensionManifest } from 'vs/platform/extensions/common/extensions' ;
2222import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator' ;
@@ -506,39 +506,9 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
506506 const { galleryExtensions } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , CancellationToken . None ) ;
507507 const galleryExtensionsByVersion = galleryExtensions . map ( rawGalleryExtension => {
508508 const id = getGalleryExtensionId ( rawGalleryExtension . publisher . publisherName , rawGalleryExtension . extensionName ) ;
509- return { rawGalleryExtension, version : ( < IExtensionIdentifierWithVersion | undefined > identifiers . find ( identifier => areSameExtensions ( identifier , { id } ) ) ) ?. version , preRelease : includePreRelease } ;
509+ return { rawGalleryExtension, version : ( < IExtensionIdentifierWithVersion | undefined > identifiers . find ( identifier => areSameExtensions ( identifier , { id } ) ) ) ?. version } ;
510510 } ) ;
511- return this . converToGalleryExtensions ( galleryExtensionsByVersion , CURRENT_TARGET_PLATFORM , ( ) => undefined , token ) ;
512- }
513-
514- async getExtensions2 ( identifiers : ReadonlyArray < IExtensionIdentifierWithPreRelease > ) : Promise < IGalleryExtension [ ] > {
515- const names : string [ ] = [ ] ; const ids : string [ ] = [ ] ;
516- for ( const identifier of identifiers ) {
517- if ( identifier . uuid ) {
518- ids . push ( identifier . uuid ) ;
519- } else {
520- names . push ( identifier . id . toLowerCase ( ) ) ;
521- }
522- }
523- let query = new Query ( )
524- . withFlags ( Flags . IncludeAssetUri , Flags . IncludeStatistics , Flags . IncludeCategoryAndTags , Flags . IncludeFiles , Flags . IncludeVersionProperties , Flags . IncludeLatestVersionOnly )
525- . withPage ( 1 , identifiers . length )
526- . withFilter ( FilterType . Target , 'Microsoft.VisualStudio.Code' ) ;
527- if ( ids . length ) {
528- query = query . withFilter ( FilterType . ExtensionId , ...ids ) ;
529- }
530- if ( names . length ) {
531- query = query . withFilter ( FilterType . ExtensionId , ...names ) ;
532- }
533-
534- const { galleryExtensions : rawGalleryExtensions } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , CancellationToken . None ) ;
535- const rawGalleryExtensionsInput = rawGalleryExtensions . map ( rawGalleryExtension => {
536- const id = getGalleryExtensionId ( rawGalleryExtension . publisher . publisherName , rawGalleryExtension . extensionName ) ;
537- const identifier = identifiers . find ( identifier => areSameExtensions ( identifier , { id, uuid : rawGalleryExtension . extensionId } ) ) ;
538- return { rawGalleryExtension, preRelease : ! ! identifier ?. preRelease } ;
539- } ) ;
540-
541- return this . converToGalleryExtensions ( rawGalleryExtensionsInput , CURRENT_TARGET_PLATFORM , ( ) => undefined , CancellationToken . None ) ;
511+ return this . converToGalleryExtensions ( galleryExtensionsByVersion , includePreRelease , CURRENT_TARGET_PLATFORM , ( ) => undefined , token ) ;
542512 }
543513
544514 async getCompatibleExtension ( arg1 : IExtensionIdentifier | IGalleryExtension , includePreRelease : boolean , targetPlatform : TargetPlatform ) : Promise < IGalleryExtension | null > {
@@ -683,43 +653,43 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
683653
684654 const { galleryExtensions, total } = await this . queryGallery ( query , CURRENT_TARGET_PLATFORM , token ) ;
685655 const telemetryData = ( index : number ) => ( { index : ( ( query . pageNumber - 1 ) * query . pageSize ) + index , querySource : options . source } ) ;
686- const extensions = await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension, preRelease : ! ! options . includePreRelease } ) ) , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
656+ const extensions = await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension } ) ) , ! ! options . includePreRelease , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
687657 const getPage = async ( pageIndex : number , ct : CancellationToken ) => {
688658 if ( ct . isCancellationRequested ) {
689659 throw canceled ( ) ;
690660 }
691661 const nextPageQuery = query . withPage ( pageIndex + 1 ) ;
692662 const { galleryExtensions } = await this . queryGallery ( nextPageQuery , CURRENT_TARGET_PLATFORM , ct ) ;
693- return await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension, preRelease : ! ! options . includePreRelease } ) ) , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
663+ return await this . converToGalleryExtensions ( galleryExtensions . map ( rawGalleryExtension => ( { rawGalleryExtension } ) ) , ! ! options . includePreRelease , CURRENT_TARGET_PLATFORM , telemetryData , token ) ;
694664 } ;
695665
696666 return { firstPage : extensions , total, pageSize : query . pageSize , getPage } as IPager < IGalleryExtension > ;
697667 }
698668
699- private async converToGalleryExtensions ( rawGalleryExtensions : { rawGalleryExtension : IRawGalleryExtension , preRelease : boolean , version ?: string } [ ] , targetPlatform : TargetPlatform , telemetryData : ( index : number ) => IStringDictionary < any > | undefined , token : CancellationToken ) : Promise < IGalleryExtension [ ] > {
700- const toExtensionWithLatestVersion = ( galleryExtension : IRawGalleryExtension , index : number , hasReleaseVersion : boolean , preRelease : boolean ) : IGalleryExtension => {
669+ private async converToGalleryExtensions ( rawGalleryExtensions : { rawGalleryExtension : IRawGalleryExtension , version ?: string } [ ] , includePreRelease : boolean , targetPlatform : TargetPlatform , telemetryData : ( index : number ) => IStringDictionary < any > | undefined , token : CancellationToken ) : Promise < IGalleryExtension [ ] > {
670+ const toExtensionWithLatestVersion = ( galleryExtension : IRawGalleryExtension , index : number , hasReleaseVersion : boolean ) : IGalleryExtension => {
701671 const allTargetPlatforms = getAllTargetPlatforms ( galleryExtension ) ;
702672 let latestVersion = galleryExtension . versions [ 0 ] ;
703673 latestVersion = galleryExtension . versions . find ( version => version . version === latestVersion . version && isTargetPlatformCompatible ( getTargetPlatformForExtensionVersion ( version ) , allTargetPlatforms , targetPlatform ) ) || latestVersion ;
704- if ( isPreReleaseVersion ( latestVersion ) && ! preRelease ) {
674+ if ( isPreReleaseVersion ( latestVersion ) && ! includePreRelease ) {
705675 latestVersion = galleryExtension . versions . find ( version => version . version !== latestVersion . version && ! isPreReleaseVersion ( version ) ) || latestVersion ;
706676 }
707677 return toExtension ( galleryExtension , latestVersion , allTargetPlatforms , hasReleaseVersion , telemetryData ( index ) ) ;
708678 } ;
709679 const result : [ number , IGalleryExtension ] [ ] = [ ] ;
710- const preReleaseVersions = new Map < string , { index : number , preRelease : boolean } > ( ) ;
680+ const preReleaseVersions = new Map < string , number > ( ) ;
711681 for ( let index = 0 ; index < rawGalleryExtensions . length ; index ++ ) {
712- const { rawGalleryExtension, version, preRelease } = rawGalleryExtensions [ index ] ;
682+ const { rawGalleryExtension, version } = rawGalleryExtensions [ index ] ;
713683 const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
714684 if ( version ) {
715685 const versionAsset = rawGalleryExtension . versions . find ( v => v . version === version ) ;
716686 if ( versionAsset ) {
717687 result . push ( [ index , toExtension ( rawGalleryExtension , versionAsset , getAllTargetPlatforms ( rawGalleryExtension ) , hasReleaseVersion ) ] ) ;
718688 }
719689 } else {
720- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion , preRelease ) ;
690+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
721691 if ( extension . properties . isPreReleaseVersion ) {
722- preReleaseVersions . set ( extension . identifier . uuid , { index, preRelease } ) ;
692+ preReleaseVersions . set ( extension . identifier . uuid , index ) ;
723693 } else {
724694 result . push ( [ index , extension ] ) ;
725695 }
@@ -743,8 +713,8 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
743713 }
744714 for ( const rawGalleryExtension of galleryExtensions ) {
745715 const hasReleaseVersion = rawGalleryExtension . versions . some ( version => ! isPreReleaseVersion ( version ) ) ;
746- const { index, preRelease } = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
747- const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion , preRelease ) ;
716+ const index = preReleaseVersions . get ( rawGalleryExtension . extensionId ) ! ;
717+ const extension = toExtensionWithLatestVersion ( rawGalleryExtension , index , hasReleaseVersion ) ;
748718 result . push ( [ index , extension ] ) ;
749719 }
750720 }
0 commit comments