Skip to content

Add Kotlin language support to code graph analyzer#626

Closed
Copilot wants to merge 5 commits intobackend/add-kotlin-supportfrom
copilot/sub-pr-592-again
Closed

Add Kotlin language support to code graph analyzer#626
Copilot wants to merge 5 commits intobackend/add-kotlin-supportfrom
copilot/sub-pr-592-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

Adds Kotlin (.kt, .kts) analysis to the code graph pipeline alongside existing Python, Java, and C# support.

New: KotlinAnalyzer

  • Parses classes, interfaces, objects (singletons), top-level functions, and methods via tree-sitter
  • Extracts inheritance and interface implementation via _get_delegation_types()constructor_invocation specifiers → base_class, plain user_type specifiers → implement_interface
  • Captures function calls, parameters, return types, and KDoc comments
  • Falls back to NullLanguageServer (AST-based symbol resolution within the analyzed project; full LSP integration deferred)

SourceAnalyzer changes

  • Registers .kt / .kts extensions and KotlinAnalyzer
  • second_pass() iterates entity.resolved_symbols (resolved Entity objects with graph IDs) instead of raw tree-sitter node IDs
  • analyze_sources() calls path.resolve() to normalize paths before populating self.files, preventing LSP definition location mismatches

Other fixes

  • AbstractAnalyzer.resolve_symbol abstract method and all implementations (Python, Java, Kotlin) consistently annotated -> list[Entity]
  • pyproject.toml: added tree-sitter-kotlin>=1.1.0,<2.0.0 with consistent indentation

Tests

  • 11 unit tests in tests/test_kotlin_analyzer.py covering class/interface/object/function extraction, labels, inheritance, and dependency detection
  • Fixture: tests/source_files/kotlin/sample.kt

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

gkorland and others added 5 commits March 21, 2026 13:16
Migrated from FalkorDB/code-graph-backend PR #95.
Original issue: FalkorDB/code-graph-backend#93
Resolves #531

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace wildcard import with explicit Entity and File imports
- Fix tree-sitter queries: Kotlin grammar uses 'identifier' not 'type_identifier'
- Fix get_entity_name: use 'identifier' for all entity types
- Separate superclass/interface in add_symbols: first delegation specifier
  is base_class, rest are implement_interface
- Use self._captures() instead of direct query.captures() calls
- Handle constructor_invocation in delegation specifiers (e.g. Shape(...))
- Fix source_analyzer second_pass: use entity.resolved_symbols instead of
  iterating raw symbol nodes, so graph edges use resolved entity IDs
- Fix resolve_method: use 'identifier' instead of 'simple_identifier'
- Add unit tests and Kotlin fixture (11 tests, all passing)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix resolve_symbol return type annotation: Entity -> list[Entity] in
  abstract and Kotlin implementations to match actual behavior
- Fix pyproject.toml indentation for tree-sitter-kotlin dependency
- Add path.resolve() in analyze_sources for LSP compatibility
- Remove unused exception variable

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ion heuristic

- Restore C# analyzer registration in SourceAnalyzer (removed unintentionally)
- Fix resolve_symbol return type annotation in Java/Python analyzers (-> list[Entity])
- Improve Kotlin delegation specifier handling: use constructor_invocation as
  class signal instead of blindly treating first specifier as base_class

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Kotlin language support Add Kotlin language support to code graph analyzer Mar 22, 2026
Copilot AI requested a review from gkorland March 22, 2026 15:35
@gkorland gkorland force-pushed the backend/add-kotlin-support branch from 57ed7da to e5eda92 Compare March 22, 2026 15:53
@gkorland gkorland closed this Mar 22, 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.

2 participants