tenets.core.analysis.implementations
Package¶
Language-specific code analyzers.
This package contains implementations of language analyzers for various programming languages. Each analyzer provides language-specific parsing and analysis capabilities.
Available analyzers: - PythonAnalyzer: Python code analysis with AST parsing - JavaScriptAnalyzer: JavaScript/TypeScript analysis - JavaAnalyzer: Java code analysis - GoAnalyzer: Go language analysis - RustAnalyzer: Rust code analysis - CppAnalyzer: C/C++ code analysis - CSharpAnalyzer: C# code analysis - SwiftAnalyzer: Swift code analysis - RubyAnalyzer: Ruby code analysis - PhpAnalyzer: PHP code analysis - KotlinAnalyzer: Kotlin code analysis - ScalaAnalyzer: Scala code analysis - DartAnalyzer: Dart code analysis - GDScriptAnalyzer: GDScript (Godot) analysis - HTMLAnalyzer: HTML markup analysis - CSSAnalyzer: CSS stylesheet analysis - GenericAnalyzer: Fallback for unsupported languages
Classes¶
CppAnalyzer¶
Bases: LanguageAnalyzer
C/C++ code analyzer.
Provides analysis for C and C++ files including: - Include directive analysis (system and local) - Class, struct, and union extraction - Template analysis - Function and method extraction - Namespace handling - Macro and preprocessor directive analysis - Modern C++ features (auto, lambdas, smart pointers) - STL usage detection - Memory management patterns
Supports both C and C++ with appropriate feature detection.
Initialize the C++ analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
Functions¶
extract_imports¶
Extract includes from C/C++ code.
Handles: - System includes: #include
PARAMETER | DESCRIPTION |
---|---|
content | C/C++ source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects representing includes |
extract_exports¶
Extract exported symbols from C/C++ code.
In C/C++, symbols are exported by default unless static. For headers, we extract declarations. For source files, we extract non-static definitions.
PARAMETER | DESCRIPTION |
---|---|
content | C/C++ source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[Dict[str, Any]] | List of exported symbols |
extract_structure¶
Extract code structure from C/C++ file.
Extracts: - Namespaces - Classes and structs with inheritance - Functions and methods - Templates - Macros and preprocessor directives - Global variables - Operator overloads
PARAMETER | DESCRIPTION |
---|---|
content | C/C++ source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with extracted elements |
calculate_complexity¶
Calculate complexity metrics for C/C++ code.
Calculates: - Cyclomatic complexity - Cognitive complexity - Preprocessor complexity - Template complexity - Memory management complexity
PARAMETER | DESCRIPTION |
---|---|
content | C/C++ source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with calculated metrics |
CSharpAnalyzer¶
Bases: LanguageAnalyzer
C# code analyzer with Unity3D support.
Provides comprehensive analysis for C# files including: - Using directives and namespace analysis - Class, interface, struct, enum, and record extraction - Property and event analysis - Async/await and Task-based patterns - LINQ query detection - Attribute processing - Unity3D specific patterns (MonoBehaviour, Coroutines, etc.) - .NET Framework/Core detection - Nullable reference types (C# 8+) - Pattern matching (C# 7+)
Supports modern C# features and Unity3D development patterns.
Initialize the C# analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
Functions¶
extract_imports¶
Extract using directives from C# code.
Handles: - using statements: using System.Collections.Generic; - using static: using static System.Math; - using aliases: using Project = PC.MyCompany.Project; - global using (C# 10+): global using System.Text; - Unity-specific usings
PARAMETER | DESCRIPTION |
---|---|
content | C# source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects with import details |
extract_exports¶
Extract public members from C# code.
In C#, public members are accessible from other assemblies. This includes public classes, interfaces, structs, enums, delegates, etc.
PARAMETER | DESCRIPTION |
---|---|
content | C# source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[Dict[str, Any]] | List of exported (public) symbols |
extract_structure¶
Extract code structure from C# file.
Extracts: - Namespace declarations - Classes with inheritance and interfaces - Properties with getters/setters - Methods including async methods - Events and delegates - Unity-specific components (MonoBehaviours, Coroutines) - LINQ queries - Attributes
PARAMETER | DESCRIPTION |
---|---|
content | C# source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with extracted elements |
calculate_complexity¶
Calculate complexity metrics for C# code.
Calculates: - Cyclomatic complexity - Cognitive complexity - Unity-specific complexity (Coroutines, Update methods) - Async/await complexity - LINQ complexity - Exception handling complexity
PARAMETER | DESCRIPTION |
---|---|
content | C# source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with calculated metrics |
CSSAnalyzer¶
Bases: LanguageAnalyzer
CSS code analyzer with preprocessor and framework support.
Provides comprehensive analysis for CSS files including: - CSS3 features and properties - SCSS/Sass preprocessor features - Less preprocessor features - PostCSS plugins and features - Tailwind CSS utility classes - UnoCSS atomic CSS - CSS-in-JS patterns - CSS Modules - BEM, OOCSS, SMACSS methodologies - Performance metrics - Browser compatibility - Accessibility considerations - Design system patterns
Supports modern CSS development practices and frameworks.
Initialize the CSS analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
tailwind_patternsinstance-attribute
¶
unocss_patternsinstance-attribute
¶
framework_patternsinstance-attribute
¶
Functions¶
extract_imports¶
Extract import statements from CSS.
Handles: - @import statements - @use (Sass) - @forward (Sass) - url() functions - CSS Modules composes
PARAMETER | DESCRIPTION |
---|---|
content | CSS source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects with import details |
extract_exports¶
Extract exported elements from CSS.
In CSS context, exports are: - Classes that can be used by HTML - IDs - Custom properties (CSS variables) - Mixins (SCSS/Less) - Functions (SCSS) - Keyframe animations - Utility classes (Tailwind/UnoCSS)
PARAMETER | DESCRIPTION |
---|---|
content | CSS source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[Dict[str, Any]] | List of exported elements |
extract_structure¶
Extract CSS document structure.
Extracts: - Rules and selectors - Media queries - CSS architecture patterns - Framework usage - Design tokens - Component structure
PARAMETER | DESCRIPTION |
---|---|
content | CSS source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with extracted elements |
calculate_complexity¶
Calculate complexity metrics for CSS.
Calculates: - Selector complexity - Specificity metrics - Rule complexity - Nesting depth - Framework complexity - Performance score - Maintainability index
PARAMETER | DESCRIPTION |
---|---|
content | CSS source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with calculated metrics |
DartAnalyzer¶
Bases: LanguageAnalyzer
Dart code analyzer with Flutter support.
Provides comprehensive analysis for Dart files including: - Import and export directives - Part and library declarations - Classes with mixins and extensions - Null safety features (?, !, late) - Async/await, Future, and Stream handling - Flutter widgets and lifecycle methods - Factory and named constructors - Extension methods - Annotations and metadata - Generics and type parameters
Supports Dart 2.x with null safety and Flutter framework patterns.
Initialize the Dart analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
Functions¶
extract_imports¶
Extract import, export, part, and library directives from Dart code.
Handles: - import statements: import 'package:flutter/material.dart'; - export statements: export 'src/widget.dart'; - part statements: part 'implementation.dart'; - part of statements: part of 'library.dart'; - library declarations: library my_library; - Conditional imports: import 'stub.dart' if (dart.library.io) 'io.dart'; - Show/hide clauses: import 'dart:math' show Random hide PI; - Deferred imports: import 'big_lib.dart' deferred as big;
PARAMETER | DESCRIPTION |
---|---|
content | Dart source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects with import details |
extract_exports¶
Extract exported symbols from Dart code.
In Dart, exports include: - Public classes (not prefixed with _) - Public functions - Public variables and constants - Public typedefs - Public enums - Extension methods
PARAMETER | DESCRIPTION |
---|---|
content | Dart source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[Dict[str, Any]] | List of exported symbols |
extract_structure¶
Extract code structure from Dart file.
Extracts: - Classes with inheritance, mixins, and interfaces - Constructors (default, named, factory) - Methods and getters/setters - Flutter widgets and lifecycle methods - Async functions and streams - Extension methods - Null safety features - Annotations
PARAMETER | DESCRIPTION |
---|---|
content | Dart source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with extracted elements |
calculate_complexity¶
Calculate complexity metrics for Dart code.
Calculates: - Cyclomatic complexity - Cognitive complexity - Null safety complexity - Async complexity - Flutter-specific complexity - Class hierarchy depth
PARAMETER | DESCRIPTION |
---|---|
content | Dart source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with calculated metrics |
GDScriptAnalyzer¶
Bases: LanguageAnalyzer
GDScript code analyzer for Godot development.
Provides comprehensive analysis for GDScript files including: - Preload and load statements - Class inheritance (extends) - Signal declarations and connections - Export variable declarations - Onready variables and node references - Godot lifecycle methods (_ready, _process, etc.) - Tool scripts and custom resources - Typed GDScript (static typing) - Inner classes - Setget properties - Remote and master/puppet keywords (networking)
Supports Godot 3.x and 4.x GDScript syntax.
Initialize the GDScript analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
Functions¶
extract_imports¶
Extract preload, load, and class references from GDScript code.
Handles: - preload statements: preload("res://path/to/script.gd") - load statements: load("res://path/to/resource.tres") - const preloads: const MyClass = preload("res://MyClass.gd") - class_name declarations (Godot 3.1+) - Tool script declarations
PARAMETER | DESCRIPTION |
---|---|
content | GDScript source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects with import details |
extract_exports¶
Extract exported symbols from GDScript code.
In GDScript, exports include: - class_name declarations (global classes) - export variables - signals - Public functions (by convention, non-underscore prefixed)
PARAMETER | DESCRIPTION |
---|---|
content | GDScript source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[Dict[str, Any]] | List of exported symbols |
extract_structure¶
Extract code structure from GDScript file.
Extracts: - Class inheritance and structure - Inner classes - Functions with type hints - Godot lifecycle methods - Signals and their connections - Export variables - Onready variables - Node references - Setget properties - Enums and constants
PARAMETER | DESCRIPTION |
---|---|
content | GDScript source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with extracted elements |
calculate_complexity¶
Calculate complexity metrics for GDScript code.
Calculates: - Cyclomatic complexity - Cognitive complexity - Godot-specific complexity (signals, exports, node references) - Nesting depth - Function count and complexity distribution
PARAMETER | DESCRIPTION |
---|---|
content | GDScript source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with calculated metrics |
GenericAnalyzer¶
Bases: LanguageAnalyzer
Generic analyzer for unsupported file types.
Provides basic analysis for text-based files including: - Line and character counting - Basic pattern matching for imports/includes - Simple complexity estimation - Keyword extraction - Configuration file parsing (JSON, YAML, XML, etc.)
This analyzer serves as a fallback for files without specific language support and can handle various text formats.
Initialize the generic analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
Functions¶
extract_imports¶
Extract potential imports/includes from generic text.
Looks for common import patterns across various languages and configuration files.
PARAMETER | DESCRIPTION |
---|---|
content | File content TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects with detected imports |
extract_exports¶
extract_structure¶
Extract basic structure from generic text.
Attempts to identify structural elements using pattern matching and indentation analysis.
PARAMETER | DESCRIPTION |
---|---|
content | File content TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with detected elements |
calculate_complexity¶
Calculate basic complexity metrics for generic text.
Provides simplified complexity estimation based on: - Line count and length - Nesting depth (indentation/braces) - Decision keywords - File type specific metrics
PARAMETER | DESCRIPTION |
---|---|
content | File content TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with basic metrics |
extract_context_relevant_sections¶
extract_context_relevant_sections(content: str, file_path: Path, prompt_keywords: List[str], search_depth: int = 2, min_confidence: float = 0.6, max_sections: int = 10) -> Dict[str, Any]
Extract sections of documentation that reference prompt keywords/concepts.
This method identifies and extracts the most relevant parts of documentation files based on direct references and semantic similarity to prompt keywords.
PARAMETER | DESCRIPTION |
---|---|
content | File content TYPE: |
file_path | Path to the file being analyzed TYPE: |
prompt_keywords | Keywords/phrases from the user's prompt |
search_depth | How deep to search (1=direct, 2=semantic, 3=deep analysis) TYPE: |
min_confidence | Minimum confidence threshold for relevance (0.0-1.0) TYPE: |
max_sections | Maximum number of contextual sections to preserve TYPE: |
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any] | Dictionary containing relevant sections with metadata |
GoAnalyzer¶
Bases: LanguageAnalyzer
Go code analyzer.
Provides comprehensive analysis for Go files including: - Import analysis with vendored and internal imports - Function, method and interface extraction - Struct analysis with embedded types - Goroutine and channel detection - Error handling patterns - Defer statement tracking - Package-level analysis - Go module support
Go's export mechanism is based on capitalization - identifiers starting with uppercase letters are exported.
Initialize the Go analyzer with logger.
Attributes¶
language_nameclass-attribute
instance-attribute
¶
file_extensionsclass-attribute
instance-attribute
¶
entry_pointsclass-attribute
instance-attribute
¶
project_indicatorsclass-attribute
instance-attribute
¶
loggerinstance-attribute
¶
Functions¶
extract_imports¶
Extract imports from Go code.
Handles: - Single imports: import "fmt" - Grouped imports: import ( "fmt" "strings" ) - Aliased imports: import f "fmt" - Dot imports: import . "fmt" - Blank imports: import _ "database/sql" - Vendored imports - Internal packages
PARAMETER | DESCRIPTION |
---|---|
content | Go source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[ImportInfo] | List of ImportInfo objects with import details |
extract_exports¶
Extract exported symbols from Go code.
In Go, exported identifiers start with an uppercase letter. This includes functions, types, constants, and variables.
PARAMETER | DESCRIPTION |
---|---|
content | Go source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
List[Dict[str, Any]] | List of exported symbols with metadata |
extract_structure¶
Extract code structure from Go file.
Extracts: - Package declaration - Functions and methods - Structs (treated as classes) - Interfaces - Type aliases - Constants and variables - Goroutines and channels - Init functions
PARAMETER | DESCRIPTION |
---|---|
content | Go source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
CodeStructure | CodeStructure object with extracted elements |
calculate_complexity¶
Calculate complexity metrics for Go code.
Calculates: - Cyclomatic complexity - Cognitive complexity - Error handling complexity - Concurrency complexity - Test coverage indicators
PARAMETER | DESCRIPTION |
---|---|
content | Go source code TYPE: |
file_path | Path to the file being analyzed TYPE: |
RETURNS | DESCRIPTION |
---|---|
ComplexityMetrics | ComplexityMetrics object with calculated metrics |
HTMLAnalyzer¶
Bases: LanguageAnalyzer
HTML code analyzer with modern web framework support.
Provides comprehensive analysis for HTML files including: - HTML5 semantic elements - CSS and JavaScript imports - Meta tags and SEO elements - Forms and input validation - Accessibility features (ARIA, alt text, etc.) - Web components and custom elements - Framework-specific patterns (React, Vue, Angular) - Microdata and structured data - DOM complexity and nesting depth - Performance hints (lazy loading, async/defer scripts) - Security considerations (CSP, integrity checks)
Supports HTML5 and modern web development practices.
Initialize the HTML analyzer with logger.