mercredi 17 juillet 2013

Natural language search in FXML

I'm pleased to introduce "Natural Language Code Search", an IDE plugin straight out of our R&D lab that might be useful for you too!

Traceability


This plugin is the result of a collaboration between dooApp and the INRIA (French public science and technology institution). We investigated a new way to automatically recover traceability links between specifications and code elements. Establishing traceability links is very important for many reasons:

  • program comprehension,
  • maintenance,
  • requirement tracing,
  • impact analysis,... 
If you are not familiar with software traceability, have a look at this introduction on Wikipedia and at this excellent paper.

Classical approach


Most classical approaches to retrieve links between specifications (in natural language) and code involves analyzing code symbols (e.g. class names). It raises two issues:
  • the developers might not always use the exact and precise domain terminology
  • the code and the specification (e.g. a regulation) might be in different languages

Our approach


In our work, we introduced a new approach based on the analyze of the UI labels. Our idea is that the specifications lead most of the time to texts displayed to the user in the user interface and that these texts will use a precise domain terminology. Then it's possible to retrieve the UI label usage in the code, to identify the pieces of code you are looking for !

Process


We designed a three-step process:
  • Index resource bundles using Apache Lucene
  • Query the indexed bundles in natural language and retrieve the best matching labels and associated keys
  • Retrieve code elements by analyzing key usages (either statically by analyzing code or dynamically by registering stacktraces of calls to ResourceBundle.get())

IntelliJ plugin


We have tested and evaluated our approach; the promising results of the evaluation lead us to develop an IntelliJ plugin wrapping the whole process. Check it out directly from the IntelliJ repository if you want to give a try !

And what about JavaFX?


At this point, you might wonder why we published this article under the JavaFX category? 
Actually, when you are developing a JavaFX application, your bundle keys are not used directly in the code but rather in FXML files. So, our plugin also lookup for key usage in the FXML file.

So, we realized that our plugin can also be used to easily retrieve FXML files associated to user interface labels, even if the query is approximate !
Don't lose time anymore trying to identify which FXML file to open when you want to modify the user interface ! Type in what you are looking for (e.g. some words that you see in the user interface) and let the plugin find it for you!
This is really handy for developers starting working on an existing project or for maintenance.

Try it yourself


The best way to understand how this plugin can help you is to try it on your own codebase:
  • Install the plugin from IntelliJ
  • Type "Ctrl+Shit+S" to open the input dialog
  • Type your query in natural language
  • Explore the results !




Aucun commentaire:

Enregistrer un commentaire

Enregistrer un commentaire