MCPcopy Create free account
hub / github.com/davidkingzyb/SCAST / doBlock

Function doBlock

js/ESTREEJS.js:560–647  ·  view source on GitHub ↗
(n,node,file,r)

Source from the content-addressed store, hash-verified

558 if(symbol)r.UML+=` ${member._value}()\n`
559 }
560 function doBlock(n,node,file,r){
561 // console.log('do block',n)
562 if(!n)return
563 if(n.type=="FunctionDeclaration"){
564 traverseFunction(n,node,file)
565 return true
566 }else if(n.type=="ForStatement"||n.type=="WhileStatement"||n.type=="DoWhileStatement"||n.type=="ForInStatement"||n.type=="ForOfStatement"){
567 n._file=file
568 n._value="for"
569 n._flow_id=n._value+n.start+'_'+node._flow_id
570 n._flow_from=node._flow_id
571 r.FlowNode[n._flow_id]=n
572 if(r.showIf){
573 r.Flow+=` ${n._flow_id}((${n._value}))\nclick ${n._flow_id} "javascript:void(onFlowClick('${n._flow_id}','${file}'))"\n`
574 r.FDPNode[n._flow_id]={id:n._flow_id,w:0,text:'🔵'}
575 }
576 if(n.test&&getRangeCode(n.test))n._flow_condition='|'+mermaidRepl(getRangeCode(n.test))+'|'
577 if(n.right&&getRangeCode(n.right))n._flow_condition='|'+mermaidRepl(getRangeCode(n.right))+'|'
578 if(r.showIf&&n.body){
579 traverseAst(n.body,(nn)=>{
580 return doBlock(nn,n,file,r)
581 })
582 }
583 if(r.showIf)return true
584 }else if(n.type=="IfStatement"){
585 n._file=file
586 n._value="if"
587 n._flow_id=n._value+n.start+'_'+node._flow_id
588 n._flow_from=node._flow_id
589 r.FlowNode[n._flow_id]=n
590 if(r.showIf){
591 r.Flow+=` ${n._flow_id}{${n._value}}\nclick ${n._flow_id} "javascript:void(onFlowClick('${n._flow_id}','${file}'))"\n`
592 r.FDPNode[n._flow_id]={id:n._flow_id,w:0,text:'🔷'}
593 }
594 if(n.test&&getRangeCode(n.test))n._flow_condition='|'+mermaidRepl(getRangeCode(n.test))+'|'
595 if(r.showIf&&n.consequent){
596 traverseAst(n.consequent,(nn)=>{
597 return doBlock(nn,n,file,r)
598 })
599 }
600 if(r.showIf&&n.alternate){
601 traverseAst(n.alternate,(nn)=>{
602 doBlock(nn,node,file,r)
603 if(n.alternate.type=="BlockStatement"){
604 return false
605 }
606 if(r.showIf)return true
607 })
608 }
609 if(r.showIf)return true
610
611 }else if(n.type=="CallExpression"){
612 n._file=file
613 n._value=getValue(n)
614 n._flow_id=n._value+'_'+node._flow_id
615 n._flow_from=node._flow_id
616 n._flow_callee=n.callee.name||n.callee.object?.name;
617 if(n._flow_callee&&r.FlowNode[n._flow_id]){

Callers 1

traverseFunctionFunction · 0.70

Calls 5

traverseFunctionFunction · 0.70
getRangeCodeFunction · 0.70
mermaidReplFunction · 0.70
traverseAstFunction · 0.70
getValueFunction · 0.70

Tested by

no test coverage detected