Stay organized with collections
Save and categorize content based on your preferences.
blockly > BasicCursor
BasicCursor class
Class for a basic cursor. This will allow the user to get to all nodes in the AST by hitting next or previous.
Signature:
export declare class BasicCursor extends Cursor
Extends: Cursor
Constructors
Constructor |
Modifiers |
Description |
(constructor)() |
|
Constructs a new instance of the BasicCursor class |
Properties
Property |
Modifiers |
Type |
Description |
registrationName |
static
readonly
|
(not declared) |
Name used for registering a basic cursor. |
Methods
Method |
Modifiers |
Description |
getNextNode_(node, isValid) |
protected |
Uses pre order traversal to navigate the Blockly AST. This will allow a user to easily navigate the entire Blockly AST without having to go in and out levels on the tree. |
getPreviousNode_(node, isValid) |
protected |
Reverses the pre order traversal in order to find the previous node. This will allow a user to easily navigate the entire Blockly AST without having to go in and out levels on the tree. |
in() |
|
For a basic cursor we only have the ability to go next and previous, so in will also allow the user to get to the next node in the pre order traversal. |
next() |
|
Find the next node in the pre order traversal. |
out() |
|
For a basic cursor we only have the ability to go next and previous, so out will allow the user to get to the previous node in the pre order traversal. |
prev() |
|
Find the previous node in the pre order traversal. |
validNode_(node) |
protected |
Decides what nodes to traverse and which ones to skip. Currently, it skips output, stack and workspace nodes. |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["The `BasicCursor` class enables navigation through the Abstract Syntax Tree (AST) of Blockly using pre-order traversal."],["It provides methods for moving to the next (`next`) and previous (`prev`) nodes in the AST."],["The `in` and `out` methods offer an alternative way to navigate, mirroring `next` and `prev` respectively."],["Users can define their navigation logic by overriding the `validNode_` method to specify which nodes should be traversed."],["`BasicCursor` extends the `Cursor` class and registers itself under the name \"basic\"."]]],["The `BasicCursor` class, extending `Cursor`, facilitates navigation through a Blockly Abstract Syntax Tree (AST). It utilizes pre-order traversal to enable users to move to the next or previous node. Key actions include `next()` and `prev()` methods to traverse the AST, and `in()` and `out()` which also move to the next or previous node, respectively. The `getNextNode_` and `getPreviousNode_` methods handle traversal logic. The `validNode_` method determines which nodes are traversed, skipping outputs, stacks and workspaces.\n"]]