-
Notifications
You must be signed in to change notification settings - Fork 59
Add Kotlin language support with full metrics + tree-sitter 0.26.3 upgrade #1206
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
base: master
Are you sure you want to change the base?
Add Kotlin language support with full metrics + tree-sitter 0.26.3 upgrade #1206
Conversation
Updates the requirements on [tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter-javascript/releases) - [Commits](tree-sitter/tree-sitter-javascript@v0.23.1...v0.25.0) --- updated-dependencies: - dependency-name: tree-sitter-javascript dependency-version: 0.25.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter-javascript/releases) - [Commits](tree-sitter/tree-sitter-javascript@v0.23.1...v0.25.0) --- updated-dependencies: - dependency-name: tree-sitter-javascript dependency-version: 0.25.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter-javascript/releases) - [Commits](tree-sitter/tree-sitter-javascript@v0.23.1...v0.25.0) --- updated-dependencies: - dependency-name: tree-sitter-javascript dependency-version: 0.25.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter-python/releases) - [Commits](tree-sitter/tree-sitter-python@v0.23.6...v0.25.0) --- updated-dependencies: - dependency-name: tree-sitter-python dependency-version: 0.25.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter-python/releases) - [Commits](tree-sitter/tree-sitter-python@v0.23.6...v0.25.0) --- updated-dependencies: - dependency-name: tree-sitter-python dependency-version: 0.25.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter](https://github.com/tree-sitter/tree-sitter) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter/releases) - [Commits](tree-sitter/tree-sitter@v0.25.3...v0.26.3) --- updated-dependencies: - dependency-name: tree-sitter dependency-version: 0.26.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter](https://github.com/tree-sitter/tree-sitter) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter/releases) - [Commits](tree-sitter/tree-sitter@v0.25.3...v0.26.3) --- updated-dependencies: - dependency-name: tree-sitter dependency-version: 0.26.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter](https://github.com/tree-sitter/tree-sitter) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter/releases) - [Commits](tree-sitter/tree-sitter@v0.25.3...v0.26.3) --- updated-dependencies: - dependency-name: tree-sitter dependency-version: 0.26.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Updates the requirements on [tree-sitter](https://github.com/tree-sitter/tree-sitter) to permit the latest version. - [Release notes](https://github.com/tree-sitter/tree-sitter/releases) - [Commits](tree-sitter/tree-sitter@v0.25.3...v0.26.3) --- updated-dependencies: - dependency-name: tree-sitter dependency-version: 0.26.3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
…mment/tree-sitter-eq-0.26.3' into tree-sitter-0.26-kotlin
…er-eq-0.26.3' into tree-sitter-0.26-kotlin
…proc/tree-sitter-eq-0.26.3' into tree-sitter-0.26-kotlin
…cpp/tree-sitter-eq-0.26.3' into tree-sitter-0.26-kotlin
…js/tree-sitter-eq-0.26.3' into tree-sitter-0.26-kotlin
…lity - Replace tree-sitter-kotlin-ng with tree-sitter-kotlin-codanna (0.3.9) - tree-sitter-kotlin-codanna is compatible with tree-sitter 0.26.3 - Update Kotlin node type mappings: - Comment -> LineComment | MultilineComment - LineStringLiteral/MultiLineStringLiteral -> StringLiteral | StringContent - Fix tree-sitter 0.26 API changes: - Node.child() now takes u32 instead of usize - Add special case for kotlin grammar's language() function (vs LANGUAGE constant) - Fix FxHashMap -> HashMap import - Add Makefile for build commands All 251 tests passing + 17 doc tests.
- tree-sitter-rust: 0.23.2 → 0.24.0 - insta: 1.29.0 → 1.46.1 - Add .claude/ to .gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive Kotlin language support to rust-code-analysis with all available code metrics, while also upgrading the tree-sitter dependency from 0.25.3 to 0.26.3. The implementation switches from tree-sitter-kotlin-ng to tree-sitter-kotlin-codanna for better compatibility with the new tree-sitter version.
Changes:
- Complete Kotlin language support with all 11 metrics (LOC, Cyclomatic, Cognitive, Halstead, ABC, WMC, NPA, NPM, NARGS, Exit, NOM)
- Tree-sitter core upgrade from 0.25.3 to 0.26.3 with corresponding API adjustments (Node lifetimes, child indexing)
- Updated language parsers (JavaScript 0.25.0, Python 0.25.0, Rust 0.24.0) and dev dependencies (insta 1.46.1, askama 0.15)
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Cargo.toml | Updates tree-sitter to 0.26.3, switches to tree-sitter-kotlin-codanna, updates parser dependencies |
| enums/Cargo.toml | Mirrors main dependency updates for enum generation |
| src/languages/language_kotlin.rs | Complete rewrite of Kotlin grammar enum definitions for new tree-sitter grammar |
| src/checker.rs | Implements Checker trait for Kotlin (comments, functions, closures, strings, else-if detection) |
| src/getter.rs | Implements Getter trait for Kotlin (space kinds, Halstead operators/operands) |
| src/metrics/*.rs | Implements all metrics (LOC, Cyclomatic, Cognitive, Halstead, ABC, WMC, NPA, NPM, NARGS, Exit) |
| src/node.rs | Adds Node lifetime annotations and u32 child indexing for tree-sitter 0.26.3, adds traverse_children helper |
| src/traits.rs | Updates get_root return type with lifetime annotation |
| src/parser.rs | Updates get_root return type with lifetime annotation |
| src/tools.rs | Minor refactoring removing unnecessary parentheses |
| src/asttools.rs | New file with unused utility functions (dead code - not imported in lib.rs) |
| tree-sitter-*/Cargo.toml | Updates internal grammars to tree-sitter 0.26.3 |
| src/macros.rs | Adds special case for tree-sitter-kotlin-codanna grammar accessor |
| Makefile | Adds convenience build/test/check targets |
| .gitignore | Adds .claude/ directory to ignore list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…estor, public methods
- npa.rs: Fix typo "interfaces" → "interface" in comment - npm.rs: Fix typo "interfaces" → "interface" in comment - cognitive.rs: Add missing space after comma in increase_nesting calls - abc.rs: Update Java grammar references to Kotlin grammar in comments - abc.rs: Fix typo "do-while statements" → "inside do-while statements"
Addressed Review CommentsAll 6 Copilot review comments have been resolved in commit a44288d:
All changes have been pushed to the |
Collapse nested if statements into single conditions using Rust's if-let chain syntax (let-chains). This modernizes the codebase to use the newer Rust idiom and satisfies clippy's collapsible_if lint. Files fixed: - src/alterator.rs - src/asttools.rs - src/checker.rs - src/find.rs - src/getter.rs - src/metrics/abc.rs - src/metrics/cognitive.rs - src/metrics/loc.rs - src/metrics/nargs.rs - src/node.rs
Additional Fix: Clippy WarningsFixed all Converted nested
All |
Update all language enum files using the enums generator to match the upgraded tree-sitter grammar versions: - tree-sitter-rust 0.24.0 - tree-sitter-javascript 0.25.0 - tree-sitter-python 0.25.0 - tree-sitter-kotlin-codanna 0.3.9 Update test snapshots to reflect changes in grammar parsing behavior across Python and JavaScript metrics tests.
Update: Enums Regenerated for tree-sitter 0.26.3All language enum files have been regenerated using the enums generator to match upgraded tree-sitter grammar versions:
Test snapshots have been updated to reflect changes in grammar parsing behavior. All tests passing. Validation results:
Commit: ecafc19 |
|
Thanks a lot for your hard work! If it’s not too much trouble, could you move the dependency updates and the CI changes into separate PRs? Once those PRs are merged, could you then rebase this one? |
Summary
This PR adds complete Kotlin language support to rust-code-analysis, including all code metrics, along with upgrading tree-sitter to version 0.26.3 and updating related dependencies.
Kotlin Language Support
Implemented all metrics for Kotlin:
Uses
tree-sitter-kotlin-codanna(0.3.9) which provides tree-sitter 0.26.3 compatibility.Dependency Updates
Internal Grammar Updates
Updated all internal grammars to tree-sitter 0.26.3:
Test Plan
Breaking Changes
None. This is an additive change with backward-compatible dependency updates.
Related Issues
Closes the need for Kotlin support in rust-code-analysis.
Addresses multiple dependabot PRs: #1200, #1201, #1202, #1203, #1204, #1205, #1184, #1185, #1186, #1192, #1193, #1150, #1152