Sunday Dec 30, 2012

Code Completion for Lang Attribute in XHTML Files

Olivier Schmitt from the French Ministry of Agriculture published a brilliant article and sample code in his (French) blog recently:

The source code:

The result is code completion for the "lang" attribute in text/xhtml files: 

Source structure, take note of the CSV file, which is a cool way to get the code completion words:

I'm thinking of making the ultimate generic solution on top of Oliver's code: a new @CompletionRegistration annotation, that takes a MIME type, content (i.e., a list of completion words), and a condition (e.g., "lang" attribute). Then, at compile time, the layer entries are generated and mapped to Oliver's code. The @CompletionRegistration annotation would not be set on a class, but within the class, i.e., similar to how file templates can now be registered via @TemplateRegistration. In other words, nothing at all would need to be implemented or extended, no API, nothing at all; instead, you'd register some info via the annotation and then everything else would be generated for you and you could immediately begin using your newly mapped completion provider.


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


  • NetBeans IDE
« December 2012 »