murtaza64 / tree-sitter-groovy

Tree sitter parser for groovy
MIT License
14 stars 10 forks source link

Labels break highlighting #13

Closed HendrikJanssen closed 1 month ago

HendrikJanssen commented 1 month ago

One of our uses of Groovy is the execution of Spock tests. Spock is a test framework, which makes extensive use of labels to mark the sections of a test. Example:

class Test {
    def "test add"() {
        when:
        def a = 10
        def b = 10
        def result = a + b

        then:
        result == 20
    }
}

Labels are kind of "inherited" from Java. With the current parser, they seem to be missing/broken. Highlighting for the example in my neovim (Note the broken def highlighting in the line right after the first label):

Bildschirmfoto 2024-07-17 um 14 47 30

In bigger files, the highlighting is all over the place.

I tried to locate label parsing in your grammar.js and could not find it, but admittedly, I am not a treesitter expert. Can you verify that labels are simply missing? If they are missing, I might give their implementation a try.

murtaza64 commented 1 month ago

I'm pretty sure I didn't implement labels (I didn't know they existed lol). Feel free to give the implementation a shot!