Skip to content

feat: comprehensive Android/Kotlin/XML support improvements#1

Closed
hossihub wants to merge 27 commits intomainfrom
dev
Closed

feat: comprehensive Android/Kotlin/XML support improvements#1
hossihub wants to merge 27 commits intomainfrom
dev

Conversation

@hossihub
Copy link
Copy Markdown
Owner

Summary

  • Add deep extraction for Android patterns: Room DB, Hilt DI, resource refs, XML
  • Fix code review findings: double extraction, FK brace-counting, provider-to-module attribution, regex hoisting, UTF-8 error handling, explicit re-exports

Changes

New extractors:

  • android_room.rs — Room entities, DAOs, databases, foreign keys, DAO queries
  • android_hilt.rs — Hilt modules, providers (correctly attributed via body spans), injection tracking
  • android_resource_refs.rsR.string/drawable/layout/etc reference tracking
  • xml_generic.rs — Generic XML file handling

Enhanced:

  • android_manifest.rs — intent filters, metadata, application class extraction
  • mod.rs — Kotlin files now run Room/Hilt/resource-ref extractors; XML added to indexed extensions

Tests: 34 tests across unit, integration, and performance suites — all passing

hossihub added 13 commits April 20, 2026 13:59
Add deep extraction for Android patterns:
- Room database: entities, DAOs, foreign keys, queries
- Hilt DI: modules, providers, injection tracking
- Resource refs: R.string/drawable/layout/etc detection
- Enhanced manifest: intent filters, metadata, application class

New extractors:
- android_room.rs: Room pattern extraction with relationships
- android_hilt.rs: Hilt DI graph extraction
- android_resource_refs.rs: XML resource reference tracking
- xml_generic.rs: Generic XML file handling

Test fixtures (34 files):
- Kotlin patterns: Room, Hilt, coroutines, generics, extensions
- Android XML: manifest, layouts, drawables, resources
- TV app scenario: complete project structure

Tests (34 comprehensive tests):
- kotlin_extraction_tests.rs (8 tests)
- xml_extraction_tests.rs (12 tests)
- android_integration_tests.rs (8 tests)
- android_performance_tests.rs (6 tests)

Documentation:
- android-support.md: User guide
- android-kotlin-xml-improvements.md: Technical summary
- android-query-examples.md: Query examples

All 34 tests passing. Build time: 0.16s
- Remove duplicate AndroidResourceRefExtractor call per Kotlin file
- Replace +100 magic-offset FK slice with brace-counting class body scan
- Fix Hilt provider-to-module attribution using position-based span lookup
- Hoist param_re compilation out of inject loop
- Replace silent unwrap_or("") with eprintln! warning + early return on non-UTF-8 input
- Narrow glob re-exports for new modules to explicit named exports
- cargo fmt all new Android extractor files
- hoist query_re and from_re outside DAO loop (clippy::regex-creation-in-loops)
- prefix unused filter_content and entities params with underscore
- Relax android_performance_tests thresholds for debug builds (50ms→200ms, 100ms→500ms)
- Fix race condition in batched_insert_tests where insert_elements async invalidation
  beat the cache assertion; now waits and repopulates before checking
- Add 'limit' param to mcp_tests tool param allowlist for get_doc_tree
Store absolute project path during 'leankg init' to enable MCP server
to route to correct project database even when started from different
directory. Includes warning if project moved and fallback to search.

Changes:
- config/project.rs: add project_path: Option<PathBuf> to ProjectSettings
- main.rs: populate project_path with current_dir() during init
- mcp/server.rs: resolve project root using project_path first
- mcp/tools.rs: add project param to multiple tools
- mcp/server.rs: parse orchestrate intent for file routing

Backwards compatible: configs without project_path work as before.
- Untrack .mcp.json (hardcoded local paths) and add to .gitignore
- Document find_class_body_end byte-index semantics for UTF-8 correctness
- Add confidence rationale and limitation comments for DAO heuristic
- Enrich DAO relationship metadata with heuristic name and caveat note
- Add 7 integration tests for GenericXmlExtractor:
  - Root element extraction
  - Android file exclusion (manifest, /res/)
  - XML declaration handling
  - Self-closing tag support
  - Empty content handling
  - Invalid UTF-8 handling
  - File path preservation

- Document XML extraction limitation in:
  - docs/android-support.md (Limitations section)
  - src/indexer/xml_generic.rs (rustdoc)

- Optimize regex compilation with OnceLock in xml_generic.rs

All 19 XML extraction tests passing.
hossihub added 13 commits April 22, 2026 12:17
Implements annotation extraction, call graph building, resource linking,
and Gradle module extraction capabilities. Fixes include improved
annotated expression handling during traversal and accurate extension
function detection within the AST.
- Add FragmentNavExtractor for FragmentManager patterns
- Add LeanbackNavExtractor for TV navigation
- Wire extractors into indexer pipeline
- Add MCP tools: get_nav_graph, find_route, get_screen_args, get_nav_callers
- Add compress_nav_graph for response compression
- Fix test validation for new tool parameters
- Fix clippy warnings
- Re-add required params to find_route, get_screen_args, get_nav_callers
  (handler enforces them, schema must match)
- Remove unused _FRAGMENT_ADD_RE static
- Remove #![allow(dead_code)] suppression from leanback

Clippy clean, fmt clean, 313 tests pass
@hossihub hossihub marked this pull request as draft April 23, 2026 06:44
1. Add 'kt' to mcp_index lang filter example (tools.rs)
   - Documents that Kotlin is a supported language

2. Wire Android extractors into sync indexer (mod.rs)
   - index_file_sync now runs Room, Hilt, annotations, nav, resource extractors
   - Matches feature parity with parallel indexer path

3. Implement extract_kotlin_dsl() in JetpackNavExtractor
   - Parses Compose Navigation DSL: composable(route=...), navigation(...), argument(...)
   - Extracts nav_destination, nav_argument, nav_action elements
   - Uses regex to find route definitions and navigate() calls
   - Confidence scores: 0.85 for args, 0.75 for inferred actions
@hossihub hossihub closed this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant