mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
feat: vendor permission system source
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { TSNode } from "#src/access-intent/bash/parser";
|
||||
|
||||
/**
|
||||
* Build a fake {@link TSNode} for testing the pure AST helpers without paying
|
||||
* for a real tree-sitter parse.
|
||||
*
|
||||
* Fills only the fields those helpers read; `children` drives both `childCount`
|
||||
* and `child(i)`, so a node's structural shape (delimiters plus a
|
||||
* `variable_name`, a quoted string's inner content) can be expressed directly.
|
||||
*
|
||||
* Prefer a real parse (`getParser()`) when the test's subject is the AST shape
|
||||
* tree-sitter actually produces; use this when the subject is the helper's
|
||||
* behavior given a shape.
|
||||
*/
|
||||
export function makeTSNode(
|
||||
type: string,
|
||||
text: string,
|
||||
children: TSNode[] = [],
|
||||
): TSNode {
|
||||
return {
|
||||
type,
|
||||
text,
|
||||
startIndex: 0,
|
||||
childCount: children.length,
|
||||
isNamed: true,
|
||||
child: (i) => children[i] ?? null,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user