@@ -33,32 +33,21 @@ import { join } from 'path';
3333import { memoize } from 'vs/base/common/decorators' ;
3434
3535export function traceRpc ( _target : any , key : string , descriptor : any ) {
36- let fnKey : string | null = null ;
37- let fn : Function | null = null ;
38-
39- if ( typeof descriptor . value === 'function' ) {
40- fnKey = 'value' ;
41- fn = descriptor . value ;
42-
43- if ( fn ! . length !== 0 ) {
44- console . warn ( 'Memoize should only be used in functions with zero parameters' ) ;
45- }
46- }
47-
48- if ( ! fn ) {
36+ if ( typeof descriptor . value !== 'function' ) {
4937 throw new Error ( 'not supported' ) ;
5038 }
51-
52- descriptor [ fnKey ! ] = async function ( ...args : any [ ] ) {
39+ const fnKey = 'value' ;
40+ const fn = descriptor . value ;
41+ descriptor [ fnKey ] = async function ( ...args : any [ ] ) {
5342 if ( this . traceRpcArgs . logService . getLevel ( ) === LogLevel . Trace ) {
54- this . traceRpcArgs . logService . trace ( `[RPC Request] PtyService#${ fn ! . name } (${ args . map ( e => JSON . stringify ( e ) ) . join ( ', ' ) } )` ) ;
43+ this . traceRpcArgs . logService . trace ( `[RPC Request] PtyService#${ fn . name } (${ args . map ( e => JSON . stringify ( e ) ) . join ( ', ' ) } )` ) ;
5544 }
5645 if ( this . traceRpcArgs . simulatedLatency ) {
5746 await timeout ( this . traceRpcArgs . simulatedLatency ) ;
5847 }
59- const result = await fn ! . apply ( this , args ) ;
48+ const result = await fn . apply ( this , args ) ;
6049 if ( this . traceRpcArgs . logService . getLevel ( ) === LogLevel . Trace ) {
61- this . traceRpcArgs . logService . trace ( `[RPC Response] PtyService#${ fn ! . name } ` , result ) ;
50+ this . traceRpcArgs . logService . trace ( `[RPC Response] PtyService#${ fn . name } ` , result ) ;
6251 }
6352 return result ;
6453 } ;
0 commit comments