mapengine

package
v2.1.17 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedLanguage = errors.New("unsupported map language")

Functions

This section is empty.

Types

type Engine

type Engine string
const (
	EngineAuto       Engine = "auto"
	EngineGoAST      Engine = "go-ast"
	EngineRegex      Engine = "regex"
	EngineTreeSitter Engine = "tree-sitter"
)

type GoASTMapper

type GoASTMapper struct{}

func (GoASTMapper) Map

func (GoASTMapper) Map(path string, content []byte, opts Options) (Result, error)

type Kind

type Kind string
const (
	KindFunc    Kind = "func"
	KindType    Kind = "type"
	KindImport  Kind = "import"
	KindConst   Kind = "const"
	KindVar     Kind = "var"
	KindPackage Kind = "package"
	KindOther   Kind = "other"
)

type Level

type Level string
const (
	LevelCompact  Level = "compact"
	LevelMinimal  Level = "minimal"
	LevelOutline  Level = "outline"
	LevelStandard Level = "standard"
)

type Mapper

type Mapper interface {
	Map(path string, content []byte, opts Options) (Result, error)
}

type Options

type Options struct {
	Engine Engine
	Level  Level
	Kind   Kind
}

func NormalizeOptions

func NormalizeOptions(opts Options) Options

type RegexMapper

type RegexMapper struct{}

func (RegexMapper) Map

func (RegexMapper) Map(path string, content []byte, opts Options) (Result, error)

type Result

type Result struct {
	Symbols       []Symbol
	Lines         []string
	Engine        Engine
	Fallback      bool
	Warnings      []string
	OriginalChars int
	MappedChars   int
}

func Map

func Map(path string, content []byte, opts Options) (Result, error)

type Symbol

type Symbol struct {
	Kind      Kind
	Name      string
	Signature string
	Line      int
	EndLine   int
	Parent    string
	Doc       string
}

type TreeSitterLanguageConfig

type TreeSitterLanguageConfig struct {
	TagsQuery       func(grammars.LangEntry) string
	TagKinds        map[string]Kind
	Signature       func(string, []byte, gotreesitter.Range) string
	MergeRegex      bool
	MergeRegexKinds map[Kind]bool
	TokenSource     func([]byte, *gotreesitter.Language) gotreesitter.TokenSource
}

type TreeSitterMapper

type TreeSitterMapper struct {
	Languages map[string]TreeSitterLanguageConfig
}

func (TreeSitterMapper) Map

func (m TreeSitterMapper) Map(path string, content []byte, opts Options) (Result, error)

Jump to

Keyboard shortcuts

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