blockly > ASTNode
ASTNode class
Class for an AST node. It is recommended that you use one of the createNode methods instead of creating a node directly.
Signature:
export declare class ASTNode
Constructors
Properties
Property |
Modifiers |
Type |
Description |
NAVIGATE_ALL_FIELDS |
static |
boolean |
True to navigate to all fields. False to only navigate to clickable fields. |
Methods
Method |
Modifiers |
Description |
createBlockNode(block) |
static |
Creates an AST node pointing to a block. |
createButtonNode(button) |
static |
Create an AST node of type button. A button in this case refers specifically to a button in a flyout. |
createConnectionNode(connection) |
static |
Creates an AST node pointing to a connection. If the connection has a parent input then create an AST node of type input that will hold the connection. |
createFieldNode(field) |
static |
Create an AST node pointing to a field. |
createInputNode(input) |
static |
Creates an AST node pointing to an input. Stores the input connection as the location. |
createStackNode(topBlock) |
static |
Create an AST node of type stack. A stack, represented by its top block, is the set of all blocks connected to a top block, including the top block. |
createTopNode(block) |
static |
Creates an AST node for the top position on a block. This is either an output connection, previous connection, or block. |
createWorkspaceNode(workspace, wsCoordinate) |
static |
Creates an AST node pointing to a workspace. |
getLocation() |
|
Gets the value pointed to by this node. It is the callers responsibility to check the node type to figure out what type of object they get back from this. |
getSourceBlock() |
|
Finds the source block of the location of this node. |
getType() |
|
The type of the current location. One of ASTNode.types |
getWsCoordinate() |
|
The coordinate on the workspace. |
in() |
|
Find the element one level below and all the way to the left of the current location. |
next() |
|
Find the element to the right of the current element in the AST. |
out() |
|
Find the next element that is one position above and all the way to the left of the current location. |
prev() |
|
Find the element to the left of the current element in the AST. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `ASTNode` class represents a node in the Abstract Syntax Tree (AST) of Blockly blocks and provides methods to navigate and manipulate the tree."],["It offers static methods for creating AST nodes for various Blockly components like blocks, fields, inputs, connections, buttons, stacks, and workspaces."],["`ASTNode` instances store location information, allowing retrieval of the associated Blockly element and its type."],["Navigation methods like `next()`, `prev()`, `in()`, and `out()` enable traversal of the AST structure relative to the current node."],["The `getLocation()` method retrieves the underlying Blockly element, while `getType()` identifies the node's type within the AST."]]],[]]