Geertjan is a DZone Zone Leader and has posted 437 posts at DZone. You can read more from them at their website. View Full User Profile

Interview: Google Protocol Buffer Plugin for NetBeans IDE

01.30.2009
| 16374 views |
  • submit to reddit

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:

Syntax navigation:

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?

  • Schliemann
  • AST* from "General Language Framework" API
  • CodeCompletionProvider
  • FileObject
  • DataObject
  • Node
  • Annotation
  • OutputListener
  • NbProcessDescriptor.

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?

  1. Search for tutorials via Google, in the NetBeans Developer FAQ, and on the NetBeans Platform Homepage.
  2. Look for similar functionality as you need in already existing plugins and in NetBeans IDE itself. Examine the sources and then write your code.
  3. 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.

 

AttachmentSize
fig.png63.54 KB
contextCodeCompletion.jpeg156.37 KB
errorMarking.jpeg48.25 KB
navigator.jpeg140.09 KB
options.jpeg39.99 KB
regenerate1.jpeg54.88 KB
regenerateMulti.jpeg48.01 KB
template.jpeg71.72 KB
Published at DZone with permission of its author, Geertjan Wielenga.
Tags:

Comments

Bryan Low replied on Mon, 2012/12/24 - 10:58pm

Tanah Merah New Launch is also near top level educational institutions such as Anglican High University, St. Anthony’s Canossian Primary& Extra University and Temasek Younger Higher education. Tampines Younger Higher education, Temasek Polytechnic and World Higher education (East Campus) is also around in the place.

For vehicle business owners, it needs less than 25 minutes to generate to the business hub and amazing Orchard Road purchasing area, via Pan-Island Expressway (PIE) and Southern southern Shore Expressway (ECP).A amazing and exclusive way of way of way of life is looking forward to you.Please see urban vista venture details and floor programs for more details.

Bryan Low replied on Fri, 2013/02/01 - 10:11pm

Twin Fountains EC facilities provide full family entertainment needs for your family and loved ones. Indulge in a serene and tranquil lifestyle right in the heart of Woodlands.

Twin Fountains Woodlands

Eric Lim replied on Wed, 2013/03/06 - 8:21am

Thank you for sharing with us on Google Protocol Buffer Plugin for NetBeans IDE.

New launch  | Urban Vista 

Bryan Low replied on Mon, 2013/03/25 - 3:21am

Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work.

Belgravia Villas

Andy Man replied on Wed, 2013/04/03 - 10:52am

 Belgravia Villas  is going to launch in May. Located in Ang Mo Kio Ave 5, it is the one and only cluster along the road.

Matt Coleman replied on Mon, 2013/04/08 - 2:51am

great interview...it has a lot of insights

 buffalo logo design 

At Ppty replied on Sat, 2013/04/20 - 1:50am

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work 

Corals at Keppel Bay 

Bryan Low replied on Tue, 2013/04/23 - 2:25am

Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work.

Ecopolitan

At Ppty replied on Sun, 2013/04/28 - 11:11am

Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work.Corals at keppel bay 

Bryan Low replied on Tue, 2013/05/14 - 7:20am

J Gateway is also near elite schools such as Fuhua Primary School and St Anthony Primary School. Yuhua Primary School and Shuqun Secondary School are also around in the area. Jurong East Condo

At Ppty replied on Wed, 2013/05/15 - 12:00am

Thanks for your insight for your fantastic posting. I’m glad I have taken the time to see this. The Trilinq 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.