Code Monkey home page Code Monkey logo

sourcecodex's Introduction

SourceCodex

A very simple platform for searching calls/callers (and terms) in code projects

Features

  • Searches for callers/callees and patterns
  • Fast enough to use for incremental completion
  • Simple to use (command line tool)
  • Simple design (only two source files: a shell script and a CoffeeScript program)
  • Supports JavaScript and CoffeeScript
  • Easy to extend for additional languages
  • Zero admin (command line option to monitor project changes means no service needed)
  • Small number of dependencies (POSIX/cygwin, node.js, and several node.js projects)

USAGE

sourcecodex [ -h | -i PATTERN | -s PATTERN | -p PATTERN | -l LIM OFF | -t PATTERN | -v | -q | -n | -d | -r | -u | -m | -c | -j | --callers F | --calls F | --defs ] [DIR]
DIR is the directory containing the files to index.
If DIR is given, a new ".sourcecodex" database is created
in DIR if it does not exist
OPTIONS:
  -h            Print this message
  -i PATTERN    Ignore files matching pattern
  -s PATTERN    Search for token pattern in files and return matched lines in grep format
  -p PATTERN    Search for prefix token pattern in files and return matched lines in grep format
  -l LIM OFF    Limit the number of search results to LIM and discard the first OFF
  -t PATTERN    Find all tokens matching pattern
  -v            Inccrease verbosity
  -q            Turn off progress notifications
  -n            Notify of changes (implies -q): 'DELETE'|'CREATE'|'MODIFY' FILE
  -d            Delete the .sourcecodex database
  -r            Delete and rebuild database
  -u            Update and then exit
  -m            Update and continue monitoring for changes
  -c            Index CoffeeScript callers and callees
  -j            Index JavaScript callers and callees
  --callers F   List call sites of F: FILE:LINE:COL:FUNC:CONTENTS
  --calls F     List F's call sites: FILE:LINE:COL:FUNC:CONTENTS
  --defs        List defs: FILE:LINE:COL:FUNC:CONTENTS

Architecture

  • built on SQLite
    • allows background updating
    • other programs can access/change the database
  • extensible
    • update/monitor command can output events like inotifywatch (CREATE/MODIFY/DELETE file)
    • other programs can query/change the database

Schema

There are 5 main tables: files, lines, lines_terms, defs, and calls.

create table files (path primary key, stamp);
create virtual table lines using fts4 (path, line_number, line);
create virtual table lines_terms using fts4aux(lines);
create table defs(file, code, line_number, col);
create table calls(file, code, call, line_number, col);

Files tracks the indexed files.

Lines stores all of the lines of the tracked files and maintains a full-text index.

Lines_terms lets you access the internals of the index like the terms (tokens).

Defs tracks the definitions in the files.

Calls tracks the calls to the definitions in the files.

Todo

  • index referenced variables
    • add column to defs and calls to specify type of def or call (func or var)
  • support full regexp search
    • maybe just narrow down the lines with a pattern and then pump them through grep
    • maybe based on Russ Cox’s work
  • remove POSIX deps (add bat file for search command)

References

sourcecodex's People

Contributors

zot avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.