/** 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); } }
throw new SchemaException(errors);
/** Confirms that {@code protoFiles} link correctly against {@code schema}. */ void validate(Schema schema, ImmutableList<AbstractProfileFileElement> profileFiles) { List<String> errors = new ArrayList<>(); for (AbstractProfileFileElement profileFile : profileFiles) { for (AbstractTypeConfigElement 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); } }
throw new SchemaException(errors);
throw new SchemaException(errors);