CodeQL library for JavaScript/TypeScript
codeql/javascript-all 0.8.11-dev (changelog, source)
Search

Class AstNode

A program element corresponding to JavaScript code, such as an expression or a statement.

This class provides generic traversal methods applicable to all AST nodes, such as obtaining the children of an AST node.

Examples:

function abs(x) {
  return x < 0 ? -x : x;
}
abs(-42);

Import path

import javascript

Direct supertypes

Indirect supertypes

Known direct subtypes

Predicates

getAChild

Gets a child node of this node.

getAChildExpr

Gets a child expression of this node.

getAChildStmt

Gets a child statement of this node.

getAToken

Gets a token belonging to this element.

getChild

Gets the ith child node of this node.

getChildExpr

Gets the ith child expression of this node.

getChildStmt

Gets the ith child statement of this node.

getChildTypeExpr

Gets the ith child type expression of this node.

getFile

Gets the file this program element comes from.

getFirstControlFlowNode

Gets the first control flow node belonging to this syntactic entity.

getFirstToken

Gets the first token belonging to this element.

getLastToken

Gets the last token belonging to this element.

getLocation

Gets this element’s location.

getNumChild

Gets the number of child nodes of this node.

getNumChildExpr

Gets the number of child expressions of this node.

getNumChildStmt

Gets the number of child statements of this node.

getParent

Gets the parent node of this node, if any.

getTopLevel

Gets the toplevel syntactic unit to which this element belongs.

inExternsFile

Holds if this syntactic entity belongs to an externs file.

isAmbient

Holds if this is part of an ambient declaration or type annotation in a TypeScript file.

Inherited predicates

getAPrimaryQlClass

Gets the primary QL class for the Locatable.

from Locatable
getContainer

Gets the function or toplevel to which this node belongs.

from NodeInStmtContainer
getEndLine

Gets the line on which this element ends.

from Locatable
getNumLines

Gets the number of lines covered by this element.

from Locatable
getPrimaryQlClasses

Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

from Locatable
getStartLine

Gets the line on which this element starts.

from Locatable
toString

Gets a textual representation of this element.

from Locatable