Package com.google.javascript.jscomp
Interface NodeTraversal.Callback
-
- All Known Subinterfaces:
NodeTraversal.ScopedCallback
- All Known Implementing Classes:
BranchCoverageInstrumentationCallback
,CheckArrayWithGoogObject
,CheckConformance
,CheckConstantCaseNames
,CheckConstPrivateProperties
,CheckDefaultExportOfGoogModule
,CheckDuplicateCase
,CheckEmptyStatements
,CheckEnums
,CheckEs6ModuleFileStructure
,CheckEs6Modules
,CheckExtraRequires
,CheckGoogModuleTypeScriptName
,CheckInterfaces
,CheckJSDocStyle
,CheckMissingOverrideTypes
,CheckMissingRequires
,CheckMissingSemicolon
,CheckNestedNames
,CheckNoMutatedEs6Exports
,CheckNullabilityModifiers
,CheckPrimitiveAsObject
,CheckPrototypeProperties
,CheckProvidesSorted
,CheckRequiresSorted
,CheckTypeImportCodeReferences
,CheckUnusedLabels
,CheckUnusedPrivateProperties
,CheckUselessBlocks
,CheckVar
,ChromePass
,ClosureCheckModule
,ControlFlowAnalysis
,ControlFlowGraph.AbstractCfgNodeTraversalCallback
,CrossChunkReferenceCollector
,Es6CheckModule
,Es6ConvertSuper
,Es6ConvertSuperConstructorCalls
,Es6ExtractClasses
,Es6ForOfConverter
,Es6NormalizeShorthandProperties
,Es6RenameVariablesInParamLists
,Es6RewriteArrowFunction
,Es6RewriteBlockScopedDeclaration
,Es6RewriteBlockScopedFunctionDeclaration
,Es6RewriteClass
,Es6RewriteClassExtendsExpressions
,Es6RewriteDestructuring
,Es6RewriteModules
,Es6RewriteRestAndSpread
,Es6RewriteScriptsToModules
,Es6SplitVariableDeclarations
,Es7RewriteExponentialOperator
,EsModuleProcessor
,FindModuleDependencies
,ForbidDynamicImportUsage
,ImplicitNullabilityCheck
,InjectTranspilationRuntimeLibraries
,J2clAssertRemovalPass
,J2clChecksPass
,J2clUtilGetDefineRewriterPass
,JsMessageVisitor
,LateEs6ToEs3Converter
,MarkUntranspilableFeaturesAsRemoved
,NodeTraversal.AbstractChangedScopeCallback
,NodeTraversal.AbstractModuleCallback
,NodeTraversal.AbstractPostOrderCallback
,NodeTraversal.AbstractPreOrderCallback
,NodeTraversal.AbstractScopedCallback
,NodeTraversal.AbstractShallowCallback
,NodeTraversal.AbstractShallowStatementCallback
,NodeTraversal.ExternsSkippingCallback
,ProcessCommonJSModules
,RewriteAsyncFunctions
,RewriteAsyncIteration
,RewriteClassFields
,RewriteDynamicImports
,RewriteJsonToModule
,RewriteLogicalAssignmentOperatorsPass
,RewriteNullishCoalesceOperator
,RewriteObjectSpread
,SourceInformationAnnotator
,TypeCheck
- Enclosing class:
- NodeTraversal
public static interface NodeTraversal.Callback
Callback for tree-based traversals
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
shouldTraverse(NodeTraversal t, Node n, Node parent)
Visits a node in preorder (before its children) and decides whether its children should be traversed.void
visit(NodeTraversal t, Node n, Node parent)
Visits a node in postorder (after its children).
-
-
-
Method Detail
-
shouldTraverse
boolean shouldTraverse(NodeTraversal t, Node n, Node parent)
Visits a node in preorder (before its children) and decides whether its children should be traversed. If the children should be traversed, they will be visited byshouldTraverse(NodeTraversal, Node, Node)
in preorder and byvisit(NodeTraversal, Node, Node)
in postorder.Siblings are always visited left-to-right.
Implementations can have side-effects (e.g. modify the parse tree). Removing the current node is legal, but removing or reordering nodes above the current node may cause nodes to be visited twice or not at all.
- Parameters:
t
- The current traversal.n
- The current node.parent
- The parent of the current node.- Returns:
- whether the children of this node should be visited
-
visit
void visit(NodeTraversal t, Node n, Node parent)
Visits a node in postorder (after its children). A node is visited in postorder iffshouldTraverse(NodeTraversal, Node, Node)
returned true for its parent. In particular, the root node is never visited in postorder.Siblings are always visited left-to-right.
Implementations can have side-effects (e.g. modify the parse tree). Removing the current node is legal, but removing or reordering nodes above the current node may cause nodes to be visited twice or not at all.
- Parameters:
t
- The current traversal.n
- The current node.parent
- The parent of the current node.
-
-