diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c55a923..7b9167b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,6 @@ jobs: - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: lts/-1 - cache: pnpm - name: 📦 Install dependencies run: pnpm install --frozen-lockfile @@ -42,7 +41,6 @@ jobs: - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: lts/-1 - cache: pnpm - run: npx changelogithub env: diff --git a/shared/src/messages.ts b/shared/src/messages.ts index 70c04e7..c302e5d 100644 --- a/shared/src/messages.ts +++ b/shared/src/messages.ts @@ -105,6 +105,7 @@ const zodTree: z.ZodType = z.lazy(() => childTypeCnt: z.number(), childCnt: z.number(), typeCnt: z.number(), + resultType: typeLine.optional(), }), ) diff --git a/src/traceTree.ts b/src/traceTree.ts index 0618d33..ff31ef2 100644 --- a/src/traceTree.ts +++ b/src/traceTree.ts @@ -4,8 +4,9 @@ import type { TraceData, TraceLine, TypeLine } from '../shared/src/traceData' import { getWorkspacePath } from './storage' import { postMessage } from './webview' import { traceFiles } from './appState' +import { createTypeLineIndex, getResultTypeForLine } from './traceTypes' -export interface Tree { id: number, line: TraceLine, children: Tree[], types: TypeLine[], childCnt: number, childTypeCnt: number, typeCnt: number } +export interface Tree { id: number, line: TraceLine, children: Tree[], types: TypeLine[], childCnt: number, childTypeCnt: number, typeCnt: number, resultType?: TypeLine } function getRoot(): Tree { return { id: 0, @@ -35,6 +36,7 @@ export function toTree(traceData: TraceData, workspacePath: string): Tree { let id = 0 const stack: Tree[] = [] + const typeLineIndex = createTypeLineIndex(traceData) treeIndexes = [tree] @@ -62,7 +64,7 @@ export function toTree(traceData: TraceData, workspacePath: string): Tree { } else if (line.dur) { endTs = line.ts + (line.dur ?? 0) - const child = { id: ++id, line, children: [], types: [], childTypeCnt: 0, childCnt: 0, typeCnt: 0 } + const child = { id: ++id, line, children: [], types: [], childTypeCnt: 0, childCnt: 0, typeCnt: 0, resultType: getResultTypeForLine(line, typeLineIndex) } treeIndexes[id] = child curr.childCnt = curr.children.push(child) stack.push(curr) diff --git a/src/traceTypes.ts b/src/traceTypes.ts new file mode 100644 index 0000000..74e4819 --- /dev/null +++ b/src/traceTypes.ts @@ -0,0 +1,20 @@ +import type { TraceData, TraceLine, TypeLine } from '../shared/src/traceData' + +export type TypeLineIndex = Map + +export function createTypeLineIndex(traceData: TraceData): TypeLineIndex { + const typeLines = new Map() + + for (const line of traceData) { + if ('id' in line) + typeLines.set(line.id, line) + } + + return typeLines +} + +export function getResultTypeForLine(line: TraceLine, typeLines: TypeLineIndex) { + const typeId = line.args?.results?.typeId + + return typeId === undefined ? undefined : typeLines.get(typeId) +} diff --git a/test/index.test.ts b/test/index.test.ts index 401553c..823f1c9 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,7 +1,33 @@ import { describe, expect, it } from 'vitest' +import type { TraceData, TraceLine } from '../shared/src/traceData' +import { createTypeLineIndex, getResultTypeForLine } from '../src/traceTypes' describe('should', () => { it('exported', () => { expect(1).toEqual(1) }) + + it('resolves result type ids from trace lines', () => { + const traceLine: TraceLine = { + pid: 1, + tid: 1, + ph: 'X', + cat: 'check', + ts: 1, + name: 'checkExpression', + dur: 10, + args: { results: { typeId: 7 } }, + } + const traceData: TraceData = [ + { + id: 7, + display: 'Promise', + ts: 2, + }, + traceLine, + ] + const typeLineIndex = createTypeLineIndex(traceData) + + expect(getResultTypeForLine(traceLine, typeLineIndex)?.display).toBe('Promise') + }) }) diff --git a/ui/components/TreeNode.vue b/ui/components/TreeNode.vue index 997a094..4434027 100644 --- a/ui/components/TreeNode.vue +++ b/ui/components/TreeNode.vue @@ -56,6 +56,15 @@ const insetClass = `border-e min-w-2 border-[var(--vscode-tree-inactiveIndentGui {{ tree.line.args?.path ?? '' }} +
+ {{ `=> #${tree.resultType.id}` }} + + {{ tree.resultType.display }} + + + {{ tree.resultType.intrinsicName }} + +