EvGeniy Ilyin
EvGeniy Ilyin

Reputation: 1929

Protocol Buffers library-dependent location in IntelliJ

I try to use import in my *.proto instructions for Protobuf. In my app, I have a few plugins with these *.proto instructions. But IntelliJ with Protocol Buffers marks imports and classes from the imported files as red.

I found, if I add in Preferences->Languages & Frameworks->Protocol Buffers strong location to my *.proto it will be green. But I have many places with *.proto, for example for each plugin in my app, and some of this *.proto can have an equal name, like featuresDto for each plugin. How can I add library-dependent location instead of strong?

However, the protobuf-generator works as expected.

[screenshot]

Upvotes: 1

Views: 387

Answers (1)

I didn't get correctly what do you mean by library-dependent location - could you please explain?

As for protobuf plugin settings: there you can find all directories, where you'll be able to import files from. E.g. if the protobuf file is located in /foo/bar/MyService.proto, and you want to be able to import it as import "bar/MyService.proto";, you should add /foo/ directory to the plugin settings. In fact those settings mean exactly the same as directories one specifies with proto-path cli argument: if any proto file can not be resolved against one of given proto-paths, compilation will not succeed.

Also you may find useful the following issues about simplifying solving imports-related problems: https://youtrack.jetbrains.com/issue/IDEA-283099 and https://youtrack.jetbrains.com/issue/IDEA-283097

Upvotes: 1

Related Questions