Skip to content

explore/typescript: multi-line block comments not tracked #113

@justrach

Description

@justrach

Problem

The TypeScript parser does not track multi-line `/* ... */` block comments. Lines inside block comments that look like function/class definitions get incorrectly parsed as real symbols.

Raised by @sanderdewijs in #87.

Failing Test

```zig
test "issue-113: TypeScript block comments should not produce symbols" {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
var explorer = Explorer.init(arena.allocator());

try explorer.indexFile("example.ts",
    \\/*
    \\function fakeFunction() {
    \\}
    \\class FakeClass {
    \\}
    \\*/
    \\
    \\function realFunction() {
    \\}
);

var outline = (try explorer.getOutline("example.ts", testing.allocator)) orelse return error.TestUnexpectedResult;
defer outline.deinit();
var fn_count: usize = 0;
for (outline.symbols.items) |sym| {
    if (sym.kind == .function) fn_count += 1;
}
// Should only find realFunction
try testing.expectEqual(@as(usize, 1), fn_count);

}
```

Expected

Only realFunction is indexed; symbols inside block comments are ignored.

Fix

Add in_block_comment state tracking to the TypeScript parser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus:doneWork item is complete

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions