relational java explorations with sqlite3 vtab
By traviscj
- 1 minutes read - 149 wordsOne idea i have been mulling over lately is exposing a java codebase relationally, with queries like:
SELECT *
FROM classes c
JOIN annotations a
ON a.class_id = c.id
WHERE a.name = 'MyAnnotationClass';
The idea here is that you could search a codebase by pretending that you had tables for a whole bunch of things like:
- classes
- annotations
- variables
- literals
- methods
This would be a useful thing because instead of relying on an IDE like IntelliJ to do “find usages” operations, you could actually script those interactions. Admittedly, of course, Java has some pretty sophisticated reflection APIs to find this sort of stuff too, but it seems like exploring the structure could be much easier writing Java code to traverse those trees.
I told sharvil about this idea and he immediately responded with a link to SQLite’s vtab API. There’s a Dr Dobbs article on using it as well.