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 | 1x 5x 5x 1x 4x 4x 4x 1x 1x 3x 1x 2x 2x 1x 1x 1x 1x 1x 1x 1x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { Store } from '@faubulous/mentor-rdf';
import { ServiceToken } from '@src/services/tokens';
import { ISparqlConnectionService } from '@src/languages/sparql/services';
import { SparqlResultsController } from '@src/views/webviews';
import { getConfig } from '@src/utilities/vscode/config';
import { WorkspaceUri } from '@src/providers/workspace-uri';
export const deleteGraph = {
id: 'mentor.command.deleteGraph',
handler: async (documentIri: string, graphIri: vscode.Uri | string) => {
// Ask for confirmation before deleting
const answer = await vscode.window.showWarningMessage(
`Are you sure you want to delete the graph "${WorkspaceUri.toCanonicalString(graphIri)}"? This action cannot be undone.`,
{ modal: true },
'Delete'
);
if (answer !== 'Delete') {
return;
}
const connectionService = container.resolve<ISparqlConnectionService>(ServiceToken.SparqlConnectionService);
const connection = connectionService.getConnectionForDocument(documentIri);
if (!connection) {
vscode.window.showErrorMessage(`Unable to retrieve SPARQL connection for document: ${documentIri}`);
return;
}
if (connection.id === 'workspace') {
container.resolve<Store>(ServiceToken.Store).deleteGraphs([WorkspaceUri.toCanonicalString(graphIri)]);
} else {
const query = getConfig().get<string>('sparql.dropGraphQuery');
if (!query) {
vscode.window.showErrorMessage('Could not retrieve query from configuration: mentor.sparql.dropGraphQuery');
return;
}
// Create an untitled SPARQL document with the drop graph query
const document = await vscode.workspace.openTextDocument({
content: query.replace('@graphIri', WorkspaceUri.toCanonicalString(graphIri)),
language: 'sparql'
});
// Set the connection for this document
await connectionService.setQuerySourceForDocument(document.uri, connection.id);
// Show the document and execute the query
await vscode.window.showTextDocument(document);
const controller = container.resolve<SparqlResultsController>(ServiceToken.SparqlResultsController);
await controller.executeQueryFromTextDocument(document);
}
}
}; |