11import { inject , injectable } from 'inversify' ;
22import * as _ from 'lodash' ;
33import * as path from 'path' ;
4- import { Disposable , Uri , workspace } from 'vscode' ;
4+ import { Disposable , Uri } from 'vscode' ;
55import { IPlatformService } from '../../common/platform/types' ;
66import { IDisposableRegistry } from '../../common/types' ;
77import { arePathsSame } from '../../common/utils' ;
@@ -21,35 +21,21 @@ import { fixInterpreterDisplayName } from './helpers';
2121
2222@injectable ( )
2323export class PythonInterpreterLocatorService implements IInterpreterLocatorService {
24- private interpretersPerResource : Map < string , Promise < PythonInterpreter [ ] > > ;
2524 private disposables : Disposable [ ] = [ ] ;
2625 private platform : IPlatformService ;
2726
2827 constructor ( @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ) {
29- this . interpretersPerResource = new Map < string , Promise < PythonInterpreter [ ] > > ( ) ;
3028 serviceContainer . get < Disposable [ ] > ( IDisposableRegistry ) . push ( this ) ;
3129 this . platform = serviceContainer . get < IPlatformService > ( IPlatformService ) ;
3230 }
3331 public async getInterpreters ( resource ?: Uri ) {
34- const resourceKey = this . getResourceKey ( resource ) ;
35- if ( ! this . interpretersPerResource . has ( resourceKey ) ) {
36- this . interpretersPerResource . set ( resourceKey , this . getInterpretersPerResource ( resource ) ) ;
37- }
38-
39- return await this . interpretersPerResource . get ( resourceKey ) ! ;
32+ return this . getInterpretersPerResource ( resource ) ;
4033 }
4134 public dispose ( ) {
4235 this . disposables . forEach ( disposable => disposable . dispose ( ) ) ;
4336 }
44- private getResourceKey ( resource ?: Uri ) {
45- if ( ! resource ) {
46- return '' ;
47- }
48- const workspaceFolder = workspace . getWorkspaceFolder ( resource ) ;
49- return workspaceFolder ? workspaceFolder . uri . fsPath : '' ;
50- }
5137 private async getInterpretersPerResource ( resource ?: Uri ) {
52- const locators = this . getLocators ( resource ) ;
38+ const locators = this . getLocators ( ) ;
5339 const promises = locators . map ( async provider => provider . getInterpreters ( resource ) ) ;
5440 const listOfInterpreters = await Promise . all ( promises ) ;
5541
@@ -73,7 +59,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
7359 return accumulator ;
7460 } , [ ] ) ;
7561 }
76- private getLocators ( resource ?: Uri ) {
62+ private getLocators ( ) {
7763 const locators : IInterpreterLocatorService [ ] = [ ] ;
7864 // The order of the services is important.
7965 if ( this . platform . isWindows ) {
0 commit comments