use of com.squareup.wire.java.internal.TypeConfigElement in project wire by square.
the class ProfileLoader method validate.
/** Confirms that {@code protoFiles} link correctly against {@code schema}. */
void validate(Schema schema, ImmutableList<ProfileFileElement> profileFiles) {
List<String> errors = new ArrayList<>();
for (ProfileFileElement profileFile : profileFiles) {
for (TypeConfigElement typeConfig : profileFile.typeConfigs()) {
ProtoType type = importedType(ProtoType.get(typeConfig.type()));
if (type == null)
continue;
Type resolvedType = schema.getType(type);
if (resolvedType == null) {
errors.add(String.format("unable to resolve %s (%s)", type, typeConfig.location()));
continue;
}
String requiredImport = resolvedType.location().path();
if (!profileFile.imports().contains(requiredImport)) {
errors.add(String.format("%s needs to import %s (%s)", typeConfig.location().path(), requiredImport, typeConfig.location()));
}
}
}
if (!errors.isEmpty()) {
throw new SchemaException(errors);
}
}
Aggregations