grepast

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatRepoMapOutput

func FormatRepoMapOutput(files map[string][]int, rootPath string) (string, error)

FormatRepoMapOutput formats multiple files with their components in a repo map style

func RenderFileWithComponents

func RenderFileWithComponents(filePath string, rootPath string, componentLines []int) (string, error)

RenderFileWithComponents renders a file with highlighted components This is the main integration point with the repomap package

Types

type TreeContext

type TreeContext struct {
	Filename                 string
	Lines                    []string
	NumLines                 int
	Color                    bool
	Verbose                  bool
	LineNumber               bool
	ParentContext            bool
	ChildContext             bool
	LastLine                 bool
	Margin                   int
	MarkLOIs                 bool
	HeaderMax                int
	ShowTopOfFileParentScope bool
	LOIPad                   int

	// Internal state
	OutputLines      map[int]string
	Scopes           []map[int]bool // Which scopes is each line part of?
	Header           [][]any        // Which lines serve as header for each scope
	Nodes            [][]any        // Tree-sitter nodes associated with each line
	ShowLines        map[int]bool
	LinesOfInterest  map[int]bool
	DoneParentScopes map[int]bool
}

TreeContext represents the context around code structures in a file

func NewTreeContext

func NewTreeContext(
	filename string,
	code string,
	color bool,
	verbose bool,
	lineNumber bool,
	parentContext bool,
	childContext bool,
	lastLine bool,
	margin int,
	markLOIs bool,
	headerMax int,
	showTopOfFileParentScope bool,
	loiPad int,
) (*TreeContext, error)

NewTreeContext creates a new TreeContext for a file

func (*TreeContext) AddChildContext

func (tc *TreeContext) AddChildContext(line int)

AddChildContext adds the child context of a line to show lines This is a simplified implementation

func (*TreeContext) AddContext

func (tc *TreeContext) AddContext()

AddContext adds context around lines of interest

func (*TreeContext) AddLinesOfInterest

func (tc *TreeContext) AddLinesOfInterest(lineNums []int)

AddLinesOfInterest adds the provided line numbers to lines of interest

func (*TreeContext) AddParentScopes

func (tc *TreeContext) AddParentScopes(line int)

AddParentScopes adds the parent scopes of a given line to show lines

func (*TreeContext) CloseSmallGaps

func (tc *TreeContext) CloseSmallGaps()

CloseSmallGaps fills single-line gaps in the shown lines

func (*TreeContext) Format

func (tc *TreeContext) Format() string

Format produces the final formatted output with appropriate markers

func (*TreeContext) GetHeader

func (tc *TreeContext) GetHeader(line int) []int

GetHeader returns the header info for a line

func (*TreeContext) GetLastLineOfScope

func (tc *TreeContext) GetLastLineOfScope(line int) int

GetLastLineOfScope finds the last line of a scope

func (*TreeContext) Grep

func (tc *TreeContext) Grep(pattern string, ignoreCase bool) map[int]bool

Grep searches for pattern in the lines and marks matching lines as lines of interest

func (*TreeContext) WalkTree

func (tc *TreeContext) WalkTree(node *sitter.Node, depth int) (int, int)

WalkTree would simulate the tree walking functionality for identifying scopes In a real implementation, this would use tree-sitter to parse the code

Jump to

Keyboard shortcuts

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