feat(code): add Kotlin comment extraction - #1183
Open
anandghegde wants to merge 1 commit into
Open
anandghegde wants to merge 1 commit into
anandghegde wants to merge 1 commit into
Conversation
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.
|
The license agreement is signed. |
|
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. |
Author
|
I have read the CLA and I agree to it |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ordinarymultiline_comment). The grammar is already vendored in go-tree-sitter, so there's no new dependency.Two small things beyond the new language:
/**as a marker. With plaincStyle, an alert in a one-line KDoc comment (/** ... */) lands two columns short. JavaScript has the same problem today (/** foo */in a.jsfile), which I've left alone here.TestCommentsnow pairsin/N.extwithout/N.jsonby file name instead of by position.10.ktsorts before2.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 containingTODOand//that must not be extracted.testdata/e2e/lint.yaml: akotlincase againsttestdata/fixtures/formats/test.kt, with all eight columns checked.make testpasses locally (the converter-dependent cases were skipped). I also ran a builtvalewith a one-word existence rule on a.ktand a.ktsfile: 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