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

Syntax: option values with arrays are not supported #25

Closed
nomaed opened this issue Jul 4, 2021 · 9 comments
Closed

Syntax: option values with arrays are not supported #25

nomaed opened this issue Jul 4, 2021 · 9 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@nomaed
Copy link

nomaed commented Jul 4, 2021

It looks like option values that are arrays are not supported, and are displayed as invalid syntax. This often breaks the entire file and also auto-formatting doesn't work.

Example from the internet:

message MyMeta {
    int32 id = 1 [(com.util.meta) = {
        needValidation: false,
        fileMap: [
            {
                key: "t",
                value: "raw_orders"
            }
        ];
    }];
}

This should be a valid protobuf option, however this how it looks actually:
Screen Shot 2021-07-04 at 10 22 29

@devkanro devkanro added the question Further information is requested label Jul 5, 2021
@devkanro
Copy link
Owner

devkanro commented Jul 5, 2021

There is no array in the MessageValue rule.

Maybe you should try to set it again(repeated field):

message MyMeta {
    int32 id = 1 [(com.util.meta) = {
        needValidation: false,
        fileMap: {
            key: "t",
            value: "raw_orders"
        },
        fileMap: {
            key: "key2",
            value: "otherValue"
        }
    }];
}

@devkanro
Copy link
Owner

devkanro commented Jul 5, 2021

There are no many documents for protobuf option, I just use protoc to compile those protos, after my test, protoc can accept both of them, but my plugin only supports the repeated syntax.

I will add array syntax support in the next version.

@devkanro devkanro added the enhancement New feature or request label Jul 5, 2021
@nomaed
Copy link
Author

nomaed commented Jul 5, 2021

You are right about not much documentation. I was looking for a while to see if this syntax even valid. But I did find it being used in a bunch of places eventually, and I saw that the native IntelliJ plugin does support it well, so I figured it is something that is worth having in your (excellent) plugin too.

Thank you!

@devkanro
Copy link
Owner

devkanro commented Jul 5, 2021

I have added array syntax support in commit f211f6d.

But I got some problems releasing it, check the issue JetBrains/intellij-platform-gradle-plugin#721 to get more details.

There is the local install package, maybe you can help me to test it before the CI work.

IntelliJ Protobuf Language Plugin-1.4.1-EAP.zip

@devkanro
Copy link
Owner

devkanro commented Jul 6, 2021

Fixed in release 1.4.1-EAP

@devkanro devkanro closed this as completed Jul 6, 2021
@jvolkman
Copy link

The option syntax is just the protobuf text format. It's not well documented, but protoc supports anything that's supported by text_format.cc. For example, even this special syntax for Any values is supported:

syntax = "proto3";
import "google/protobuf/descriptor.proto";
import "google/protobuf/any.proto";

package foo.bar;

message MyType {
  repeated google.protobuf.Any any = 1;
  bool value = 2;
}

message AnyType1 {
  google.protobuf.Any any = 1;
  string foo = 2;
}

message AnyType2 {
  google.protobuf.Any any = 1;
  string bar = 2;
}

extend google.protobuf.FileOptions {
  MyType opt = 2000;
}

option (opt) = {
  any {
    [type.googleapis.com/foo.bar.AnyType1] {
      foo: "foo"
      any {
        [type.googleapis.com/foo.bar.AnyType2] {
          bar: "bar"
        }
      }
    }
  }
};

@devkanro
Copy link
Owner

devkanro commented Jul 26, 2021

@jvolkman Thanks for your information, I will try to add prototext support in the next version.

@devkanro
Copy link
Owner

@jvolkman
Do you own write access permission to your plugin after JetBrains adopts it?
I'm a little curious about the way you work with JetBrains.

@jvolkman
Copy link

@jvolkman
Do you own write access permission to your plugin after JetBrains adopts it?
I'm a little curious about the way you work with JetBrains.

I still have access to the marketplace entry but not the intellij-plugins repository. I would need to submit PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants