feat: add Kotlin language support for codebase analysis (#287)
Adds full C3.x pipeline support for Kotlin (.kt, .kts): - Language detection patterns (40+ weighted patterns for data/sealed classes, coroutines, companion objects, KMP, etc.) - AST regex parser in code_analyzer.py (classes, objects, functions, extension functions, suspend functions) - Dependency extraction for Kotlin import statements (with alias support) - Design pattern adaptations (object→Singleton, companion→Factory, sealed→Strategy, data→Builder, Flow→Observer) - Test example extraction for JUnit 4/5, Kotest, MockK, Spek - Config detection for build.gradle.kts / settings.gradle.kts - Extension maps registered in codebase_scraper, unified_codebase_analyzer, github_scraper, generate_router Also fixes pre-existing parser count tests (35→36 for doctor command added in previous commit). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -678,6 +678,18 @@ class GenericTestAnalyzer:
|
||||
"assertion": r"assert(?:Equals|True|False|NotNull)\(([^)]+)\)",
|
||||
"test_function": r"@Test\s+public\s+void\s+(\w+)\(\)",
|
||||
},
|
||||
"kotlin": {
|
||||
# Object instantiation: val x = Foo(args) or val x: Type = Foo(args)
|
||||
"instantiation": r"(?:val|var)\s+(\w+)(?:\s*:\s*[\w<>.,\s?]+)?\s*=\s*(\w+)\(([^)]*)\)",
|
||||
# JUnit assertions + Kotest matchers
|
||||
"assertion": r"(?:assert(?:Equals|True|False|NotNull|That)\(([^)]+)\)|(\w+)\s+should(?:Be|Equal|Match|Have|Contain|Throw)\b)",
|
||||
# JUnit @Test, Kotest test functions, Spek describe/it
|
||||
"test_function": r"(?:@Test\s+fun\s+(\w+)\s*\(|fun\s+[\"']([^\"']+)[\"']\s*\(|(?:test|it|should)\s*\(\s*[\"']([^\"']+)[\"'])",
|
||||
# MockK mocking patterns
|
||||
"mock": r"(?:mockk<([\w<>]+)>\s*\(|every\s*\{\s*(\w+)\.(\w+)|verify\s*\{)",
|
||||
# Coroutine test patterns
|
||||
"coroutine_test": r"(?:runTest\s*\{|runBlocking\s*\{|testCoroutineDispatcher)",
|
||||
},
|
||||
"csharp": {
|
||||
# Object instantiation patterns (var, explicit type, generic)
|
||||
"instantiation": r"(?:var|[\w<>]+)\s+(\w+)\s*=\s*new\s+([\w<>]+)\(([^)]*)\)",
|
||||
@@ -929,6 +941,9 @@ class TestExampleExtractor:
|
||||
"*_test.go",
|
||||
"*_test.rs",
|
||||
"Test*.java",
|
||||
"*Test.kt",
|
||||
"Test*.kt",
|
||||
"*Spec.kt", # Kotest/Spek naming convention
|
||||
"Test*.cs",
|
||||
"*Test.php",
|
||||
"*_spec.rb",
|
||||
@@ -944,6 +959,8 @@ class TestExampleExtractor:
|
||||
".go": "Go",
|
||||
".rs": "Rust",
|
||||
".java": "Java",
|
||||
".kt": "Kotlin",
|
||||
".kts": "Kotlin",
|
||||
".cs": "C#",
|
||||
".php": "PHP",
|
||||
".rb": "Ruby",
|
||||
|
||||
Reference in New Issue
Block a user