Objective-C headers are parsed as C++, producing wrong nodes

Đang mở
#2,620 1 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.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
67/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, objective-c
Lĩnh vực
devtools

Hướng nghiên cứu

Start by tracing how file extensions select grammars for indexing, then compare the existing Objective-C grammar behavior for the reported Thing.h and Thing.m examples. Check how the C++ header extension overlaps with Objective-C headers and look for related parser tests. Done when the header produces a Class node for Thing and does not record NSObject or @end as a Variable.

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

Mô tả

bug parsing/quality priority/high

Thanks for codebase-memory-mcp. It has become the first thing I reach for on a mixed Objective-C and Swift project, which is how I came across this.

Version: main 4d9592b

What happens

Objective-C headers are indexed with the C++ grammar. The effect is not mainly parse errors, it is wrong content in the graph: the class does not appear at all, and the superclass name is recorded as a Variable. That is easy to miss, because nothing reports a failure.

Minimal reproduction

One file, three lines, indexed twice under two different names. The bytes are identical both times:

#import <Foundation/Foundation.h>

@interface Thing : NSObject
- (void)doWork;
@end
$ codebase-memory-mcp cli --json index_repository --repo-path <repo> --name t --mode full
$ codebase-memory-mcp cli --json search_graph --project t --name_pattern ".*"

Named Thing.h:

t.Thing.NSObject   Variable   Thing.h   3-3

The same bytes named Thing.m:

t.Thing.Thing      Class      Thing.m   3-5

So the file itself parses, and the Objective-C grammar is already vendored and working. Only the file name decides which grammar is used.

An empty interface gives a matching artifact: @end is recorded as a Variable named end.

Since .h is also a C++ header extension, I realise this is not a one-line call to make. I have looked into it a fair bit and would be glad to open a pull request if you are open to one. Either way, thank you for the tool.

Note: The error reproduction steps above were drafted with the assistance of AI.

Ngôn ngữ chính
C
Star
45.8k
Fork
3.8k
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
195

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 DeusData/codebase-memory-mcp

Tất cả issue của DeusData/codebase-memory-mcp

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.