@@ -33,32 +33,21 @@ import { join } from 'path';
33
33
import { memoize } from 'vs/base/common/decorators' ;
34
34
35
35
export 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' ) {
49
37
throw new Error ( 'not supported' ) ;
50
38
}
51
-
52
- descriptor [ fnKey ! ] = async function ( ...args : any [ ] ) {
39
+ const fnKey = 'value' ;
40
+ const fn = descriptor . value ;
41
+ descriptor [ fnKey ] = async function ( ...args : any [ ] ) {
53
42
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 ( ', ' ) } )` ) ;
55
44
}
56
45
if ( this . traceRpcArgs . simulatedLatency ) {
57
46
await timeout ( this . traceRpcArgs . simulatedLatency ) ;
58
47
}
59
- const result = await fn ! . apply ( this , args ) ;
48
+ const result = await fn . apply ( this , args ) ;
60
49
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 ) ;
62
51
}
63
52
return result ;
64
53
} ;
0 commit comments