@@ -13,7 +13,13 @@ import {
1313
1414import { DeprecatePythonPath } from '../../common/experiments/groups' ;
1515import { traceDecorators , traceError } from '../../common/logger' ;
16- import { IConfigurationService , IExperimentsManager , IInterpreterPathService , Resource } from '../../common/types' ;
16+ import {
17+ IConfigurationService ,
18+ IExperimentService ,
19+ IExperimentsManager ,
20+ IInterpreterPathService ,
21+ Resource
22+ } from '../../common/types' ;
1723import { createDeferred , Deferred , sleep } from '../../common/utils/async' ;
1824import { swallowExceptions } from '../../common/utils/decorators' ;
1925import { noop } from '../../common/utils/misc' ;
@@ -26,6 +32,30 @@ import { FileBasedCancellationStrategy } from '../common/cancellationUtils';
2632import { ProgressReporting } from '../progress' ;
2733import { ILanguageClientFactory , ILanguageServerFolderService , ILanguageServerProxy } from '../types' ;
2834
35+ namespace InExperiment {
36+ export const Method = 'python/inExperiment' ;
37+
38+ export interface IRequest {
39+ experimentName : string ;
40+ }
41+
42+ export interface IResponse {
43+ inExperiment : boolean ;
44+ }
45+ }
46+
47+ namespace GetExperimentValue {
48+ export const Method = 'python/getExperimentValue' ;
49+
50+ export interface IRequest {
51+ experimentName : string ;
52+ }
53+
54+ export interface IResponse < T extends boolean | number | string > {
55+ value : T | undefined ;
56+ }
57+ }
58+
2959@injectable ( )
3060export class NodeLanguageServerProxy implements ILanguageServerProxy {
3161 public languageClient : LanguageClient | undefined ;
@@ -41,6 +71,7 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
4171 @inject ( IConfigurationService ) private readonly configurationService : IConfigurationService ,
4272 @inject ( ILanguageServerFolderService ) private readonly folderService : ILanguageServerFolderService ,
4373 @inject ( IExperimentsManager ) private readonly experiments : IExperimentsManager ,
74+ @inject ( IExperimentService ) private readonly experimentService : IExperimentService ,
4475 @inject ( IInterpreterPathService ) private readonly interpreterPathService : IInterpreterPathService
4576 ) {
4677 this . startupCompleted = createDeferred < void > ( ) ;
@@ -187,5 +218,23 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
187218 ) ;
188219 } ) ;
189220 }
221+
222+ this . languageClient ! . onRequest (
223+ InExperiment . Method ,
224+ async ( params : InExperiment . IRequest ) : Promise < InExperiment . IResponse > => {
225+ const inExperiment = await this . experimentService . inExperiment ( params . experimentName ) ;
226+ return { inExperiment } ;
227+ }
228+ ) ;
229+
230+ this . languageClient ! . onRequest (
231+ GetExperimentValue . Method ,
232+ async < T extends boolean | number | string > (
233+ params : GetExperimentValue . IRequest
234+ ) : Promise < GetExperimentValue . IResponse < T > > => {
235+ const value = await this . experimentService . getExperimentValue < T > ( params . experimentName ) ;
236+ return { value } ;
237+ }
238+ ) ;
190239 }
191240}
0 commit comments