ast

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBreakingChangeReport

func FormatBreakingChangeReport(report *BreakingChangeReport) string

FormatBreakingChangeReport generates a formatted report for PR comments

func FormatImpactReport

func FormatImpactReport(impact *FileImpact) string

FormatImpactReport generates a human-readable impact report

func IsBreaking

func IsBreaking(report *BreakingChangeReport) bool

IsBreaking returns true if the change is a breaking change (not just a warning)

Types

type BreakingChange

type BreakingChange struct {
	Type        BreakingChangeType `json:"type"`
	Symbol      Symbol             `json:"symbol"`
	OldValue    string             `json:"old_value,omitempty"`
	NewValue    string             `json:"new_value,omitempty"`
	FilePath    string             `json:"file_path"`
	Line        int                `json:"line"`
	Severity    string             `json:"severity"` // "warning", "error", "critical"
	Description string             `json:"description"`
	Suggestion  string             `json:"suggestion,omitempty"`
}

BreakingChange represents a single breaking change

func GetBreakingChanges

func GetBreakingChanges(report *BreakingChangeReport) []BreakingChange

GetBreakingChanges returns only the breaking changes (critical and error)

type BreakingChangeDetector

type BreakingChangeDetector struct {
	// contains filtered or unexported fields
}

BreakingChangeDetector detects breaking API changes

func NewBreakingChangeDetector

func NewBreakingChangeDetector() *BreakingChangeDetector

NewBreakingChangeDetector creates a new breaking change detector

func (*BreakingChangeDetector) DetectBreakingChanges

func (d *BreakingChangeDetector) DetectBreakingChanges(oldContent, newContent, filename string) (*BreakingChangeReport, error)

DetectBreakingChanges compares old and new code to find breaking changes

type BreakingChangeReport

type BreakingChangeReport struct {
	FileName      string           `json:"file_name"`
	TotalChanges  int              `json:"total_changes"`
	CriticalCount int              `json:"critical_count"`
	ErrorCount    int              `json:"error_count"`
	WarningCount  int              `json:"warning_count"`
	Changes       []BreakingChange `json:"changes"`
	Summary       string           `json:"summary"`
	HasBreaking   bool             `json:"has_breaking"`
}

BreakingChangeReport contains all detected breaking changes

type BreakingChangeType

type BreakingChangeType string

BreakingChangeType represents different types of breaking changes

const (
	BreakingRemoval           BreakingChangeType = "removal"
	BreakingSignatureChange   BreakingChangeType = "signature_change"
	BreakingTypeChange        BreakingChangeType = "type_change"
	BreakingVisibilityChange  BreakingChangeType = "visibility_change"
	BreakingParameterChange   BreakingChangeType = "parameter_change"
	BreakingReturnTypeChange  BreakingChangeType = "return_type_change"
	BreakingRequiredParameter BreakingChangeType = "required_parameter"
	BreakingBehaviorChange    BreakingChangeType = "behavior_change"
)

type FileImpact

type FileImpact struct {
	FilePath        string   `json:"file_path"`
	ChangedSymbols  []Symbol `json:"changed_symbols"`
	Impacts         []Impact `json:"impacts"`
	TotalReferences int      `json:"total_references"`
	AffectedFiles   []string `json:"affected_files"`
	OverallSeverity string   `json:"overall_severity"`
}

FileImpact represents the impact analysis for a changed file

type Impact

type Impact struct {
	ChangedSymbol   Symbol      `json:"changed_symbol"`
	AffectedFiles   []string    `json:"affected_files"`
	AffectedSymbols []Symbol    `json:"affected_symbols"`
	References      []Reference `json:"references"`
	Severity        string      `json:"severity"` // "low", "medium", "high", "critical"
	Description     string      `json:"description"`
}

Impact represents the impact of changing a symbol

type ImpactAnalyzer

type ImpactAnalyzer struct {
	// contains filtered or unexported fields
}

ImpactAnalyzer analyzes cross-file impact of code changes

func NewImpactAnalyzer

func NewImpactAnalyzer() *ImpactAnalyzer

NewImpactAnalyzer creates a new impact analyzer

func (*ImpactAnalyzer) AnalyzeImpact

func (a *ImpactAnalyzer) AnalyzeImpact(oldContent, newContent, filename string) (*FileImpact, error)

AnalyzeImpact analyzes the impact of changes in a diff

func (*ImpactAnalyzer) FindSymbol

func (a *ImpactAnalyzer) FindSymbol(name string) []Symbol

FindSymbol finds a symbol by name

func (*ImpactAnalyzer) GetDependents

func (a *ImpactAnalyzer) GetDependents(filename string) []string

GetDependents returns files that depend on the given file

func (*ImpactAnalyzer) GetSymbolReferences

func (a *ImpactAnalyzer) GetSymbolReferences(symbolName string) []Reference

GetSymbolReferences returns all references to a symbol

func (*ImpactAnalyzer) GetSymbolsInFile

func (a *ImpactAnalyzer) GetSymbolsInFile(filename string) []Symbol

GetSymbolsInFile returns all symbols in a file

func (*ImpactAnalyzer) IndexFile

func (a *ImpactAnalyzer) IndexFile(filename string, content string) error

IndexFile adds a file to the symbol table

type Language

type Language string

Language represents a supported programming language

const (
	LangGo         Language = "go"
	LangTypeScript Language = "typescript"
	LangJavaScript Language = "javascript"
	LangPython     Language = "python"
	LangRust       Language = "rust"
	LangJava       Language = "java"
	LangUnknown    Language = "unknown"
)

func DetectLanguage

func DetectLanguage(filename string) Language

DetectLanguage determines the language from file extension

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser extracts symbols from source code

func NewParser

func NewParser() *Parser

NewParser creates a new AST parser

func (*Parser) GetLanguageFromFilename

func (p *Parser) GetLanguageFromFilename(filename string) string

GetLanguageFromFilename returns the language name as a string

func (*Parser) ParseFile

func (p *Parser) ParseFile(filename string, content string) ([]Symbol, error)

ParseFile extracts symbols from a file

type Reference

type Reference struct {
	FilePath string `json:"file_path"`
	Line     int    `json:"line"`
	Context  string `json:"context"` // The line content
}

Reference represents a reference to a symbol

type Symbol

type Symbol struct {
	Name       string     `json:"name"`
	Kind       SymbolKind `json:"kind"`
	StartLine  int        `json:"start_line"`
	EndLine    int        `json:"end_line"`
	Signature  string     `json:"signature,omitempty"`
	Exported   bool       `json:"exported"`
	Parameters []string   `json:"parameters,omitempty"`
	ReturnType string     `json:"return_type,omitempty"`
	Parent     string     `json:"parent,omitempty"` // For methods: the receiver type
	FilePath   string     `json:"file_path"`
}

Symbol represents a code symbol (function, class, variable, etc.)

type SymbolKind

type SymbolKind string

SymbolKind represents the type of symbol

const (
	SymbolFunction  SymbolKind = "function"
	SymbolMethod    SymbolKind = "method"
	SymbolClass     SymbolKind = "class"
	SymbolInterface SymbolKind = "interface"
	SymbolStruct    SymbolKind = "struct"
	SymbolVariable  SymbolKind = "variable"
	SymbolConstant  SymbolKind = "constant"
	SymbolType      SymbolKind = "type"
	SymbolImport    SymbolKind = "import"
)

type SymbolTable

type SymbolTable struct {
	Symbols    map[string][]Symbol    // symbol name -> symbols (can have multiple with same name)
	ByFile     map[string][]Symbol    // file path -> symbols in that file
	References map[string][]Reference // symbol name -> references to it
}

SymbolTable stores all symbols across the codebase

Jump to

Keyboard shortcuts

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