protobuf-jetbrains-plugin
protobuf-jetbrains-plugin copied to clipboard
Support using `optional` in proto3
Describe the bug
Since protoc version 3.15, it enabled the use of optional in proto3 by default. See field_presence. But this plugin still reports errors when using optional.
To Reproduce Steps to reproduce the behavior:
syntax = "proto3";
message Msg {
optional int32 foo = 1;
}
Expected behavior No error, no warning.
Screenshots

Plugin (please complete the following information):
- Plugin version: 0.12.0
Additional context The check action may be as follows:
private void checkFieldLabelProto3(FieldNode field) {
Optional<FieldLabel> fieldLabel = field.getFieldLabel();
fieldLabel.ifPresent(label -> {
if (label == FieldLabel.OPTIONAL
|| label == FieldLabel.REQUIRED) {
String message = message("error.illegal.field.label", label.getName());
markError(field.getFieldLabelNode(), null, message);
}
});
}
Yes please! I was under the mistaken impression that proto3 doesn't support has_field for primitives, until I found out that they added support as long as the field is marked optional. Now that I want to use it, I have this amazing plugin complaining about my .protos.
FWIW I have the same issue in v 0.13 (and some recent reviews on IJ marketplace complain about the same).