Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +41,6 @@ jobs:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: lts/-1
cache: pnpm

- run: npx changelogithub
env:
Expand Down
1 change: 1 addition & 0 deletions shared/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const zodTree: z.ZodType<Tree> = z.lazy(() =>
childTypeCnt: z.number(),
childCnt: z.number(),
typeCnt: z.number(),
resultType: typeLine.optional(),
}),
)

Expand Down
6 changes: 4 additions & 2 deletions src/traceTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -35,6 +36,7 @@ export function toTree(traceData: TraceData, workspacePath: string): Tree {
let id = 0

const stack: Tree[] = []
const typeLineIndex = createTypeLineIndex(traceData)

treeIndexes = [tree]

Expand Down Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions src/traceTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { TraceData, TraceLine, TypeLine } from '../shared/src/traceData'

export type TypeLineIndex = Map<number, TypeLine>

export function createTypeLineIndex(traceData: TraceData): TypeLineIndex {
const typeLines = new Map<number, TypeLine>()

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)
}
26 changes: 26 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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<string>',
ts: 2,
},
traceLine,
]
const typeLineIndex = createTypeLineIndex(traceData)

expect(getResultTypeForLine(traceLine, typeLineIndex)?.display).toBe('Promise<string>')
})
})
9 changes: 9 additions & 0 deletions ui/components/TreeNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ const insetClass = `border-e min-w-2 border-[var(--vscode-tree-inactiveIndentGui
{{ tree.line.args?.path ?? '' }}
</span>
</div>
<div v-if="tree.resultType" class="min-w-64 max-w-96 truncate text-[var(--vscode-descriptionForeground)]" :title="tree.resultType.display ?? tree.resultType.intrinsicName ?? `type ${tree.resultType.id}`">
{{ `=> #${tree.resultType.id}` }}
<span v-if="tree.resultType.display">
{{ tree.resultType.display }}
</span>
<span v-else-if="tree.resultType.intrinsicName">
{{ tree.resultType.intrinsicName }}
</span>
</div>
<div class="flex flex-row min-w-40">
<button v-if="'args' in tree.line && tree.line.args?.pos !== undefined" class="mr-2 pb-1 mb-1 bg-[var(--vscode-button-background, green)] rounded-sm focus:ring-[var(--vscode-focusBorder, blue)] focus:outline-none focus:ring-1 " @click="gotoPosition">
<UIcon primary name="i-heroicons-arrow-left-on-rectangle" class="relative top-1 hover:backdrop-invert-[10%] hover:invert-[20%] bg-[var(--vscode-button-foreground, white)] " />
Expand Down