Skip to content

Commit 6b21ce6

Browse files
committed
Introduce field-level diagnostics for rewrite rules
Enable field-aware metadata aggregation and diagnostics for rewrite rules, enhancing visibility of affected fields in composed and standalone operations. Refactor combinators and wrappers to support this functionality. Signed-off-by: Erik Pförtner <splatcrafter@splatgames.de>
1 parent 7e6c098 commit 6b21ce6

17 files changed

Lines changed: 2327 additions & 81 deletions

File tree

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)