LinterCheckAstNode - Scoped, Global
-
- UpdatedJan 30, 2025
- 2 minutes to read
- Yokohama
- API reference
The LinterCheckAstNode API provides methods for getting abstract syntax tree (AST) node details in linter checks.
This API is included with the Instance Scan (com.glide.instance_scan) plugin and runs in the sn_instance_scan
namespace. For more information, see Instance Scan.
Use the methods in this class to run linter checks on AST node types by adding code to the Script field in the Linter Check form. For more information, see Advanced linter check scripts.
Create a linter check to identify any issues in a script. When a linter check is run on a record, an abstract syntax tree for its code is generated. You can use the abstract syntax tree to analyze issues with the code.
Access methods in this API using the Instance Scan engine.rootNode object.
LinterCheckAstNode - getNameIdentifier()
Retrieves the string value of a name node type. A name node represents a simple identifier that is not a keyword, such as a function or variable name.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | If the linter object is a name node type, return the name as a string. Null otherwise. |
Example
The following example uses the Findings API incrementWithNode() method in a linter check. Use this method in the Script field of the Linter Check form.
LinterCheckAstNode - getParent()
Gets the parent node object of the accessed node.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Object | Parent node object of the accessed node. |
Example
The following example uses the Findings API incrementWithNode() method in a linter check. Use this method in the Script field of the Linter Check form.
LinterCheckAstNode - getTypeName()
Gets the type of the accessed node.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Type name of the accessed node. For example, a function call in the source is
tokenized as a node with the type name of CALL .
|
Example
The following example uses the Findings API incrementWithNode() method in a linter check. Use this method in the Script field of the Linter Check form.
LinterCheckAstNode - visit(Function callbackFunction)
Accesses each node in the subtree starting from this node and executes a given callback function on each node.
Name | Type | Description |
---|---|---|
callbackFunction | Function | Callback function to be executed on each node in the subtree of this node. This callback function takes a node as a parameter which is the node to be visited. |
Type | Description |
---|---|
None |
Example
The following example uses the Findings API incrementWithNode() method in a linter check. Use this method in the Script field of the Linter Check form.