Code Search for GNOME Builder : Final report

This is the final report for my GSOC Project Code Search for GNOME Builder. First I want to thank to Christian Hergert for helping me in this project. I successfully achieved 2 objectives in this project, fuzzy search of symbols in the project and improving Go to Definition in GNOME Builder. Here is the final code GitHub of this project which will be merged.

This is the design of the project,

Indexing

To be able to find symbols which matches fuzzily to given query or which is definition of a reference or declaration we need an index of all symbols in the project. IdeCodeIndexService will monitor file changes and indexes project using IdeCodeIndexBuilder. For indexing IdeCodeIndexBuilder will,

Get build flags for each file using IdeBuildSystem,

Get all symbols in a file using IdeCodeIndexer by giving file and build flags,

Write all symbols returned by IdeCodeIndexer to disk and

Load all indexes using IdeCodeIndexIndex.

Currently we can only index C/C++ source files. Indexing for other languages can be done simply by implementing IdeCodeIndexer corresponding to that language.

We will maintain 2 indexes for each directory in project. One will contain (name, file, line, column, flags) of all symbols in all files in that directory and this index is created using DzlFuzzyIndex from libdazzle. Another will contain (key, file, line, column, flags) of all symbols and is created using IdePersistentMap implemented in this project.

Fuzzy Search of symbols

I implemented IdeSearchProvider which will return fuzzy matches when a query is given using IdeCodeIndexIndex. Symbols can also be filtered by their types like function, enum, struct, etc. For finding matches IdeCodeIndexIndex will,

Get matches from each index using DzlFuzzyIndex and

Return top matches, according to score, from all the indexes.

Goto definition

A symbol resolver is implemented which will return definition of a reference at a location. For finding definition of a reference at some location it will,

Get key of declaration of reference which is there at given location using IdeCodeIndexer and

Search index to find definition which has given key using IdeCodeIndexIndex and return that symbol.

These are demos of these 2 features,

Finally I want to thank GNOME and Google Summer of Code for giving me this great opportunity.