Skip to documentation
SLOP

tiny.smg.scan.core.tree

Reference tiny.smg scan core tree

Defined in scan.core.

API (4)

Actions

Public operations.

No direct callersNo direct callsscan.coretree
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callersprivate; no linktools.smg.src.scan.core.treeboundedLineLengthscan.core.treecompactParseCandidateAny
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate; no linktools.smg.src.scan.pipeline.scanextractZigTreeCallsFromNodescan.core.treefindChild
Static calls · unresolved targets: 0 · external targets: 3.
No direct callersNo direct callsscan.core.treehasDescendant
Static calls · unresolved targets: 0 · external targets: 3.

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

Definitions5
Public names9
Members0
Version26.7.0
Revisiondaab053ee433