handle object subnodes

useEther_5013
aniket-engg 4 years ago committed by Aniket
parent f0ef450b5c
commit c71e8249b1
  1. 9
      libs/remix-astwalker/src/astWalker.ts

@ -80,7 +80,7 @@ export class AstWalker extends EventEmitter {
}
getASTNodeChildren(ast: AstNode): AstNode[] {
const nodes = ast.nodes // for ContractDefinition
let nodes = ast.nodes // for ContractDefinition
|| ast.body // for FunctionDefinition, ModifierDefinition, WhileStatement, DoWhileStatement, ForStatement
|| ast.statements // for Block, YulBlock
|| ast.members // for StructDefinition, EnumDefinition
@ -92,6 +92,13 @@ export class AstWalker extends EventEmitter {
|| ast.subExpression // for UnaryOperation
|| ast.eventCall // for EmitStatement
|| []
// If 'nodes' is not an array, convert it into one, for example: ast.body
if(nodes && !Array.isArray(nodes)) {
const tempArr = []
tempArr.push(nodes)
nodes = tempArr
}
if (ast.body && ast.overrides && ast.parameters && ast.returnParameters && ast.modifiers) { // for FunctionDefinition
nodes.push(ast.overrides)

Loading…
Cancel
Save