Skip to content

Support using optional in proto3Β #160

@ByteGen

Description

@ByteGen

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);
            }
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions