Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1b8fd36
refactoring: move constants to the dedicated file
KyrylR Aug 25, 2026
f848e15
refactoring: move args to the dedicated compiler dir
KyrylR Aug 25, 2026
4ded0db
refactoring: compiler parsing logic to the dedicated file
KyrylR Aug 25, 2026
a418722
refactoring: move compile.ts to the compiler dir
KyrylR Aug 25, 2026
ba2f99d
refactoring: move compile commands to the dedicated dir
KyrylR Aug 25, 2026
e9f6043
refactoring: move tasks.ts into tasks dir (name it as provider)
KyrylR Aug 25, 2026
08905dc
refactoring: move statusBar.ts to lsp dir
KyrylR Aug 25, 2026
536360c
refactoring: move client.ts to lsp dir
KyrylR Aug 25, 2026
c084ecd
refactoring: extract executable search from find_server
KyrylR Aug 25, 2026
f5785fe
refactoring: shell free executable discovery
KyrylR Aug 25, 2026
23dc3d6
refactoring: refactor types for compilation task
KyrylR Aug 25, 2026
ce6624f
refactoring: centralized ids and compiler commands for compile task
KyrylR Aug 25, 2026
b888294
refactoring: improved compiler process management
KyrylR Aug 25, 2026
cb8b7df
refactoring: rewrite completion of the server installation
KyrylR Aug 25, 2026
59da970
refactoring: improve lsp requests lifecycle
KyrylR Aug 25, 2026
3a5e3a5
refactoring: move find server to the lsp dir and rename it to install.ts
KyrylR Aug 25, 2026
2ad35f3
refactoring: move SimplicityHLCompiler singleton to the extension.ts
KyrylR Aug 25, 2026
92b5983
refactoring: move StatusBar singleton to the lps/client.ts
KyrylR Aug 25, 2026
0457bbc
refactoring: remove commands.ts in favor of contracts.ts
KyrylR Aug 25, 2026
5571308
refactoring: use contracts instead of hardcoded values in compiler/in…
KyrylR Aug 25, 2026
38fd792
refactoring: improve LSP workspace dir resolution
KyrylR Aug 25, 2026
eff275a
refactoring: refactored LSP client startup
KyrylR Aug 25, 2026
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"compile": "npm run check-types && node esbuild.mjs --production",
"check": "npm test && npm run eslint-check && npm run compile",
"check-types": "tsc --noEmit",
"test": "node --test -r ts-node/register src/features.test.ts",
"test": "node --test -r ts-node/register src/contracts.test.ts src/find_executable.test.ts",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.mjs --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
Expand Down
135 changes: 0 additions & 135 deletions src/client.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/commands.ts

This file was deleted.

71 changes: 39 additions & 32 deletions src/compile_commands.ts → src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
// Registers commands accessible via Command Palette and keybindings.

import * as vscode from "vscode";
import * as path from "path";
import { getCompiler } from "./compile";
import * as path from "node:path";
import type { CompileResult, SimplicityHLCompiler } from "../compiler";
import type { CompileOptions } from "../compiler/args";
import {
COMMAND_IDS,
CONFIGURATION_SECTION,
LANGUAGE_IDS,
SETTINGS,
} from "../contracts";

function showCompilationFailed(): void {
vscode.window.showErrorMessage(
Expand All @@ -20,14 +27,17 @@ async function getSimplicityHLDocument(): Promise<vscode.TextDocument | undefine
}

const document = editor.document;
if (document.languageId !== "simplicityhl") {
if (document.languageId !== LANGUAGE_IDS.source) {
vscode.window.showWarningMessage("Current file is not a SimplicityHL file (.simf)");
return undefined;
}

// Auto-save before compile if enabled
const config = vscode.workspace.getConfiguration("simplicityhl");
const autoSave = config.get<boolean>("build.autoSaveBeforeCompile", true);
const config = vscode.workspace.getConfiguration(CONFIGURATION_SECTION);
const autoSave = config.get<boolean>(
SETTINGS.autoSaveBeforeCompile.key,
SETTINGS.autoSaveBeforeCompile.default,
);
if (autoSave && document.isDirty) {
const saved = await document.save();
if (!saved) {
Expand All @@ -41,17 +51,24 @@ async function getSimplicityHLDocument(): Promise<vscode.TextDocument | undefine
return document;
}

async function compileActiveDocument(
compiler: () => SimplicityHLCompiler,
options: CompileOptions = {},
): Promise<CompileResult | undefined> {
const document = await getSimplicityHLDocument();
return document && compiler().compileFile(document.uri.fsPath, options);
}

// Register all compile-related commands
export function registerCompileCommands(context: vscode.ExtensionContext): void {
// Basic compile - compiles the current .simf file
export function registerCompileCommands(
context: vscode.ExtensionContext,
compiler: () => SimplicityHLCompiler,
): void {
const compileFileCommand = vscode.commands.registerCommand(
"simplicityhl.compileFile",
COMMAND_IDS.compileFile,
async () => {
const document = await getSimplicityHLDocument();
if (!document) return;

const compiler = getCompiler();
const result = await compiler.compileFile(document.uri.fsPath);
const result = await compileActiveDocument(compiler);
if (!result) return;

if (result.success) {
// Offer to copy output to clipboard
Expand All @@ -71,15 +88,11 @@ export function registerCompileCommands(context: vscode.ExtensionContext): void
}
);

// Compile with debug symbols - includes debug info in output
const compileDebugCommand = vscode.commands.registerCommand(
"simplicityhl.compileFileDebug",
COMMAND_IDS.compileFileDebug,
async () => {
const document = await getSimplicityHLDocument();
if (!document) return;

const compiler = getCompiler();
const result = await compiler.compileFile(document.uri.fsPath, { debug: true });
const result = await compileActiveDocument(compiler, { debug: true });
if (!result) return;

if (result.success) {
vscode.window.showInformationMessage("Compiled with debug symbols!");
Expand All @@ -89,9 +102,8 @@ export function registerCompileCommands(context: vscode.ExtensionContext): void
}
);

// Compile with witness - satisfies the program with witness data
const compileWithWitnessCommand = vscode.commands.registerCommand(
"simplicityhl.compileWithWitness",
COMMAND_IDS.compileWithWitness,
async () => {
const document = await getSimplicityHLDocument();
if (!document) return;
Expand Down Expand Up @@ -125,8 +137,7 @@ export function registerCompileCommands(context: vscode.ExtensionContext): void
return;
}

const compiler = getCompiler();
const result = await compiler.compileFile(simfPath, { witnessFile });
const result = await compiler().compileFile(simfPath, { witnessFile });

if (result.success) {
const action = await vscode.window.showInformationMessage(
Expand All @@ -149,15 +160,11 @@ export function registerCompileCommands(context: vscode.ExtensionContext): void
}
);

// Compile to JSON - outputs result in JSON format in a new editor
const compileJsonCommand = vscode.commands.registerCommand(
"simplicityhl.compileJson",
COMMAND_IDS.compileJson,
async () => {
const document = await getSimplicityHLDocument();
if (!document) return;

const compiler = getCompiler();
const result = await compiler.compileFile(document.uri.fsPath, { json: true });
const result = await compileActiveDocument(compiler, { json: true });
if (!result) return;

if (result.success && result.program) {
// Show JSON output in a new untitled document
Expand All @@ -184,6 +191,6 @@ export function registerCompileCommands(context: vscode.ExtensionContext): void
compileFileCommand,
compileDebugCommand,
compileWithWitnessCommand,
compileJsonCommand
compileJsonCommand,
);
}
56 changes: 56 additions & 0 deletions src/compiler/args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { ExperimentalFeatures, TaskCommand } from "../contracts";

export interface CompileOptions {
debug?: boolean;
witnessFile?: string;
json?: boolean;
}

export function compilerFeatureArguments(
features: ExperimentalFeatures,
): string[] {
const args: string[] = [];
if (features.imports) {
args.push("-Z", "imports");
}
if (features.enums) {
args.push("-Z", "enums");
}
return args;
}

export function compilerArguments(
file: string,
features: ExperimentalFeatures,
options: CompileOptions = {},
): string[] {
const args = [file, ...compilerFeatureArguments(features)];
if (options.witnessFile) {
args.push("-w", options.witnessFile);
}
if (options.debug) {
args.push("--debug");
}
if (options.json) {
args.push("--json");
}
return args;
}

export function taskCompilerArguments(
command: TaskCommand,
file: string,
witnessFile: string | undefined,
features: ExperimentalFeatures,
): string[] {
switch (command) {
case "compile":
return compilerArguments(file, features);
case "compile-debug":
return compilerArguments(file, features, { debug: true });
case "compile-with-witness":
return compilerArguments(file, features, {
witnessFile: witnessFile || "${file/.simf/.wit/}",
});
}
}
Loading
Loading