1
1
import { inject , injectable } from 'inversify' ;
2
2
import * as _ from 'lodash' ;
3
3
import * as path from 'path' ;
4
- import { Disposable , Uri , workspace } from 'vscode' ;
4
+ import { Disposable , Uri } from 'vscode' ;
5
5
import { IPlatformService } from '../../common/platform/types' ;
6
6
import { IDisposableRegistry } from '../../common/types' ;
7
7
import { arePathsSame } from '../../common/utils' ;
@@ -21,35 +21,21 @@ import { fixInterpreterDisplayName } from './helpers';
21
21
22
22
@injectable ( )
23
23
export class PythonInterpreterLocatorService implements IInterpreterLocatorService {
24
- private interpretersPerResource : Map < string , Promise < PythonInterpreter [ ] > > ;
25
24
private disposables : Disposable [ ] = [ ] ;
26
25
private platform : IPlatformService ;
27
26
28
27
constructor ( @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ) {
29
- this . interpretersPerResource = new Map < string , Promise < PythonInterpreter [ ] > > ( ) ;
30
28
serviceContainer . get < Disposable [ ] > ( IDisposableRegistry ) . push ( this ) ;
31
29
this . platform = serviceContainer . get < IPlatformService > ( IPlatformService ) ;
32
30
}
33
31
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 ) ;
40
33
}
41
34
public dispose ( ) {
42
35
this . disposables . forEach ( disposable => disposable . dispose ( ) ) ;
43
36
}
44
- private getResourceKey ( resource ?: Uri ) {
45
- if ( ! resource ) {
46
- return '' ;
47
- }
48
- const workspaceFolder = workspace . getWorkspaceFolder ( resource ) ;
49
- return workspaceFolder ? workspaceFolder . uri . fsPath : '' ;
50
- }
51
37
private async getInterpretersPerResource ( resource ?: Uri ) {
52
- const locators = this . getLocators ( resource ) ;
38
+ const locators = this . getLocators ( ) ;
53
39
const promises = locators . map ( async provider => provider . getInterpreters ( resource ) ) ;
54
40
const listOfInterpreters = await Promise . all ( promises ) ;
55
41
@@ -73,7 +59,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
73
59
return accumulator ;
74
60
} , [ ] ) ;
75
61
}
76
- private getLocators ( resource ?: Uri ) {
62
+ private getLocators ( ) {
77
63
const locators : IInterpreterLocatorService [ ] = [ ] ;
78
64
// The order of the services is important.
79
65
if ( this . platform . isWindows ) {
0 commit comments