@@ -14,36 +14,22 @@ import {
1414} from '../common/application/types' ;
1515import { STANDARD_OUTPUT_CHANNEL } from '../common/constants' ;
1616import '../common/extensions' ;
17- import { IPlatformService } from '../common/platform/types' ;
1817import {
1918 IConfigurationService , IDisposableRegistry ,
2019 IOutputChannel , IPythonSettings
2120} from '../common/types' ;
2221import { displayProgress } from '../common/utils/decorators' ;
2322import { LanguageService } from '../common/utils/localize' ;
24- import { OSDistro , OSType } from '../common/utils/platform' ;
2523import { IServiceContainer } from '../ioc/types' ;
2624import { sendTelemetryEvent } from '../telemetry' ;
2725import { PYTHON_LANGUAGE_SERVER_PLATFORM_NOT_SUPPORTED } from '../telemetry/constants' ;
2826import {
2927 ExtensionActivators , IExtensionActivationService ,
30- IExtensionActivator
28+ IExtensionActivator ,
29+ ILanguageServerCompatibilityService
3130} from './types' ;
3231
3332const jediEnabledSetting : keyof IPythonSettings = 'jediEnabled' ;
34- const LS_MIN_OS_VERSIONS : [ OSType , OSDistro , string ] [ ] = [
35- // See: https://code.visualstudio.com/docs/supporting/requirements
36- [ OSType . OSX , OSDistro . Unknown , '10.12' ] , // Sierra or higher
37- [ OSType . Windows , OSDistro . Unknown , '6.1' ] , // Win 7 or higher
38- // tslint:disable-next-line: no-suspicious-comment
39- // TODO: Are these right?
40- [ OSType . Linux , OSDistro . Ubuntu , '14.04' ] , // "precise"
41- [ OSType . Linux , OSDistro . Debian , '7' ] ,
42- [ OSType . Linux , OSDistro . RHEL , '7' ] ,
43- [ OSType . Linux , OSDistro . CentOS , '7' ] ,
44- [ OSType . Linux , OSDistro . Fedora , '23' ]
45- ] ;
46-
4733type ActivatorInfo = { jedi : boolean ; activator : IExtensionActivator } ;
4834
4935@injectable ( )
@@ -53,7 +39,8 @@ export class ExtensionActivationService implements IExtensionActivationService,
5339 private readonly output : OutputChannel ;
5440 private readonly appShell : IApplicationShell ;
5541
56- constructor ( @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ) {
42+ constructor ( @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ,
43+ @inject ( ILanguageServerCompatibilityService ) private readonly lsCompatibility : ILanguageServerCompatibilityService ) {
5744 this . workspaceService = this . serviceContainer . get < IWorkspaceService > ( IWorkspaceService ) ;
5845 this . output = this . serviceContainer . get < OutputChannel > ( IOutputChannel , STANDARD_OUTPUT_CHANNEL ) ;
5946 this . appShell = this . serviceContainer . get < IApplicationShell > ( IApplicationShell ) ;
@@ -70,10 +57,8 @@ export class ExtensionActivationService implements IExtensionActivationService,
7057 }
7158
7259 let jedi = this . useJedi ( ) ;
73- if ( ! jedi && ! isLSSupported ( this . serviceContainer ) ) {
60+ if ( ! jedi && ! await this . lsCompatibility . isSupported ( ) ) {
7461 this . appShell . showWarningMessage ( 'The Python Language Server is not supported on your platform.' ) ;
75- // tslint:disable-next-line:no-suspicious-comment
76- // TODO: Only send once (ever)?
7762 sendTelemetryEvent ( PYTHON_LANGUAGE_SERVER_PLATFORM_NOT_SUPPORTED ) ;
7863 jedi = true ;
7964 }
@@ -119,30 +104,3 @@ export class ExtensionActivationService implements IExtensionActivationService,
119104 return workspacesUris . filter ( uri => configuraionService . getSettings ( uri ) . jediEnabled ) . length > 0 ;
120105 }
121106}
122-
123- function isLSSupported ( services : IServiceContainer ) : boolean {
124- const platform = services . get < IPlatformService > ( IPlatformService ) ;
125- let minVer = '' ;
126- for ( const [ osType , distro , ver ] of LS_MIN_OS_VERSIONS ) {
127- if ( platform . info . type === osType && platform . info . distro === distro ) {
128- minVer = ver ;
129- break ;
130- }
131- }
132- if ( minVer === '' ) {
133- return true ;
134- }
135- minVer = normalizeVersion ( minVer ) ;
136- return platform . info . version . compare ( minVer ) >= 0 ;
137- }
138-
139- function normalizeVersion ( ver : string ) : string {
140- ver = ver . replace ( / \. 0 0 * / , '.' ) ;
141- if ( / ^ \d \d * $ / . test ( ver ) ) {
142- return `${ ver } .0.0` ;
143- } else if ( / ^ \d \d * \. \d \d * $ / . test ( ver ) ) {
144- return `${ ver } .0` ;
145- } else {
146- return ver ;
147- }
148- }
0 commit comments