Skip to content

Read Kotlin import names from AST children - #873

Closed
yzxcj797 wants to merge 1 commit into
tirth8205:stagingfrom
yzxcj797:fix/862-kotlin-import-comments
Closed

yzxcj797 wants to merge 1 commit into
tirth8205:stagingfrom
yzxcj797:fix/862-kotlin-import-comments

Conversation

@yzxcj797

Copy link
Copy Markdown
Contributor

Summary

_extract_import was fixed to read a Kotlin import_header identifier child instead of folded node text, but _collect_import_names still parsed raw text. When tree-sitter folded a trailing KDoc into the final import, the per-name import map stored a key containing the comment, so calls to that imported function remained unresolved.

The Kotlin branch now builds import bindings from AST children:

  • identifier → module;
  • import_alias → local alias;
  • wildcard imports remain excluded from per-name bindings.

Java import handling remains unchanged.

Fixes #862.

Testing

  • Added an end-to-end regression with import dep.helper, a trailing KDoc, and a helper() call.
  • On clean main, the call target stayed unresolved as helper; with the fix it resolves to dep/Helper.kt::helper.
  • pytest tests/test_pr862_edges.py tests/test_kotlin_imports.py tests/test_pr824_edges.py -q — 23 passed
  • ruff check on changed files — passes
  • git diff --check — passes

@github-actions

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.30 (LOW) — 3 changed function(s)/class(es), 0 affected flow(s), 1 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.30 low code_review_graph/parser.py::CodeParser code_review_graph/parser.py:2405 yes
0.30 low code_review_graph/parser.py::CodeParser._collect_import_names code_review_graph/parser.py:13394 no
0.05 low tests/test_pr862_edges.py::test_import_name_with_trailing_kdoc_still_attributes_calls tests/test_pr862_edges.py:8 (test)

Test gaps

  • code_review_graph/parser.py::CodeParser._collect_import_names (code_review_graph/parser.py:13394)

Token savings: this graph-backed report used ~164,026 fewer tokens (~100%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@tirth8205

Copy link
Copy Markdown
Owner

Integrated on integration/token-efficiency-hardening as 84a5501. Kotlin imports with trailing KDoc are read from syntax children so their calls retain the correct import attribution. The fixture was corrected to use the supported portable helper.kt naming; the focused import and Kotlin tests passed without expanding symbol-to-file resolution.

@tirth8205

Copy link
Copy Markdown
Owner

Merged into staging through the integration PR #988 (merge commit 3030ca8). Your change is carried by commit 84a5501, which keeps you as the author (yzxcj797). It will be promoted staging → testing → main and released from there. Thank you for the contribution! Closing this PR since its content is now on staging.

@tirth8205 tirth8205 closed this Sep 15, 2026
Bakul2006 pushed a commit to Bakul2006/code-review-graph that referenced this pull request Sep 15, 2026
Port the reviewed token-efficiency implementation with targeted regression coverage.

Source-PR: tirth8205#873
Maintainer corrections and scope extraction applied where needed.
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.

Kotlin: _collect_import_names still folds trailing comments into per-name import attribution

2 participants