Skip to content

Feature Request: Add support for Kotlin repositories #376

@Chokitus

Description

@Chokitus

Is your feature request related to a problem? Please describe.

I'm currently unable to use CodeGraphContext with my Kotlin projects. As a developer who works extensively with Kotlin for backend development, this limitation prevents me from leveraging the powerful code analysis capabilities of this tool on a significant portion of my work. The existing support for Java is a great foundation, and I believe that adding Kotlin support would be a natural and valuable extension.

Describe the solution you'd like

I propose adding support for Kotlin repositories by implementing a KotlinTreeSitterParser, similar to the existing JavaTreeSitterParser. This would involve the following:

  • Tree-sitter Grammar for Kotlin: Integrate the tree-sitter-kotlin grammar to enable parsing of Kotlin code.

  • Tree-sitter Queries for Kotlin: Develop a set of tree-sitter queries, analogous to the JAVA_QUERIES, to extract key information from Kotlin source files, including:

    • Functions: Top-level functions, extension functions, and member functions.
    • Classes: Classes, data classes, objects, and interfaces.
    • Imports: Import statements.
    • Calls: Function and constructor calls.
  • KotlinTreeSitterParser Class: Create a KotlinTreeSitterParser class that uses the Kotlin tree-sitter grammar and queries to parse .kt and .kts files and extract the relevant code constructs. This class would mirror the structure and functionality of the JavaTreeSitterParser.

  • Pre-scan Function: Implement a pre_scan_kotlin function, similar to pre_scan_java, to perform an initial scan of Kotlin files and identify key declarations.

  • Build Tool Awareness (Optional but Recommended): While the current Java implementation doesn't seem to integrate with build tools, Kotlin projects heavily rely on Gradle. For a more robust implementation, it would be beneficial to have some level of awareness of the Gradle project structure to better resolve dependencies and understand the overall project architecture.

Describe alternatives you've considered

The only alternative at the moment is to not use CodeGraphContext for my Kotlin projects, which is unfortunate as I find the tool very valuable for the other supported languages.

Additional context

Kotlin's seamless interoperability with Java makes it a popular choice for modern software development. By leveraging the existing infrastructure for Java support, I believe that adding support for Kotlin can be a streamlined process. This would not only make the tool more versatile but also attract a larger community of developers who are increasingly adopting Kotlin for their projects.

Metadata

Metadata

Assignees

Labels

Hacktoberfest25This issue is created as a part of Hacktoberfest 2025 programgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions