{"modulePath":"github.com/codefit-cli/codefit","version":"v0.2.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package syntax\n\nPackage syntax is codefit's parser-agnostic AST boundary. It defines [Node](#Node), the minimal tree interface the core navigates, so the engine (ruleengine, sensors) can walk a parsed file without importing any concrete parser (go/ast, gotreesitter, ...). Each language provider adapts its parser's nodes to this interface.\n\nThe interface is deliberately minimal: it carries only what parsing and tree navigation need today. Operators that need more (e.g. pattern-inside wanting a parent pointer) extend it when they are implemented, with a real caller — not speculatively (see ADR 0003).\n\n## Types\n\n```go\ntype Node interface {\n\t// Type is the node's grammar type, e.g. \"function_declaration\",\n\t// \"jsx_element\", \"import_statement\".\n\tType() string\n\t// Text is the source slice this node spans.\n\tText() []byte\n\t// NamedChildCount / NamedChild iterate the named children (anonymous tokens\n\t// like punctuation are skipped).\n\tNamedChildCount() int\n\tNamedChild(i int) Node\n\t// ChildByField returns the child under a grammar field name (e.g. \"name\",\n\t// \"parameters\", \"body\"), or nil when absent.\n\tChildByField(name string) Node\n\t// StartLine is the 1-based line where the node begins, for findings.\n\tStartLine() int\n\t// StartByte and EndByte are the node's [start,end) byte range in the source.\n\t// Byte ranges power pattern-inside via containment (A is inside B when\n\t// B.StartByte \u003c= A.StartByte \u0026\u0026 A.EndByte \u003c= B.EndByte) and give findings a\n\t// precise location. They were chosen over a Parent() pointer because both\n\t// parsers expose them natively (gotreesitter directly; go/ast via Pos/End +\n\t// FileSet) whereas go/ast has no native parent — so this extension converges\n\t// cleanly across both parsers (ADR 0003).\n\tStartByte() int\n\tEndByte() int\n\t// HasError reports whether this node (or its subtree, for the root) contains\n\t// a syntax error — the runtime-level check for parse failures.\n\tHasError() bool\n}\n```\nNode is one node of a parsed file, exposed to the core in a parser-agnostic way. A language provider returns the root Node from its parse; the core walks the tree only through this interface.\n\nMinimal by design (ADR 0003): only what tree navigation needs now. No Parent() until the ruleengine's pattern-inside operator needs it (Prompt 1.2), so the interface is not shaped for a caller that does not yet exist.\n\n","path":"github.com/codefit-cli/codefit/internal/core/syntax","name":"syntax","synopsis":"Package syntax is codefit's parser-agnostic AST boundary.","isRedistributable":true}
