Skip to content

Commit 0f87c26

Browse files
committed
chore: add variable control
ref: sourceplusplus/sourceplusplus#428
1 parent 3419814 commit 0f87c26

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/main/kotlin/spp/protocol/instrument/LiveBreakpoint.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package spp.protocol.instrument
1919
import io.vertx.codegen.annotations.DataObject
2020
import io.vertx.core.json.JsonObject
2121
import spp.protocol.instrument.throttle.InstrumentThrottle
22+
import spp.protocol.instrument.variable.LiveVariableControl
2223

2324
/**
2425
* A live breakpoint represents a non-breaking breakpoint.
@@ -28,6 +29,7 @@ import spp.protocol.instrument.throttle.InstrumentThrottle
2829
*/
2930
@DataObject
3031
data class LiveBreakpoint(
32+
val variableControl: LiveVariableControl? = null,
3133
override val location: LiveSourceLocation,
3234
override val condition: String? = null,
3335
override val expiresAt: Long? = null,
@@ -42,6 +44,7 @@ data class LiveBreakpoint(
4244
override val type: LiveInstrumentType = LiveInstrumentType.BREAKPOINT
4345

4446
constructor(json: JsonObject) : this(
47+
variableControl = json.getJsonObject("variableControl")?.let { LiveVariableControl(it) },
4548
location = LiveSourceLocation(json.getJsonObject("location")),
4649
condition = json.getString("condition"),
4750
expiresAt = json.getLong("expiresAt"),
@@ -57,6 +60,7 @@ data class LiveBreakpoint(
5760
override fun toJson(): JsonObject {
5861
val json = JsonObject()
5962
json.put("type", type.name)
63+
json.put("variableControl", variableControl?.toJson())
6064
json.put("location", location.toJson())
6165
json.put("condition", condition)
6266
json.put("expiresAt", expiresAt)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Source++, the continuous feedback platform for developers.
3+
* Copyright (C) 2022 CodeBrig, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package spp.protocol.instrument.variable
18+
19+
import io.vertx.codegen.annotations.DataObject
20+
import io.vertx.core.json.JsonObject
21+
22+
/**
23+
* Allows for fine-grained control over the serialization of [LiveVariable]s.
24+
*/
25+
@DataObject
26+
data class LiveVariableControl(
27+
val maxObjectDepth: Int? = null,
28+
val maxObjectSize: Int? = null,
29+
val maxCollectionLength: Int? = null,
30+
val variableTypeConfig: Map<String, LiveVariableControl> = emptyMap(),
31+
val variableNameConfig: Map<String, LiveVariableControl> = emptyMap()
32+
) {
33+
constructor(json: JsonObject) : this(
34+
maxObjectDepth = json.getInteger("maxObjectDepth"),
35+
maxObjectSize = json.getInteger("maxObjectSize"),
36+
maxCollectionLength = json.getInteger("maxCollectionLength"),
37+
variableTypeConfig = json.getJsonObject("variableTypeConfig")
38+
.associate { it.key to LiveVariableControl(it.value as JsonObject) },
39+
variableNameConfig = json.getJsonObject("variableNameConfig")
40+
.associate { it.key to LiveVariableControl(it.value as JsonObject) }
41+
)
42+
43+
fun toJson(): JsonObject {
44+
return JsonObject.mapFrom(this)
45+
}
46+
}

0 commit comments

Comments
 (0)