visitor
luau
local visitor = require("@std/syntax/visitor")WARNING
These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.
Summary
| Entry | Description |
|---|---|
| Visitor | A table of callbacks invoked during CST traversal. Each visit callback receives the corresponding node and |
Types
Visitor
A table of callbacks invoked during CST traversal. Each visit callback receives the corresponding node and
returns true to continue visiting its children, or false to skip them. "End" callbacks fire after all children
of that sort have been visited. Override only the callbacks you care about; unset callbacks default to visiting all children.
luau
type Visitor = {
visitStatBlock: (types.CstStatBlock) -> boolean,
visitStatBlockEnd: (types.CstStatBlock) -> (),
visitStatDo: (types.CstStatDo) -> boolean,
visitStatIf: (types.CstStatIf) -> boolean,
visitStatWhile: (types.CstStatWhile) -> boolean,
visitStatRepeat: (types.CstStatRepeat) -> boolean,
visitStatBreak: (types.CstStatBreak) -> boolean,
visitStatContinue: (types.CstStatContinue) -> boolean,
visitStatReturn: (types.CstStatReturn) -> boolean,
visitStatLocalDeclaration: (types.CstStatLocal) -> boolean,
visitStatLocalDeclarationEnd: (types.CstStatLocal) -> (),
visitStatConstDeclaration: (types.CstStatConst) -> boolean,
visitStatConstDeclarationEnd: (types.CstStatConst) -> (),
visitStatFor: (types.CstStatFor) -> boolean,
visitStatForEnd: (types.CstStatFor) -> (),
visitStatForIn: (types.CstStatForIn) -> boolean,
visitStatForInEnd: (types.CstStatForIn) -> (),
visitStatAssign: (types.CstStatAssign) -> boolean,
visitStatCompoundAssign: (types.CstStatCompoundAssign) -> boolean,
visitStatFunction: (types.CstStatFunction) -> boolean,
visitStatLocalFunction: (types.CstStatLocalFunction) -> boolean,
visitStatTypeAlias: (types.CstStatTypeAlias) -> boolean,
visitStatTypeFunction: (types.CstStatTypeFunction) -> boolean,
visitStatExpr: (types.CstStatExpr) -> boolean,
visitExpr: (types.CstExpr) -> boolean,
visitExprEnd: (types.CstExpr) -> (),
visitExprConstantNil: (types.CstExprConstantNil) -> boolean,
visitExprConstantString: (types.CstExprConstantString) -> boolean,
visitExprConstantBool: (types.CstExprConstantBool) -> boolean,
visitExprConstantNumber: (types.CstExprConstantNumber) -> boolean,
visitExprConstantInteger: (types.CstExprConstantInteger) -> boolean,
visitExprLocal: (types.CstExprLocal) -> boolean,
visitExprGlobal: (types.CstExprGlobal) -> boolean,
visitExprCall: (types.CstExprCall) -> boolean,
visitExprUnary: (types.CstExprUnary) -> boolean,
visitExprBinary: (types.CstExprBinary) -> boolean,
visitExprFunction: (types.CstExprFunction) -> boolean,
visitExprFunctionEnd: (types.CstExprFunction) -> (),
visitExprInstantiate: (types.CstExprInstantiate) -> boolean,
visitTableExprItem: (types.CstTableExprItem) -> boolean,
visitExprTable: (types.CstExprTable) -> boolean,
visitExprIndexName: (types.CstExprIndexName) -> boolean,
visitExprIndexExpr: (types.CstExprIndexExpr) -> boolean,
visitExprGroup: (types.CstExprGroup) -> boolean,
visitExprInterpString: (types.CstExprInterpString) -> boolean,
visitExprTypeAssertion: (types.CstExprTypeAssertion) -> boolean,
visitExprIfElse: (types.CstExprIfElse) -> boolean,
visitExprVarargs: (types.CstExprVarargs) -> boolean,
visitTypeReference: (types.CstTypeReference) -> boolean,
visitTypeSingletonBool: (types.CstTypeSingletonBool) -> boolean,
visitTypeSingletonString: (types.CstTypeSingletonString) -> boolean,
visitTypeTypeof: (types.CstTypeTypeof) -> boolean,
visitTypeGroup: (types.CstTypeGroup) -> boolean,
visitTypeOptional: (types.CstTypeOptional) -> boolean,
visitTypeUnion: (types.CstTypeUnion) -> boolean,
visitTypeIntersection: (types.CstTypeIntersection) -> boolean,
visitTypeArray: (types.CstTypeArray) -> boolean,
visitTypeTable: (types.CstTypeTable) -> boolean,
visitTypeFunction: (types.CstTypeFunction) -> boolean,
visitTypePackExplicit: (types.CstTypePackExplicit) -> boolean,
visitTypePackGeneric: (types.CstTypePackGeneric) -> boolean,
visitTypePackVariadic: (types.CstTypePackVariadic) -> boolean,
visitToken: (types.CstToken) -> boolean,
visitLocal: (types.CstLocal) -> boolean,
visitAttribute: (types.CstAttribute) -> boolean,
}