Skip to content

Commit de92196

Browse files
authored
Merge pull request #264 from aether-framework/feature/field-aware-diagnostics
Enhance field-level diagnostics and documentation
2 parents 7e6c098 + 8cbfb46 commit de92196

97 files changed

Lines changed: 8431 additions & 432 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/DataVersion.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import de.splatgames.aether.datafixers.api.fix.DataFixer;
2828
import de.splatgames.aether.datafixers.api.schema.Schema;
2929
import org.jetbrains.annotations.NotNull;
30+
import org.jetbrains.annotations.Nullable;
3031

3132
import java.util.Objects;
3233

@@ -171,7 +172,7 @@ public int compareTo(@NotNull final DataVersion o) {
171172
* @see #hashCode()
172173
*/
173174
@Override
174-
public boolean equals(final Object obj) {
175+
public boolean equals(@Nullable final Object obj) {
175176
if (this == obj) {
176177
return true;
177178
}
@@ -222,6 +223,7 @@ public int hashCode() {
222223
* @return a string representation of this data version in the format {@code "DataVersion{version=N}"}
223224
*/
224225
@Override
226+
@NotNull
225227
public String toString() {
226228
return "DataVersion{" + "version=" + this.version + '}';
227229
}

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/TypeReference.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import de.splatgames.aether.datafixers.api.type.Type;
2929
import de.splatgames.aether.datafixers.api.type.TypeRegistry;
3030
import org.jetbrains.annotations.NotNull;
31+
import org.jetbrains.annotations.Nullable;
3132

3233
/**
3334
* A unique identifier for a data type in the data fixing system.
@@ -183,7 +184,7 @@ public int hashCode() {
183184
* @see #hashCode()
184185
*/
185186
@Override
186-
public boolean equals(final Object obj) {
187+
public boolean equals(@Nullable final Object obj) {
187188
if (this == obj) {
188189
return true;
189190
}
@@ -217,6 +218,7 @@ public boolean equals(final Object obj) {
217218
* @see #getId()
218219
*/
219220
@Override
221+
@NotNull
220222
public String toString() {
221223
return "TypeReference{" + "id='" + this.id + '\'' + '}';
222224
}

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/diagnostic/DiagnosticOptions.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
* @param captureRuleDetails whether to capture individual rule application details
5454
* @param maxSnapshotLength maximum length for snapshot strings (0 for unlimited)
5555
* @param prettyPrintSnapshots whether to format snapshots for readability
56+
* @param captureFieldDetails whether to capture field-level operation metadata from
57+
* {@link de.splatgames.aether.datafixers.api.rewrite.FieldAwareRule}
58+
* implementations; requires {@code captureRuleDetails} to be
59+
* {@code true} to have any effect (since 1.0.0)
5660
* @author Erik Pförtner
5761
* @see DiagnosticContext
5862
* @see MigrationReport
@@ -62,7 +66,8 @@ public record DiagnosticOptions(
6266
boolean captureSnapshots,
6367
boolean captureRuleDetails,
6468
int maxSnapshotLength,
65-
boolean prettyPrintSnapshots
69+
boolean prettyPrintSnapshots,
70+
boolean captureFieldDetails
6671
) {
6772

6873
/**
@@ -79,13 +84,14 @@ public record DiagnosticOptions(
7984
* <li>{@code captureRuleDetails} = {@code true}</li>
8085
* <li>{@code maxSnapshotLength} = {@code 10000}</li>
8186
* <li>{@code prettyPrintSnapshots} = {@code true}</li>
87+
* <li>{@code captureFieldDetails} = {@code true}</li>
8288
* </ul>
8389
*
8490
* @return default diagnostic options
8591
*/
8692
@NotNull
8793
public static DiagnosticOptions defaults() {
88-
return new DiagnosticOptions(true, true, DEFAULT_MAX_SNAPSHOT_LENGTH, true);
94+
return new DiagnosticOptions(true, true, DEFAULT_MAX_SNAPSHOT_LENGTH, true, true);
8995
}
9096

9197
/**
@@ -97,13 +103,14 @@ public static DiagnosticOptions defaults() {
97103
* <li>{@code captureRuleDetails} = {@code false}</li>
98104
* <li>{@code maxSnapshotLength} = {@code 0}</li>
99105
* <li>{@code prettyPrintSnapshots} = {@code false}</li>
106+
* <li>{@code captureFieldDetails} = {@code false}</li>
100107
* </ul>
101108
*
102109
* @return minimal diagnostic options
103110
*/
104111
@NotNull
105112
public static DiagnosticOptions minimal() {
106-
return new DiagnosticOptions(false, false, 0, false);
113+
return new DiagnosticOptions(false, false, 0, false, false);
107114
}
108115

109116
/**
@@ -127,6 +134,7 @@ public static final class Builder {
127134
private boolean captureRuleDetails = true;
128135
private int maxSnapshotLength = DEFAULT_MAX_SNAPSHOT_LENGTH;
129136
private boolean prettyPrintSnapshots = true;
137+
private boolean captureFieldDetails = true;
130138

131139
private Builder() {
132140
}
@@ -197,6 +205,24 @@ public Builder prettyPrintSnapshots(final boolean prettyPrintSnapshots) {
197205
return this;
198206
}
199207

208+
/**
209+
* Sets whether to capture field-level operation metadata.
210+
*
211+
* <p>When enabled and {@code captureRuleDetails} is also enabled, the migration
212+
* report will include structured metadata about which fields each rule affects.
213+
* This information is extracted from rules that implement
214+
* {@link de.splatgames.aether.datafixers.api.rewrite.FieldAwareRule}.</p>
215+
*
216+
* @param captureFieldDetails {@code true} to capture field-level details
217+
* @return this builder
218+
* @since 1.0.0
219+
*/
220+
@NotNull
221+
public Builder captureFieldDetails(final boolean captureFieldDetails) {
222+
this.captureFieldDetails = captureFieldDetails;
223+
return this;
224+
}
225+
200226
/**
201227
* Builds the diagnostic options.
202228
*
@@ -208,7 +234,8 @@ public DiagnosticOptions build() {
208234
this.captureSnapshots,
209235
this.captureRuleDetails,
210236
this.maxSnapshotLength,
211-
this.prettyPrintSnapshots
237+
this.prettyPrintSnapshots,
238+
this.captureFieldDetails
212239
);
213240
}
214241
}

0 commit comments

Comments
 (0)