Export status is answered in three places, two of them hand-mirrored regexes

Đang mở
#1,721 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #2896 của @johnhldiver-beep — đã đóng, không merge

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
devtools

Hướng nghiên cứu

Read the TypeScript and JavaScript extraction entry points at src/extraction/languages/typescript.ts:110-116 and javascript.ts:68, then compare src/extraction/tree-sitter.ts:2368, 2843 with codegraph-kernel/src/tsjs/extractors.rs:301 and the resolver change in #1720. The issue calls for export status to cover the listed ES and CommonJS forms and for the resolver's per-file fact to derive from it. Done should include corpus measurement; no specific test file is named.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Three places in the codebase answer "is this name exported from this file", none of them shares an implementation, and they disagree about what counts.

isExported — the AST one. src/extraction/languages/typescript.ts:110-116 and javascript.ts:68 walk the parent chain for an export_statement ancestor. That is exact for export function f, and blind to everything else: const x = …; export { x } and every CommonJS form (module.exports, exports.x, exports["x"]) leave isExported false on the declaration's node.

isExportedLater — a regex, written because of that blindness. src/extraction/tree-sitter.ts:2368 runs one anchored regex over the file source for export default NAME / export { NAME }, and codegraph-kernel/src/tsjs/extractors.rs:301 mirrors it in Rust — two implementations that must be kept in step by hand, with only a doc comment saying so. Its single call site is the store-extraction condition at tree-sitter.ts:2843, so the fix it represents is scoped to Zustand stores rather than available generally.

A third, per-file, in the resolver. #1720 needs "does this file export anything at all" and cannot use either of the above — isExported would answer no for a CommonJS module, and isExportedLater answers a per-name question, not a per-file one. So it adds another source regex.

The result is that a CommonJS module's exports are invisible to the graph as exports, export { x } is visible only to store extraction, and the resolver re-derives a coarser version of the same fact from the same file text. Each site is individually defensible; together they mean the question has no single answer to point at, and the two regexes drift independently across a language boundary.

Worth considering: compute export status once during extraction — covering the export_statement ancestor, later export { … } / export default, and the CommonJS forms — and persist it on the node, with the per-file "exports nothing" fact derived from it. That would let #1720's guard read a stored fact instead of the file text, make CommonJS exports visible generally, and leave one implementation per language rather than two hand-mirrored regexes plus an AST walk.

Raising it as an issue rather than a PR because it touches extraction, the kernel and the resolver at once, changes what is persisted, and would want to be measured on a corpus the way the resolution changes have been — not something to fold into a PR already under review.

Ngôn ngữ chính
C
Star
73.2k
Fork
4.7k
Merge trung bình
3 giờ 39 phút
Pull request đã merge (30 ngày)
528

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của colbymchenry/codegraph

Tất cả issue của colbymchenry/codegraph

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.