By Geertjan-Oracle on Dec 30, 2012
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 package-info.java 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.