@Override public void exitMap(ProtoParser.MapContext ctx) { final Field field = context.pop(Field.class); final Message message = context.peek(Message.class); String name = ctx.fieldName().getText(); SourceCodeLocation codeLocation = getSourceCodeLocation(ctx); Message map = new Message(message); String mapEntryTypeName = name + "_entry"; map.setName(mapEntryTypeName); map.setSourceCodeLocation(codeLocation); map.getOptions().set(codeLocation, OPTION_MAP_ENTRY, Value.createBoolean(true)); String keyTypeName = ctx.mapKey().getText(); Field keyField = createMapKeyField(map, keyTypeName, codeLocation); map.addField(keyField); String valueTypeName = ctx.mapValue().getText(); Field valueField = createMapValueField(map, valueTypeName, codeLocation); map.addField(valueField); Integer tag = Integer.decode(ctx.tag().getText()); field.setName(name); field.setTag(tag); field.setIndex(message.getFieldCount() + 1); field.setModifier(REPEATED); field.setTypeName(mapEntryTypeName); field.setType(map); field.setSourceCodeLocation(codeLocation); message.addField(field); message.addMessage(map); attachComments(ctx, field, true); }
@Override public void exitMap(ProtoParser.MapContext ctx) { final Field field = context.pop(Field.class); final Message message = context.peek(Message.class); String name = ctx.fieldName().getText(); SourceCodeLocation codeLocation = getSourceCodeLocation(ctx); Message map = new Message(message); String mapEntryTypeName = name + "_entry"; map.setName(mapEntryTypeName); map.setSourceCodeLocation(codeLocation); map.getOptions().set(codeLocation, OPTION_MAP_ENTRY, Value.createBoolean(true)); String keyTypeName = ctx.mapKey().getText(); Field keyField = createMapKeyField(map, keyTypeName, codeLocation); map.addField(keyField); String valueTypeName = ctx.mapValue().getText(); Field valueField = createMapValueField(map, valueTypeName, codeLocation); map.addField(valueField); Integer tag = Integer.decode(ctx.tag().getText()); field.setName(name); field.setTag(tag); field.setIndex(message.getFieldCount() + 1); field.setModifier(REPEATED); field.setTypeName(mapEntryTypeName); field.setType(map); field.setSourceCodeLocation(codeLocation); message.addField(field); message.addMessage(map); attachComments(ctx, field, true); }