solidity-ast
solidity-ast copied to clipboard
Provide types or helpers for common deref operations
Let deref: ASTDereferencer, we could have additional helpers:
-
deref.functionCall(node: FunctionCall): FunctionDefinition | VariableDeclaration | undefined -
deref.scope(node: FunctionDefinition | StructDefinition | ...): ContractDefinition | SourceUnit -
deref.scope(node: VariableDeclaration): Block | ContractDefinition | SourceUnit - (...others)
Alternatively, we can provide arrays of node types for each of these use cases that could be passed in to deref function.
From testing, I found the following although I'm not sure if these are exhaustive:
- A
FunctionCall'sexpression.referencedDeclarationcan reference any of the following types:'FunctionDefinition', 'EventDefinition', 'ContractDefinition', 'StructDefinition' - A
ContractDefinition'sscopecan reference any of the following types:'ContractDefinition', 'SourceUnit'
FunctionCall's expression.referencedDeclaration can also reference 'VariableDeclaration', 'ErrorDefinition'