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,

Code Index_1.png

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,

  1. Get build flags for each file using IdeBuildSystem,
  2. Get all symbols in a file using IdeCodeIndexer by giving file and build flags,
  3. Write all symbols returned by IdeCodeIndexer to disk and
  4. 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,

  1. Get matches from each index using DzlFuzzyIndex and
  2. 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,

  1. Get key of declaration of reference which is there at given location using IdeCodeIndexer and
  2. 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.

Leave a comment