Skip to content

feat(code): add Kotlin comment extraction - #1183

Open
anandghegde wants to merge 1 commit into
vale-cli:v3from
anandghegde:feat/kotlin-support
Open

anandghegde wants to merge 1 commit into
vale-cli:v3from
anandghegde:feat/kotlin-support

Conversation

@anandghegde

Copy link
Copy Markdown

Closes #1125.

Adds Kotlin (.kt, .kts) to the tree-sitter comment extractors, following the same layout as the Elixir support in #1151. It extracts // line comments and /* */ block comments, KDoc /** */ included (the grammar parses KDoc as an ordinary multiline_comment). The grammar is already vendored in go-tree-sitter, so there's no new dependency.

Two small things beyond the new language:

  • The padding lists /** as a marker. With plain cStyle, an alert in a one-line KDoc comment (/** ... */) lands two columns short. JavaScript has the same problem today (/** foo */ in a .js file), which I've left alone here.
  • TestComments now pairs in/N.ext with out/N.json by file name instead of by position. 10.kt sorts before 2.py, so the positional pairing broke as soon as there were more than ten fixtures.

Tests:

  • testdata/comments/{in,out}/10.kt, 11.kts: line-comment runs, a KDoc block with a tag, an inline block comment, a trailing comment, a one-line KDoc, and strings containing TODO and // that must not be extracted.
  • testdata/e2e/lint.yaml: a kotlin case against testdata/fixtures/formats/test.kt, with all eight columns checked.

make test passes locally (the converter-dependent cases were skipped). I also ran a built vale with a one-word existence rule on a .kt and a .kts file: it flagged the word only in line, block and KDoc comments, not in identifiers or strings, and the line/column numbers were right.

Assisted-by: Claude Code

Extract `//` line comments and `/* */` block comments, including KDoc
`/** */`, from `.kt` and `.kts` files using the Kotlin grammar already
vendored in go-tree-sitter.

The padding lists `/**` as a marker so that a one-line KDoc comment's
alerts land on the right column; `cStyle` stops at `/*` and would put
them two columns short.

TestComments now pairs each input with its output by file name rather
than by position, since `10.kt` sorts before `2.py`.

Closes vale-cli#1125.
@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown

The license agreement is signed.
Posted by the CLA Assistant Lite bot.

@github-actions

Copy link
Copy Markdown

Before this is reviewed, please read the AI-Assisted Contributions section of the contributing guide and make sure this change meets it: you can explain every line, the description is your own and brief, it fixes a bug you hit or a feature agreed in an issue, it does not touch undocumented options, and any substantial tool use is noted.

@anandghegde

Copy link
Copy Markdown
Author

I have read the CLA and I agree to it

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Add Kotlin support or support / document adding a Code type in vale.ini

1 participant