diff --git a/README.md b/README.md index cc31230..a3074e2 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,100 @@ -# vscode-liquidjava +# LiquidJava VS Code Extension -The vscode extension to validate java programs with refinement types. +The **LiquidJava VS Code extension** adds support for **refinement types**, extending the Java standard type system directly inside VS Code, using the [LiquidJava](https://github.com/CatarinaGamboa/liquidjava) verifier. It provides error diagnostics and syntax highlighting for refinements. -### Install extension on Visual Studio Code -1. Open the client folder in terminal -2. `code --install-extension liquid-java-0.0.1.vsix` -3. Open Visual Studio Code and open a Java project (with src folder inside). If the project contains the `liquidjava-api.jar` then the extension will be activated, otherwise the LiquidJava verification is not applied. +## Getting Started -The `liquidjava-api.jar` can be found in this project in the path`vscode-liquidjava\server\lib` +### GitHub Codespaces +To try out the extension on an example project without setting up your local environment: +1. Log in to GitHub +2. Click the button below +3. Select the `4-core` option +4. Press `Create codespace` + +The codespace will open in your browser and automatically install the LiquidJava extension shortly. + + [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/CatarinaGamboa/liquidjava-examples) + +### Local Setup + +To set up the extension locally, install the [LiquidJava Extension](https://marketplace.visualstudio.com/items?itemName=AlcidesFonseca.liquid-java) from the VS Code Marketplace and add the `liquidjava-api` dependency to your Java project. + +#### Maven +```xml + + io.github.rcosta358 + liquidjava-api + 0.0.2 + +``` + +#### Gradle +```groovy +repositories { + mavenCentral() +} + +dependencies { + implementation 'io.github.rcosta358:liquidjava-api:0.0.2' +} +``` + +## Development ### Developer Mode -1. Run **Client on Visual Studio Code**: -* Open the client folder on terminal -* `npm install` -* Open client folder on Visual Studio Code. -* Make sure you have the redhat extension for [Language support for Java ™](https://github.com/redhat-developer/vscode-java) installed and enabled. -* The code in `extension.ts` must be the same as the code in `extension_test.ts` -* Go to `Run-> Run Extension` (or press `F5`). A new window appears with the liquidjava extension enabled. -* Open a Java project. If the project contains the `liquid-java-api.jar` then the liquidjava verification will start in a few seconds. + +To run the extension in developer mode, which automatically spawns the server in a separate process: + +1. Open the `client` folder in VS Code +2. Run `npm install` +3. Make sure you have the Red Hat extension for [Language Support for Java™](https://github.com/redhat-developer/vscode-java) installed and enabled +4. Go to `Run` > `Run Extension` (or press `F5`) +5. A new VS Code instance will start with the LiquidJava extension enabled +6. Open a Java project containing the `liquid-java-api.jar` in the `lib` folder ### Debugging Mode -Server and Client connect through sockets and run in different environments that allow a better debugging -1. Run **Server** on **Eclipse**: -* Open Eclipse. -* Import the Maven project that is in the server folder. -* Run `App.java` with a port as argument. - -2. Run **Client** on **Visual Studio Code**: -* Open client folder on VSCode -* Copy all the code on file `extension-network.ts` to `extension.ts`. -* Go to Run-> Run Extension (or press F5). A new vscode appears to use the extension. - -#### Create Server Jar -When the server is ready to be exported, export the jar. In Eclipse follow the steps: -1. Inside eclipse make `File > Export > Runnable JAR file`. -2. In lauch configuration choose `main - vscode-liquid-java-server`. -3. In the output path choose the `client/server` folder of this extension. It should look like: `$USER$\vscode-liquidjava\client\server\language-server-liquidjava.jar` -4. The name of the jar must be `language-server-liquidjava.jar` for the client to be able to call it on Developer Mode. - -### Project -**Server** - implements an [LSP](https://microsoft.github.io/language-server-protocol/) in Java for the LiquidJava language, using the library [LSP4J](https://github.com/eclipse/lsp4j). - -**Client** - implements the vscode client for the LiquidJava Server. -The client depends on [Language support for Java ™ for Visual Studio Code](https://github.com/redhat-developer/vscode-java) to enable all the Java errors outside the scope of LiquidJava. + +To run the extension in debugging mode by manually starting the server and connecting the client to it: + +* Run the server: + - Open the `server` folder in your IDE + - Run `App.java`, which will start the server on port `50000` + - View the server logs in the console + +* Run the client: + - Open the `client` folder in VS Code + - Set the `DEBUG` variable to `true` in [`client/src/extension.ts`](./client/src/extension.ts) + - Go to `Run` > `Run Extension` (or press `F5`) + - 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.jar` in the `lib` folder + - View the client logs in the `LiquidJava` output channel or by clicking the status indicator + +### Create Server JAR + +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 `server` folder + - Select `File > Export > Runnable JAR file` + - In the launch configuration, choose `main - vscode-liquid-java-server` + - In the output path, choose the `/client/server` folder of this extension +- In **VS Code**: + - Open the `server` folder + - Use the Export Jar feature (`Ctrl+Shift+P` > `Java: Export Jar`) + - Select `App` as the main class + - Select `OK` + - Copy the generated JAR from the root directory to the `/client/server` folder +- In **IntelliJ**: + - Open the `server` folder + - Go to `File` > `Project Structure` > `Artifacts` + - Select `Add a new Jar` > `From modules with dependencies` + - Select `App` as the main class + - Build the artifact via `Build` > `Build Artifacts` > `Build` + - Copy the generated JAR from the `out/artifacts` folder to the `/client/server` folder + +### Project Structure +- `/server` - Implements the [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) in Java using the [LSP4J](https://github.com/eclipse/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™](https://github.com/redhat-developer/vscode-java) for regular Java errors +- `/lib` - Contains the `liquidjava-api.jar` required for the extension to be activated in a Java project \ No newline at end of file diff --git a/client/liquid-java-0.0.14.vsix b/client/liquid-java-0.0.14.vsix deleted file mode 100644 index 508bc81..0000000 --- a/client/liquid-java-0.0.14.vsix +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2d49572c9ff0f184694d8d0b1b95b05b3cd3566844906ac365359c7dcabfaded -size 65202517 diff --git a/client/liquid-java-0.0.15.vsix b/client/liquid-java-0.0.15.vsix index 86f2399..20c262b 100644 --- a/client/liquid-java-0.0.15.vsix +++ b/client/liquid-java-0.0.15.vsix @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78fd4ada11415d47090ac672b78b4a20450e50f361f59e412912858eb2e70faa -size 209281657 +oid sha256:c99792c43e9fdc8d6223e26464b86bbac339f7f34830ad2510b5c26cfd6e95b5 +size 72270316 diff --git a/client/src/extension.ts b/client/src/extension.ts index ef215a3..e818fde 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -9,7 +9,7 @@ import { LiquidJavaLogger, createLogger } from "./logging"; import { applyItalicOverlay } from "./decorators"; const SERVER_JAR_FILENAME = "language-server-liquidjava.jar"; -const API_JAR_GLOB = "**/liquidjava-api*.jar"; +const API_JAR_GLOB= "lib/liquidjava-api*.jar"; const DEBUG = false; const DEBUG_PORT = 50000; @@ -73,7 +73,7 @@ export async function deactivate() { * @returns true if the extension can be activated, false otherwise */ async function isJarPresent(): Promise { - const uris = await vscode.workspace.findFiles(API_JAR_GLOB, null, 100); + const uris = await vscode.workspace.findFiles(API_JAR_GLOB); return uris.length > 0; } diff --git a/client/update.sh b/client/update.sh new file mode 100644 index 0000000..1845cd3 --- /dev/null +++ b/client/update.sh @@ -0,0 +1,4 @@ +#!/bin/bash +version="0.0.15" +vsce package +code --install-extension liquid-java-$version.vsix \ No newline at end of file diff --git a/install.bat b/install.bat new file mode 100644 index 0000000..4dc0303 --- /dev/null +++ b/install.bat @@ -0,0 +1,55 @@ +@echo off +setlocal enabledelayedexpansion + +set "version=0.0.15" + +:: Check if extension is already installed +code --list-extensions 2>nul | findstr "liquid-java" >nul 2>&1 +if %errorlevel% equ 0 ( + echo ✅ LiquidJava extension already installed! + exit /b 0 +) + +:: Setup script for LiquidJava development environment +echo 🚀 Starting LiquidJava development environment setup... + +:: Check if Git LFS is installed +git lfs version >nul 2>&1 +if %errorlevel% neq 0 ( + echo 📦 Git LFS not found. Please install Git LFS manually from https://git-lfs.github.io/ + echo After installing Git LFS, run: git lfs install + pause + exit /b 1 +) else ( + echo ✅ Git LFS already installed +) + +:: Pull LFS files +echo 🔄 Pulling Git LFS files... +git lfs pull + +:: Check if the VSIX file exists and is valid +set "vsix_path=.\client\extension\liquid-java-%version%.vsix" +if exist "%vsix_path%" ( + echo 🔍 VSIX file found, checking integrity... + for %%A in ("%vsix_path%") do set "file_size=%%~zA" + if !file_size! lss 1000 ( + echo ❌ VSIX file appears to be an LFS pointer file ^(too small^) + ) else ( + echo ✅ VSIX file appears to be valid ^(!file_size! bytes^) + ) +) else ( + echo ❌ VSIX file not found at %vsix_path% +) + +:: Install extension +echo 🔧 Installing LiquidJava VSCode extension... +code --install-extension "%vsix_path%" +if %errorlevel% equ 0 ( + echo ✅ Extension installed successfully +) else ( + echo ❌ Failed to install the extension +) + +echo 🎉 Installation complete! +pause \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..536cb1b --- /dev/null +++ b/install.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +version="0.0.15" + +# Check if extension is already installed +if code --list-extensions | grep -q "liquid-java" 2>/dev/null; then + echo "✅ LiquidJava extension already installed!" + exit 0 +fi + +# Setup script for LiquidJava development environment +echo "🚀 Starting LiquidJava development environment setup..." + +# Install Git LFS if not already installed +if ! command -v git-lfs &> /dev/null; then + echo "📦 Installing Git LFS..." + sudo apt-get update && sudo apt-get install -y git-lfs + git lfs install +else + echo "✅ Git LFS already installed" +fi + +# Pull LFS files +echo "🔄 Pulling Git LFS files..." +git lfs pull + +# Check if the VSIX file exists and is valid +if [ -f "./client/extension/liquid-java-$version.vsix" ]; then + echo "🔍 VSIX file found, checking integrity..." + file_size=$(stat -c%s "./client/extension/liquid-java-$version.vsix") + if [ "$file_size" -lt 1000 ]; then + echo "❌ VSIX file appears to be an LFS pointer file (too small)" + else + echo "✅ VSIX file appears to be valid ($file_size bytes)" + fi +else + echo "❌ VSIX file not found at ./extension/liquid-java-$version.vsix" +fi + +# Install extension +echo "🔧 Installing LiquidJava VSCode extension..." +code --install-extension ./client/extension/liquid-java-$version.vsix +if [ $? -eq 0 ]; then + echo "✅ Extension installed successfully" +else + echo "❌ Failed to install the extension" +fi + +echo "🎉 Installation complete!" \ No newline at end of file