/** * 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; }
/** * 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; }
@Test public void testGetLocation_message() { MessageType outer = getOuterMessage(); MessageType inner = getInnerMessage(); verifyLocation("message OuterMessage {", outer.getLocation()); verifyLocation("message InnerMessage {", inner.getLocation()); }
@VisitsBefore void visit(MessageType message) { // Add the message to the set of known types. addType(message.getLocation(), message.getFullName(), TypeRef.of(message)); // Add the message's package to the set of known packages addPackage(message.getFile().getFullName()); // Build the field-by-name map for this message, and record field simple names. Map<String, Field> fieldByName = Maps.newLinkedHashMap(); for (Field field : message.getFields()) { fieldNames.add(field.getSimpleName()); Field old = fieldByName.put(field.getSimpleName(), field); if (old != null) { model .getDiagReporter() .report( Diag.error( field.getLocation(), "Duplicate declaration of field '%s'. Previous location: %s", field.getSimpleName(), old.getLocation().getDisplayString())); } } message.setFieldByNameMap(ImmutableMap.copyOf(fieldByName)); }
@VisitsBefore void visit(MessageType message) { // Add the message to the set of known types. addType(message.getLocation(), message.getFullName(), TypeRef.of(message)); // Add the message's package to the set of known packages addPackage(message.getFile().getFullName()); // Build the field-by-name map for this message, and record field simple names. Map<String, Field> fieldByName = Maps.newLinkedHashMap(); for (Field field : message.getFields()) { fieldNames.add(field.getSimpleName()); Field old = fieldByName.put(field.getSimpleName(), field); if (old != null) { model .getDiagReporter() .report( Diag.error( field.getLocation(), "Duplicate declaration of field '%s'. Previous location: %s", field.getSimpleName(), old.getLocation().getDisplayString())); } } message.setFieldByNameMap(ImmutableMap.copyOf(fieldByName)); }