apex-dev-tools / apex-dev-tools/apex-log-parser

✨ feat: Typed per-kind event indexes and a public tree visitor

Đang mở
#34 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
TypeScript
Star
2
Fork
0
Merge trung bình
5 giờ 51 phút
Pull request đã merge (30 ngày)
32

Mô tả

### Problem

The parser already builds `eventIndex` and `eventsById`, but exposes no way to reach the events of one
kind, so every consumer writes its own recursive walk:

- Analyzer `log-viewer/src/features/database/services/Database.ts:61,80,100` — three near-identical
walks: `getSOQLLines`, `getDMLLines`, `getSOSLLines`.
- MCP `src/tools/apexLogSource.ts:156-163` — a generic `walkLog`, used by `queryPlans.ts`,
`listLimitRisks.ts` and the operation tools, each filtering on a raw type string such as
`node.type !== "SOQL_EXECUTE_BEGIN"`.

Each walk re-traverses the whole tree, after the parser has already visited every node.

### Proposed solution

- Typed per-kind indexes on `ApexLog`: `soqlEvents`, `dmlEvents`, `soslEvents`, and a general
`eventsByType` map. Populate during the existing traversal, so there is no extra pass.
- A public tree visitor, so a consumer with a kind the parser does not index does not have to
hand-roll recursion. Iterative, not recursive — a deep log must not overflow the stack.

Decide whether the indexes hold events or ids: ids keep the retained size down, and `eventsById`
already exists to resolve them.

#### Acceptance

- `Database.ts` can delete its three walks.
- MCP can delete `walkLog` for the indexed kinds.
- No measurable parse-time regression (see the performance issue for the harness).

### Alternatives considered

_None recorded._

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

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.