Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tags.scm attempt #158

Open
gminorcoles opened this issue Dec 13, 2024 · 0 comments
Open

tags.scm attempt #158

gminorcoles opened this issue Dec 13, 2024 · 0 comments

Comments

@gminorcoles
Copy link

gminorcoles commented Dec 13, 2024

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)
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

No branches or pull requests

1 participant