Skip to content

kothavade/CodeSense

Repository files navigation

Important

There is a Next.js/React rewrite in progress, in the rewrite branch.

You can access the current version of this rewrite at codesense.kothavade.com

👨‍💻🔍 CodeSense

A hoogle.haskell.org inspired code search engine that works with any typed language (only support C and Rust for now, more to come).

Live demo available at codesense-v1.kothavade.com!

Usage

Upload a .c, .h or .rs file, paste a link to raw source code (eg. a raw.githubusercontent.com link), or select one of the examples provided.

Then, search for a function by name, or by parameter types and return type--for example, if you want to find this function from raylib.h:

Color ColorAlpha(Color color, float alpha);

you can search for it by name: colora, or by type: Color, float -> Color.

Searching is flexible--both Color, float -> and -> Color are valid searches, for example.

Develop

Using Nix

$ nix develop # or `direnv allow`, if you prefer
$ pnpm dev

Other Package Managers

First, install the dependencies:

Then, set the node and WASM dependencies:

$ ./build-wasm.sh # Builds language-specific WASM binaries
$ pnpm i
$ pnpm wasm # Links main tree-sitter WASM binary from node_modules
$ pnpm dev

Technology

  • This application uses Tree-sitter, an incremental parsing library with support for almost every language1, compiled to WebAssembly to parse source code in-browser
    • Functions, parameters, and return types are found using custom written Tree-sitter queries2, found in /queries
  • The UI is build with SolidJS3 with Vite as the build tool/bundler and PicoCSS for styling

Footnotes

  1. https://tree-sitter.github.io/tree-sitter/#parsers

  2. https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax

  3. basically fast react