Skip to content

tags.scm attempt #158

@gminorcoles

Description

@gminorcoles

Hi,
I am not familiar with tree-sitter as a developer, but I am a new user of a downstream tool called aider which use tags.scm to help with LLM pair programming. aider relies on a tags.scm to support a language. kotlin has no tags.scm. I rashly thought I might be ale to create one even though I dont know much about it. I made an attempt, and I wonder if anyone has the time or inclination to evaluate it? when I test it using tree-sitter test it passes the test cases in test/corpus now. that is as far as I have gotten. I did this by serializing the kotlin grammar.js and the tree-sitter-query grammar.js and a combination of eyeballing and getting an LLM to help. I feel that if I have both of those grammars I should be able to write something that generates valid queries?

; Definitions

; Classes
(class_declaration
  (type_identifier) @definition.class)

; Enum Classes
(class_declaration
  (modifiers (class_modifier) @mod)
  (type_identifier) @definition.class.enum
  (#eq? @mod "enum"))

; Enum Entries
(enum_class_body
  (enum_entry
    (simple_identifier) @definition.field.enum))

; Object Declarations
(object_declaration
  (type_identifier) @definition.class.object)

; Companion Objects
(companion_object
  (type_identifier) @definition.class.companion)

; Type Aliases
(type_alias
  (type_identifier) @definition.typealias)

; Functions
(function_declaration
  (simple_identifier) @definition.function)

; Properties
(property_declaration
  (variable_declaration
    (simple_identifier) @definition.field))

; Function Parameters
(parameter
  (simple_identifier) @definition.parameter)

; Local Variables
((variable_declaration
    (simple_identifier) @definition.var)
 (#match? @definition.var "^[a-z]"))

; Type Parameters
(type_parameter
  (type_identifier) @definition.typeparameter)

; Destructuring Declarations
(multi_variable_declaration
  (variable_declaration) @definition.destructuring)

; Lambdas
(lambda_literal) @definition.lambda

; Annotations
(annotation
  (user_type
    (type_identifier) @definition.annotation))

; References

; Function Calls
(call_expression
  (simple_identifier) @reference.call)

; Property Access
(navigation_expression
  (simple_identifier) @reference.field)

; Object References
(object_literal
  (class_body) @reference.object)

; Type References
(user_type
  (type_identifier) @reference.type)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions