Skip to content

feat: Android navigation and Kotlin analysis support#18

Merged
linhdmn merged 1 commit intoFreePeak:mainfrom
hossihub:dev
Apr 24, 2026
Merged

feat: Android navigation and Kotlin analysis support#18
linhdmn merged 1 commit intoFreePeak:mainfrom
hossihub:dev

Conversation

@hossihub
Copy link
Copy Markdown
Contributor

@hossihub hossihub commented Apr 20, 2026

Summary

Complete Android/Kotlin navigation system with comprehensive language analysis improvements. Adds Jetpack Compose navigation parsing, annotation extraction, Room/Hilt support, and enhanced call graph resolution.

Key Features

  • Android Navigation: XML and Kotlin DSL parsers for Jetpack Compose Navigation
  • Kotlin Metadata: Suspend, inline, extension functions, class kinds (data, sealed, etc.)
  • Android Frameworks: Room entities, Hilt components, Gradle dependencies
  • MCP Tools: get_nav_graph, find_route, get_screen_args, get_nav_callers
  • Call Graphs: Multi-language resolution with confidence scoring
  • Resource Linking: Android resource references (R.id, R.layout, etc.)

Changes

  • 15+ new indexer modules (android_, kotlin_, xml_)
  • 30+ relationship types for navigation, DI, annotations
  • Parallel and sync indexer pipelines with Android support
  • Comprehensive test fixtures and integration tests
  • Documentation and design specs

Testing

  • Android integration tests with fixture apps
  • Performance benchmarks for indexing
  • 200+ fixture files covering Android patterns
  • Format and lint checks passing

✅ Squashed into single comprehensive commit for clean history

@linhdmn
Copy link
Copy Markdown
Member

linhdmn commented Apr 20, 2026

Hi @hossihub please make the pipeline success running.

Copy link
Copy Markdown
Member

@linhdmn linhdmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review with inline comments

Comment thread .mcp.json Outdated
"--watch"
],
"command": "/Users/linh.doan/work/harvey/freepeak/leankg/.worktrees/feature-leankg-proc/target/debug/deps/test_all_tools_return_data-a17b878fb83cf791"
"command": "/var/home/christian/Documents/Dev/LeanKG/target/debug/deps/mcp_tools_full_tests-a9f9067ddb2e673b"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Hardcoded local development path - this should be excluded or made relative

Copy link
Copy Markdown
Member

@linhdmn linhdmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review with additional comments

// Link DAOs to database (heuristic: DAOs referenced in same file as database)
for dao in daos {
// Simple heuristic: if DAO is in same file as Database, assume relationship
relationships.push(Relationship {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: This heuristic links DAOs to databases based on same-file presence. What's the confidence score rationale (0.7)? Should this be documented as a limitation?

fn extract_providers(
&self,
content: &str,
modules: &[CodeElement],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider handling Unicode properly - char_indices() may not correctly handle multi-byte characters when incrementing by 1

hossihub added a commit to hossihub/LeanKG that referenced this pull request Apr 20, 2026
- 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
"string" => "uses_string_resource",
"drawable" => "uses_drawable_resource",
"layout" => "uses_layout_resource",
"id" => "references_view_by_id",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concern: Both extract_r_references (line ~29) and extract_resource_methods (line ~67) will match getString(R.string.xxx), creating duplicate relationships. Consider deduplicating or having one pattern exclude what the other catches.

Comment thread src/mcp/server.rs
@@ -42,33 +44,114 @@ impl Clone for MCPServer {
graph_engine_cache: self.graph_engine_cache.clone(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IntentParser::new() is called on every MCPServer clone. If MCPServer is cloned frequently, consider using Arc<IntentParser> to share the parser instance.

// Create a CodeElement for the XML document structure
elements.push(CodeElement {
qualified_name: format!("{}::{}", self.file_path, root_element),
element_type: "XMLDocument".to_string(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Generic XML extraction only captures the root element name. No child elements, attributes, or structure are extracted. Consider documenting this as a limitation in user-facing docs.

@hossihub hossihub force-pushed the dev branch 2 times, most recently from 57c5346 to d8c1268 Compare April 23, 2026 06:54
@hossihub hossihub changed the title feat: comprehensive Android/Kotlin/XML support improvements feat: Android navigation and Kotlin analysis support Apr 23, 2026
- Complete Jetpack Compose Navigation XML parser (res/navigation/*.xml)
- Kotlin DSL navigation support: composable(route), navigation(), argument()
- Fragment-based navigation extractor with regex pattern matching
- Android TV / Leanback navigation support
- Navigation relationship types: nav_action, requires_arg, deep_link, navigates_to

- Deep annotation extractor with metadata (annotation_entry, annotation_name, arguments)
- Room database extractor (@entity, @dao, @database detection)
- Hilt dependency injection component graph extraction
- Android resource reference linking (R.id, R.layout, R.string)
- ViewBinding and synthetic imports detection
- Gradle build system parsing (multi-module dependencies)

- Function modifiers: suspend, inline, operator, infix, extension, receiver_type
- Class kinds: data, sealed, abstract, open, object, companion
- Type parameters and generics
- Scope function tagging in call graphs (let, run, apply, with, etc.)
- Extension function detection and resolution

- Multi-language call graph builder with confidence scoring
- Kotlin scope function awareness (confidence 0.3)
- Extension function call resolution
- Cross-file call resolution with unresolved symbol tracking
- Support for Go, TypeScript, Python, Rust, Java, Kotlin, Bash, Ruby, PHP, Elixir, R, Perl

- get_nav_graph: Query navigation destinations, actions, arguments
- find_route: Resolve route strings and action IDs
- get_screen_args: List destination arguments with types
- get_nav_callers: Find all navigation call sites
- search_annotations: Find code by annotation type
- Existing tools now work uniformly across all languages

- Parallel and sync indexer paths for performance
- XML layout extractor for Android layouts
- Terraform configuration parser
- CI/CD YAML detection and parsing
- Maven and Gradle dependency management
- Cicd yaml framework detection

- Navigation elements: nav_graph, nav_destination, nav_argument, nav_action, nav_deep_link
- Relationship types: 30+ types covering imports, calls, tests, annotations, navigation
- Business logic traceability (code-to-requirements linking)
- Metadata support for confidence scores and element-specific attributes

- Integration tests for Android navigation parsing
- Performance benchmarks for indexing operations
- Fixture files for Android XML, Kotlin patterns, complex scenarios
- Android support documentation and query examples

- Fixed nav tool schema mismatches
- Removed dead code from navigation pipeline
- Proper error handling for malformed XML/Kotlin
- Consistent qualified name schemes across all languages
@linhdmn linhdmn merged commit 9f75453 into FreePeak:main Apr 24, 2026
4 checks passed
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.

2 participants