feat: Add comprehensive Swift language detection support (#223)

* feat: Add comprehensive Swift language detection support

Add Swift language detection with 40+ patterns covering syntax, stdlib, frameworks, and idioms. Implement fork-friendly architecture with separate swift_patterns.py module and graceful import fallback.

Key changes:
- New swift_patterns.py: 40+ Swift detection patterns (SwiftUI, Combine, async/await, property wrappers, etc.)
- Enhanced language_detector.py: Graceful import handling, robust pattern compilation with error recovery
- Comprehensive test suite: 19 tests covering syntax, frameworks, edge cases, and error handling
- Updated .gitignore: Exclude Claude-specific config files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: Fix Swift pattern false positives and add comprehensive error handling

Critical Fixes (Priority 0):
- Fix 'some' and 'any' keyword false positives by requiring capitalized type names
- Use (?-i:[A-Z]) to enforce case-sensitivity despite global IGNORECASE flag
- Prevents "some random" from being detected as Swift code

Error Handling (Priority 1):
- Wrap pattern validation in try/except to prevent module import crashes
- Add SWIFT_PATTERNS verification with logging after import
- Gracefully degrade to empty dict on validation errors
- Add 7 comprehensive error handling tests

Improvements (Priority 2):
- Remove fragile line number references in comments
- Add 5 new tests for previously untested patterns:
  * Property observers (willSet/didSet)
  * Memory management (weak var, unowned, [weak self])
  * String interpolation

Test Results:
- All 92 tests passing (72 Swift + 20 language detection)
- Fixed regression: test_detect_unknown now passes
- 12 new tests added (7 error handling + 5 feature coverage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Edinho
2026-01-01 17:25:53 +01:00
committed by GitHub
parent e26ba876ae
commit 98d73611ad
4 changed files with 2088 additions and 4 deletions

File diff suppressed because it is too large Load Diff