The LiquidJava VS Code extension adds support for refinement types, extending the Java standard type system directly inside VS Code, using the LiquidJava verifier. It provides error diagnostics and syntax highlighting for refinements.
To try out the extension on an example project without setting up your local environment:
- Log in to GitHub
- Click the button below
- Select the
4-coreoption - Press
Create codespace
The codespace will open in your browser and automatically install the LiquidJava extension shortly.
To set up the extension locally, install the LiquidJava extension in the VS Code Marketplace or the Open VSX Marketplace and add the liquidjava-api dependency to your Java project.
<dependency>
<groupId>io.github.liquid-java</groupId>
<artifactId>liquidjava-api</artifactId>
<version>0.0.2</version>
</dependency>repositories {
mavenCentral()
}
dependencies {
implementation 'io.github.liquid-java:liquidjava-api:0.0.2'
}To run the extension in developer mode, which automatically spawns the server in a separate process:
- Open the
clientfolder in VS Code - Run
npm install - Make sure you have the Red Hat extension for Language Support for Java™ installed and enabled
- Go to
Run>Run Extension(or pressF5) - A new VS Code instance will start with the LiquidJava extension enabled
- Open a Java project containing the
liquid-java-api.jarin thelibfolder
To run the extension in debugging mode by manually starting the server and connecting the client to it:
-
Run the server:
- Open the
serverfolder in your IDE - Run
App.java, which will start the server on port50000 - View the server logs in the console
- Open the
-
Run the client:
- Open the
clientfolder in VS Code - Set the
DEBUGvariable totrueinclient/src/extension.ts - Go to
Run>Run Extension(or pressF5) - A new VS Code instance will open with the LiquidJava extension enabled, which will connect to the server on port
50000 - Open a Java project containing the
liquid-java-api.jarin thelibfolder - View the client logs in the
LiquidJavaoutput channel or by clicking the status indicator
- Open the
To build the language server, export it as a runnable JAR file named language-server-liquidjava.jar and place it in /client/server.
- In Eclipse:
- Open the
serverfolder - Select
File > Export > Runnable JAR file - In the launch configuration, choose
main - vscode-liquid-java-server - In the output path, choose the
/client/serverfolder of this extension
- Open the
- In VS Code:
- Open the
serverfolder - Use the Export Jar feature (
Ctrl+Shift+P>Java: Export Jar) - Select
Appas the main class - Select
OK - Copy the generated JAR from the root directory to the
/client/serverfolder
- Open the
- In IntelliJ:
- Open the
serverfolder - Go to
File>Project Structure>Artifacts - Select
Add a new Jar>From modules with dependencies - Select
Appas the main class - Build the artifact via
Build>Build Artifacts>Build - Copy the generated JAR from the
out/artifactsfolder to the/client/serverfolder
- Open the
/server- Implements the Language Server Protocol (LSP) in Java using the LSP4J library/client- Implements the VS Code extension in TypeScript that connects to the language server using LSP- It depends on Language Support for Java™ for regular Java errors
/lib- Contains theliquidjava-api.jarrequired for the extension to be activated in a Java project