Important bugfixes
This commit is contained in:
parent
9340babe61
commit
a0e79ab1d9
@ -711,6 +711,10 @@ public class SourcesGenerator {
|
|||||||
for (Entry<String, CustomTypesConfiguration> entry : versionConfiguration.customTypes.entrySet()) {
|
for (Entry<String, CustomTypesConfiguration> entry : versionConfiguration.customTypes.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
CustomTypesConfiguration customTypeConfiguration = entry.getValue();
|
CustomTypesConfiguration customTypeConfiguration = entry.getValue();
|
||||||
|
Optional<CustomTypesConfiguration> nextVersionCustomTypeConfiguration = nextVersion
|
||||||
|
.map(s -> Objects.requireNonNull(configuration.versions.get(s).customTypes.get(key),
|
||||||
|
() -> "Custom type " + key + " not found in version " + s
|
||||||
|
));
|
||||||
typeOptionalSerializers.put(key, ClassName.bestGuess(customTypeConfiguration.serializer));
|
typeOptionalSerializers.put(key, ClassName.bestGuess(customTypeConfiguration.serializer));
|
||||||
typeSerializeStatement.put(key,
|
typeSerializeStatement.put(key,
|
||||||
new SerializeCodeBlockGenerator(CodeBlock
|
new SerializeCodeBlockGenerator(CodeBlock
|
||||||
@ -727,8 +731,8 @@ public class SourcesGenerator {
|
|||||||
typeMustGenerateSerializer.put(key, false);
|
typeMustGenerateSerializer.put(key, false);
|
||||||
typeTypes.put(key, ClassName.bestGuess(customTypeConfiguration.javaClass));
|
typeTypes.put(key, ClassName.bestGuess(customTypeConfiguration.javaClass));
|
||||||
typeFamily.put(key, Family.OTHER);
|
typeFamily.put(key, Family.OTHER);
|
||||||
if (nextVersion.isPresent()) {
|
if (nextVersionCustomTypeConfiguration.isPresent()) {
|
||||||
nextVersionTypeTypes.put(key, ClassName.bestGuess(customTypeConfiguration.javaClass));
|
nextVersionTypeTypes.put(key, ClassName.bestGuess(nextVersionCustomTypeConfiguration.get().javaClass));
|
||||||
nextVersionTypeFamily.put(key, Family.OTHER);
|
nextVersionTypeFamily.put(key, Family.OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1495,6 +1499,12 @@ public class SourcesGenerator {
|
|||||||
if (!isFirst.getAndSet(false)) {
|
if (!isFirst.getAndSet(false)) {
|
||||||
deserializeMethod.addCode(", ");
|
deserializeMethod.addCode(", ");
|
||||||
}
|
}
|
||||||
|
if (currentVarNumber.getInt(field) < 0) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Field " + field + " in class " + type + " has an invalid var number ("
|
||||||
|
+ currentVarNumber.getInt(field) + ") after upgrading from version " + version
|
||||||
|
+ " to version " + nextVersion.orElse("---"));
|
||||||
|
}
|
||||||
deserializeMethod.addCode("$$field$$" + currentVarNumber.getInt(field) + "$$" + field);
|
deserializeMethod.addCode("$$field$$" + currentVarNumber.getInt(field) + "$$" + field);
|
||||||
}
|
}
|
||||||
deserializeMethod.addStatement(")");
|
deserializeMethod.addStatement(")");
|
||||||
@ -2612,12 +2622,17 @@ public class SourcesGenerator {
|
|||||||
.add("$T.Nullable" + type + "SerializerInstance.deserialize(dataInput)", versionClassType).build());
|
.add("$T.Nullable" + type + "SerializerInstance.deserialize(dataInput)", versionClassType).build());
|
||||||
typeMustGenerateSerializer.put("-" + type, true);
|
typeMustGenerateSerializer.put("-" + type, true);
|
||||||
typeTypes.put("-" + type, ClassName.get(joinPackage(versionPackage, "data.nullables"), "Nullable" + type));
|
typeTypes.put("-" + type, ClassName.get(joinPackage(versionPackage, "data.nullables"), "Nullable" + type));
|
||||||
|
}
|
||||||
|
if (typeFamily != null) {
|
||||||
typeFamily.put("-" + type, nullableFamily);
|
typeFamily.put("-" + type, nullableFamily);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextVersionNullableTypeNeeded) {
|
if (nextVersionNullableTypeNeeded) {
|
||||||
assert nextVersionTypeTypes != null;
|
assert nextVersionTypeTypes != null;
|
||||||
assert nextVersionTypeFamily != null;
|
assert nextVersionTypeFamily != null;
|
||||||
nextVersionTypeTypes.put("-" + type, ClassName.get(joinPackage(nextVersionPackage.orElseThrow(), "data.nullables"), "Nullable" + type));
|
nextVersionTypeTypes.put("-" + type, ClassName.get(joinPackage(nextVersionPackage.orElseThrow(), "data.nullables"), "Nullable" + type));
|
||||||
|
}
|
||||||
|
if (nextVersionTypeFamily != null) {
|
||||||
nextVersionTypeFamily.put("-" + type, nullableFamily);
|
nextVersionTypeFamily.put("-" + type, nullableFamily);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2653,12 +2668,17 @@ public class SourcesGenerator {
|
|||||||
type
|
type
|
||||||
);
|
);
|
||||||
typeTypes.put("§" + type, getImmutableArrayType(arrayClassName.get()));
|
typeTypes.put("§" + type, getImmutableArrayType(arrayClassName.get()));
|
||||||
|
}
|
||||||
|
if (typeFamily != null) {
|
||||||
typeFamily.put("§" + type, Family.I_TYPE_ARRAY);
|
typeFamily.put("§" + type, Family.I_TYPE_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextVersionArrayTypeNeeded) {
|
if (nextVersionArrayTypeNeeded) {
|
||||||
assert nextVersionTypeTypes != null;
|
assert nextVersionTypeTypes != null;
|
||||||
assert nextVersionTypeFamily != null;
|
assert nextVersionTypeFamily != null;
|
||||||
nextVersionTypeTypes.put("§" + type, getImmutableArrayType(nextArrayClassName.get()));
|
nextVersionTypeTypes.put("§" + type, getImmutableArrayType(nextArrayClassName.get()));
|
||||||
|
}
|
||||||
|
if (nextVersionTypeFamily != null) {
|
||||||
nextVersionTypeFamily.put("§" + type, Family.I_TYPE_ARRAY);
|
nextVersionTypeFamily.put("§" + type, Family.I_TYPE_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user