sourcecode

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sourcecode parses source files into deterministic structural metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Path      string
	Language  Language
	Package   string
	Imports   []Import
	Symbols   []Symbol
	Generated bool
}

File is a parsed source file structure suitable for maps, retrieval, and chunking.

type GoParser

type GoParser struct{}

GoParser parses Go files using the standard library parser and AST.

func (GoParser) Parse

func (GoParser) Parse(path string, src []byte) (File, error)

Parse returns deterministic structure for one Go source file.

type Import

type Import struct {
	Name string
	Path string
}

Import describes one source import/dependency declaration.

type Language

type Language string

Language identifies the parser/language used for a source file.

const (
	LanguageGo Language = "go"
)

Supported source languages.

type Parser

type Parser interface {
	Parse(path string, src []byte) (File, error)
}

Parser parses a source file into structural metadata.

type Symbol

type Symbol struct {
	Kind        SymbolKind
	Name        string
	Receiver    string
	Signature   string
	StartLine   int
	EndLine     int
	StartOffset int
	EndOffset   int
}

Symbol is a deterministic top-level source declaration range.

type SymbolKind

type SymbolKind string

SymbolKind identifies the structural kind of a parsed symbol.

const (
	SymbolKindConst     SymbolKind = "const"
	SymbolKindVar       SymbolKind = "var"
	SymbolKindType      SymbolKind = "type"
	SymbolKindTypeAlias SymbolKind = "type_alias"
	SymbolKindStruct    SymbolKind = "struct"
	SymbolKindInterface SymbolKind = "interface"
	SymbolKindFunc      SymbolKind = "func"
	SymbolKindMethod    SymbolKind = "method"
)

Supported symbol kinds.

func (SymbolKind) IsType

func (k SymbolKind) IsType() bool

IsType reports whether k is any named type declaration shape.

Jump to

Keyboard shortcuts

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