This project is an extension for VS Code to provide the features of the Checker Framework, via the Checker Framework Language Server.
You can either install the extension from the VS Code Extension Marketplace or install a locally-built version of the extension. Please refer to the Build from source section below for instructions on how to build from source.
After installing the extension, when you open or save any .java
file it will be checked
by the Checker Framework Nullness Checker.
Other type systems and options can be enabled in the configuration.
The first time the extension is run, two dependencies will be downloaded: the latest version of the Checker Framework (eisop/checker-framework) and the Checker Framework Language Server.
A JDK is required, i.e. JAVA_HOME
needs to be properly set. JDK versions 8, 9, and 11 are supported. Node.js and npm are also required.
The following configuration parameters are available:
The list of checkers that are used to check source files. Shorthand names and full names are both supported. The list of all checkers can be found in the Checker Framework manual.
"checker-framework.checkers": [
"interning",
"org.checkerframework.checker.nullness.NullnessChecker"
]
The list of command-line options that are passed to the Checker Framework. This can include options to javac. See the list of standard Checker Framework options. In addition, a list of options that can change the behaviors of this plugin is included in LSP-related Command-Line Options.
Sample setting:
"checker-framework.commandLineOptions": [
"-proc:only"
]
The path to the root folder of the Checker Framework to use. The directory should follow the layout of an unzipped Checker Framework release zip file. By default, this extension will set this up for you.
Sample setting:
"checker-framework.frameworkPath": "/Users/joe/env/checker-framework-3.0.0"
The path of the jar file of the Checker Frameowrk Language Server. This will usually be set up automatically.
Sample setting:
"checker-framework.languageServerPath": "/Users/bob/env/checker-framework-languageserver-all.jar"
This specifies from which Github organization to download the Checker Framework release.
The default is eisop
.
Sample setting:
"checker-framework.checkerframework_org": "eisop"
This specifies from which Github repository under checkerframework_org
to download the Checker Framework.
The default is checker-framework
.
Combined with checkerframework_org
, the default Checker Framework is eisop/checker-framework
.
Sample setting:
"checker-framework.checkerframework_repo": "checker-framework"
This specifies from which Github organization to download the Checker Framework Language Server.
The default is eisopux
.
Sample setting:
"checker-framework.languageserver_org": "eisopux"
This specifies from which Github repository under languageserver_org
to download the Checker Framework Language Server.
The default is checker-framework-languageserver
.
Combined with languageserver_org
, the default language server is eisopux/checker-framework-languageserver
.
Sample setting:
"checker-framework.languageserver_repo": "checker-framework-languageserver"
This section provides a list of the Checker Framework command-line options that are related to the features of this LSP
plugin. You can turn on/off an option by adding/removing the corresponding flag in
commandLineOptions
.
-AlspTypeInfo
: Once enabled, the plugin will display a pop-up showing the related type information when hovering on some meaningful syntax in the source file. This option is enabled by default.
- Install the newest Node.js version for your operating system (OS); see the Node.Js homepage.
- Install a Git client for your OS; see the Git homepage.
- Create a working directory for the project and change into it.
- Clone the project in the new directory
git clone https://github.com/eisopux/checker-framework-vscode.git
. - Change into the cloned directory
cd checker-framework-vscode
. - Install dependencies using
npm install
, as superuser. (UseOpen command prompt (CMD) (admin)
on Windows.) See the npm Docs. - Run
npm run vsce
to generate a.vsix
file. - Run
code --install-extension checker-framework-language-server-0.2.0.vsix
; replace the-0.2.0
with the current version number. - Under
View -> Extensions
in VS Code check that the 'checker-framework-language-server' is installed.
During development, you can simply start the program from the command line and run as a new VS Code instance:
- Follow the Building from source instructions.
- Open up this project (
checker-framework-vscode
) in VS Code and start a new instance by clicking onRun
in the menu bar, thenStart Debugging
. - Open a
.java
file (this can be a simple Hello World example) in the[Extension Development Host]
instance of VSCode.
- Change back into your project working directory.
- Clone the downloader in the project directory
git clone https://github.com/eisopux/checker-framework-languageserver-downloader.git
- Change into the downloader folder and run
./gradlew assemble
. See file[README.md](https://github.com/eisopux/checker-framework-languageserver-downloader/blob/master/README.md)
for more details. - Copy
build/libs/checker-framework-languageserver-downloader-all.jar
to the plugin’s folder and rename it to replace the filechecker-framework-languageserver-downloader.jar
You can use a local language server or Checker Framework. Update the appropriate field in .vscode/settings.json
with your custom path, like in the following example:
{
"checker-framework.frameworkPath": "/path/to/custom/framework",
"checker-framework.languageServerPath": "/path/to/custom/languageserver.jar"
}
Save the file and restart Visual Studio Code.
To get log information use Toggle Developer Tools
in the Command Palette
in Visual Studio Code.
This project is licensed under the MIT License - see the LICENSE file for details
This project is inspired and helped by the following projects: