Interview: Google Protocol Buffer Plugin for NetBeans IDE
Join the DZone community and get the full member experience.Join For Free
One of the students in the recent NetBeans Platform Certified Training in Warsaw, Piotr Tabor, has been working on a very interesting certification project: treating NetBeans IDE as a tools platform, he's created features for working with Google Protocol Buffers.
Certification projects are, essentially, homework that students do after the course to prove that they have understood the material. They can choose the topic themselves, so long as it involves the usage of the NetBeans APIs in some way. Upon successful completion of this homework task, they become NetBeans Certified Engineers. Below follows an interview with Piotr, where he talks about his project, the things he learned, and the NetBeans Platform in general.
Hi Piotr, can you start by saying a bit about who you are? I'm a PhD student at the University of Warsaw. I am working on new ideas connected to object databases and database query languages (http://sbql.pl/). For a living, I'm working as a Java Architect and developer, creating infrastructures that enable the integration of web portals.
You created a NetBeans plugin for 'protocol buffers'. Why did you do that? I like "protocol buffers" and there was no support for this technology in IDEs (neither NetBeans IDE nor Eclipse). And I also had to do a project to finish the NetBeans Platform Certified Training. The plugin's project page is http://code.google.com/p/protobuf-netbeans-plugin/.
Can you say a few things to introduce us to 'protocol buffers', such as who uses them and why? Protocol buffers ("protobuf") is a technology by Google that has similar goals to XML: a data interchange format that is hierarchical and independent of the platform and developer's environment. The problem with XML is that it is very slow in parsing and that it is space ineffective. There is no such drawback in protobuf, because of its binary format.
To use protobuf, you have to write a description of a message, in a simple but special language, and then use the "protoc" (protobuf compiler) program to generate serialize, deserialize and transport classes for Java, C++ and Python. There are also "unofficial" (not provided by Google) generators to other languages.
You can also generate an RPC service, based on the message format you created. That's a very effective alternative to Web Services.
So your plugin supports this language. Can you describe the main features? I provided editor support for *.proto files (message format description files), with syntax coloring, tree navigation through the code, error markers on the lines where the error is found, and context-aware code completion:
You also can regenerate code (using protoc), by selecting the "Regenerate" action from the context menu.
Finally, I created my own Update Center, which contains the modules that make up this plugin. Go here to see it, register it in the Plugin Manager, and you'll be able to install my project into your IDE.
Can you show some more screenshots?
Error marks in the editor:
Generate Java code from Proto file in the editor:
Generate Java code from multiple Proto files in the explorer views:
Proto file template:
Options window extension for Protoc compiler:
Which feature was the most challenging to create? Context aware code completion was the most complicated part of the code. There were two problems:
- How to acquire ASTTree (parsing result of current code) from Schliemann. I found the sources of the "AST Browser" in NetBeans to learn how to do that.
- How to know in which syntax construction the caret is? The problem was connected to the fact that Schliemann recognizes whitespace chars (SKIP syntax tokens) as part of previous syntax construction.
What are the main NetBeans API classes that you used?
- AST* from "General Language Framework" API
Did you enjoy creating the plugin? What did you like most & least about creating it? Sure. It's quite simple compared to the usefulness of the results you acquire. There is only the general "huge API" problem: there are so many things available in the API that you never really know if the functionality you are coding is already available in existing NetBeans API libraries or not.
Do you have any tips for people beginning to use the NetBeans Platform?
- Search for tutorials via Google, in the NetBeans Developer FAQ, and on the NetBeans Platform Homepage.
- Look for similar functionality as you need in already existing plugins and in NetBeans IDE itself. Examine the sources and then write your code.
- Install "Tools" -> "Plugins" -> "Available Plugins" -> "NetBeans API Documentation". NetBeans code completion for NetBeans API classes is very helpful.
Are you going to continue developing this plugin and, if so, which features will be added next? Yes. At least I want to fix bugs and it would be cool to integrate code generation with the build process. I'm not sure if I should do that by coding in my plugin automatic tweaking ./nbproject/build-impl.xml file or is there some layout.xml binding to provide my own build goal for "generate-sources" phase. (It works this way in Maven 2, to which I contributed some time ago ).
Any final thoughts? Thanks to Karol Harezlak, Toni Epple and Geertjan for the NetBeans Platform Certified Training in Warsaw, where I learned that creating plugins is relatively easy.
Opinions expressed by DZone contributors are their own.