tiny.smg.scan.core.tree
Defined in scan.core.
API (4)
Actions
Public operations.
Source
Source: tools/smg/src/scan/core/root.zig:4
zig
pub const tree = @import("tree.zig");Source: tools/smg/src/scan/core/tree.zig
zig
const std = @import("std");const smg = @import("../../root.zig");const text = smg.text;const tree = smg.tree;pub fn findChild(node: tree.Node, kind: []const u8) ?tree.Node { const children = tree.childCount(node); for (0..children) |raw_index| { const child = tree.child(node, @intCast(raw_index)); if (std.mem.eql(u8, tree.kind(child), kind)) return child; } return null;}pub fn namedChildByIndex(node: tree.Node, index: usize) ?tree.Node { if (index >= tree.namedChildCount(node)) return null; return tree.namedChild(node, @intCast(index));}pub fn hasDescendant(node: tree.Node, kind: []const u8) bool { const children = tree.childCount(node); for (0..children) |raw_index| { const child_node = tree.child(node, @intCast(raw_index)); if (std.mem.eql(u8, tree.kind(child_node), kind) or hasDescendant(child_node, kind)) return true; } return false;}pub fn compactParseCandidateAny(source: []const u8, prefixes: []const []const u8) bool { const trimmed = text.trim(source); if (trimmed.len == 0 or trimmed.len > 4096) return false; var matches = false; for (prefixes) |prefix| { if (std.mem.startsWith(u8, trimmed, prefix)) { matches = true; break; } } if (!matches) return false; return boundedLineLength(trimmed, 512);}fn boundedLineLength(source: []const u8, limit: usize) bool { var current: usize = 0; for (source) |byte| { if (byte == '\n') { current = 0; continue; } current += 1; if (current > limit) return false; } return true;}Audit
| Definitions | 5 |
|---|---|
| Public names | 9 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |