Skip to main content

Module ast

Module ast 

Source
Expand description

AST representation and pattern extraction data structures.

This module provides language-agnostic AST representations and specialized structures for pattern detection in different programming languages.

§Design Pattern Extraction

The module supports extracting design patterns from source code:

  • Class hierarchies with inheritance and decorators
  • Method definitions with abstract/override tracking
  • Module-level singleton instances
  • Assignment and expression analysis

§Example

use debtmap::core::ast::{ClassDef, ModuleScopeAnalysis};

// Extract classes from Python AST
let classes: Vec<ClassDef> = extractor.extract_classes(&module);

// Analyze module scope for singletons
let scope: ModuleScopeAnalysis = extractor.extract_module_scope(&module);

§Performance Considerations

Pattern extraction is designed to add minimal overhead (< 5%) to existing parsing operations by extracting data during the single-pass AST traversal.

Structs§

Assignment
AstNode
ClassDef
Represents a class definition with its metadata.
GoAst
Go AST wrapper
MethodDef
Represents a method definition within a class.
ModuleScopeAnalysis
Analysis of module-level scope for pattern detection.
PythonAst
Python AST wrapper
RustAst
SingletonInstance
SolidityAst
Solidity AST wrapper
TypeScriptAst
TypeScript/JavaScript AST wrapper

Enums§

Ast
Expression
JsLanguageVariant
JavaScript/TypeScript language variant
NodeKind
Scope

Functions§

combine_asts
filter_ast