Search Indexed Source

org.jmonde.sis

org.jmonde.sis searches an indexed source tree and can:

Creating the index

The names of the files to be indexed are read from standard input. Directory names can also be given and the entire contents of each directory will be indexed.

A shell script (etc/mksis) is provided to invoke the index creation jar:

  #!/bin/sh
  java -jar <path-to>/org.jmonde.sis.index-6.0.jar "$@"

Type mksis -help for a brief description of the options.

Use mksis something like...

  % cd ~/Java/src
  % ls | mksis -m 2

Index creation can take a long time and should be scheduled to automatically run every day during off hours.

Find all occurrences of an identifier

The distribution includes a shell script (etc/sis) that invokes the index search jar:

  #!/bin/sh
  java -jar <path-to>/org.jmonde.sis.search-6.0.jar "$@"

Type sis -help for a brief description of the options.

sis takes the identifier to search for (the identifier is treated as a literal text string, not a regular expression). The output is similar to that produced by grep -n.

For example, to find all references to BufferedOutputStream in the Java libraries:

  % sis BufferedOutputStream
  /home/mike/Java/src/java/io/OutputStream.java:33: * @see     java.io.BufferedOutputStream
  /home/mike/Java/src/java/io/BufferedOutputStream.java:14: * @(#)BufferedOutputStream.java	1.34 05/11/17
  /home/mike/Java/src/java/io/BufferedOutputStream.java:33:class BufferedOutputStream extends FilterOutputStream {
  /home/mike/Java/src/java/io/BufferedOutputStream.java:53:    public BufferedOutputStream(OutputStream out) {
  /home/mike/Java/src/java/io/BufferedOutputStream.java:66:    public BufferedOutputStream(OutputStream out, int size) {
  /home/mike/Java/src/java/io/BufferedOutputStream.java:104:     * BufferedOutputStreams will not copy data unnecessarily.
  /home/mike/Java/src/java/io/FileDescriptor.java:129:     * example, by a BufferedOutputStream object), those buffers must
  /home/mike/Java/src/java/net/SocksSocketImpl.java:23:import java.io.BufferedOutputStream;
  /home/mike/Java/src/java/net/SocksSocketImpl.java:109:				 BufferedOutputStream out) throws IOException {
  /home/mike/Java/src/java/net/SocksSocketImpl.java:422:	BufferedOutputStream out = new BufferedOutputStream(cmdOut, 512);
  /home/mike/Java/src/java/net/SocksSocketImpl.java:744:	BufferedOutputStream out = new BufferedOutputStream(cmdOut, 512);
  /home/mike/Java/src/java/util/logging/SocketHandler.java:20:import java.io.BufferedOutputStream;
  /home/mike/Java/src/java/util/logging/SocketHandler.java:140:        super.internalSetOutputStream(new BufferedOutputStream(this.socket
  /home/mike/Java/src/java/util/logging/FileHandler.java:20:import java.io.BufferedOutputStream;
  /home/mike/Java/src/java/util/logging/FileHandler.java:226:        output = new MeasureOutputStream(new BufferedOutputStream(
  /home/mike/Java/src/java/util/logging/FileHandler.java:262:            output = new MeasureOutputStream(new BufferedOutputStream(
  /home/mike/Java/src/java/util/jar/JarOutputStream.java:65:	man.write(new BufferedOutputStream(this));
  /home/mike/Java/src/java/lang/UNIXProcess.java:148:                            stdin_stream = new BufferedOutputStream(new
  /home/mike/Java/src/java/lang/System.java:105:		err = com.ibm.jvm.io.ConsolePrintStream.localize(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err)), true);
  /home/mike/Java/src/java/lang/System.java:106:		out = com.ibm.jvm.io.ConsolePrintStream.localize(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out)), true);
  /home/mike/Java/src/javax/xml/bind/helpers/AbstractMarshallerImpl.java:35:import java.io.BufferedOutputStream;
  /home/mike/Java/src/javax/xml/bind/helpers/AbstractMarshallerImpl.java:93:            OutputStream os = new BufferedOutputStream(new FileOutputStream(output));
  % 

Find a file by name

The -sf option is used to print all file names that match a regular expression.

  % sis -sf MouseEvent
  /home/mike/Java/src/java/awt/event/MouseEvent.java
  /home/mike/Java/src/javax/swing/event/MenuDragMouseEvent.java
  % sis -i -sf ellipse
  /home/mike/Java/src/java/awt/geom/Ellipse2D.java
  /home/mike/Java/src/java/awt/geom/EllipseIterator.java
  % 

Matching a token

The -st option is used to print all tokens that match a regular expression.

  % sis -st -i ellipse
  ellipseBounds
  ellipse
  EllipseIterator
  Ellipse2D
  %

Emacs integration

The distribution includes etc/sis.el which integrates org.jmonde.sis with Emacs. The shell script sis is required to be in the path.

The Emacs function sis prompts for an identifier, invokes the sis shell script, and displays the search results in a grep-like buffer. next-error (C-x `) can then be used to walk through the hits.

The function sis-find-file prompts for a file name, invokes the sis shell script to find the file, and then displays the file in a buffer.

Put sis.el in your load-path, byte compile it, and configure it to your liking...
  (autoload 'sis "sis" "sis" t)
  (autoload 'sis-find-file "sis" "sis-find-file" t)
  (define-key global-map [f6] 'sis)
  (define-key global-map [f8] 'sis-find-file)

Try it out

The source is available under the GNU General Public License.
Download

% jar xf org.jmonde.sis-6.0.jar
% cd org.jmonde.sis-6.0
% ant -q

BUILD SUCCESSFUL
Total time: 13 seconds
/* !! Modify etc/mksis and etc/sis to point to the build directory !! */
% chmod +x etc/mksis etc/sis
% ls | etc/mksis -xf '\.jar$' -xf '\.class$' -xf doc
% etc/sis TokenizerRegex
/home/mike/src/org.jmonde.sis-6.0/src/TokenizerJavaSimple.java:43:    private final Tokenizer myDelegate = new TokenizerRegex(ourPattern);
/home/mike/src/org.jmonde.sis-6.0/src/TokenizerRegex.java:2:  TokenizerRegex.java
/home/mike/src/org.jmonde.sis-6.0/src/TokenizerRegex.java:27:public class TokenizerRegex implements Tokenizer {
/home/mike/src/org.jmonde.sis-6.0/src/TokenizerRegex.java:34:    public TokenizerRegex(Pattern pattern) {
/home/mike/src/org.jmonde.sis-6.0/test/TokenizerRegexTest.java:24:import org.jmonde.sis.TokenizerRegex;
/home/mike/src/org.jmonde.sis-6.0/test/TokenizerRegexTest.java:30:        return new TokenizerRegex(RegexUtil.compilePattern(p, false));
% etc/sis -sf TokenizerRegex
/home/mike/src/org.jmonde.sis-6.0/output/src/org/jmonde/sis/TokenizerRegex.class
/home/mike/src/org.jmonde.sis-6.0/output/test/TokenizerRegexTest.class
/home/mike/src/org.jmonde.sis-6.0/src/TokenizerRegex.java
/home/mike/src/org.jmonde.sis-6.0/test/TokenizerRegexTest.java
% etc/sis -st TokenizerRegex
TokenizerRegexTest
makeTokenizerRegexp
TokenizerRegex
% 

Release 6.0 Notes

Bugs

org.jmonde.sis was written for ASCII files. The results will be disappointing when used on non-ASCII files.

See Also

GNU ID Utils

Enjoy!

P.S.
This software is named in honor of Claydie May Phelps, known to us kids as Aunt Sis.