All files / commands/document implement-prefixes.ts

100% Statements 9/9
100% Branches 4/4
100% Functions 3/3
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      1x     3x   3x 2x 3x   2x 1x        
import * as vscode from 'vscode';
import { resolvePrefixDefinitionService } from '@src/languages/resolve-prefix-definition-service';
 
export const implementPrefixes = {
	id: 'mentor.command.implementPrefixes',
	handler: async (documentUri: vscode.Uri, prefixes: string[]) => {
		const document = vscode.workspace.textDocuments.find(doc => doc.uri.toString() === documentUri.toString());
 
		if (document) {
			const service = resolvePrefixDefinitionService(document);
			const edit = await service.implementPrefixes(document, prefixes.map(p => ({ prefix: p, namespaceIri: undefined })));
 
			if (edit.size > 0) {
				await vscode.workspace.applyEdit(edit);
			}
		}
	}
};