Skip to content

Add Kotlin language support#625

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

Add Kotlin language support#625
Copilot wants to merge 5 commits intobackend/add-kotlin-supportfrom
copilot/sub-pr-592

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

Adds Kotlin (.kt/.kts) to the analyzer pipeline alongside Python, Java, and C#, using tree-sitter-kotlin for AST-based extraction.

Analyzer (api/analyzers/kotlin/analyzer.py)

  • Extracts class_declaration, object_declaration, and function_declaration nodes
  • Labels: Class, Interface (detected via interface keyword child), Object, Method, Function
  • KDoc (/** ... */) extraction via prev_sibling inspection
  • _get_delegation_types() walks delegation specifiers in order: constructor_invocationbase_class, plain user_typeimplement_interface
  • resolve_symbol returns list[Entity] consistent with the abstract base contract

Pipeline wiring (api/analyzers/source_analyzer.py)

  • Registered .kt/.kts in the analyzers dict and analyze_sources glob
  • NullLanguageServer for Kotlin (kotlin-language-server not yet integrated; AST-based resolution handles same-file symbols)
  • path = path.resolve() added at top of analyze_sources to ensure LSP definition paths match self.files keys
  • Restored C# analyzer registration (was inadvertently dropped)

Abstract base (api/analyzers/analyzer.py)

  • resolve_symbol signature corrected to -> list[Entity] on the abstract method and all implementations (Python, Java, Kotlin)

Tests

  • tests/test_kotlin_analyzer.py: 11 unit tests covering entity extraction, labels, inheritance symbol separation, and dependency detection
  • tests/source_files/kotlin/sample.kt: fixture with class/interface/object/function, delegation specifiers, and KDoc comments

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

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 Mar 22, 2026
Copilot AI requested a review from gkorland March 22, 2026 15:37
@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