apex-dev-tools / apex-dev-tools/apex-log-parser
✨ feat: Typed per-kind event indexes and a public tree visitor
- 主要语言
- TypeScript
- 星标
- 2
- 派生
- 0
- 平均合并
- 5 小时 51 分钟
- 30 天内合并 PR
- 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 还没有评估数据。