Google has launched Code Search for several of its popular open-source projects, giving the wider software community what until now has been one of Google's most popular internal tools for developers.
Code Search or 'CS' for open-source Google projects for now supports Angular, Bazel, Dart, ExoPlayer, Firebase SDK, Flutter, Go, gVisor, Kythe, Nomulus, Outline, and Tensorflow – which represent a small portion of Google's open-source projects, but ones that open-source communities may benefit from search being available on their respective repositories.
According to Hildrum, Google engineers use Code Search daily to understand the codebase, for example, to search for half-remembered functions, figure out what calls the function they're looking at, and to spot when a line of code has been changed. There's also a 'blame' button that highlights which user last changed each line of code.
When users type a term, the search box offers suggestions on the fly with the type of code object, the repository, and the path. Users who want to, for example, search for a function 'foo' in a Google file can specify 'lang:go function:foo' to avoid searching files where foo is just a comment. Other filters include case sensitive, class name, content, file, and symbol.
Some open-source repositories have cross-references enabled by Kythe, Google's open-source tool for creating developer tools. Projects with cross-references include Bazel, Go, gVisor, Kyth, Nomulus, and Tensorflow.
"Open-source communities use a broader set of build systems than Google. To support cross-references, Kythe added drop-in support for Bazel, CMake, Maven, and Go," noted Hildrum.
"Projects using other build systems can use Kythe-provided wrappers for clang and javac to instrument their builds; these are used by Chromium and Android AOSP to provide compilation information for Kythe."