public void reportWarning(LocationContext locationContext, String formatString, Object... args) { report(Kind.WARNING, locationContext, formatString, args); }
public void reportWarning(LocationContext locationContext, String formatString, Object... args) { report(Kind.WARNING, locationContext, formatString, args); }
public void reportError(LocationContext locationContext, String formatString, Object... args) { report(Kind.ERROR, locationContext, formatString, args); }
public void reportError(LocationContext locationContext, String formatString, Object... args) { report(Kind.ERROR, locationContext, formatString, args); }
private void addType(Location location, String fullName, TypeRef type) { String typeName = SymbolTable.getTypeNameInSymbolTable(fullName); TypeRef old = types.put(typeName , type); if (old != null) { model .getDiagReporter() .report( Diag.error( location, "Duplicate declaration of type '%s'. Previous location: %s", fullName, old.getLocation().getDisplayString())); } } }
/** * Resolves a type based on the given partial name. This does not assume that the name, as * obtained from the descriptor, is in absolute form. */ private TypeRef resolveType(Location location, FieldDescriptorProto.Type kind, String name) { TypeRef type; switch (kind) { case TYPE_MESSAGE: case TYPE_ENUM: case TYPE_GROUP: type = symbolTable.resolveType(namespaces.peek(), name); break; default: type = TypeRef.of(kind); } if (type == null) { model.getDiagReporter().report(Diag.error(location, "Unresolved type '%s'", name)); } return type; } }
/** * Resolves a type based on the given partial name. This does not assume that the name, as * obtained from the descriptor, is in absolute form. */ private TypeRef resolveType(Location location, FieldDescriptorProto.Type kind, String name) { TypeRef type; switch (kind) { case TYPE_MESSAGE: case TYPE_ENUM: case TYPE_GROUP: type = symbolTable.resolveType(namespaces.peek(), name); break; default: type = TypeRef.of(kind); } if (type == null) { model.getDiagReporter().report(Diag.error(location, "Unresolved type '%s'", name)); } return type; } }
private void addType(Location location, String fullName, TypeRef type) { String typeName = SymbolTable.getTypeNameInSymbolTable(fullName); TypeRef old = types.put(typeName , type); if (old != null) { model .getDiagReporter() .report( Diag.error( location, "Duplicate declaration of type '%s'. Previous location: %s", fullName, old.getLocation().getDisplayString())); } } }
private void errorSince(int version, Element elem, String message, Object... params) { if (!errorContext.isEmpty()) { message = message + " " + errorContext + "."; } Diag diag = elem.getModel().getConfigVersion() >= version ? Diag.error(elem.getLocation(), message, params) : Diag.warning( elem.getLocation(), message + String.format( " Note: this will be an error for config version %s and later.", version), params); elem.getModel().getDiagReporter().report(diag); }
private void errorSince(int version, Element elem, String message, Object... params) { if (!errorContext.isEmpty()) { message = message + " " + errorContext + "."; } Diag diag = elem.getModel().getConfigVersion() >= version ? Diag.error(elem.getLocation(), message, params) : Diag.warning( elem.getLocation(), message + String.format( " Note: this will be an error for config version %s and later.", version), params); elem.getModel().getDiagReporter().report(diag); }
@VisitsBefore void visit(EnumType enumType) { // Add the enum type to the set of known types. addType(enumType.getLocation(), enumType.getFullName(), TypeRef.of(enumType)); // Build the field-by-name map for this enum type. Map<String, EnumValue> valueByName = Maps.newLinkedHashMap(); for (EnumValue value : enumType.getValues()) { EnumValue old = valueByName.put(value.getSimpleName(), value); if (old != null) { model .getDiagReporter() .report( Diag.error( value.getLocation(), "Duplicate declaration of enum value '%s'. Previous location: %s", value.getSimpleName(), old.getLocation().getDisplayString())); } } enumType.setValueByNameMap(ImmutableMap.copyOf(valueByName)); }
@VisitsBefore void visit(EnumType enumType) { // Add the enum type to the set of known types. addType(enumType.getLocation(), enumType.getFullName(), TypeRef.of(enumType)); // Build the field-by-name map for this enum type. Map<String, EnumValue> valueByName = Maps.newLinkedHashMap(); for (EnumValue value : enumType.getValues()) { EnumValue old = valueByName.put(value.getSimpleName(), value); if (old != null) { model .getDiagReporter() .report( Diag.error( value.getLocation(), "Duplicate declaration of enum value '%s'. Previous location: %s", value.getSimpleName(), old.getLocation().getDisplayString())); } } enumType.setValueByNameMap(ImmutableMap.copyOf(valueByName)); }
@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)); }
@VisitsBefore void visit(Field field) { // Resolve type of this field. TypeRef type = resolveType(field.getLocation(), field.getProto().getType(), field.getProto().getTypeName()); if (type != null) { if (field.isRepeated()) { type = type.makeRepeated(); } else if (!field.isOptional()) { type = type.makeRequired(); } field.setType(type); } // Check for resolution of oneof. if (field.getProto().hasOneofIndex() && field.getOneof() == null) { // Indicates the oneof index could not be resolved. model .getDiagReporter() .report( Diag.error( field.getLocation(), "Unresolved oneof reference (indicates internal inconsistency of input; oneof " + "index: %s)", field.getProto().getOneofIndex())); } findOptionTypes(field.getOptionFields()); }
@VisitsBefore void visit(Field field) { // Resolve type of this field. TypeRef type = resolveType(field.getLocation(), field.getProto().getType(), field.getProto().getTypeName()); if (type != null) { if (field.isRepeated()) { type = type.makeRepeated(); } else if (!field.isOptional()) { type = type.makeRequired(); } field.setType(type); } // Check for resolution of oneof. if (field.getProto().hasOneofIndex() && field.getOneof() == null) { // Indicates the oneof index could not be resolved. model .getDiagReporter() .report( Diag.error( field.getLocation(), "Unresolved oneof reference (indicates internal inconsistency of input; oneof " + "index: %s)", field.getProto().getOneofIndex())); } findOptionTypes(field.getOptionFields()); }