| 218 | } |
| 219 | __name(getText, "getText"); |
| 220 | var Tree = class _Tree { |
| 221 | static { |
| 222 | __name(this, "Tree"); |
| 223 | } |
| 224 | /** @internal */ |
| 225 | [0] = 0; |
| 226 | // Internal handle for Wasm |
| 227 | /** @internal */ |
| 228 | textCallback; |
| 229 | /** The language that was used to parse the syntax tree. */ |
| 230 | language; |
| 231 | /** @internal */ |
| 232 | constructor(internal, address, language, textCallback) { |
| 233 | assertInternal(internal); |
| 234 | this[0] = address; |
| 235 | this.language = language; |
| 236 | this.textCallback = textCallback; |
| 237 | } |
| 238 | /** Create a shallow copy of the syntax tree. This is very fast. */ |
| 239 | copy() { |
| 240 | const address = C._ts_tree_copy(this[0]); |
| 241 | return new _Tree(INTERNAL, address, this.language, this.textCallback); |
| 242 | } |
| 243 | /** Delete the syntax tree, freeing its resources. */ |
| 244 | delete() { |
| 245 | C._ts_tree_delete(this[0]); |
| 246 | this[0] = 0; |
| 247 | } |
| 248 | /** Get the root node of the syntax tree. */ |
| 249 | get rootNode() { |
| 250 | C._ts_tree_root_node_wasm(this[0]); |
| 251 | return unmarshalNode(this); |
| 252 | } |
| 253 | /** |
| 254 | * Get the root node of the syntax tree, but with its position shifted |
| 255 | * forward by the given offset. |
| 256 | */ |
| 257 | rootNodeWithOffset(offsetBytes, offsetExtent) { |
| 258 | const address = TRANSFER_BUFFER + SIZE_OF_NODE; |
| 259 | C.setValue(address, offsetBytes, "i32"); |
| 260 | marshalPoint(address + SIZE_OF_INT, offsetExtent); |
| 261 | C._ts_tree_root_node_with_offset_wasm(this[0]); |
| 262 | return unmarshalNode(this); |
| 263 | } |
| 264 | /** |
| 265 | * Edit the syntax tree to keep it in sync with source code that has been |
| 266 | * edited. |
| 267 | * |
| 268 | * You must describe the edit both in terms of byte offsets and in terms of |
| 269 | * row/column coordinates. |
| 270 | */ |
| 271 | edit(edit) { |
| 272 | marshalEdit(edit); |
| 273 | C._ts_tree_edit_wasm(this[0]); |
| 274 | } |
| 275 | /** Create a new {@link TreeCursor} starting from the root of the tree. */ |
| 276 | walk() { |
| 277 | return this.rootNode.walk(); |