All files / commands/validation cancel-validation.ts

100% Statements 7/7
100% Branches 4/4
100% Functions 1/1
100% Lines 7/7

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                    1x     3x   3x 1x     2x         2x 1x        
import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { ShaclValidationService } from '@src/services/validation/shacl-validation-service';
 
/**
 * Prompts the user to cancel the batch SHACL validation currently in flight. Invoked by
 * clicking the validation status bar item; cancellation happens only after the user
 * confirms via the shown notification, never silently.
 */
export const cancelValidation = {
	id: 'mentor.command.cancelValidation',
	handler: async () => {
		const service = container.resolve<ShaclValidationService>(ServiceToken.ShaclValidationService);
 
		if (!service.isValidating) {
			return;
		}
 
		const choice = await vscode.window.showWarningMessage(
			'SHACL validation is running.',
			'Cancel Validation'
		);
 
		if (choice === 'Cancel Validation') {
			service.cancelActiveValidation();
		}
	}
};