Skip to content
Merged
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: 0 additions & 3 deletions src/aspectValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ export class AspectValidationController {
const editor = vscode.window.activeTextEditor;
await this.validateDocument(editor?.document, 'manual');
}),
this.workspace.onDidSaveTextDocument(async document => {
await this.validateDocument(document, 'save');
}),
);
}

Expand Down
14 changes: 11 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
const logOutputChannel = vscode.window.createOutputChannel('RDF/Turtle and SAMM Aspect Models Language Server', { log: true });
context.subscriptions.push(logOutputChannel);
outputChannel = logOutputChannel;
settings = new TurtleExtensionSettings(context);
settings = new TurtleExtensionSettings();
sammCliDownloader = new SammCliDownloader(context, settings, outputChannel);
languageClient = new TurtleLanguageClient(outputChannel, settings.getSammCliLspServerPort(), settings.getLanguageClientTraceLevel());
aspectValidationController = new AspectValidationController(createUnavailableClient(), vscode.window, vscode.workspace, outputChannel);
Expand Down Expand Up @@ -81,8 +81,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
function queueLanguageServicesRestart(reason: string): Promise<void> {
restartChain = restartChain
.then(() => restartLanguageServices(reason))
.catch(error => {
vscode.window.showErrorMessage(`Failed to start required language services: ${error instanceof Error ? error.message : String(error)}`);
.catch(async error => {
const selection = await vscode.window.showErrorMessage(`Failed to start required language services: ${error instanceof Error ? error.message : String(error)}`, 'Configure SAMM CLI Executable', 'Check Extension Settings');
if (selection === 'Configure SAMM CLI Executable') {
void selectSammCliExecutable();
} else if (selection === 'Check Extension Settings') {
void vscode.commands.executeCommand('workbench.action.openSettings', 'turtle.languageServerSettings');
}
});

return restartChain;
Expand Down Expand Up @@ -188,6 +193,7 @@ async function selectSammCliExecutable(): Promise<void> {
return;
}
await settings.setSammCliPath(selectedPath);
await settings.setEmbeddedLanguageServerStartEnabled(true);
restartReason = `Changed SAMM CLI to custom executable: ${selectedPath}`;
} else {
if (!pick.releaseTag) {
Expand All @@ -199,6 +205,7 @@ async function selectSammCliExecutable(): Promise<void> {
}
const downloadedPath = await sammCliDownloader.downloadRelease(pick.releaseTag, downloadType);
await settings.setSammCliPath(downloadedPath);
await settings.setEmbeddedLanguageServerStartEnabled(true);
restartReason = `Changed SAMM CLI to GitHub release ${pick.releaseTag} (${downloadType === 'jar' ? 'JAR' : 'native executable'})`;
}

Expand Down Expand Up @@ -230,6 +237,7 @@ async function promptForDownloadType(): Promise<'native' | 'jar' | undefined> {

async function promptForCustomExecutablePath(): Promise<string | undefined> {
const selection = await vscode.window.showOpenDialog({
defaultUri: vscode.Uri.file(settings.getSammCliPath() || ''),
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
Expand Down
2 changes: 2 additions & 0 deletions src/sammCliDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface GitHubRelease {

const SAMM_CLI_STORAGE_DIR = 'SAMM CLI';
const RELEASES_PAGE_SIZE = 20;
const SAMM_CLI_MINIMUM_SUPPORTED_VERSION = 'v2.15.0';

export class SammCliDownloader {
constructor(
Expand Down Expand Up @@ -103,6 +104,7 @@ export class SammCliDownloader {
const releases = await response.json() as Array<GitHubRelease>;
return releases
.filter(release => !release.draft && !release.prerelease)
.filter(release => this.compareVersions(release.tag_name, SAMM_CLI_MINIMUM_SUPPORTED_VERSION) >= 0)
.map(release => release.tag_name)
.slice(0, limit);
}
Expand Down
7 changes: 4 additions & 3 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
import * as vscode from 'vscode';

export class TurtleExtensionSettings {
constructor(
private readonly context: vscode.ExtensionContext,
) { }

isEmbeddedLanguageServerStartEnabled(): boolean {
return vscode.workspace.getConfiguration('turtle.languageServerSettings').get<boolean>('activateEmbeddedLanguageServer', true);
}

async setEmbeddedLanguageServerStartEnabled(enabled: boolean): Promise<void> {
await vscode.workspace.getConfiguration('turtle.languageServerSettings').update('activateEmbeddedLanguageServer', enabled, vscode.ConfigurationTarget.Global);
}

getSammCliPath(): string {
return vscode.workspace.getConfiguration('turtle.languageServerSettings').get<string>('sammCliPath', '');
}
Expand Down
Loading