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 | 1x 3x 3x 3x 1x 1x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { ISparqlConnectionService } from '@src/languages/sparql/services';
import { resolveNotebookFromContext } from '../utilities/vscode/notebook';
export const setNotebookInference = {
id: 'mentor.command.setNotebookInference',
handler: async (context?: any) => {
const connectionService = container.resolve<ISparqlConnectionService>(ServiceToken.SparqlConnectionService);
const notebook = resolveNotebookFromContext(context);
if (!notebook) {
vscode.window.showWarningMessage('No notebook is currently open.');
return;
}
// Show quick pick to select inference setting
const items = [
{ label: 'On', description: 'Include inferred triples in query results.', value: true },
{ label: 'Off', description: 'Only return asserted triples.', value: false },
{ label: 'Default', description: 'Use connection defaults for each cell.', value: undefined }
];
const selected = await vscode.window.showQuickPick(items, {
placeHolder: 'Set inference for all cells in this notebook'
});
if (selected === undefined) {
return; // User cancelled
}
// Update all cells in the notebook
const cells = notebook.getCells();
const edits: vscode.NotebookEdit[] = [];
for (const cell of cells) {
const metadata = { ...cell.metadata };
Iif (selected.value === undefined) {
delete metadata.inferenceEnabled;
} else {
metadata.inferenceEnabled = selected.value;
}
edits.push(vscode.NotebookEdit.updateCellMetadata(cell.index, metadata));
}
Eif (edits.length > 0) {
const workspaceEdit = new vscode.WorkspaceEdit();
workspaceEdit.set(notebook.uri, edits);
await vscode.workspace.applyEdit(workspaceEdit);
// Notify listeners to refresh code lenses
connectionService.notifyDocumentConnectionChanged(notebook.uri);
}
const statusText = selected.value === undefined
? 'Cleared inference settings'
: selected.value ? 'Enabled inference' : 'Disabled inference';
vscode.window.setStatusBarMessage(`${statusText} for all ${cells.length} cells`, 3000);
}
};
|