Support for Proto3 well known types
ethiery opened this issue · 11 comments
First of all, thanks for this plugin, very useful.
Is your feature request related to a problem? Please describe.
I am using proto3, and importing some well know types. It seems that these are not currently supported out of box, since I am getting a "File not found" error on the import, and an "Unresolved reference" error on all usages.
Describe the solution you'd like
It would be great if protobuf/src/google/protobuf/ was automatically added as an include path of this plugin.
Additional context
Example:
syntax = "proto3";
import "google/protobuf/timestamp.proto";
package myproto;
message MyMessage {
google.protobuf.Timestamp created_at = 1;
}
It should work already this way. What plugin version are you using?
Using v0.13.0 in Goland 2018.3.5.
I just tried opening the same .proto file with IntelliJ Ultimate 2018.3.5, and it works as expected. Navigating to the declaration of google.protobuf.Timestamp
shows that it is pulled from a protobuf jar packaged with the plugin (~/.IntelliJIdea2018.3/config/plugins/protobuf-jetbrains-plugin/lib/protobuf-java-3.6.1-sources.jar!/google/protobuf/timestamp.proto).
I found the same jar under /.GoLand2018.3/config/plugins/protobuf-jetbrains-plugin/lib/, but for some reason its content does not seem to be in the include paths of the plugin in GoLand.
For the record, manually adding a path to the well known types in the include paths of the plugin works:
go get -d github.com/protocolbuffers/protobuf
Let me know if there is anything else I can do to help diagnose
In IntelliJ IDEA libraries are visible in "Project Structure" dialog. Unfortunately, I could not find it in GoLand.
However, we can check library settings manually in <project name>.iml
file inside .idea/
folder in project directory:
kshchepanovskyi@ks-laptop:~/go/src/awesomeProject/.idea$ cat awesomeProject.iml
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Bundled Protobuf Distribution" level="application" />
</component>
</module>
There should be Bundled Protobuf Distribution
entry in the list.
Alright, I think I have isolated the issue.
I have created this minimum project.
At the root, you'll find the hello.proto
we've been discussing previously, and two folders:
hello_go
which contains the go code generated by protochello_java
which contains the java code generated protoc
The issue occurs if you:
- open
/hello_go
(not the root) with Goland
- Within this Goland window, open
hello.proto
(which is thus outside the project).
- Resulting in the issue I described.
For the record, Bundled Protobuf Distribution" does not appear in
/hello_go/.idea/hello_go.iml`:
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
A few other experiments.
Opening /hello_go
with IntelliJ
This does not seem to be a Goland specific issue per se, since repeating the same 3 steps with IntelliJ instead of Goland leads to the same result.
Opening /hello_java
with IntelliJ
Interestingly, repeating the same 3 steps with IntelliJ and with the hello_java
folder does not lead to any issue:
However, inspecting the project structure or navigating to the declaration of google.protobuf.timestamp
show that the plugin picks it up not from the bundled protobuf distribution, but from the "com.google.protobuf:protobuf-java:3.7.0"
gradle dependency required for the generated java code to compile.
Opening /
with Golang
Finally, opening the root folder of the repo with Goland works fine:
And in that case, the bundled protobuf distribution appears in /.idea/MRE_protobuf_plugin.iml
:
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Bundled Protobuf Distribution" level="application" />
</component>
</module>
Conclusion
So to me, the issue seems to stem from the fact that both IntelliJ and Goland only include the bundled protobuf distribution if there is a .proto file within the project.
I hope that helps, thanks for the time you are spending on this.
@briantopping since StringValue
isn't in your declared package, you'll need to qualify it. E.g.,
google.protobuf.StringValue username = 1;
Ah perfect! Wish I had realized that, thanks!!
This issue is closed as plugin is not supported anymore.
Please switch to https://github.com/jvolkman/intellij-protobuf-editor.