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 | 1x 4x 4x 4x 4x 1x 1x 3x 3x 2x 2x 1x 1x 1x 1x 1x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { ISparqlConnectionRegistry } from '@src/languages/sparql/services';
import { IDocumentConnectionService } from '@src/languages/sparql/services';
import { resolveNotebookFromContext } from '../../utilities/vscode/notebook';
export const setNotebookConnection = {
id: 'mentor.command.setNotebookConnection',
handler: async (context?: any) => {
const connectionRegistry = container.resolve<ISparqlConnectionRegistry>(ServiceToken.SparqlConnectionRegistry);
const documentConnectionService = container.resolve<IDocumentConnectionService>(ServiceToken.DocumentConnectionService);
const notebook = resolveNotebookFromContext(context);
if (!notebook) {
vscode.window.showWarningMessage('No notebook is currently open.');
return;
}
// Show quick pick to select connection
const connections = connectionRegistry.getConnections();
if (connections.length === 0) {
vscode.window.showWarningMessage('No SPARQL connections configured.');
return;
}
const items = connections.map(connection => ({
label: `$(arrow-swap) ${connection.endpointUrl}`,
description: connection.description,
connection
}));
const selected = await vscode.window.showQuickPick(items, {
placeHolder: 'Select SPARQL connection for all cells in this notebook'
});
Iif (!selected) {
return;
}
// Update all cells in one bulk edit; the service fires the change event
// once per cell so URI-scoped consumers (code lenses, FROM-graph linting)
// re-evaluate each cell against the new connection.
await documentConnectionService.setConnectionForNotebook(notebook, selected.connection.id);
vscode.window.setStatusBarMessage(
`Set connection to "${selected.connection.endpointUrl}" for all ${notebook.getCells().length} cells`,
3000
);
}
};
|