diff --git a/pom.xml b/pom.xml
index aed3f0b0..f8da1e97 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,6 @@
Schema2proto - XSD schema to protobuf.
schema2proto-lib
- schema2proto-wire
schema2proto-maven-plugin
schema2proto-xsdproto
schema2proto-xsom
@@ -59,11 +58,6 @@
pom
import
-
- ${project.groupId}
- schema2proto-wire
- ${project.version}
-
${project.groupId}
schema2proto-xsom
@@ -189,6 +183,11 @@
wire-runtime-jvm
${wire.version}
+
+ com.squareup.wire
+ wire-schema-jvm
+ ${wire.version}
+
org.assertj
assertj-core
diff --git a/schema2proto-lib/pom.xml b/schema2proto-lib/pom.xml
index aea1743f..1f67041b 100644
--- a/schema2proto-lib/pom.xml
+++ b/schema2proto-lib/pom.xml
@@ -37,8 +37,12 @@
slf4j-simple
- no.entur
- schema2proto-wire
+ com.squareup.wire
+ wire-schema-jvm
+
+
+ com.squareup.okio
+ okio
com.google.protobuf
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/EnumConflictChecker.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/EnumConflictChecker.java
index 2d5cefef..6227f8c2 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/EnumConflictChecker.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/EnumConflictChecker.java
@@ -36,20 +36,20 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.squareup.wire.schema.EnumConstant;
-import com.squareup.wire.schema.EnumType;
import com.squareup.wire.schema.Location;
-import com.squareup.wire.schema.ProtoFile;
import no.entur.schema2proto.compatibility.protolock.ProtolockEnum;
import no.entur.schema2proto.compatibility.protolock.ProtolockEnumConstant;
+import no.entur.schema2proto.wire.MutableEnumConstant;
+import no.entur.schema2proto.wire.MutableEnumType;
+import no.entur.schema2proto.wire.MutableProtoFile;
public class EnumConflictChecker {
private final static Logger LOGGER = LoggerFactory.getLogger(EnumConflictChecker.class);
private boolean failIfRemovedFieldsTriggered;
- public boolean tryResolveEnumConflicts(ProtoFile file, EnumType enumType, ProtolockEnum protolockEnum) {
+ public boolean tryResolveEnumConflicts(MutableProtoFile file, MutableEnumType enumType, ProtolockEnum protolockEnum) {
SortedSet lockEnumConstants = Collections.unmodifiableSortedSet(new TreeSet<>(Arrays.asList(protolockEnum.getEnumFields()))); // from
// proto.lock
SortedSet xsdEnumConstants = Collections.unmodifiableSortedSet(
@@ -90,7 +90,7 @@ public boolean tryResolveEnumConflicts(ProtoFile file, EnumType enumType, Protol
AtomicInteger nextId = new AtomicInteger(maxLockId + 1);
- for (EnumConstant constant : enumType.constants()) {
+ for (MutableEnumConstant constant : enumType.constants()) {
if (!lockNames.contains(constant.getName())) {
while (enumType.reserveds().stream().anyMatch(s -> s.matchesTag(nextId.get()))) {
nextId.incrementAndGet();
@@ -108,7 +108,7 @@ public boolean tryResolveEnumConflicts(ProtoFile file, EnumType enumType, Protol
return failIfRemovedFieldsTriggered;
}
- private void reserveEnumConstant(ProtoFile file, EnumType e, ProtolockEnumConstant newEnumConstant) {
+ private void reserveEnumConstant(MutableProtoFile file, MutableEnumType e, ProtolockEnumConstant newEnumConstant) {
String reservationDoc = "Reservation added by schema2proto";
Location loc = new Location("", "", 0, 0);
@@ -123,7 +123,7 @@ private void reserveEnumConstant(ProtoFile file, EnumType e, ProtolockEnumConsta
failIfRemovedFieldsTriggered = true;
}
- private static Optional getConstant(EnumType e, String intrudingConstantName) {
+ private static Optional getConstant(MutableEnumType e, String intrudingConstantName) {
return e.constants().stream().filter(z -> z.getName().equals(intrudingConstantName)).findFirst();
}
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/FieldConflictChecker.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/FieldConflictChecker.java
index 208f38ec..ac097650 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/FieldConflictChecker.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/FieldConflictChecker.java
@@ -41,20 +41,20 @@
import org.slf4j.LoggerFactory;
import com.google.common.collect.BiMap;
-import com.squareup.wire.schema.Field;
import com.squareup.wire.schema.Location;
-import com.squareup.wire.schema.MessageType;
-import com.squareup.wire.schema.ProtoFile;
import no.entur.schema2proto.compatibility.protolock.ProtolockField;
import no.entur.schema2proto.compatibility.protolock.ProtolockMessage;
+import no.entur.schema2proto.wire.MutableField;
+import no.entur.schema2proto.wire.MutableMessageType;
+import no.entur.schema2proto.wire.MutableProtoFile;
public class FieldConflictChecker {
private final Logger LOGGER = LoggerFactory.getLogger(FieldConflictChecker.class);
private boolean failIfRemovedFieldsTriggered;
- public boolean tryResolveFieldConflicts(ProtoFile file, MessageType protoMessage, ProtolockMessage protolockMessage) {
+ public boolean tryResolveFieldConflicts(MutableProtoFile file, MutableMessageType protoMessage, ProtolockMessage protolockMessage) {
// Compute helper maps
SortedSet lockFileFields = Collections.unmodifiableSortedSet(getFields(protolockMessage)); // from proto.lock
@@ -84,7 +84,7 @@ public boolean tryResolveFieldConflicts(ProtoFile file, MessageType protoMessage
if (originalIdForField == null) {
originalIdForField = findNextAvailableFieldNum(protoMessage, protoMessageFieldAsLockFields, lockFileFields).get();
}
- Optional intrudingField = getField(protoMessage, protoMessageFieldAsLockField.getName());
+ Optional intrudingField = getField(protoMessage, protoMessageFieldAsLockField.getName());
intrudingField.get().updateTag(originalIdForField);
//
@@ -164,8 +164,8 @@ public boolean tryResolveFieldConflicts(ProtoFile file, MessageType protoMessage
}
- private void updateFieldTag(AtomicInteger nextAvailableFieldNum, int overlappingId, Optional intrudingField, Optional existingField,
- Integer idFromLockFile) {
+ private void updateFieldTag(AtomicInteger nextAvailableFieldNum, int overlappingId, Optional intrudingField,
+ Optional existingField, Integer idFromLockFile) {
intrudingField.ifPresent(x -> {
if (idFromLockFile != null) {
x.updateTag(idFromLockFile);
@@ -178,7 +178,7 @@ private void updateFieldTag(AtomicInteger nextAvailableFieldNum, int overlapping
}
@NotNull
- private AtomicInteger findNextAvailableFieldNum(MessageType e, SortedSet xsdFields, SortedSet lockFields) {
+ private AtomicInteger findNextAvailableFieldNum(MutableMessageType e, SortedSet xsdFields, SortedSet lockFields) {
AtomicInteger nextAvailableFieldNum = new AtomicInteger(
xsdFields.stream().max(Comparator.comparing(ProtolockField::getId)).orElse(new ProtolockField(0, null)).getId() + 1);
@@ -207,15 +207,15 @@ private boolean isReserved(ProtolockMessage protolockMessage, ProtolockField fie
return reservedFieldNum;
}
- private Optional getField(MessageType e, String fieldName) {
+ private Optional getField(MutableMessageType e, String fieldName) {
return e.fieldsAndOneOfFields().stream().filter(z -> z.name().equals(fieldName)).findFirst();
}
- private Optional getField(MessageType e, Integer fieldId) {
+ private Optional getField(MutableMessageType e, Integer fieldId) {
return e.fieldsAndOneOfFields().stream().filter(z -> z.tag() == fieldId).findFirst();
}
- private void reserveField(ProtoFile file, MessageType e, ProtolockField newField) {
+ private void reserveField(MutableProtoFile file, MutableMessageType e, ProtolockField newField) {
String reservationDoc = "Reservation added by schema2proto";
Location loc = new Location("", "", 0, 0);
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/ProtolockBackwardsCompatibilityChecker.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/ProtolockBackwardsCompatibilityChecker.java
index 4f272515..857a3df5 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/ProtolockBackwardsCompatibilityChecker.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/compatibility/ProtolockBackwardsCompatibilityChecker.java
@@ -33,16 +33,16 @@
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-import com.squareup.wire.schema.EnumType;
import com.squareup.wire.schema.Location;
-import com.squareup.wire.schema.MessageType;
-import com.squareup.wire.schema.ProtoFile;
import no.entur.schema2proto.compatibility.protolock.ProtolockDefinition;
import no.entur.schema2proto.compatibility.protolock.ProtolockDefinitions;
import no.entur.schema2proto.compatibility.protolock.ProtolockEnum;
import no.entur.schema2proto.compatibility.protolock.ProtolockFile;
import no.entur.schema2proto.compatibility.protolock.ProtolockMessage;
+import no.entur.schema2proto.wire.MutableEnumType;
+import no.entur.schema2proto.wire.MutableMessageType;
+import no.entur.schema2proto.wire.MutableProtoFile;
public class ProtolockBackwardsCompatibilityChecker {
@@ -66,7 +66,7 @@ public ProtolockDefinitions getDefinitions() {
return definitions;
}
- private void copyReservations(ProtolockMessage protolockMessage, MessageType protoMessage) {
+ private void copyReservations(ProtolockMessage protolockMessage, MutableMessageType protoMessage) {
if (protolockMessage.getReservedIds() != null && protolockMessage.getReservedIds().length > 0) {
Arrays.stream(protolockMessage.getReservedIds()).forEach(reservedId -> protoMessage.addReserved(reservationDoc, reservationLocation, reservedId));
}
@@ -75,7 +75,7 @@ private void copyReservations(ProtolockMessage protolockMessage, MessageType pro
.forEach(reservedName -> protoMessage.addReserved(reservationDoc, reservationLocation, reservedName));
}
- protoMessage.nestedTypes().stream().filter(z -> z instanceof MessageType).map(k -> (MessageType) k).forEach(nestedType -> {
+ protoMessage.nestedTypes().stream().filter(z -> z instanceof MutableMessageType).map(k -> (MutableMessageType) k).forEach(nestedType -> {
if (protolockMessage.getMessages() != null) {
Arrays.stream(protolockMessage.getMessages()).forEach(nestedProtolockMessage -> {
if (nestedProtolockMessage.getName().equals(nestedType.getName())) {
@@ -87,7 +87,7 @@ private void copyReservations(ProtolockMessage protolockMessage, MessageType pro
}
- private void copyReservations(ProtolockEnum protolockEnum, EnumType protoEnum) {
+ private void copyReservations(ProtolockEnum protolockEnum, MutableEnumType protoEnum) {
LOGGER.debug("Copying reservations for message {} and enum {}", protolockEnum, protoEnum);
if (protolockEnum.getReservedIds() != null && protolockEnum.getReservedIds().length > 0) {
Arrays.stream(protolockEnum.getReservedIds()).forEach(reservedId -> protoEnum.addReserved(reservationDoc, reservationLocation, reservedId));
@@ -97,7 +97,7 @@ private void copyReservations(ProtolockEnum protolockEnum, EnumType protoEnum) {
}
}
- public boolean resolveBackwardIncompatibilities(ProtoFile protoFile) {
+ public boolean resolveBackwardIncompatibilities(MutableProtoFile protoFile) {
LOGGER.debug("Trying to resolve backward incompabilities in file {}", protoFile);
AtomicBoolean failIfRemovedFieldsTriggered = new AtomicBoolean(false);
@@ -107,7 +107,7 @@ public boolean resolveBackwardIncompatibilities(ProtoFile protoFile) {
if (protolockFile != null) {
// For each enum on file level (global enums)
- protoFile.types().stream().filter(type -> type instanceof EnumType).map(enumType -> (EnumType) enumType).forEach(enumType -> {
+ protoFile.types().stream().filter(type -> type instanceof MutableEnumType).map(enumType -> (MutableEnumType) enumType).forEach(enumType -> {
if (protolockFile.getEnums() != null) {
Arrays.stream(protolockFile.getEnums()).filter(pe -> pe.getName().equals(enumType.name())).findFirst().ifPresent(protolockEnum -> {
copyReservations(protolockEnum, enumType);
@@ -119,7 +119,7 @@ public boolean resolveBackwardIncompatibilities(ProtoFile protoFile) {
}
});
- protoFile.types().stream().filter(z -> z instanceof MessageType).map(ke -> (MessageType) ke).forEach(e -> {
+ protoFile.types().stream().filter(z -> z instanceof MutableMessageType).map(ke -> (MutableMessageType) ke).forEach(e -> {
// For each root level message in file
ProtolockMessage protolockMessage = getProtolockMessage(protolockFile, e);
if (protolockMessage != null) {
@@ -134,7 +134,7 @@ public boolean resolveBackwardIncompatibilities(ProtoFile protoFile) {
return failIfRemovedFieldsTriggered.get();
}
- private boolean resolveBackwardIncompatibilities(ProtoFile protoFile, ProtolockMessage protolockMessage, MessageType protoMessage) {
+ private boolean resolveBackwardIncompatibilities(MutableProtoFile protoFile, ProtolockMessage protolockMessage, MutableMessageType protoMessage) {
LOGGER.debug("Resolving backward compabilities in file {}, message {}", protoFile.name(), protoMessage);
AtomicBoolean failIfRemovedFieldsTriggered = new AtomicBoolean(false);
@@ -149,7 +149,7 @@ private boolean resolveBackwardIncompatibilities(ProtoFile protoFile, ProtolockM
failIfRemovedFieldsTriggered.set(true);
}
- protoMessage.nestedTypes().stream().filter(type -> type instanceof MessageType).map(r -> (MessageType) r).forEach(nestedProtoMessage -> {
+ protoMessage.nestedTypes().stream().filter(type -> type instanceof MutableMessageType).map(r -> (MutableMessageType) r).forEach(nestedProtoMessage -> {
ProtolockMessage nestedProtolockMessage = getNestedProtolockMessage(protolockMessage, nestedProtoMessage);
if (nestedProtolockMessage != null) {
if (resolveBackwardIncompatibilities(protoFile, nestedProtolockMessage, nestedProtoMessage)) {
@@ -162,11 +162,11 @@ private boolean resolveBackwardIncompatibilities(ProtoFile protoFile, ProtolockM
}
- private boolean tryResolveEnumConflicts(ProtoFile protoFile, MessageType protoMessage, ProtolockMessage protolockMessage) {
+ private boolean tryResolveEnumConflicts(MutableProtoFile protoFile, MutableMessageType protoMessage, ProtolockMessage protolockMessage) {
LOGGER.debug("Trying to resolve enum conflicts in file {}, message {}", protoFile.name(), protoMessage);
AtomicBoolean failIfRemovedFieldsTriggered = new AtomicBoolean(false);
// For each enum in proto, try to find mismatching enum values and resolve
- protoMessage.nestedTypes().stream().filter(type -> type instanceof EnumType).map(type -> (EnumType) type).forEach(enumType -> {
+ protoMessage.nestedTypes().stream().filter(type -> type instanceof MutableEnumType).map(type -> (MutableEnumType) type).forEach(enumType -> {
// Find matching in protolockmessage
if (protolockMessage.getEnums() != null) {
Arrays.stream(protolockMessage.getEnums()).filter(e -> e.getName().equals(enumType.name())).findFirst().ifPresent(protolockEnum -> {
@@ -180,7 +180,7 @@ private boolean tryResolveEnumConflicts(ProtoFile protoFile, MessageType protoMe
return failIfRemovedFieldsTriggered.get();
}
- private ProtolockMessage getProtolockMessage(ProtolockFile protolockFile, MessageType protoMessage) {
+ private ProtolockMessage getProtolockMessage(ProtolockFile protolockFile, MutableMessageType protoMessage) {
if (protolockFile != null && protolockFile.getMessages() != null) {
return Arrays.stream(protolockFile.getMessages()).filter(message -> message.getName().equals(protoMessage.getName())).findFirst().orElse(null);
}
@@ -188,7 +188,7 @@ private ProtolockMessage getProtolockMessage(ProtolockFile protolockFile, Messag
return null;
}
- private ProtolockMessage getNestedProtolockMessage(ProtolockMessage protolockMessage, MessageType nestedProtoMessage) {
+ private ProtolockMessage getNestedProtolockMessage(ProtolockMessage protolockMessage, MutableMessageType nestedProtoMessage) {
if (protolockMessage != null && protolockMessage.getMessages() != null) {
return Arrays.stream(protolockMessage.getMessages())
.filter(subMessage -> subMessage.getName().equals(nestedProtoMessage.getName()))
@@ -199,7 +199,7 @@ private ProtolockMessage getNestedProtolockMessage(ProtolockMessage protolockMes
}
}
- private ProtolockFile getProtolockFile(ProtoFile protoFile) {
+ private ProtolockFile getProtolockFile(MutableProtoFile protoFile) {
String fullPath = protoFile.toString();
if (!fullPath.contains("/")) {
// Assume no package in filename yet
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/LocalType.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/LocalType.java
index 03e4bb94..dce6fedd 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/LocalType.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/LocalType.java
@@ -22,21 +22,22 @@
*/
package no.entur.schema2proto.generateproto;
-import com.squareup.wire.schema.Field;
-import com.squareup.wire.schema.MessageType;
import com.sun.xml.xsom.XSComplexType;
import com.sun.xml.xsom.XSComponent;
+import no.entur.schema2proto.wire.MutableField;
+import no.entur.schema2proto.wire.MutableMessageType;
+
public class LocalType {
XSComponent xsComponent;
- MessageType localType;
- MessageType enclosingType;
- Field referencingField;
+ MutableMessageType localType;
+ MutableMessageType enclosingType;
+ MutableField referencingField;
String targetPackage;
XSComplexType enclosingComplexType;
- public LocalType(XSComponent xsComponent, MessageType localType, MessageType enclosingType, Field referencingField, String targetPackage,
- XSComplexType enclosingComplexType) {
+ public LocalType(XSComponent xsComponent, MutableMessageType localType, MutableMessageType enclosingType, MutableField referencingField,
+ String targetPackage, XSComplexType enclosingComplexType) {
this.xsComponent = xsComponent;
this.localType = localType;
this.enclosingType = enclosingType;
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java
index 63d1992a..f755881b 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/ProtoSerializer.java
@@ -60,17 +60,9 @@
import org.slf4j.LoggerFactory;
import com.google.common.base.CaseFormat;
-import com.squareup.wire.schema.EnumConstant;
-import com.squareup.wire.schema.EnumType;
-import com.squareup.wire.schema.Field;
+import com.squareup.wire.schema.Field.Label;
import com.squareup.wire.schema.Location;
-import com.squareup.wire.schema.MessageType;
-import com.squareup.wire.schema.OneOf;
-import com.squareup.wire.schema.Options;
-import com.squareup.wire.schema.ProtoFile;
import com.squareup.wire.schema.Schema;
-import com.squareup.wire.schema.SchemaLoader;
-import com.squareup.wire.schema.Type;
import com.squareup.wire.schema.internal.parser.OptionElement;
import com.squareup.wire.schema.internal.parser.OptionElement.Kind;
import com.sun.xml.xsom.XSComplexType;
@@ -79,6 +71,15 @@
import no.entur.schema2proto.InvalidConfigurationException;
import no.entur.schema2proto.compatibility.BackwardsCompatibilityCheckException;
import no.entur.schema2proto.compatibility.ProtolockBackwardsCompatibilityChecker;
+import no.entur.schema2proto.wire.MutableEnumConstant;
+import no.entur.schema2proto.wire.MutableEnumType;
+import no.entur.schema2proto.wire.MutableField;
+import no.entur.schema2proto.wire.MutableMessageType;
+import no.entur.schema2proto.wire.MutableOneOf;
+import no.entur.schema2proto.wire.MutableOptions;
+import no.entur.schema2proto.wire.MutableProtoFile;
+import no.entur.schema2proto.wire.MutableType;
+import no.entur.schema2proto.wire.WireSchemaLoader;
public class ProtoSerializer {
@@ -124,7 +125,7 @@ public ProtoSerializer(Schema2ProtoConfiguration configuration, TypeAndNameMappe
}
- public void serialize(Map packageToProtoFileMap, List localTypes) throws InvalidXSDException, IOException {
+ public void serialize(Map packageToProtoFileMap, List localTypes) throws InvalidXSDException, IOException {
// Remove temporary generated name suffix
replaceGeneratedTypePlaceholder(packageToProtoFileMap, SchemaParser.GENERATED_NAME_PLACEHOLDER, SchemaParser.TYPE_SUFFIX);
@@ -212,7 +213,7 @@ public void serialize(Map packageToProtoFileMap, List packageToProtoFileMap, List entry : packageToProtoFileMap.entrySet()) {
- ProtoFile protoFile = entry.getValue();
+ for (Entry entry : packageToProtoFileMap.entrySet()) {
+ MutableProtoFile protoFile = entry.getValue();
File destFolder = createPackageFolderStructure(configuration.outputDirectory, protoFile.packageName());
File outputFile = new File(destFolder, protoFile.location().getPath().toLowerCase());
@@ -247,26 +248,26 @@ public void serialize(Map packageToProtoFileMap, List packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void sortFieldsByTag(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> {
- mt.nestedTypes().stream().filter(MessageType.class::isInstance).forEach(z -> sortFieldsByTag((MessageType) z));
+ mt.nestedTypes().stream().filter(MutableMessageType.class::isInstance).forEach(z -> sortFieldsByTag((MutableMessageType) z));
sortFieldsByTag(mt);
});
}
}
- private void sortFieldsByTag(MessageType mt) {
- Collections.sort(mt.fields(), Comparator.comparingInt(Field::tag));
- mt.oneOfs().forEach(oneOf -> Collections.sort(oneOf.fields(), Comparator.comparingInt(Field::tag)));
+ private void sortFieldsByTag(MutableMessageType mt) {
+ Collections.sort(mt.fields(), Comparator.comparingInt(MutableField::tag));
+ mt.oneOfs().forEach(oneOf -> Collections.sort(oneOf.fields(), Comparator.comparingInt(MutableField::tag)));
}
- private boolean resolveBackwardIncompatibilities(Map packageToProtoFileMap) {
+ private boolean resolveBackwardIncompatibilities(Map packageToProtoFileMap) {
LOGGER.debug("Checking for backward incompatible changes");
AtomicBoolean possibleIncompatibilitiesDetected = new AtomicBoolean(false);
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
if (backwardsCompatibilityChecker.resolveBackwardIncompatibilities(file)) {
possibleIncompatibilitiesDetected.set(true);
}
@@ -276,13 +277,13 @@ private boolean resolveBackwardIncompatibilities(Map packageT
return possibleIncompatibilitiesDetected.get();
}
- private void sortTypesInProtofile(Map packageToProtoFileMap) {
- packageToProtoFileMap.values().forEach(e -> e.types().sort(Comparator.comparing(x -> x.type().simpleName())));
+ private void sortTypesInProtofile(Map packageToProtoFileMap) {
+ packageToProtoFileMap.values().forEach(e -> e.types().sort(Comparator.comparing(x -> x.type().getSimpleName())));
}
- private void addPackedOptionToRepeatedFields(Map packageToProtoFileMap, boolean b) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void addPackedOptionToRepeatedFields(Map packageToProtoFileMap, boolean b) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> {
messageTypes(mt.nestedTypes()).forEach(e -> addPackedOptionToRepeatedFields(packageToProtoFileMap, file, e, b));
addPackedOptionToRepeatedFields(packageToProtoFileMap, file, mt, b);
@@ -290,38 +291,42 @@ private void addPackedOptionToRepeatedFields(Map packageToPro
}
}
- private void addPackedOptionToRepeatedFields(Map packageToProtoFileMap, ProtoFile protoFile, MessageType mt, boolean packed) {
+ private void addPackedOptionToRepeatedFields(Map packageToProtoFileMap, MutableProtoFile protoFile, MutableMessageType mt,
+ boolean packed) {
mt.fields()
.stream()
- .filter(e -> e.label() == Field.Label.REPEATED)
+ .filter(e -> e.label() == Label.REPEATED)
.filter(e -> isExposedToPackedBug(packageToProtoFileMap, protoFile, e))
.forEach(e -> addPackedOption(e, packed));
}
- private void addPackedOption(Field f, boolean packed) {
+ private void addPackedOption(MutableField f, boolean packed) {
OptionElement packedOptionElement = new OptionElement("packed", Kind.BOOLEAN, packed, false);
- f.options().getOptionElements().add(packedOptionElement);
+ f.options().optionElements().add(packedOptionElement);
}
- private boolean isExposedToPackedBug(Map packageToProtoFileMap, ProtoFile protoFile, Field elementType) {
+ private boolean isExposedToPackedBug(Map packageToProtoFileMap, MutableProtoFile protoFile, MutableField elementType) {
return PACKABLE_SCALAR_TYPES_SET.contains(elementType.getElementType()) || isEnum(elementType, protoFile, packageToProtoFileMap);
}
- private boolean isEnum(Field elementType, ProtoFile protoFile, Map packageToProtoFileMap) {
+ private boolean isEnum(MutableField elementType, MutableProtoFile protoFile, Map packageToProtoFileMap) {
String packageName = elementType.packageName();
if (packageName != null) {
protoFile = packageToProtoFileMap.get(packageName);
}
- return protoFile.types().stream().filter(EnumType.class::isInstance).anyMatch(e -> ((EnumType) e).name().equals(elementType.getElementType()));
+ return protoFile.types()
+ .stream()
+ .filter(MutableEnumType.class::isInstance)
+ .anyMatch(e -> ((MutableEnumType) e).name().equals(elementType.getElementType()));
}
- private void removeUnwantedFields(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void removeUnwantedFields(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> removeUnwantedFields(file, "", mt));
}
}
- private void removeUnwantedFields(ProtoFile file, final String outerMessagePath, MessageType mt) {
+ private void removeUnwantedFields(MutableProtoFile file, final String outerMessagePath, MutableMessageType mt) {
// Recursive nested type removal
StringBuilder nestedPathBuilder = new StringBuilder();
if (!outerMessagePath.equals("")) {
@@ -339,20 +344,20 @@ private void removeUnwantedFields(ProtoFile file, final String outerMessagePath,
path = outerMessagePath + ".";
}
- List fieldsToRemove = removeUnwantedFields(file.packageName(), path + mt.getName(), mt.fields());
- for (Field f : fieldsToRemove) {
+ List fieldsToRemove = removeUnwantedFields(file.packageName(), path + mt.getName(), mt.fields());
+ for (MutableField f : fieldsToRemove) {
mt.removeDeclaredField(f);
String documentation = StringUtils.trimToEmpty(mt.documentation());
documentation += " NOTE: Removed field " + f;
mt.updateDocumentation(documentation);
}
- List oneOfsToRemove = new ArrayList<>();
+ List oneOfsToRemove = new ArrayList<>();
- for (OneOf oneOf : mt.oneOfs()) {
+ for (MutableOneOf oneOf : mt.oneOfs()) {
- List oneOfFieldsToRemove = removeUnwantedFields(file.packageName(), path + mt.getName(), oneOf.fields());
- for (Field f : oneOfFieldsToRemove) {
+ List oneOfFieldsToRemove = removeUnwantedFields(file.packageName(), path + mt.getName(), oneOf.fields());
+ for (MutableField f : oneOfFieldsToRemove) {
oneOf.fields().remove(f);
String documentation = StringUtils.trimToEmpty(mt.documentation());
@@ -367,7 +372,7 @@ private void removeUnwantedFields(ProtoFile file, final String outerMessagePath,
}
// Remove empty oneOfs
- for (OneOf oneOfToRemove : oneOfsToRemove) {
+ for (MutableOneOf oneOfToRemove : oneOfsToRemove) {
mt.removeOneOf(oneOfToRemove);
String documentation = StringUtils.trimToEmpty(mt.documentation());
@@ -376,11 +381,11 @@ private void removeUnwantedFields(ProtoFile file, final String outerMessagePath,
}
}
- private List removeUnwantedFields(String packageName, String messageName, List fields) {
+ private List removeUnwantedFields(String packageName, String messageName, List fields) {
- List fieldsToRemove = new ArrayList<>();
+ List fieldsToRemove = new ArrayList<>();
- for (Field field : fields) {
+ for (MutableField field : fields) {
if (typeAndFieldNameMapper.ignoreOutputField(packageName, messageName, field.name())) {
fieldsToRemove.add(field);
}
@@ -400,7 +405,7 @@ private File createPackageFolderStructure(File outputDirectory, String packageNa
}
@NotNull
- private String getPathFromPackageNameAndType(String packageName, Type type) {
+ private String getPathFromPackageNameAndType(String packageName, MutableType type) {
String protoFileName = customTypeImportToProtoFile.get(buildFullyQualifiedTypeName(packageName, type));
if (protoFileName != null) {
@@ -415,8 +420,8 @@ private String getPathFromPackageName(String packageName) {
return packageName.replace('.', '/');
}
- private String buildFullyQualifiedTypeName(String packageName, Type type) {
- return packageName + "." + type.type().simpleName();
+ private String buildFullyQualifiedTypeName(String packageName, MutableType type) {
+ return packageName + "." + type.type().getSimpleName();
}
// Loads imported file and reads all qualified types
@@ -431,16 +436,15 @@ private List getFullyQualifiedTypes(String pathName) {
} else {
File fileToImport = new File(path, pathName);
if (fileToImport.exists()) {
- SchemaLoader schemaLoader = new SchemaLoader();
+ List sources = new ArrayList<>();
for (String importRootFolder : configuration.customImportLocations) {
- schemaLoader.addSource(new File(importRootFolder).toPath());
+ sources.add(new File(importRootFolder).toPath());
}
- schemaLoader.addProto(pathName);
- Schema schema = schemaLoader.load();
- ProtoFile customImportFile = schema.protoFile(pathName);
+ Schema schema = WireSchemaLoader.load(sources, Collections.singletonList(pathName));
+ com.squareup.wire.schema.ProtoFile customImportFile = schema.protoFile(pathName);
- for (Type type : customImportFile.types()) {
- String qualifiedName = buildFullyQualifiedTypeName(customImportFile.packageName(), type);
+ for (com.squareup.wire.schema.Type type : customImportFile.getTypes()) {
+ String qualifiedName = customImportFile.getPackageName() + "." + type.getType().getSimpleName();
typeNames.add(qualifiedName);
customTypeImportToProtoFile.put(qualifiedName, pathName);
@@ -462,27 +466,27 @@ private List getFullyQualifiedTypes(String pathName) {
}
- private void replaceGeneratedTypePlaceholder(Map packageToProtoFileMap, String generatedRandomTypeSuffix, String newTypeSuffix) {
+ private void replaceGeneratedTypePlaceholder(Map packageToProtoFileMap, String generatedRandomTypeSuffix, String newTypeSuffix) {
- for (Entry protoFile : packageToProtoFileMap.entrySet()) {
+ for (Entry protoFile : packageToProtoFileMap.entrySet()) {
replaceGeneratedTypePlaceholder(packageToProtoFileMap, generatedRandomTypeSuffix, newTypeSuffix, protoFile.getValue().types(),
protoFile.getValue().packageName());
}
}
- private void replaceGeneratedTypePlaceholder(Map packageToProtoFileMap, String generatedRandomTypePlaceholder, String newTypeSuffix,
- List types, String packageName) {
+ private void replaceGeneratedTypePlaceholder(Map packageToProtoFileMap, String generatedRandomTypePlaceholder,
+ String newTypeSuffix, List types, String packageName) {
Set usedNames = findExistingTypeNamesInProtoFile(types);
- for (Type type : types) {
+ for (MutableType type : types) {
// Recurse into nested types
replaceGeneratedTypePlaceholder(packageToProtoFileMap, generatedRandomTypePlaceholder, newTypeSuffix, type.nestedTypes(), packageName);
- if (type instanceof MessageType) {
- MessageType mt = (MessageType) type;
+ if (type instanceof MutableMessageType) {
+ MutableMessageType mt = (MutableMessageType) type;
replaceGeneratedTypePlaceholder(packageToProtoFileMap, generatedRandomTypePlaceholder, newTypeSuffix, packageName, usedNames, mt);
- } else if (type instanceof EnumType) {
- EnumType et = (EnumType) type;
+ } else if (type instanceof MutableEnumType) {
+ MutableEnumType et = (MutableEnumType) type;
String messageName = et.name();
if (messageName.contains(generatedRandomTypePlaceholder)) {
String newMessageName = messageName.replaceAll(generatedRandomTypePlaceholder, newTypeSuffix);
@@ -498,8 +502,8 @@ private void replaceGeneratedTypePlaceholder(Map packageToPro
}
}
- private void replaceGeneratedTypePlaceholder(Map packageToProtoFileMap, String generatedRandomTypePlaceholder, String newTypeSuffix,
- String packageName, Set usedNames, MessageType mt) {
+ private void replaceGeneratedTypePlaceholder(Map packageToProtoFileMap, String generatedRandomTypePlaceholder,
+ String newTypeSuffix, String packageName, Set usedNames, MutableMessageType mt) {
String messageName = mt.getName();
if (messageName.contains(generatedRandomTypePlaceholder)) {
String newMessageName = messageName.replaceAll(generatedRandomTypePlaceholder, newTypeSuffix);
@@ -513,25 +517,25 @@ private void replaceGeneratedTypePlaceholder(Map packageToPro
}
}
- private void uppercaseMessageNames(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void uppercaseMessageNames(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
uppercaseMessageNames(packageToProtoFileMap, file.types(), file.packageName());
}
}
- private void uppercaseMessageNames(Map packageToProtoFileMap, List types, String packageName) {
+ private void uppercaseMessageNames(Map packageToProtoFileMap, List types, String packageName) {
Set usedNames = findExistingTypeNamesInProtoFile(types);
- for (Type type : types) {
+ for (MutableType type : types) {
// Recurse into nested types
uppercaseMessageNames(packageToProtoFileMap, type.nestedTypes(), packageName);
- if (type instanceof MessageType) {
- MessageType mt = (MessageType) type;
+ if (type instanceof MutableMessageType) {
+ MutableMessageType mt = (MutableMessageType) type;
uppercaseMessageNames(packageToProtoFileMap, packageName, usedNames, mt);
- } else if (type instanceof EnumType) {
- EnumType et = (EnumType) type;
+ } else if (type instanceof MutableEnumType) {
+ MutableEnumType et = (MutableEnumType) type;
String messageName = et.name();
String newMessageName = messageName;
@@ -584,7 +588,7 @@ private CaseFormat getCaseFormatName(String s) throws IllegalFormatException {
throw new IllegalArgumentException(String.format("Couldn't find the case format of the given string '%s'", s));
}
- private void uppercaseMessageNames(Map packageToProtoFileMap, String packageName, Set usedNames, MessageType mt) {
+ private void uppercaseMessageNames(Map packageToProtoFileMap, String packageName, Set usedNames, MutableMessageType mt) {
String messageName = mt.getName();
if (!Character.isUpperCase(messageName.charAt(0))) {
String newMessageName = StringUtils.capitalize(messageName);
@@ -598,38 +602,38 @@ private void uppercaseMessageNames(Map packageToProtoFileMap,
}
}
- private void updateEnumValues(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
- List types = file.types();
+ private void updateEnumValues(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
+ List types = file.types();
updateEnumValues(types);
}
}
- private void updateEnumValues(List types) {
- for (Type t : types) {
- if (t instanceof EnumType) {
- EnumType e = (EnumType) t;
+ private void updateEnumValues(List types) {
+ for (MutableType t : types) {
+ if (t instanceof MutableEnumType) {
+ MutableEnumType e = (MutableEnumType) t;
updateEnum(e);
}
updateEnumValues(t.nestedTypes());
}
}
- private void updateEnum(EnumType e) {
+ private void updateEnum(MutableEnumType e) {
// add UNSPECIFIED value first
List optionElementsUnspecified = new ArrayList<>();
// Prefix with enum type name
String enumValuePrefix = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, e.name()) + UNDERSCORE;
- for (EnumConstant ec : e.constants()) {
+ for (MutableEnumConstant ec : e.constants()) {
String enumValue = escapeEnumValue(ec.getName());
if (enumValue.equalsIgnoreCase("UNSPECIFIED")) {
enumValue = "UNSPECIFIED_ENUM_VALUE"; // Handle collision with UNSPECIFIED special value according to Google style guide
}
ec.updateName(enumValuePrefix + enumValue);
}
- EnumConstant unspecified = new EnumConstant(new Location("", "", 0, 0), enumValuePrefix + "UNSPECIFIED", 0, "Default",
- new Options(Options.ENUM_VALUE_OPTIONS, optionElementsUnspecified));
+ MutableEnumConstant unspecified = new MutableEnumConstant(new Location("", "", 0, 0), enumValuePrefix + "UNSPECIFIED", 0, "Default",
+ new MutableOptions(MutableOptions.ENUM_VALUE_OPTIONS, optionElementsUnspecified));
e.constants().add(0, unspecified);
}
@@ -670,30 +674,29 @@ private String escapeEnumValue(String name) {
}
private void parseWrittenFiles() throws IOException {
- SchemaLoader schemaLoader = new SchemaLoader();
-
try {
+ List sources = new ArrayList<>();
+ for (String importRootFolder : configuration.customImportLocations) {
+ sources.add(new File(importRootFolder).toPath());
+ }
+ sources.add(configuration.outputDirectory.toPath());
+
+ List protos = new ArrayList<>();
if (configuration.includeValidationRules) {
- schemaLoader.addProto(VALIDATION_PROTO_IMPORT);
+ protos.add(VALIDATION_PROTO_IMPORT);
}
if (configuration.includeXsdOptions) {
- schemaLoader.addProto(XSDOPTIONS_PROTO_IMPORT);
+ protos.add(XSDOPTIONS_PROTO_IMPORT);
}
- for (String importRootFolder : configuration.customImportLocations) {
- schemaLoader.addSource(new File(importRootFolder).toPath());
- }
-
- schemaLoader.addSource(configuration.outputDirectory);
-
- for (Path s : schemaLoader.sources()) {
+ for (Path s : sources) {
LOGGER.debug("Linking proto from path {}", s);
}
- for (String s : schemaLoader.protos()) {
+ for (String s : protos) {
LOGGER.debug("Linking proto {}", s);
}
- schemaLoader.load();
+ WireSchemaLoader.load(sources, protos);
} catch (IOException e) {
throw new ConversionException("Parsing of written output failed, the proto files are not valid", e);
}
@@ -711,17 +714,17 @@ private void parseWrittenFiles() throws IOException {
*
* @Override public Iterator iterator() { return iterator; } }; }
*/
- private void computeFilenames(Map packageToProtoFileMap) {
- for (Entry protoFile : packageToProtoFileMap.entrySet()) {
- ProtoFile file = protoFile.getValue();
+ private void computeFilenames(Map packageToProtoFileMap) {
+ for (Entry protoFile : packageToProtoFileMap.entrySet()) {
+ MutableProtoFile file = protoFile.getValue();
String filename = protoFile.getKey().replaceAll("\\.", UNDERSCORE) + ".proto";
Location loc = new Location("", filename, 0, 0);
file.setLocation(loc);
}
}
- private void addConfigurationSpecifiedOptions(Map packageToProtoFileMap) {
- for (Entry protoFile : packageToProtoFileMap.entrySet()) {
+ private void addConfigurationSpecifiedOptions(Map packageToProtoFileMap) {
+ for (Entry protoFile : packageToProtoFileMap.entrySet()) {
for (Entry option : configuration.options.entrySet()) {
Kind kind = null;
@@ -739,10 +742,10 @@ private void addConfigurationSpecifiedOptions(Map packageToPr
}
}
- private void includeGoPackageNameOptions(Map packageToProtoFileMap) {
- for (ProtoFile protoFile : packageToProtoFileMap.values()) {
+ private void includeGoPackageNameOptions(Map packageToProtoFileMap) {
+ for (MutableProtoFile protoFile : packageToProtoFileMap.values()) {
String optionName = "go_package";
- boolean alreadySet = protoFile.options().getOptionElements().stream().anyMatch(existingOption -> optionName.equals(existingOption.getName()));
+ boolean alreadySet = protoFile.options().optionElements().stream().anyMatch(existingOption -> optionName.equals(existingOption.getName()));
if (!alreadySet) {
String goPackageName = packageNameToGoPackageName(configuration.goPackageSourcePrefix, protoFile.packageName());
OptionElement optionElement = new OptionElement(optionName, OptionElement.Kind.STRING, goPackageName, false);
@@ -751,10 +754,10 @@ private void includeGoPackageNameOptions(Map packageToProtoFi
}
}
- private void resolveRecursiveImports(Map packageToProtoFileMap) {
+ private void resolveRecursiveImports(Map packageToProtoFileMap) {
Map> imports = new HashMap<>();
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
List fileImports = new ArrayList<>();
fileImports.addAll(file.imports());
@@ -765,12 +768,12 @@ private void resolveRecursiveImports(Map packageToProtoFileMa
imports.put(file.toString(), fileImports);
}
- for (Entry protoFileEntry : packageToProtoFileMap.entrySet()) {
- ProtoFile protoFile = protoFileEntry.getValue();
+ for (Entry protoFileEntry : packageToProtoFileMap.entrySet()) {
+ MutableProtoFile protoFile = protoFileEntry.getValue();
String filename = protoFile.location().getPath();
if (hasRecursiveImports(imports, filename, filename)) {
LOGGER.error("File {} recursively imports itself.", filename);
- // TODO: Extract affected types to a separate, common ProtoFile
+ // TODO: Extract affected types to a separate, common MutableProtoFile
}
}
@@ -799,13 +802,13 @@ private boolean hasRecursiveImports(Map> imports, String ro
return false;
}
- private void addConfigurationSpecifiedImports(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void addConfigurationSpecifiedImports(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
for (String customImport : configuration.customImports) {
boolean customImportInUse = false;
List qualifiedTypes = getFullyQualifiedTypes(customImport);
- typeloop: for (Type type : file.types()) {
+ typeloop: for (MutableType type : file.types()) {
for (String qualifiedType : qualifiedTypes) {
customImportInUse = isCustomImportInUseInNestedTypes(qualifiedType, type);
if (customImportInUse) {
@@ -828,18 +831,18 @@ private void addConfigurationSpecifiedImports(Map packageToPr
}
}
- private boolean isCustomImportInUseInNestedTypes(String importPackage, Type type) {
+ private boolean isCustomImportInUseInNestedTypes(String importPackage, MutableType type) {
AtomicBoolean customImportInUse = new AtomicBoolean(false);
- if (type instanceof MessageType) {
- for (Field field : ((MessageType) type).fieldsAndOneOfFields()) {
+ if (type instanceof MutableMessageType) {
+ for (MutableField field : ((MutableMessageType) type).fieldsAndOneOfFields()) {
if (field.getElementType() != null && field.getElementType().equalsIgnoreCase(importPackage)) {
customImportInUse.set(true);
}
}
if (!customImportInUse.get()) {
messageTypes(type.nestedTypes()).forEach(mt -> {
- for (Field field : ((MessageType) type).fieldsAndOneOfFields()) {
+ for (MutableField field : ((MutableMessageType) type).fieldsAndOneOfFields()) {
if (field.getElementType() != null && field.getElementType().equalsIgnoreCase(importPackage)) {
customImportInUse.set(true);
}
@@ -856,8 +859,8 @@ private boolean isCustomImportInUseInNestedTypes(String importPackage, Type type
return customImportInUse.get();
}
- private void computeLocalImports(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void computeLocalImports(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
SortedSet imports = new TreeSet<>(file.imports());
messageTypes(file.types()).forEach(mt -> computeLocalImports(packageToProtoFileMap, file, imports, mt));
@@ -868,16 +871,17 @@ private void computeLocalImports(Map packageToProtoFileMap) {
}
}
- private void computeLocalImports(Map packageToProtoFileMap, ProtoFile file, SortedSet imports, MessageType messageType) {
+ private void computeLocalImports(Map packageToProtoFileMap, MutableProtoFile file, SortedSet imports,
+ MutableMessageType messageType) {
messageTypes(messageType.nestedTypes()).forEach(e -> computeLocalImports(packageToProtoFileMap, file, imports, e));
- for (Field field : messageType.fieldsAndOneOfFields()) {
+ for (MutableField field : messageType.fieldsAndOneOfFields()) {
String packageName = StringUtils.trimToNull(field.packageName());
if (file.packageName() != null && file.packageName().equals(packageName)) {
field.clearPackageName();
} else if (packageName != null) {
// Add import
- ProtoFile fileToImport = packageToProtoFileMap.get(packageName);
+ MutableProtoFile fileToImport = packageToProtoFileMap.get(packageName);
if (fileToImport != null) {
imports.add(getPathFromPackageNameAndType(packageName, messageType) + "/" + fileToImport.location().getPath());
} else {
@@ -887,20 +891,20 @@ private void computeLocalImports(Map packageToProtoFileMap, P
}
}
- private void moveFieldPackageNameToFieldTypeName(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void moveFieldPackageNameToFieldTypeName(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(this::moveFieldPackageNameToFieldTypeName);
}
}
// Recursively loops through all fields for all nested types
- private void moveFieldPackageNameToFieldTypeName(MessageType messageType) {
+ private void moveFieldPackageNameToFieldTypeName(MutableMessageType messageType) {
messageTypes(messageType.nestedTypes()).forEach(this::moveFieldPackageNameToFieldTypeName);
- List fields = messageType.fieldsAndOneOfFields();
+ List fields = messageType.fieldsAndOneOfFields();
- for (Field field : fields) {
+ for (MutableField field : fields) {
String fieldPackageName = StringUtils.trimToNull(field.packageName());
if (fieldPackageName != null) {
field.clearPackageName();
@@ -912,11 +916,11 @@ private void moveFieldPackageNameToFieldTypeName(MessageType messageType) {
/*
* Adds leading '.' to field.elementType when needed. Ref.: https://developers.google.com/protocol-buffers/docs/proto3#packages-and-name-resolution
*/
- private void addLeadingPeriodToElementType(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void addLeadingPeriodToElementType(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> {
// TODO must this be done for nested types as well or handled differently?
- for (Field field : mt.fieldsAndOneOfFields()) {
+ for (MutableField field : mt.fieldsAndOneOfFields()) {
String fieldElementType = StringUtils.trimToNull(field.getElementType());
if (fieldElementType != null && fieldElementType.contains(".")) {
for (String pkg : packageToProtoFileMap.keySet()) {
@@ -934,18 +938,18 @@ private void addLeadingPeriodToElementType(Map packageToProto
}
}
- private void translateTypes(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void translateTypes(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
translateTypes(packageToProtoFileMap, file.types(), file.packageName());
}
}
- private void translateTypes(Map packageToProtoFileMap, List types, String packageName) {
+ private void translateTypes(Map packageToProtoFileMap, List types, String packageName) {
if (!types.isEmpty()) {
Set usedNames = findExistingTypeNamesInProtoFile(types);
- for (Type type : types) {
- if (type instanceof MessageType) {
- MessageType mt = (MessageType) type;
+ for (MutableType type : types) {
+ if (type instanceof MutableMessageType) {
+ MutableMessageType mt = (MutableMessageType) type;
translateTypes(packageToProtoFileMap, type.nestedTypes(), packageName);
@@ -964,8 +968,8 @@ private void translateTypes(Map packageToProtoFileMap, List packageToProtoFileMap, List fields) {
- for (Field field : fields) {
+ private void translateTypes(List fields) {
+ for (MutableField field : fields) {
// Translate basic types as well
if (field.packageName() == null && basicTypes.contains(field.getElementType())) {
String newFieldType = typeAndFieldNameMapper.translateType(field.getElementType());
@@ -997,13 +1001,13 @@ private void translateTypes(List fields) {
}
}
- private void replaceTypes(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void replaceTypes(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
replaceTypesRecursive(file.types());
}
}
- private void replaceTypesRecursive(List types) {
+ private void replaceTypesRecursive(List types) {
messageTypes(types).forEach(mt -> {
replaceTypesRecursive(mt.nestedTypes());
replaceTypes(mt.fieldsAndOneOfFields());
@@ -1011,33 +1015,33 @@ private void replaceTypesRecursive(List types) {
}
- private void replaceTypes(List fields) {
- for (Field field : fields) {
+ private void replaceTypes(List fields) {
+ for (MutableField field : fields) {
String newFieldType = typeAndFieldNameMapper.replaceType(field.getElementType());
field.updateElementType(newFieldType);
}
}
- private void updateTypeReferences(Map packageToProtoFileMap, String packageNameOfType, String oldName, String newName) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void updateTypeReferences(Map packageToProtoFileMap, String packageNameOfType, String oldName, String newName) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
updateTypeReferences(packageNameOfType, oldName, newName, file.types(), file.packageName());
}
}
- private void updateTypeReferences(String packageNameOfType, String oldName, String newName, List types, String currentMessageTypePackage) {
- for (Type type : types) {
+ private void updateTypeReferences(String packageNameOfType, String oldName, String newName, List types, String currentMessageTypePackage) {
+ for (MutableType type : types) {
updateTypeReferences(packageNameOfType, oldName, newName, type.nestedTypes(), currentMessageTypePackage);
- if (type instanceof MessageType) {
- MessageType mt = (MessageType) type;
+ if (type instanceof MutableMessageType) {
+ MutableMessageType mt = (MutableMessageType) type;
updateTypeReferences(packageNameOfType, oldName, newName, mt, mt.fieldsAndOneOfFields(), currentMessageTypePackage);
}
}
}
- private void updateTypeReferences(String packageNameOfType, String oldName, String newName, MessageType mt, Collection fields,
+ private void updateTypeReferences(String packageNameOfType, String oldName, String newName, MutableMessageType mt, Collection fields,
String currentMessageTypePackage) {
- for (Field field : fields) {
+ for (MutableField field : fields) {
if (samePackage(field.packageName(), packageNameOfType)) {
String fieldType = field.getElementType();
if (fieldType.equals(oldName)) {
@@ -1047,25 +1051,25 @@ private void updateTypeReferences(String packageNameOfType, String oldName, Stri
}
}
- Options options = mt.options();
+ MutableOptions options = mt.options();
// Avoid concurrent mod exception
- List listCopy = new ArrayList<>(options.getOptionElements());
+ List listCopy = new ArrayList<>(options.optionElements());
- listCopy.stream().filter(e -> e.getName().equals(MessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME)).forEach(e -> {
+ listCopy.stream().filter(e -> e.getName().equals(MutableMessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME)).forEach(e -> {
String packageAndType = (String) e.getValue();
if (packageAndType.equals(".")) {
String packageName = packageAndType.substring(0, packageAndType.lastIndexOf('.'));
String messageName = packageAndType.substring(packageName.hashCode() + 1);
if (packageName.equals(packageAndType) && oldName.equals(messageName)) {
- options.replaceOption(MessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME,
- new OptionElement(MessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME, Kind.STRING, packageName + "." + newName, true));
+ options.replaceOption(MutableMessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME,
+ new OptionElement(MutableMessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME, Kind.STRING, packageName + "." + newName, true));
}
} else if (currentMessageTypePackage.equals(packageNameOfType) && packageAndType.equals(oldName)) {
- options.replaceOption(MessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME,
- new OptionElement(MessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME, Kind.STRING, newName, true));
+ options.replaceOption(MutableMessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME,
+ new OptionElement(MutableMessageType.XSD_BASE_TYPE_MESSAGE_OPTION_NAME, Kind.STRING, newName, true));
}
});
@@ -1083,21 +1087,21 @@ private boolean samePackage(String packageNameOfFile, String packageNameOfRefere
}
}
- private Set findExistingTypeNamesInProtoFile(List types) {
+ private Set findExistingTypeNamesInProtoFile(List types) {
Set existingTypeNames = new HashSet<>();
- for (Type t : types) {
- if (t instanceof MessageType) {
- existingTypeNames.add(((MessageType) t).getName());
- } else if (t instanceof EnumType) {
- existingTypeNames.add(((EnumType) t).name());
+ for (MutableType t : types) {
+ if (t instanceof MutableMessageType) {
+ existingTypeNames.add(((MutableMessageType) t).getName());
+ } else if (t instanceof MutableEnumType) {
+ existingTypeNames.add(((MutableEnumType) t).name());
}
}
return existingTypeNames;
}
- private void translateFieldNames(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void translateFieldNames(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> {
messageTypes(mt.nestedTypes()).forEach(e -> translateFieldNames(e.fieldsAndOneOfFields()));
@@ -1108,16 +1112,16 @@ private void translateFieldNames(Map packageToProtoFileMap) {
}
}
- private void translateFieldNames(List fields) {
- for (Field field : fields) {
+ private void translateFieldNames(List fields) {
+ for (MutableField field : fields) {
String fieldName = field.name();
String newFieldName = typeAndFieldNameMapper.translateFieldName(fieldName);
field.updateName(newFieldName);
}
}
- private void handleFieldNameCaseInsensitives(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void handleFieldNameCaseInsensitives(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> {
@@ -1130,10 +1134,10 @@ private void handleFieldNameCaseInsensitives(Map packageToPro
}
}
- private void handleFieldNameCaseInsensitives(List fields) {
+ private void handleFieldNameCaseInsensitives(List fields) {
Set fieldNamesUppercase = new HashSet<>();
- for (Field field : fields) {
+ for (MutableField field : fields) {
String fieldName = field.name();
boolean existedBefore = fieldNamesUppercase.add(fieldName.toUpperCase());
if (!existedBefore) {
@@ -1143,17 +1147,17 @@ private void handleFieldNameCaseInsensitives(List fields) {
}
}
- private void underscoreFieldNames(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void underscoreFieldNames(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(this::underscoreFieldNames);
}
}
- private void underscoreFieldNames(MessageType mt) {
+ private void underscoreFieldNames(MutableMessageType mt) {
messageTypes(mt.nestedTypes()).forEach(this::underscoreFieldNames);
- for (Field field : mt.fieldsAndOneOfFields()) {
+ for (MutableField field : mt.fieldsAndOneOfFields()) {
String fieldName = field.name();
boolean startsWithUnderscore = fieldName.startsWith(UNDERSCORE);
boolean endsWithUnderscore = fieldName.endsWith(UNDERSCORE);
@@ -1178,8 +1182,8 @@ private void underscoreFieldNames(MessageType mt) {
}
- private void escapeReservedJavaKeywords(Map packageToProtoFileMap) {
- for (ProtoFile file : packageToProtoFileMap.values()) {
+ private void escapeReservedJavaKeywords(Map packageToProtoFileMap) {
+ for (MutableProtoFile file : packageToProtoFileMap.values()) {
messageTypes(file.types()).forEach(mt -> {
messageTypes(mt.nestedTypes()).forEach(this::escapeReservedJavaKeywords);
escapeReservedJavaKeywords(mt);
@@ -1188,8 +1192,8 @@ private void escapeReservedJavaKeywords(Map packageToProtoFil
}
}
- private void escapeReservedJavaKeywords(MessageType mt) {
- for (Field field : mt.fieldsAndOneOfFields()) {
+ private void escapeReservedJavaKeywords(MutableMessageType mt) {
+ for (MutableField field : mt.fieldsAndOneOfFields()) {
String fieldName = field.name();
String newFieldName = typeAndFieldNameMapper.escapeFieldName(fieldName);
field.updateName(newFieldName);
@@ -1233,12 +1237,12 @@ public String toString() {
}
}
- private void moveReusedLocalTypesToGlobal(Map packageToProtoFileMap, List localTypesAllPackages) {
+ private void moveReusedLocalTypesToGlobal(Map packageToProtoFileMap, List localTypesAllPackages) {
LOGGER.debug("Reorganizing embedded local types into global if reused");
localTypesAllPackages.forEach(e -> LOGGER.debug("{} -> {}", e.enclosingType.getName(), e.localType.getName()));
- for (Entry protoFileEntry : packageToProtoFileMap.entrySet()) {
+ for (Entry protoFileEntry : packageToProtoFileMap.entrySet()) {
String currentPackageName = protoFileEntry.getKey();
@@ -1289,7 +1293,7 @@ private void moveReusedLocalTypesToGlobal(Map packageToProtoF
if (packageName == null) {
packageName = Schema2ProtoConfiguration.DEFAULT_PROTO_PACKAGE;
}
- ProtoFile enclosingFile = packageToProtoFileMap.get(packageName);
+ MutableProtoFile enclosingFile = packageToProtoFileMap.get(packageName);
// DuplicateCheck
String candidateName = currentComponent.messageName;
@@ -1302,15 +1306,15 @@ private void moveReusedLocalTypesToGlobal(Map packageToProtoF
first.localType.getName(), ToStringBuilder.reflectionToString(enclosingTypes.toArray(), ToStringStyle.SIMPLE_STYLE)));
}
candidateName = StringUtils.capitalize(enclosingTypes.iterator().next()) + "_"
- + StringUtils.capitalize(first.localType.type().simpleName());
+ + StringUtils.capitalize(first.localType.type().getSimpleName());
LOGGER.debug("Candidate name for inherited local type prefixed with enclosing type {}", candidateName);
} else {
LOGGER.debug("Candidate name for inherited local type {} is unique - keeping as is", candidateName);
}
- Optional existingType = checkForExistingType(enclosingFile, candidateName);
+ Optional existingType = checkForExistingType(enclosingFile, candidateName);
if (!existingType.isPresent()) {
- MessageType localToBecomeGlobal = first.localType;
+ MutableMessageType localToBecomeGlobal = first.localType;
localToBecomeGlobal.updateName(candidateName);
enclosingFile.types().add(localToBecomeGlobal);
@@ -1336,10 +1340,10 @@ private void moveReusedLocalTypesToGlobal(Map packageToProtoF
}
@NotNull
- private Optional checkForExistingType(ProtoFile enclosingFile, String candidateName) {
- Optional existingType = Optional.empty();
- for (Type type : enclosingFile.types()) {
- if (candidateName.equals(type.type().simpleName())) {
+ private Optional checkForExistingType(MutableProtoFile enclosingFile, String candidateName) {
+ Optional existingType = Optional.empty();
+ for (MutableType type : enclosingFile.types()) {
+ if (candidateName.equals(type.type().getSimpleName())) {
existingType = Optional.of(type);
break;
}
@@ -1347,8 +1351,8 @@ private Optional checkForExistingType(ProtoFile enclosingFile, String cand
return existingType;
}
- private Stream messageTypes(List types) {
- return types.stream().filter(MessageType.class::isInstance).map(MessageType.class::cast);
+ private Stream messageTypes(List types) {
+ return types.stream().filter(MutableMessageType.class::isInstance).map(MutableMessageType.class::cast);
}
}
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/Schema2Proto.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/Schema2Proto.java
index 69c5c541..7dbe6139 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/Schema2Proto.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/Schema2Proto.java
@@ -53,9 +53,8 @@
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
-import com.squareup.wire.schema.ProtoFile;
-
import no.entur.schema2proto.InvalidConfigurationException;
+import no.entur.schema2proto.wire.MutableProtoFile;
public class Schema2Proto {
private static final String OPTION_OUTPUT_DIRECTORY = "outputDirectory";
@@ -110,7 +109,7 @@ public static void parseAndSerialize(Schema2ProtoConfiguration configuration) th
SchemaParser xp = new SchemaParser(configuration);
LOGGER.info("Starting to parse {}", configuration.xsdFile);
- Map packageToFiles = xp.parse();
+ Map packageToFiles = xp.parse();
List localTypes = xp.getLocalTypes();
TypeAndNameMapper pbm = new TypeAndNameMapper(configuration);
diff --git a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/SchemaParser.java b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/SchemaParser.java
index 340d7eb2..fbb5f9cf 100644
--- a/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/SchemaParser.java
+++ b/schema2proto-lib/src/main/java/no/entur/schema2proto/generateproto/SchemaParser.java
@@ -22,7 +22,7 @@
*/
package no.entur.schema2proto.generateproto;
-import static com.squareup.wire.schema.MessageType.XSD_MESSAGE_OPTIONS_PACKAGE;
+import static no.entur.schema2proto.wire.MutableMessageType.XSD_MESSAGE_OPTIONS_PACKAGE;
import java.io.IOException;
import java.net.URI;
@@ -53,18 +53,10 @@
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-import com.squareup.wire.schema.EnumConstant;
-import com.squareup.wire.schema.EnumType;
-import com.squareup.wire.schema.Field;
+import com.squareup.wire.Syntax;
import com.squareup.wire.schema.Field.Label;
import com.squareup.wire.schema.Location;
-import com.squareup.wire.schema.MessageType;
-import com.squareup.wire.schema.OneOf;
-import com.squareup.wire.schema.Options;
-import com.squareup.wire.schema.ProtoFile;
-import com.squareup.wire.schema.ProtoFile.Syntax;
import com.squareup.wire.schema.ProtoType;
-import com.squareup.wire.schema.Type;
import com.squareup.wire.schema.internal.parser.OptionElement;
import com.sun.xml.xsom.XSAttContainer;
import com.sun.xml.xsom.XSAttGroupDecl;
@@ -88,6 +80,15 @@
import com.sun.xml.xsom.parser.XSOMParser;
import com.sun.xml.xsom.util.DomAnnotationParserFactory;
+import no.entur.schema2proto.wire.MutableEnumConstant;
+import no.entur.schema2proto.wire.MutableEnumType;
+import no.entur.schema2proto.wire.MutableField;
+import no.entur.schema2proto.wire.MutableMessageType;
+import no.entur.schema2proto.wire.MutableOneOf;
+import no.entur.schema2proto.wire.MutableOptions;
+import no.entur.schema2proto.wire.MutableProtoFile;
+import no.entur.schema2proto.wire.MutableType;
+
public class SchemaParser implements ErrorHandler {
public static final String TYPE_SUFFIX = "Type";
@@ -97,9 +98,9 @@ public class SchemaParser implements ErrorHandler {
private static final String DEFAULT_PROTO_PRIMITIVE = "string";
public static final String SIMPLECONTENT_VALUE_FIELD_NAME = "value";
- private final Map packageToProtoFileMap = new TreeMap<>();
+ private final Map packageToProtoFileMap = new TreeMap<>();
- private final Map> elementDeclarationsPerMessageType = new HashMap<>();
+ private final Map> elementDeclarationsPerMessageType = new HashMap<>();
private Set basicTypes;
private int nestingLevel = 0;
@@ -122,7 +123,7 @@ public SchemaParser(Schema2ProtoConfiguration configuration) {
init();
}
- public Map parse() throws SAXException, IOException {
+ public Map parse() throws SAXException, IOException {
@SuppressWarnings("java:S2755") // Needs fix inside XSOM package
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
@@ -139,12 +140,12 @@ public Map parse() throws SAXException, IOException {
return packageToProtoFileMap;
}
- private void addType(String namespace, Type type) {
- ProtoFile file = getProtoFileForNamespace(namespace);
+ private void addType(String namespace, MutableType type) {
+ MutableProtoFile file = getProtoFileForNamespace(namespace);
file.types().add(type);
}
- private ProtoFile getProtoFileForPackage(String packageName) {
+ private MutableProtoFile getProtoFileForPackage(String packageName) {
if (StringUtils.trimToNull(packageName) == null) {
packageName = Schema2ProtoConfiguration.DEFAULT_PROTO_PACKAGE;
@@ -154,22 +155,22 @@ private ProtoFile getProtoFileForPackage(String packageName) {
packageName = configuration.defaultProtoPackage;
}
- return packageToProtoFileMap.computeIfAbsent(packageName, k -> new ProtoFile(Syntax.PROTO_3, k));
+ return packageToProtoFileMap.computeIfAbsent(packageName, k -> new MutableProtoFile(Syntax.PROTO_3, k));
}
- private ProtoFile getProtoFileForNamespace(String namespace) {
+ private MutableProtoFile getProtoFileForNamespace(String namespace) {
String packageName = NamespaceHelper.xmlNamespaceToProtoPackage(namespace, configuration.forceProtoPackage);
return getProtoFileForPackage(packageName);
}
- private Type getType(String namespace, String typeName) {
- ProtoFile protoFileForNamespace = getProtoFileForNamespace(namespace);
- for (Type type : protoFileForNamespace.types()) {
- if (type instanceof MessageType) {
- if (((MessageType) type).getName().equals(typeName)) {
+ private MutableType getType(String namespace, String typeName) {
+ MutableProtoFile protoFileForNamespace = getProtoFileForNamespace(namespace);
+ for (MutableType type : protoFileForNamespace.types()) {
+ if (type instanceof MutableMessageType) {
+ if (((MutableMessageType) type).getName().equals(typeName)) {
return type;
}
- } else if (type instanceof EnumType && ((EnumType) type).name().equals(typeName)) {
+ } else if (type instanceof MutableEnumType && ((MutableEnumType) type).name().equals(typeName)) {
return type;
}
}
@@ -208,7 +209,7 @@ private String processElement(XSElementDecl element, XSSchemaSet schemaSet) {
if (element.getType() instanceof XSComplexType && element.getType() != schemaSet.getAnyType()) {
cType = (XSComplexType) element.getType();
- MessageType t = processComplexType(cType, element.getName(), schemaSet, null, null);
+ MutableMessageType t = processComplexType(cType, element.getName(), schemaSet, null, null);
if (cType.isGlobal()) {
addType(element.getTargetNamespace(), t);
}
@@ -252,17 +253,17 @@ private String processSimpleType(XSSimpleType xs, String elementName) {
return typeName;
}
- private void addField(MessageType message, Field newField) {
+ private void addField(MutableMessageType message, MutableField newField) {
addField(message, null, newField);
}
- private void addField(MessageType message, OneOf oneOf, Field newField) {
+ private void addField(MutableMessageType message, MutableOneOf oneOf, MutableField newField) {
// Verify with protolock that field number is not already used for a different field
// Remove old fields of same type (element or attribute)
- Field existingField = null;
- for (Field f : message.fieldsAndOneOfFields()) {
+ MutableField existingField = null;
+ for (MutableField f : message.fieldsAndOneOfFields()) {
if (newField.name().equals(f.name())) {
existingField = f;
break;
@@ -286,23 +287,23 @@ private void addField(MessageType message, OneOf oneOf, Field newField) {
}
}
- private MessageType createWrapper(String typeName, MessageType messageType, String wrapperFieldName, String targetNamespace, XSParticle particle,
- String fieldDoc, Location location, XSComplexType parentType, String wrapperDoc) {
+ private MutableMessageType createWrapper(String typeName, MutableMessageType messageType, String wrapperFieldName, String targetNamespace,
+ XSParticle particle, String fieldDoc, Location location, XSComplexType parentType, String wrapperDoc) {
// Add message type to file
List messageOptions = new ArrayList<>();
- Options options = new Options(Options.MESSAGE_OPTIONS, messageOptions);
+ MutableOptions options = new MutableOptions(MutableOptions.MESSAGE_OPTIONS, messageOptions);
- MessageType wrapperType = new MessageType(ProtoType.get(typeName), location, wrapperDoc, typeName, options);
+ MutableMessageType wrapperType = new MutableMessageType(ProtoType.get(typeName), location, wrapperDoc, typeName, options);
wrapperType.setWrapperMessageType(true);
messageType.nestedTypes().add(wrapperType);
- Options fieldOptions = getFieldOptions(particle);
+ MutableOptions fieldOptions = getFieldOptions(particle);
String fieldPackagename = NamespaceHelper.xmlNamespaceToProtoFieldPackagename(targetNamespace, configuration.forceProtoPackage);
- Field field = new Field(fieldPackagename, location, Label.REPEATED, wrapperFieldName, fieldDoc, messageType.getNextFieldNum(), typeName, fieldOptions,
- false);
+ MutableField field = new MutableField(fieldPackagename, location, Label.REPEATED, wrapperFieldName, fieldDoc, messageType.getNextFieldNum(), typeName,
+ fieldOptions, false);
addField(messageType, field);
@@ -313,13 +314,13 @@ private MessageType createWrapper(String typeName, MessageType messageType, Stri
}
- private void navigateSubTypes(XSParticle parentParticle, MessageType messageType, Set