parse

package
v0.0.0-...-78728ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package parse extracts symbol-level spans (functions, methods, types) from source files so the chunker can build embeddable chunks.

Language strategy (matches CKG's parse package):

  • Go: go/parser + go/ast (stdlib, no CGO)
  • TypeScript / JavaScript: tree-sitter
  • Solidity: tree-sitter

Each parser turns one file into []SymbolSpan. The chunker then produces Chunks (with optional long-function splits) from those spans.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser interface {
	// Language returns the CKV language tag this parser handles
	// ("go" | "typescript" | "solidity" | "markdown").
	Language() string
	// Parse takes the full source text and returns the symbol spans
	// found within. The file argument is informational (used in
	// errors); the parser does not read from disk.
	Parse(file string, src []byte) ([]SymbolSpan, error)
}

Parser is the contract every per-language parser fulfills.

type SymbolSpan

type SymbolSpan struct {
	Name      string           // qualified name when known (e.g. "Server.handleEdges")
	Kind      types.SymbolKind // KindFunction, KindMethod, ...
	StartLine int
	EndLine   int
	Text      string // raw source for this span (signature + body)
}

SymbolSpan is one indexable region of a source file. Line numbers are 1-based and inclusive on both ends.

Directories

Path Synopsis
Package fuzzcheck provides shared invariant checks for parser fuzz tests.
Package fuzzcheck provides shared invariant checks for parser fuzz tests.
Package golang parses Go source via the stdlib go/parser+go/ast.
Package golang parses Go source via the stdlib go/parser+go/ast.
Package javascript parses .js / .jsx / .mjs / .cjs source files.
Package javascript parses .js / .jsx / .mjs / .cjs source files.
Package markdown parses *.md / *.markdown files into heading-level SymbolSpans so docs/ADR content becomes searchable alongside source code.
Package markdown parses *.md / *.markdown files into heading-level SymbolSpans so docs/ADR content becomes searchable alongside source code.
Package prdoc parses PR descriptions and commit messages into chunks for the PR corpus index.
Package prdoc parses PR descriptions and commit messages into chunks for the PR corpus index.
Package solidity parses .sol via the vendored tree-sitter-solidity grammar (see internal/parse/solidity/binding).
Package solidity parses .sol via the vendored tree-sitter-solidity grammar (see internal/parse/solidity/binding).
binding
Package binding wraps tree-sitter-solidity (vendored from github.com/JoranHonig/tree-sitter-solidity v1.2.13, MIT-licensed — see ./LICENSE) into a *sitter.Language for go-tree-sitter.
Package binding wraps tree-sitter-solidity (vendored from github.com/JoranHonig/tree-sitter-solidity v1.2.13, MIT-licensed — see ./LICENSE) into a *sitter.Language for go-tree-sitter.
Package typescript parses .ts and .tsx source via tree-sitter.
Package typescript parses .ts and .tsx source via tree-sitter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL