Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { IWorkspaceIndexerService } from '@src/services/core';
import { ShaclValidationService } from '@src/services/validation/shacl-validation-service';
export const viewShaclReport = {
id: 'mentor.command.viewShaclReport',
handler: async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
const indexer = container.resolve<IWorkspaceIndexerService>(ServiceToken.WorkspaceIndexerService);
if (!indexer.indexingFinished) {
// Wait for indexing to finish; allow the user to cancel.
const proceeded = await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: 'Mentor: Waiting for workspace indexing to complete…',
cancellable: true,
},
async (_progress, token) => {
return new Promise<boolean>((resolve) => {
token.onCancellationRequested(() => resolve(false));
indexer.waitForIndexed().then(() => resolve(true));
});
}
);
if (!proceeded) {
return;
}
}
const service = container.resolve<ShaclValidationService>(ServiceToken.ShaclValidationService);
const lastResult = service.getLastResult(editor.document.uri);
if (!lastResult) {
vscode.window.showInformationMessage('No SHACL validation results available. Run validation first.');
return;
}
const format = await vscode.window.showQuickPick(
[
{
id: 'problems',
label: 'View Problems',
description: 'Focus the Problems panel'
},
{
id: 'turtle',
label: 'Export as Turtle',
description: '(text/turtle)'
},
{
id: 'plaintext',
label: 'Export as Plain Text',
description: '(text/plain)'
}
],
{
placeHolder: 'Select an action for the SHACL validation report',
title: 'View SHACL Report'
}
);
if (!format) {
return;
}
if (format.id === 'problems') {
await vscode.commands.executeCommand('workbench.panel.markers.view.focus');
return;
}
let content: string | undefined;
let language: string;
if (format.id === 'turtle') {
content = await service.getReportAsTurtle(editor.document.uri);
language = 'turtle';
} else {
content = service.getReportAsText(editor.document.uri);
language = 'plaintext';
}
if (!content) {
vscode.window.showWarningMessage('Failed to generate the validation report.');
return;
}
const document = await vscode.workspace.openTextDocument({ content, language });
await vscode.window.showTextDocument(document, { preview: true });
}
};
|