Skip to content

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

Python
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-attributeinstance-attribute
Python
language_name = 'cpp'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.c', '.cc', '.cpp', '.cxx', '.c++', '.h', '.hh', '.hpp', '.hxx', '.h++']
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

Extract includes from C/C++ code.

Handles: - System includes: #include - Local includes: #include "myheader.h" - Conditional includes with #ifdef - Include guards

PARAMETERDESCRIPTION
content

C/C++ source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects representing includes

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

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.

PARAMETERDESCRIPTION
content

C/C++ source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of exported symbols

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

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

PARAMETERDESCRIPTION
content

C/C++ source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with extracted elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

Calculate complexity metrics for C/C++ code.

Calculates: - Cyclomatic complexity - Cognitive complexity - Preprocessor complexity - Template complexity - Memory management complexity

PARAMETERDESCRIPTION
content

C/C++ source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with calculated metrics

CSharpAnalyzer

Python
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-attributeinstance-attribute
Python
language_name = 'csharp'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.cs', '.csx']
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

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

PARAMETERDESCRIPTION
content

C# source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects with import details

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

Extract public members from C# code.

In C#, public members are accessible from other assemblies. This includes public classes, interfaces, structs, enums, delegates, etc.

PARAMETERDESCRIPTION
content

C# source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of exported (public) symbols

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

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

PARAMETERDESCRIPTION
content

C# source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with extracted elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

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

PARAMETERDESCRIPTION
content

C# source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with calculated metrics

CSSAnalyzer

Python
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-attributeinstance-attribute
Python
language_name = 'css'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.css', '.scss', '.sass', '.less', '.styl', '.stylus', '.pcss', '.postcss']
loggerinstance-attribute
Python
logger = get_logger(__name__)
tailwind_patternsinstance-attribute
Python
tailwind_patterns = _load_tailwind_patterns()
unocss_patternsinstance-attribute
Python
unocss_patterns = _load_unocss_patterns()
framework_patternsinstance-attribute
Python
framework_patterns = _load_framework_patterns()

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

Extract import statements from CSS.

Handles: - @import statements - @use (Sass) - @forward (Sass) - url() functions - CSS Modules composes

PARAMETERDESCRIPTION
content

CSS source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects with import details

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

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)

PARAMETERDESCRIPTION
content

CSS source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of exported elements

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

Extract CSS document structure.

Extracts: - Rules and selectors - Media queries - CSS architecture patterns - Framework usage - Design tokens - Component structure

PARAMETERDESCRIPTION
content

CSS source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with extracted elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

Calculate complexity metrics for CSS.

Calculates: - Selector complexity - Specificity metrics - Rule complexity - Nesting depth - Framework complexity - Performance score - Maintainability index

PARAMETERDESCRIPTION
content

CSS source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with calculated metrics

DartAnalyzer

Python
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-attributeinstance-attribute
Python
language_name = 'dart'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.dart']
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

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;

PARAMETERDESCRIPTION
content

Dart source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects with import details

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

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

PARAMETERDESCRIPTION
content

Dart source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of exported symbols

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

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

PARAMETERDESCRIPTION
content

Dart source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with extracted elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

Calculate complexity metrics for Dart code.

Calculates: - Cyclomatic complexity - Cognitive complexity - Null safety complexity - Async complexity - Flutter-specific complexity - Class hierarchy depth

PARAMETERDESCRIPTION
content

Dart source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with calculated metrics

GDScriptAnalyzer

Python
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-attributeinstance-attribute
Python
language_name = 'gdscript'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.gd', '.tres', '.tscn']
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

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

PARAMETERDESCRIPTION
content

GDScript source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects with import details

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

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)

PARAMETERDESCRIPTION
content

GDScript source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of exported symbols

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

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

PARAMETERDESCRIPTION
content

GDScript source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with extracted elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

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

PARAMETERDESCRIPTION
content

GDScript source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with calculated metrics

GenericAnalyzer

Python
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-attributeinstance-attribute
Python
language_name = 'generic'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = []
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

Extract potential imports/includes from generic text.

Looks for common import patterns across various languages and configuration files.

PARAMETERDESCRIPTION
content

File content

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects with detected imports

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

Extract potential exports from generic text.

Looks for common export patterns and definitions.

PARAMETERDESCRIPTION
content

File content

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of potential exported symbols

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

Extract basic structure from generic text.

Attempts to identify structural elements using pattern matching and indentation analysis.

PARAMETERDESCRIPTION
content

File content

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with detected elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

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

PARAMETERDESCRIPTION
content

File content

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with basic metrics

extract_context_relevant_sections
Python
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.

PARAMETERDESCRIPTION
content

File content

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

prompt_keywords

Keywords/phrases from the user's prompt

TYPE:List[str]

search_depth

How deep to search (1=direct, 2=semantic, 3=deep analysis)

TYPE:intDEFAULT:2

min_confidence

Minimum confidence threshold for relevance (0.0-1.0)

TYPE:floatDEFAULT:0.6

max_sections

Maximum number of contextual sections to preserve

TYPE:intDEFAULT:10

RETURNSDESCRIPTION
Dict[str, Any]

Dictionary containing relevant sections with metadata

GoAnalyzer

Python
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-attributeinstance-attribute
Python
language_name = 'go'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.go']
entry_pointsclass-attributeinstance-attribute
Python
entry_points = ['main.go', 'go.mod', 'go.sum', 'cmd/*/main.go']
project_indicatorsclass-attributeinstance-attribute
Python
project_indicators = {'module': ['go.mod', 'go.sum'], 'cli': ['cmd/', 'main.go'], 'library': ['lib.go', 'pkg/']}
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

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

PARAMETERDESCRIPTION
content

Go source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[ImportInfo]

List of ImportInfo objects with import details

extract_exports
Python
extract_exports(content: str, file_path: Path) -> List[Dict[str, Any]]

Extract exported symbols from Go code.

In Go, exported identifiers start with an uppercase letter. This includes functions, types, constants, and variables.

PARAMETERDESCRIPTION
content

Go source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of exported symbols with metadata

extract_structure
Python
extract_structure(content: str, file_path: Path) -> CodeStructure

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

PARAMETERDESCRIPTION
content

Go source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
CodeStructure

CodeStructure object with extracted elements

calculate_complexity
Python
calculate_complexity(content: str, file_path: Path) -> ComplexityMetrics

Calculate complexity metrics for Go code.

Calculates: - Cyclomatic complexity - Cognitive complexity - Error handling complexity - Concurrency complexity - Test coverage indicators

PARAMETERDESCRIPTION
content

Go source code

TYPE:str

file_path

Path to the file being analyzed

TYPE:Path

RETURNSDESCRIPTION
ComplexityMetrics

ComplexityMetrics object with calculated metrics

HTMLAnalyzer

Python
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.

Attributes

language_nameclass-attributeinstance-attribute
Python
language_name = 'html'
file_extensionsclass-attributeinstance-attribute
Python
file_extensions = ['.html', '.htm', '.xhtml', '.vue', '.jsx', '.tsx']
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

extract_imports
Python
extract_imports(content: str, file_path: Path) -> List[ImportInfo]

Extract external resource imports from HTML.

Handles: - tags for CSS -