Skip to content

Commit 13fa318

Browse files
committed
Clean up comments and fix build errors
1 parent 7481f36 commit 13fa318

File tree

8 files changed

+29
-35
lines changed

8 files changed

+29
-35
lines changed

workflow-trace-viewer/api/workflow-trace-viewer.api

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,15 @@ public final class com/squareup/workflow1/traceviewer/MainKt {
1414
public static synthetic fun main ([Ljava/lang/String;)V
1515
}
1616

17-
public final class com/squareup/workflow1/traceviewer/SandboxState {
18-
public static final field $stable I
19-
public fun <init> ()V
20-
public final fun getOffset-F1C5BW0 ()J
21-
public final fun getScale ()F
22-
public final fun reset ()V
23-
public final fun setOffset-k-4lQ0M (J)V
24-
public final fun setScale (F)V
25-
}
26-
2717
public final class com/squareup/workflow1/traceviewer/util/ComposableSingletons$UploadFileKt {
2818
public static final field INSTANCE Lcom/squareup/workflow1/traceviewer/util/ComposableSingletons$UploadFileKt;
2919
public static field lambda-1 Lkotlin/jvm/functions/Function3;
3020
public fun <init> ()V
3121
public final fun getLambda-1$wf1_workflow_trace_viewer ()Lkotlin/jvm/functions/Function3;
3222
}
3323

34-
public final class com/squareup/workflow1/traceviewer/util/SandboxBackgroundKt {
35-
public static final fun SandboxBackground (Lcom/squareup/workflow1/traceviewer/SandboxState;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
24+
public final class com/squareup/workflow1/traceviewer/util/JsonParserKt {
25+
public static final field ROOT_ID Ljava/lang/String;
3626
}
3727

3828
public final class com/squareup/workflow1/traceviewer/util/UploadFileKt {

workflow-trace-viewer/build.gradle.kts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ kotlin {
2727
implementation(libs.filekit.dialogs.compose)
2828
}
2929
}
30-
3130
jvmTest {
3231
dependencies {
3332
implementation(kotlin("test"))
@@ -60,8 +59,8 @@ compose {
6059
}
6160

6261
tasks.named<Test>("jvmTest") {
63-
useJUnitPlatform()
64-
testLogging {
65-
events("passed", "skipped", "failed")
66-
}
62+
useJUnitPlatform()
63+
testLogging {
64+
events("passed", "skipped", "failed")
65+
}
6766
}

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public fun App(
6868

6969
// The states are reset when a new file is selected.
7070
UploadFile(
71-
onFileSelect = {
71+
resetOnFileSelect = {
7272
selectedTraceFile = it
7373
selectedNode = null
7474
frameIndex = 0

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/ui/WorkflowInfoPanel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ internal fun RightInfoPanel(
4040
selectedNode: Node?,
4141
modifier: Modifier = Modifier
4242
) {
43-
// This row is aligned to the right of the screen.
4443
Row(
4544
modifier = modifier
4645
) {

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/ui/WorkflowTree.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ internal fun RenderDiagram(
6767
}
6868

6969
if (!isLoading) {
70-
// DrawTree(frames[frameInd], affectedNodes[frameInd], onNodeSelect)
7170
DrawTree(fullTree[frameInd], affectedNodes[frameInd], onNodeSelect)
7271
}
7372
}

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/util/JsonParser.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal suspend fun parseTrace(
3030
val workflowAdapter = createMoshiAdapter()
3131
val parsedRenderPasses = try {
3232
workflowAdapter.fromJson(jsonString) ?: return ParseResult.Failure(
33-
IllegalArgumentException("The provided file does not contain a valid trace.")
33+
IllegalArgumentException("Provided trace file is empty or malformed.")
3434
)
3535
/*
3636
this parsing method can never be called without a provided file, so we can assume that there
@@ -73,6 +73,7 @@ private fun createMoshiAdapter(): JsonAdapter<List<List<Node>>> {
7373
*/
7474
private fun getFrameFromRenderPass(renderPass: List<Node>): Node {
7575
val childrenByParent: Map<String, List<Node>> = renderPass.groupBy { it.parentId }
76+
println(childrenByParent)
7677
val root = childrenByParent[ROOT_ID]?.single()
7778
return buildTree(root!!, childrenByParent)
7879
}
@@ -94,8 +95,11 @@ private fun buildTree(node: Node, childrenByParent: Map<String, List<Node>>): No
9495
}
9596

9697
/**
97-
* Every new frame starts with the same roots as the main tree, so we can do a simple traversal to
98-
* add any missing child nodes from the frame.
98+
* Every new frame starts with the same roots as the main tree, so we can fold each frame into the
99+
* current tree, add all the missing children or replace any new ones, and then store the newly
100+
* merged tree.
101+
*
102+
* @return Node the newly formed tree with the frame merged into it.
99103
*/
100104
internal fun mergeFrameIntoMainTree(
101105
frame: Node,

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/util/UploadFile.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import io.github.vinceglb.filekit.dialogs.compose.rememberFilePickerLauncher
2020
*/
2121
@Composable
2222
public fun UploadFile(
23-
onFileSelect: (PlatformFile?) -> Unit,
23+
resetOnFileSelect: (PlatformFile?) -> Unit,
2424
modifier: Modifier = Modifier,
2525
) {
2626
val launcher = rememberFilePickerLauncher(
2727
type = FileKitType.File(listOf("json", "txt")),
2828
title = "Select Workflow Trace File"
2929
) {
30-
onFileSelect(it)
30+
resetOnFileSelect(it)
3131
}
3232

3333
Button(

workflow-trace-viewer/src/jvmTest/kotlin/com/squareup/workflow1/traceviewer/util/JsonParserTest.kt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.squareup.workflow1.traceviewer.util
22

33
import com.squareup.workflow1.traceviewer.model.Node
4+
import com.squareup.workflow1.traceviewer.util.ROOT_ID
45
import kotlin.test.Test
56
import kotlin.test.assertEquals
67
import kotlin.test.assertTrue
@@ -11,12 +12,12 @@ class JsonParserTest {
1112
fun `test mergeFrameIntoMainTree with new children`() {
1213
// Create main tree with one child
1314
val mainChild = createNode("child1", "root", "1")
14-
val mainTree = createNode("root", "root", "0", mutableListOf(mainChild))
15+
val mainTree = createNode("root", "root", "0", "0", listOf(mainChild))
1516

1617
// Create frame with a new child
1718
val frameChild1 = createNode("child1", "root", "1")
1819
val frameChild2 = createNode("child2", "root", "2")
19-
val frame = createNode("root", "root", "0", mutableListOf(frameChild1, frameChild2))
20+
val frame = createNode("root", "root", "0", "0", listOf(frameChild1, frameChild2))
2021

2122
// Merge frame into main tree
2223
val mergedTree = mergeFrameIntoMainTree(frame, mainTree)
@@ -31,15 +32,15 @@ class JsonParserTest {
3132
fun `test mergeFrameIntoMainTree with nested children`() {
3233
// Create main tree with nested structure
3334
val nestedChild = createNode("nested1", "child1", "2")
34-
val mainChild = createNode("child1", "root", "1", mutableListOf(nestedChild))
35-
val mainTree = createNode("root", "root", "0", mutableListOf(mainChild))
35+
val mainChild = createNode("child1", "root", "1", "0", listOf(nestedChild))
36+
val mainTree = createNode("root", "root", "0", "0", listOf(mainChild))
3637

3738
// Create frame with new nested child
3839
val frameNestedChild1 = createNode("nested1", "child1", "2")
3940
val frameNestedChild2 = createNode("nested2", "child1", "3")
40-
val frameChild = createNode("child1", "root", "1",
41+
val frameChild = createNode("child1", "root", "1", "0",
4142
mutableListOf(frameNestedChild1, frameNestedChild2))
42-
val frame = createNode("root", "root", "0", mutableListOf(frameChild))
43+
val frame = createNode("root", "root", "0", "0", listOf(frameChild))
4344

4445
// Merge frame into main tree
4546
val mergedTree = mergeFrameIntoMainTree(frame, mainTree)
@@ -59,7 +60,7 @@ class JsonParserTest {
5960

6061
// Create frame with children
6162
val frameChild = createNode("child1", "root", "1")
62-
val frame = createNode("root", "root", "0", mutableListOf(frameChild))
63+
val frame = createNode("root", "root", "0", "0", listOf(frameChild))
6364

6465
// Merge frame into main tree
6566
val mergedTree = mergeFrameIntoMainTree(frame, mainTree)
@@ -73,7 +74,7 @@ class JsonParserTest {
7374
fun `test mergeFrameIntoMainTree with empty frame children`() {
7475
// Create main tree with children
7576
val mainChild = createNode("child1", "root", "1")
76-
val mainTree = createNode("root", "root", "0", mutableListOf(mainChild))
77+
val mainTree = createNode("root", "root", "0", "0", listOf(mainChild))
7778

7879
// Create empty frame
7980
val frame = createNode("root", "root", "0")
@@ -90,16 +91,18 @@ class JsonParserTest {
9091
name: String,
9192
parent: String,
9293
id: String,
93-
children: MutableList<Node> = mutableListOf()
94+
parentId: String = "0",
95+
children: List<Node> = emptyList()
9496
): Node {
9597
return Node(
9698
name = name,
99+
id = id,
97100
parent = parent,
101+
parentId = parentId,
98102
props = "",
99103
state = "",
100104
rendering = "",
101105
children = children,
102-
id = id
103106
)
104107
}
105108
}

0 commit comments

Comments
 (0)