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

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

オープン
#34 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
TypeScript
スター
2
フォーク
0
平均マージ
5時間 51分
マージ済み PR(30日)
32

説明

### 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._

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。