Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Searchfox Update: Java & Kotlin code indexing

121 views
Skip to first unread message

Nicolas Guichard

unread,
Nov 23, 2023, 9:36:11 AM11/23/23
to dev-pl...@mozilla.org
Hi all,

There is already quite a bit of Java and some Kotlin code in mozilla-central for GeckoView and that number should only increase as progress is made towards absorbing firefox-android.
It was already possible to browse that code from Searchfox obviously, but without most of the interesting features:
* no Go to declaration/definition
* no search for uses/subclasses/superclasses/overrides/...
* no diagrams

All of that is now available for Java (and Kotlin) code too!

A few examples:
- A search for the org.mozilla.geckoview.GeckoSession.PromptDelegate.AutocompleteRequest class reveals a superclass, and a number of uses in both Java main source and Kotlin android tests.
https://searchfox.org/mozilla-central/search?q=symbol:S_java_java_org%2Fmozilla%2Fgeckoview%2FGeckoSession%23PromptDelegate%23AutocompleteRequest%23

- A search for the org.mozilla.geckoview.Autocomplete.StorageDelegate.onAddressFetch method links to a user in Java main code and a few overrides in Kotlin tests.
https://searchfox.org/mozilla-central/search?q=symbol:S_java_java_org%2Fmozilla%2Fgeckoview%2FAutocomplete%23StorageDelegate%23onAddressFetch().

- A query for all (transitive) callers to the method org::mozilla::geckoview::Autofill::Session::getDefaultDimensions with up to 2 indirect calls
https://searchfox.org/mozilla-central/query/default?q=calls-to%3A%27org%3A%3Amozilla%3A%3Ageckoview%3A%3AAutofill%3A%3ASession%3A%3AgetDefaultDimensions%27+depth%3A2

On the technical side this is enabled by emitting SemanticDB files when building using javac/kotlinc compiler plugins[1;2] then turning that into an SCIP index using scip-java[1]. This SCIP index is then consumed just like the SCIP index that rust-analyzer produces for Rust code.
[1] https://github.com/sourcegraph/scip-java
[2] https://github.com/sourcegraph/scip-kotlin

The next step is to add support for the autogenerated JNI bindings so one may easily jump to/from Java code from/to C++ code.

Cheers,
--
Nicolas Guichard | nicolas....@kdab.com | Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts
Reply all
Reply to author
Forward
0 new messages