-
Notifications
You must be signed in to change notification settings - Fork 212
Description
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 aKotlinTreeSitterParser
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 theJavaTreeSitterParser
. -
Pre-scan Function: Implement a
pre_scan_kotlin
function, similar topre_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.