parser

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package parser extracts symbols from Go source files using go/packages for type-checked parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileResult

type FileResult struct {
	Path    string
	Package string
	Symbols []Symbol
}

FileResult holds parsed symbols for a single file.

type ParseResult

type ParseResult struct {
	Files []FileResult
}

ParseResult holds results for all parsed files.

func Parse

func Parse(ctx context.Context, dir string, patterns []string) (*ParseResult, error)

Parse loads Go packages from dir matching the given patterns and extracts symbols from every source file. The patterns argument uses Go package patterns (e.g., "./..." to load all packages under dir).

type Symbol

type Symbol struct {
	Name       string // identifier name
	Kind       string // "func", "method", "struct", "interface", "const", "var"
	Package    string // package name (e.g., "foo")
	Receiver   string // for methods only (e.g., "*MyStruct")
	Signature  string // full signature line
	DocComment string // doc comment text
	Body       string // source body text
	LineStart  int    // first line number
	LineEnd    int    // last line number
	FilePath   string // absolute file path
}

Symbol represents a single Go declaration extracted from source.

Jump to

Keyboard shortcuts

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