Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using optional in proto3 #160

Open
ByteGen opened this issue Jul 20, 2021 · 1 comment
Open

Support using optional in proto3 #160

ByteGen opened this issue Jul 20, 2021 · 1 comment

Comments

@ByteGen
Copy link

ByteGen commented Jul 20, 2021

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
image

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);
            }
        });
    }
@ByteGen ByteGen changed the title Support using optional in the plugin for proto3 Support using optional in proto3 Jul 20, 2021
@davidmankin
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants