Skip to content

Commit 826fa55

Browse files
committed
nbt: Add friendly output formatting for IntelliJ debugger
1 parent 89bc992 commit 826fa55

14 files changed

+26
-1
lines changed

api/src/main/java/net/kyori/adventure/text/AbstractComponent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected Stream<? extends ExaminableProperty> examinablePropertiesWithoutChildr
143143
return Stream.concat(
144144
this.examinablePropertiesWithoutChildren(),
145145
Stream.of(
146-
ExaminableProperty.of("style", this.style)
146+
ExaminableProperty.of("children", this.children)
147147
)
148148
);
149149
}

nbt/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dependencies {
22
api("net.kyori:examination-api:1.1.0")
33
api("net.kyori:examination-string:1.1.0")
44
compileOnlyApi("org.checkerframework:checker-qual:3.10.0")
5+
compileOnlyApi("org.jetbrains:annotations:20.1.0")
56
}
67

78
jar {

nbt/src/main/java/net/kyori/adventure/nbt/ByteArrayBinaryTagImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import net.kyori.examination.ExaminableProperty;
3030
import org.checkerframework.checker.nullness.qual.NonNull;
3131
import org.checkerframework.checker.nullness.qual.Nullable;
32+
import org.jetbrains.annotations.Debug;
3233

34+
@Debug.Renderer(text = "\"byte[\" + this.value.length + \"]\"", childrenArray = "this.value", hasChildren = "this.value.length > 0")
3335
final class ByteArrayBinaryTagImpl extends ArrayBinaryTagImpl implements ByteArrayBinaryTag {
3436
final byte[] value;
3537

nbt/src/main/java/net/kyori/adventure/nbt/ByteBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding a {@code byte} value.
@@ -79,6 +80,7 @@ public interface ByteBinaryTag extends NumberBinaryTag {
7980
byte value();
8081
}
8182

83+
@Debug.Renderer(text = "\"0x\" + Integer.toString(this.value, 16)", hasChildren = "false")
8284
final class ByteBinaryTagImpl extends AbstractBinaryTag implements ByteBinaryTag {
8385
private final byte value;
8486

nbt/src/main/java/net/kyori/adventure/nbt/CompoundBinaryTagImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
import net.kyori.examination.ExaminableProperty;
3434
import org.checkerframework.checker.nullness.qual.NonNull;
3535
import org.checkerframework.checker.nullness.qual.Nullable;
36+
import org.jetbrains.annotations.Debug;
3637

3738
import static java.util.Objects.requireNonNull;
3839

40+
@Debug.Renderer(text = "\"CompoundBinaryTag[length=\" + this.tags.size() + \"]\"", childrenArray = "this.tags.entrySet().toArray()", hasChildren = "!this.tags.isEmpty()")
3941
final class CompoundBinaryTagImpl extends AbstractBinaryTag implements CompoundBinaryTag {
4042
static final CompoundBinaryTag EMPTY = new CompoundBinaryTagImpl(Collections.emptyMap());
4143
private final Map<String, BinaryTag> tags;

nbt/src/main/java/net/kyori/adventure/nbt/DoubleBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding a {@code double} value.
@@ -59,6 +60,7 @@ public interface DoubleBinaryTag extends NumberBinaryTag {
5960
double value();
6061
}
6162

63+
@Debug.Renderer(text = "String.valueOf(this.value) + \"d\"", hasChildren = "false")
6264
final class DoubleBinaryTagImpl extends AbstractBinaryTag implements DoubleBinaryTag {
6365
private final double value;
6466

nbt/src/main/java/net/kyori/adventure/nbt/FloatBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding a {@code float} value.
@@ -59,6 +60,7 @@ public interface FloatBinaryTag extends NumberBinaryTag {
5960
float value();
6061
}
6162

63+
@Debug.Renderer(text = "String.valueOf(this.value) + \"f\"", hasChildren = "false")
6264
final class FloatBinaryTagImpl extends AbstractBinaryTag implements FloatBinaryTag {
6365
private final float value;
6466

nbt/src/main/java/net/kyori/adventure/nbt/IntArrayBinaryTagImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
import net.kyori.examination.ExaminableProperty;
3434
import org.checkerframework.checker.nullness.qual.NonNull;
3535
import org.checkerframework.checker.nullness.qual.Nullable;
36+
import org.jetbrains.annotations.Debug;
3637

38+
@Debug.Renderer(text = "\"int[\" + this.value.length + \"]\"", childrenArray = "this.value", hasChildren = "this.value.length > 0")
3739
final class IntArrayBinaryTagImpl extends ArrayBinaryTagImpl implements IntArrayBinaryTag {
3840
final int[] value;
3941

nbt/src/main/java/net/kyori/adventure/nbt/IntBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding an {@code int} value.
@@ -59,6 +60,7 @@ public interface IntBinaryTag extends NumberBinaryTag {
5960
int value();
6061
}
6162

63+
@Debug.Renderer(text = "String.valueOf(this.value) + \"i\"", hasChildren = "false")
6264
final class IntBinaryTagImpl extends AbstractBinaryTag implements IntBinaryTag {
6365
private final int value;
6466

nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTagImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
import org.checkerframework.checker.index.qual.NonNegative;
3737
import org.checkerframework.checker.nullness.qual.NonNull;
3838
import org.checkerframework.checker.nullness.qual.Nullable;
39+
import org.jetbrains.annotations.Debug;
3940

41+
@Debug.Renderer(text = "\"ListBinaryTag[type=\" + this.type.toString() + \"]\"", childrenArray = "this.tags.toArray()", hasChildren = "!this.tags.isEmpty()")
4042
final class ListBinaryTagImpl extends AbstractBinaryTag implements ListBinaryTag {
4143
static final ListBinaryTag EMPTY = new ListBinaryTagImpl(BinaryTagTypes.END, Collections.emptyList());
4244
private final List<BinaryTag> tags;

nbt/src/main/java/net/kyori/adventure/nbt/LongArrayBinaryTagImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
import net.kyori.examination.ExaminableProperty;
3434
import org.checkerframework.checker.nullness.qual.NonNull;
3535
import org.checkerframework.checker.nullness.qual.Nullable;
36+
import org.jetbrains.annotations.Debug;
3637

38+
@Debug.Renderer(text = "\"long[\" + this.value.length + \"]\"", childrenArray = "this.value", hasChildren = "this.value.length > 0")
3739
final class LongArrayBinaryTagImpl extends ArrayBinaryTagImpl implements LongArrayBinaryTag {
3840
final long[] value;
3941

nbt/src/main/java/net/kyori/adventure/nbt/LongBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding a {@code long} value.
@@ -59,6 +60,7 @@ public interface LongBinaryTag extends NumberBinaryTag {
5960
long value();
6061
}
6162

63+
@Debug.Renderer(text = "String.valueOf(this.value) + \"l\"", hasChildren = "false")
6264
final class LongBinaryTagImpl extends AbstractBinaryTag implements LongBinaryTag {
6365
private final long value;
6466

nbt/src/main/java/net/kyori/adventure/nbt/ShortBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding a {@code short} value.
@@ -59,6 +60,7 @@ public interface ShortBinaryTag extends NumberBinaryTag {
5960
short value();
6061
}
6162

63+
@Debug.Renderer(text = "String.valueOf(this.value) + \"s\"", hasChildren = "false")
6264
final class ShortBinaryTagImpl extends AbstractBinaryTag implements ShortBinaryTag {
6365
private final short value;
6466

nbt/src/main/java/net/kyori/adventure/nbt/StringBinaryTag.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.examination.ExaminableProperty;
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.checkerframework.checker.nullness.qual.Nullable;
30+
import org.jetbrains.annotations.Debug;
3031

3132
/**
3233
* A binary tag holding a {@link String} value.
@@ -59,6 +60,7 @@ public interface StringBinaryTag extends BinaryTag {
5960
@NonNull String value();
6061
}
6162

63+
@Debug.Renderer(text = "\"\\\"\" + this.value + \"\\\"\"", hasChildren = "false")
6264
final class StringBinaryTagImpl extends AbstractBinaryTag implements StringBinaryTag {
6365
private final String value;
6466

0 commit comments

Comments
 (0)