@@ -205,6 +205,7 @@ export class CalleeFuncProvider extends ProjectWebviewProvider {
205205 let nodes = '' ;
206206 let edges = '' ;
207207 let edgeNumber = 0 ; // use to set id of a new edge
208+ let numberOfCallees = 0 , numberOfCalls = 0 ;
208209 let stmtNodes = [ ] ; // nodes for statements like goto, break, etc.
209210 info . CallGraph . forEach ( ( callees , caller ) => {
210211 let callerID = `${ caller . ID } ` ;
@@ -217,6 +218,7 @@ export class CalleeFuncProvider extends ProjectWebviewProvider {
217218 }
218219 nodes += ',color: "darkorange"' ;
219220 } else {
221+ ++ numberOfCallees ;
220222 let f = caller as msg . Function ;
221223 nodes += `{id: '${ callerID } ', label: '${ f . Name } '` ;
222224 if ( ! f . User )
@@ -238,26 +240,31 @@ export class CalleeFuncProvider extends ProjectWebviewProvider {
238240 }
239241 edges += `{id: ${ edgeNumber } , from: '${ callerID } ', to: '${ calleeID } '` ;
240242 // Add property to Go To a corresponding statement in a source code from webview.
241- if ( callee . StartLocation . length > 0 &&
242- ( ! isFunction ( caller ) || caller . User ) ) {
243- edges += `,location: [` ;
244- for ( let loc of callee . StartLocation ) {
245- let resolvedLoc = resolveLocation ( project , loc ) ;
246- let goto = encodeURI ( 'command:tsar.open-project?' +
247- JSON . stringify ( project . uri . with ( {
248- query : JSON . stringify ( resolvedLoc )
249- } ) ) ) ;
250- edges += `
251- {
252- Goto: '${ goto } ',
253- Filename: '${ path . basename ( resolvedLoc . Path ) } ',
254- Line: ${ loc . Line } ,
255- Column: ${ loc . Column }
256- },` ;
257- }
258- // Remove last comma.
259- edges = edges . substr ( 0 , edges . length - 1 ) ;
260- edges += ']' ;
243+ if ( ! isFunction ( caller ) || caller . User ) {
244+ if ( callee . StartLocation . length > 0 ) {
245+ edges += `,location: [` ;
246+ for ( let loc of callee . StartLocation ) {
247+ if ( numberOfCalls >= 0 )
248+ ++ numberOfCalls ;
249+ let resolvedLoc = resolveLocation ( project , loc ) ;
250+ let goto = encodeURI ( 'command:tsar.open-project?' +
251+ JSON . stringify ( project . uri . with ( {
252+ query : JSON . stringify ( resolvedLoc )
253+ } ) ) ) ;
254+ edges += `
255+ {
256+ Goto: '${ goto } ',
257+ Filename: '${ path . basename ( resolvedLoc . Path ) } ',
258+ Line: ${ loc . Line } ,
259+ Column: ${ loc . Column }
260+ },` ;
261+ }
262+ // Remove last comma.
263+ edges = edges . substr ( 0 , edges . length - 1 ) ;
264+ edges += ']' ;
265+ } else {
266+ numberOfCalls = - 1 ;
267+ }
261268 }
262269 edges += '},' ;
263270 }
@@ -294,6 +301,9 @@ export class CalleeFuncProvider extends ProjectWebviewProvider {
294301 <div class="container-fluid pt-4" style="height:100%">
295302 <h3>${ this . _title ( ) . replace ( '{0}' , gotoTarget ) } </h3>
296303 <h5>${ subtitle } </h5>
304+ <p>A total number of callees is ${ numberOfCallees } .</p>
305+ <p>A total number of calls from user-defined functions is
306+ ${ numberOfCalls < 0 ? 'unknown' : numberOfCalls } .</p>
297307 <div class="row" style="height:100%">
298308 <div class="col-9" style="height:100%">
299309 <div id="callGraph" style="height:90%"}></div>
0 commit comments