From d4de04ceb01422307d9f3cd252b313dd896454aa Mon Sep 17 00:00:00 2001
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Date: Thu, 12 Dec 2024 18:27:01 +0100
Subject: keep formatting around javadocs
---
.../paper/datacomponent/DataComponentTypes.java | 2 +-
.../generatedApi/org/bukkit/block/Biome.java | 2 +-
.../types/registry/RegistryFieldRewriter.java | 4 ++--
.../rewriter/types/simple/trial/ConstantInfo.java | 14 ++++++-------
.../simple/trial/DataComponentTypesRewriter.java | 23 +++++++--------------
.../simple/trial/VillagerProfessionRewriter.java | 24 +++++++---------------
6 files changed, 25 insertions(+), 44 deletions(-)
(limited to 'paper-generator')
diff --git a/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java
index bc2ea58794..b1664fd911 100644
--- a/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java
+++ b/paper-generator/generatedApi/io/papermc/paper/datacomponent/DataComponentTypes.java
@@ -222,7 +222,7 @@ public final class DataComponentTypes {
*
can't be changed or removed in Anvil
* is not styled with italics when displayed to player
* does not show labels where applicable
- * (for example: banner markers, names in item frames)
+ * (for example: banner markers, names in item frames)
*
*
* @see #CUSTOM_NAME
diff --git a/paper-generator/generatedApi/org/bukkit/block/Biome.java b/paper-generator/generatedApi/org/bukkit/block/Biome.java
index c59ab8f194..28e6f9110c 100644
--- a/paper-generator/generatedApi/org/bukkit/block/Biome.java
+++ b/paper-generator/generatedApi/org/bukkit/block/Biome.java
@@ -165,7 +165,7 @@ public interface Biome extends OldEnum, Keyed, net.kyori.adventure.transl
@NotNull
private static Biome getBiome(@NotNull String key) {
- return Registry.BIOME.get(NamespacedKey.minecraft(key));
+ return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(key));
}
/**
diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java
index c2ca350571..b54233c402 100644
--- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java
+++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java
@@ -74,7 +74,7 @@ public class RegistryFieldRewriter extends SearchReplaceRewriter {
while (referenceIterator.hasNext()) {
Holder.Reference reference = referenceIterator.next();
- this.rewriteJavadocs(reference, metadata.indent(), builder);
+ this.rewriteJavadocs(reference, metadata.replacedContent(), metadata.indent(), builder);
SingleFlagHolder requiredFeature = this.getRequiredFeature(reference);
if (requiredFeature != null) {
@@ -98,7 +98,7 @@ public class RegistryFieldRewriter extends SearchReplaceRewriter {
}
}
- protected void rewriteJavadocs(Holder.Reference reference, String indent, StringBuilder builder) {
+ protected void rewriteJavadocs(Holder.Reference reference, String replacedContent, String indent, StringBuilder builder) {
}
protected boolean canPrintField(Holder.Reference reference) {
diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java
index 910b0528bb..db14ef4a6b 100644
--- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java
+++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ConstantInfo.java
@@ -1,30 +1,30 @@
package io.papermc.generator.rewriter.types.simple.trial;
-import java.util.List;
+import io.papermc.typewriter.parser.token.CharSequenceBlockToken;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
class ConstantInfo {
private @MonotonicNonNull String constantName;
- private @MonotonicNonNull List javadocs;
+ private @MonotonicNonNull CharSequenceBlockToken token;
public void constantName(String name) {
this.constantName = name;
}
- public void javadocs(List javadocs) {
- this.javadocs = javadocs;
+ public void javadocs(CharSequenceBlockToken token) {
+ this.token = token;
}
public String constantName() {
return this.constantName;
}
- public List javadocs() {
- return this.javadocs;
+ public CharSequenceBlockToken javadocs() {
+ return this.token;
}
public boolean isComplete() {
- return this.constantName != null && this.javadocs != null;
+ return this.constantName != null && this.token != null;
}
}
diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java
index 3291e78943..6e1e0019e9 100644
--- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java
+++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java
@@ -65,10 +65,10 @@ public class DataComponentTypesRewriter extends RegistryFieldRewriter> javadocsPerConstant;
+ private @MonotonicNonNull Map javadocsPerConstant;
- private Map> parseConstantJavadocs(String content) {
- Map> map = new HashMap<>();
+ private Map parseConstantJavadocs(String content) {
+ Map map = new HashMap<>();
Lexer lex = new Lexer(content.toCharArray());
SequenceTokens.wrap(lex, FORMAT_TOKENS)
@@ -76,7 +76,7 @@ public class DataComponentTypesRewriter extends RegistryFieldRewriter {
- info.javadocs(((CharSequenceBlockToken) token).value());
+ info.javadocs(((CharSequenceBlockToken) token));
}, TokenTaskBuilder::asOptional)
.skip(TokenType.PUBLIC).skip(TokenType.STATIC).skip(TokenType.FINAL)
.skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC))
@@ -144,20 +144,11 @@ public class DataComponentTypesRewriter extends RegistryFieldRewriter> reference, String indent, StringBuilder builder) {
+ protected void rewriteJavadocs(Holder.Reference> reference, String replacedContent, String indent, StringBuilder builder) {
String constantName = this.rewriteFieldName(reference);
if (this.javadocsPerConstant.containsKey(constantName)) {
- builder.append(indent).append("/**");
- builder.append('\n');
- for (String line : this.javadocsPerConstant.get(constantName)) {
- builder.append(indent).append(" *");
- if (!line.isEmpty()) {
- builder.append(' ').append(line);
- }
- builder.append('\n');
- }
- builder.append(indent).append(" */");
- builder.append('\n');
+ CharSequenceBlockToken token = this.javadocsPerConstant.get(constantName);
+ builder.append(indent).append(replacedContent, token.pos(), token.endPos()).append('\n');
}
}
diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java
index 4ea601fbe1..b973d3fe6c 100644
--- a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java
+++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java
@@ -10,7 +10,6 @@ import io.papermc.typewriter.parser.token.TokenType;
import io.papermc.typewriter.replace.SearchMetadata;
import java.util.EnumSet;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
@@ -30,10 +29,10 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter> javadocsPerConstant;
+ private @MonotonicNonNull Map javadocsPerConstant;
- private Map> parseConstantJavadocs(String content) {
- Map> map = new HashMap<>();
+ private Map parseConstantJavadocs(String content) {
+ Map map = new HashMap<>();
Lexer lex = new Lexer(content.toCharArray());
SequenceTokens.wrap(lex, FORMAT_TOKENS)
@@ -41,7 +40,7 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter {
- info.javadocs(((CharSequenceBlockToken) token).value());
+ info.javadocs(((CharSequenceBlockToken) token));
}, TokenTaskBuilder::asOptional)
.skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC))
.map(TokenType.IDENTIFIER, token -> {
@@ -91,20 +90,11 @@ public class VillagerProfessionRewriter extends RegistryFieldRewriter reference, String indent, StringBuilder builder) {
+ protected void rewriteJavadocs(Holder.Reference reference, String replacedContent, String indent, StringBuilder builder) {
String constantName = this.rewriteFieldName(reference);
if (this.javadocsPerConstant.containsKey(constantName)) {
- builder.append(indent).append("/**");
- builder.append('\n');
- for (String line : this.javadocsPerConstant.get(constantName)) {
- builder.append(indent).append(" *");
- if (!line.isEmpty()) {
- builder.append(' ').append(line);
- }
- builder.append('\n');
- }
- builder.append(indent).append(" */");
- builder.append('\n');
+ CharSequenceBlockToken token = this.javadocsPerConstant.get(constantName);
+ builder.append(indent).append(replacedContent, token.pos(), token.endPos()).append('\n');
}
}
}
--
cgit v1.2.3