Skip to content

Development

Caibin Chen edited this page Oct 7, 2017 · 4 revisions

Prerequisite

You need to install the following tools for building JavaComp from source code:

Build the jar

To build the jar, cd to the directory of the source code, then build it with the bazel build command:

bazel build //src/main/java/org/javacomp/server:JavaComp_deploy.jar

The jar file is available at bazel-bin/src/main/java/org/javacomp/server/JavaComp_deploy.jar

Run tests

To run all tests, use the bazel test command:

bazel test ... -k

The -k option allows skipping failed tests.

Code style

JavaComp follows Google Java Style.

Use the Google Java format tool to format the Java code. The fix-format.sh script can help formatting all changed .java files.

Tools

Several tools are available for helping development.

fix-format.sh

This script can fix the code styles for .java files and BUILD files. It requires the following tools:

To run it, cd to the repository root directory and run

script/fix-format.sh -f -c

Option -f tells the script to change the files for fixing the style issues. -c means only check the files that are changed but not committed yet.

AstPrinter

AstPrinter prints the JCCompilationUnit of a .java file parsed by javac parser. It's useful for debugging and developing FileContentFixer.

To run it, make sure your current directory is in the repository and run:

bazel run //src/main/java/org/javacomp/tool:AstPrinter -- [-f] <java-filename>

<java-filename> is the filename of the .java file. If option -f is present, the content of the .java file will be modified by FileContentFixer before parsing.

ScopePrinter

ScopePrinter prints the internal representation of a parsed .java file. It's useful for debugging completion or parsing bugs.

To run it, make sure your current directory is in the repository and run:

bazel run //src/main/java/org/javacomp/tool:ScopePrinter -- [-f] <java-filename>

<java-filename> is the filename of the .java file. If option -f is present, the content of the .java file will be modified by FileContentFixer before parsing.