nesting

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NestingClassifier

type NestingClassifier interface {
	// IsNestingNode returns true if the given node introduces a new nesting level
	// (e.g. if, for, while, with, try blocks).
	IsNestingNode(node any) bool

	// Children returns the child nodes of the given node.
	Children(node any) []any

	// Location returns the line number of the given node.
	Location(node any) int
}

NestingClassifier abstracts the language-specific logic for determining which AST nodes introduce nesting levels. Language adapters implement this to classify their own node types.

type Result

type Result struct {
	MaxDepth    int
	DeepestLine int
}

Result holds the nesting depth analysis result.

func ComputeMaxDepth

func ComputeMaxDepth(root any, classifier NestingClassifier) *Result

ComputeMaxDepth computes the maximum nesting depth of the given AST tree. It uses the NestingClassifier to determine which nodes increase nesting depth.

Jump to

Keyboard shortcuts

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