@@ -1575,12 +1575,12 @@ export class GoDebugSession extends LoggingDebugSession {
1575
1575
log ( 'EvaluateRequest' ) ;
1576
1576
const re = new RegExp ( / \w + (? = \( .* \) ) / , 'g' ) ;
1577
1577
if ( re . test ( args . expression ) ) {
1578
- this . evaluateCallImpl ( args ) . then ( out => {
1578
+ this . evaluateCallImpl ( args ) . then ( ( out ) => {
1579
1579
const state = this . delve . isApiV1 ? < DebuggerState > out : ( < CommandOut > out ) . State ;
1580
1580
response . body = this . convertDebugVariableToProtocolVariable ( state . currentThread . ReturnValues [ 0 ] ) ;
1581
1581
this . sendResponse ( response ) ;
1582
1582
log ( 'EvaluateCallResponse' ) ;
1583
- } , err => {
1583
+ } , ( err ) => {
1584
1584
this . sendErrorResponse ( response , 2009 , 'Unable to complete call: "{e}"' , { e : err . toString ( ) } ) ;
1585
1585
} ) ;
1586
1586
} else {
@@ -1602,36 +1602,6 @@ export class GoDebugSession extends LoggingDebugSession {
1602
1602
}
1603
1603
}
1604
1604
1605
- private evaluateCallImpl ( args : DebugProtocol . EvaluateArguments ) : Thenable < DebuggerState | CommandOut > {
1606
- // default to the topmost stack frame of the current goroutine
1607
- let goroutineId = - 1 ;
1608
- let frameId = 0 ;
1609
- // args.frameId won't be specified when evaluating global vars
1610
- if ( args . frameId ) {
1611
- [ goroutineId , frameId ] = this . stackFrameHandles . get ( args . frameId ) ;
1612
- }
1613
- const scope = {
1614
- goroutineID : goroutineId ,
1615
- frame : frameId
1616
- } ;
1617
- const evalSymbolArgs = this . delve . isApiV1 ? {
1618
- symbol : args . expression ,
1619
- scope
1620
- } : {
1621
- Expr : args . expression ,
1622
- Scope : scope ,
1623
- Cfg : this . delve . loadConfig ,
1624
- Unsafe : true
1625
- } ;
1626
- const returnValue = this . delve . callPromise < DebuggerState | CommandOut > ( 'Command' ,
1627
- [ { name : 'call' , returnInfoLoadConfig : this . delve . loadConfig , expr : evalSymbolArgs . Expr , unsafe : false , goroutineID : scope . goroutineID } ] ) . then ( val => val ,
1628
- err => {
1629
- logError ( 'Failed to call function: ' , JSON . stringify ( evalSymbolArgs . Expr , null , ' ' ) , '\n\rCall error:' , err . toString ( ) ) ;
1630
- return Promise . reject ( err ) ;
1631
- } ) ;
1632
- return returnValue ;
1633
- }
1634
-
1635
1605
protected setVariableRequest (
1636
1606
response : DebugProtocol . SetVariableResponse ,
1637
1607
args : DebugProtocol . SetVariableArguments
@@ -2099,6 +2069,54 @@ export class GoDebugSession extends LoggingDebugSession {
2099
2069
return this . delve . callPromise ( 'Command' , [ { name : 'continue' } ] ) . then ( callback , errorCallback ) ;
2100
2070
}
2101
2071
2072
+ private evaluateCallImpl ( args : DebugProtocol . EvaluateArguments ) : Thenable < DebuggerState | CommandOut > {
2073
+ // default to the topmost stack frame of the current goroutine
2074
+ let goroutineId = - 1 ;
2075
+ let frameId = 0 ;
2076
+ // args.frameId won't be specified when evaluating global vars
2077
+ if ( args . frameId ) {
2078
+ [ goroutineId , frameId ] = this . stackFrameHandles . get ( args . frameId ) ;
2079
+ }
2080
+ const scope = {
2081
+ goroutineID : goroutineId ,
2082
+ frame : frameId
2083
+ } ;
2084
+ const evalSymbolArgs = this . delve . isApiV1
2085
+ ? {
2086
+ symbol : args . expression ,
2087
+ scope
2088
+ }
2089
+ : {
2090
+ Expr : args . expression ,
2091
+ Scope : scope ,
2092
+ Cfg : this . delve . loadConfig ,
2093
+ Unsafe : true
2094
+ } ;
2095
+ const returnValue = this . delve
2096
+ . callPromise < DebuggerState | CommandOut > ( 'Command' , [
2097
+ {
2098
+ name : 'call' ,
2099
+ returnInfoLoadConfig : this . delve . loadConfig ,
2100
+ expr : evalSymbolArgs . Expr ,
2101
+ unsafe : false ,
2102
+ goroutineID : scope . goroutineID
2103
+ }
2104
+ ] )
2105
+ . then (
2106
+ ( val ) => val ,
2107
+ ( err ) => {
2108
+ logError (
2109
+ 'Failed to call function: ' ,
2110
+ JSON . stringify ( evalSymbolArgs . Expr , null , ' ' ) ,
2111
+ '\n\rCall error:' ,
2112
+ err . toString ( )
2113
+ ) ;
2114
+ return Promise . reject ( err ) ;
2115
+ }
2116
+ ) ;
2117
+ return returnValue ;
2118
+ }
2119
+
2102
2120
private evaluateRequestImpl ( args : DebugProtocol . EvaluateArguments ) : Thenable < EvalOut | DebugVariable > {
2103
2121
// default to the topmost stack frame of the current goroutine
2104
2122
let goroutineId = - 1 ;
0 commit comments