private boolean packageHasEnums(Model model) { for (TypeRef type : model.getSymbolTable().getDeclaredTypes()) { if (type.isEnum() && type.getEnumType().isReachable()) { return true; } } return false; }
private void acceptMessages(Iterable<MessageType> messages) { for (MessageType message : messages) { if (ignoreMapEntry && message.isMapEntry() || !scoper.isReachable(message)) { continue; } visit(message); } }
private void report( Diag.Kind kind, LocationContext locationContext, String formatString, Object... args) { Location location = locationContext.resolve(locationResolver); Diag diag = Diag.create(location, formatString, kind, args); if (diag.getKind() == Kind.WARNING && diagSuppressor.isDiagSuppressed(diag, location)) { return; } diagCollector.addDiag(diag); }
private static java.lang.String generateTypeUrl(TypeRef type) { java.lang.String name; if (type.isMessage()) { name = type.getMessageType().getFullName(); } else { name = type.getEnumType().getFullName(); } return DescriptorNormalization.TYPE_SERVICE_BASE_URL + "/" + name; }
private void error(String message, Object... args) { model .getDiagReporter() .getDiagCollector() .addDiag(Diag.error(SimpleLocation.TOPLEVEL, message, args)); }
private void warning(String message, Object... args) { model .getDiagReporter() .getDiagCollector() .addDiag(Diag.warning(SimpleLocation.TOPLEVEL, message, args)); } }
@Override public List<Diag> getDiags() { return model.getDiagReporter().getDiagCollector().getDiags(); } };
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); } }
/** Creates an model where all protos in the descriptor are considered to be sources. */ public static Model create(FileDescriptorSet proto) { DiagCollector diagCollector = new BoundedDiagCollector(); return new Model( proto, null, ExperimentsImpl.none(), ExtensionPool.EMPTY, diagCollector, new DiagSuppressor(diagCollector)); }
public void report(Diag diag) { if (diag.getKind() == Kind.WARNING && diagSuppressor.isDiagSuppressed(diag, diag.getLocation())) { return; } diagCollector.addDiag(diag); }
/** * Creates a field that represents an extension. */ public static Field createAsExtension(MessageType parent, Extension extension, String path, String name) { Field field = new Field(parent, extension.getProto(), path, null, name); field.getFile().addExtension(extension, field); return field; }
@Override public String getContainerName() { return element.getFile().getLocation().getDisplayString(); }
/** Return true if the element is reachable with the current scoper. */ public boolean isReachable() { return getModel().getScoper().isReachable(this); }
/** * If this is a message or enum type, return its declaration location, otherwise * SimpleLocation.UNKNOWN. */ public Location getLocation() { return messageType != null ? messageType.getLocation() : enumType != null ? enumType.getLocation() : SimpleLocation.UNKNOWN; }
/** * Returns the service config file location of the given named field in the (sub)message. Returns * {@link SimpleLocation#TOPLEVEL} if the location is not known. */ @Override public Location getLocationInConfig(Message message, String fieldName) { return getServiceConfigSource().getLocationInConfig(message, fieldName); }
private static java.lang.String generateTypeUrl(TypeRef type) { java.lang.String name; if (type.isMessage()) { name = type.getMessageType().getFullName(); } else { name = type.getEnumType().getFullName(); } return DescriptorNormalization.TYPE_SERVICE_BASE_URL + "/" + name; }
private void report( Diag.Kind kind, LocationContext locationContext, String formatString, Object... args) { Location location = locationContext.resolve(locationResolver); Diag diag = Diag.create(location, formatString, kind, args); if (diag.getKind() == Kind.WARNING && diagSuppressor.isDiagSuppressed(diag, location)) { return; } diagCollector.addDiag(diag); }
/** Helper to access the full name of the input (request) message of a method. */ public static String getInputMessageName(Method method) { return method.getInputType().getMessageType().getFullName(); } }
/** Creates an model where all protos in the descriptor are considered to be sources. */ public static Model create(FileDescriptorSet proto) { DiagCollector diagCollector = new BoundedDiagCollector(); return new Model( proto, null, ExperimentsImpl.none(), ExtensionPool.EMPTY, diagCollector, new DiagSuppressor(diagCollector)); }
private void acceptMessages(Iterable<MessageType> messages) { for (MessageType message : messages) { if (ignoreMapEntry && message.isMapEntry() || !scoper.isReachable(message)) { continue; } visit(message); } }