Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Latte Extension Dev",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"image": "mcr.microsoft.com/devcontainers/javascript-node:22",
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -16,4 +16,3 @@
},
"postCreateCommand": "npm install"
}

2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 20
java-version: 21
distribution: temurin

- name: Setup Node.js
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ permissions:
jobs:
checks:
name: Checks
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest

defaults:
Expand Down Expand Up @@ -66,9 +65,13 @@ jobs:
grep -Fx 'extension/media/webview.js' /tmp/liquid-java-vsix-files.txt

integration:
name: VS Code integration
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
name: VS Code integration (${{ matrix.version }})
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ${{ (github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && fromJSON('["stable", "minimum"]') || fromJSON('["stable"]') }}

defaults:
run:
Expand Down Expand Up @@ -98,15 +101,16 @@ jobs:
- name: Build server
run: npm run build:server

- name: Run VS Code stable smoke test
- name: Run VS Code fixture tests
env:
JAVA_HOME: ${{ steps.java.outputs.path }}
VSCODE_TEST_VERSION: ${{ matrix.version }}
run: xvfb-run -a npm test

- name: Upload VS Code logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: vscode-logs
name: vscode-logs-${{ matrix.version }}
path: client/.vscode-test/user-data/logs
if-no-files-found: ignore
18 changes: 13 additions & 5 deletions client/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { readFileSync } from 'node:fs';
import { defineConfig } from '@vscode/test-cli';
import { minVersion } from 'semver';

export default defineConfig({
files: 'out/test/**/*.test.js',
version: 'stable',
workspaceFolder: 'test-fixtures/failing',
const { engines } = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
const version = process.env.VSCODE_TEST_VERSION === 'minimum'
? minVersion(engines.vscode).version
: 'stable';

export default defineConfig(['failing', 'passing'].map(fixture => ({
label: fixture,
files: fixture === 'failing' ? 'out/test/**/*.test.js' : 'out/test/smoke.test.js',
version,
workspaceFolder: `test-fixtures/${fixture}`,
extensionDevelopmentPath: '.',
launchArgs: ['--disable-extensions', '--disable-workspace-trust'],
mocha: { ui: 'tdd', timeout: 120_000 },
});
})));
16 changes: 9 additions & 7 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"homepage": "https://liquid-java.github.io",
"engines": {
"node": ">=22",
"vscode": "^1.82.0"
},
"languages": [
Expand Down Expand Up @@ -168,13 +169,14 @@
"@eslint/js": "^9.39.0",
"@types/mocha": "^10.0.10",
"@types/node": "^24.7.2",
"@types/vscode": "^1.82.0",
"@types/vscode": "~1.82.0",
"@vscode/test-cli": "^0.0.15",
"@vscode/test-electron": "^3.1.0",
"@vscode/vsce": "^3.0.0",
"eslint": "^9.39.0",
"jsonc-parser": "^0.4.2",
"minimist": "^1.2.7",
"semver": "^7.7.4",
"ts-loader": "^9.5.4",
"typescript": "~5.3.0",
"typescript-eslint": "^8.0.0",
Expand Down
3 changes: 2 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { LiquidJavaTestApi } from "./types/test-api";
* @param context The extension context
*/
export async function activate(context: vscode.ExtensionContext): Promise<LiquidJavaTestApi> {
context.subscriptions.push(extension.diagnosticsEmitter);
context.subscriptions.push(extension.diagnosticsEmitter, extension.failureEmitter);
registerLogger(context);
extension.logger!.client.info("Activating LiquidJava extension...");

Expand All @@ -42,6 +42,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<Liquid
return {
ready,
onDiagnostics: extension.diagnosticsEmitter.event,
onFailure: extension.failureEmitter.event,
getState: () => ({
status: extension.status,
diagnostics: [...(extension.diagnostics ?? [])],
Expand Down
1 change: 1 addition & 0 deletions client/src/services/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function handleLJFailure() {
if (extension.context)
extension.webview?.sendMessage({ type: "context", context: extension.context, errorAtCursor: extension.errorAtCursor });
updateStatusBar("crashed");
extension.failureEmitter.fire();
}

/**
Expand Down
1 change: 1 addition & 0 deletions client/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class ExtensionState {
file?: string;
diagnostics?: LJDiagnostic[];
readonly diagnosticsEmitter = new vscode.EventEmitter<LJDiagnostic[]>();
readonly failureEmitter = new vscode.EventEmitter<void>();
stateMachine?: LJStateMachine | null;
context?: LJContext;
currentSelection?: Range;
Expand Down
45 changes: 29 additions & 16 deletions client/src/test/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { LJDiagnostic } from '../types/diagnostics';
import type { LiquidJavaTestApi } from '../types/test-api';

suite('Bundled LiquidJava extension', () => {
test('activates, becomes ready, and verifies the failing fixture', async () => {
test('activates, becomes ready, and verifies its isolated fixture', async () => {
const installed = vscode.extensions.getExtension<LiquidJavaTestApi>('AlcidesFonseca.liquid-java');
assert.ok(installed, 'LiquidJava must be loaded in the Extension Host');
assert.equal(installed.packageJSON.main, './dist/extension.js');
Expand All @@ -16,17 +16,25 @@ suite('Bundled LiquidJava extension', () => {
assert.notEqual(api.getState().status, 'stopped');

const workspace = vscode.workspace.workspaceFolders?.[0];
assert.ok(workspace, 'the failing fixture must have its own workspace');
const uri = vscode.Uri.joinPath(workspace.uri, 'src/main/java/FailingRefinement.java');
assert.ok(workspace, 'the fixture must have its own workspace');
const passing = path.basename(workspace.uri.fsPath) === 'passing';
const file = passing ? 'PassingRefinement.java' : 'FailingRefinement.java';
const uri = vscode.Uri.joinPath(workspace.uri, `src/main/java/${file}`);
const subscriptions: vscode.Disposable[] = [];
const nextFixtureDiagnostics = () => new Promise<LJDiagnostic[]>((resolve) => {
const subscription = api.onDiagnostics((diagnostics) => {
if (diagnostics.some(d => d.type === 'refinement-error' && path.resolve(d.file) === uri.fsPath)) {
subscription.dispose();
resolve(diagnostics);
}
const nextFixtureDiagnostics = () => new Promise<LJDiagnostic[]>((resolve, reject) => {
const dispose = () => {
diagnosticsSubscription.dispose();
failureSubscription.dispose();
};
const diagnosticsSubscription = api.onDiagnostics((diagnostics) => {
dispose();
resolve(diagnostics);
});
subscriptions.push(subscription);
const failureSubscription = api.onFailure(() => {
dispose();
reject(new Error(`LiquidJava verifier crashed while checking ${file} (status: ${api.getState().status})`));
});
subscriptions.push(diagnosticsSubscription, failureSubscription);
});
try {
// settle automatic verification before testing the manual command
Expand All @@ -38,12 +46,17 @@ suite('Bundled LiquidJava extension', () => {
const manualDiagnostics = nextFixtureDiagnostics();
await vscode.commands.executeCommand('liquidjava.verify');
const diagnostics = await manualDiagnostics;
const error = diagnostics.find(d => d.type === 'refinement-error' && path.resolve(d.file) === uri.fsPath);
assert.ok(error);
assert.equal(error.category, 'error');
assert.equal(error.title, 'Refinement Error');
assert.ok(error.position, 'the diagnostic must identify the invalid assignment');
assert.equal(api.getState().status, 'failed');
if (passing) {
assert.deepEqual(diagnostics, [], 'correct code must emit an explicit empty result');
assert.equal(api.getState().status, 'passed');
} else {
const error = diagnostics.find(d => d.type === 'refinement-error' && vscode.Uri.file(path.resolve(d.file)).fsPath === uri.fsPath);
assert.ok(error, `expected a refinement error for ${file}; received ${JSON.stringify(diagnostics)}`);
assert.equal(error.category, 'error');
assert.equal(error.title, 'Refinement Error');
assert.ok(error.position, 'the diagnostic must identify the invalid assignment');
assert.equal(api.getState().status, 'failed');
}
assert.deepEqual(api.getState().diagnostics, diagnostics);
} finally {
subscriptions.forEach(subscription => subscription.dispose());
Expand Down
1 change: 1 addition & 0 deletions client/src/types/test-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface WebviewMessage {
export interface LiquidJavaTestApi {
readonly ready: Promise<void>;
readonly onDiagnostics: vscode.Event<LJDiagnostic[]>;
readonly onFailure: vscode.Event<void>;
getState(): { status: ExtensionStatus | undefined; diagnostics: LJDiagnostic[] };
readonly onWebviewMessage: vscode.Event<WebviewMessage>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import liquidjava.specification.Refinement;

public class PassingRefinement {
@Refinement("_ > 0")
int positive = 1;
}
7 changes: 1 addition & 6 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${pVersion.compiler}</version>
<configuration>
<source>20</source>
<target>20</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -102,8 +98,7 @@
<properties>
<lsp4j.version>0.24.0</lsp4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<maven.compiler.release>20</maven.compiler.release>
<!-- versions -->
<version.memcompiler>1.3.0</version.memcompiler>
<version.spoon>10.4.2</version.spoon>
Expand Down
Loading