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 | 11x 7x 7x 1x 6x 6x 2x 4x 8x 3x 1x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { IDocumentContextService } from '@src/services/document';
/**
* A definition provider that navigates to workspace documents or notebook cells
* when the cursor is on a `workspace:` graph IRI (e.g. in a SPARQL `FROM` or
* `GRAPH` clause, or a Turtle `<workspace:///…>` reference).
*/
export class WorkspaceGraphDefinitionProvider implements vscode.DefinitionProvider {
private get _contextService() {
return container.resolve<IDocumentContextService>(ServiceToken.DocumentContextService);
}
provideDefinition(document: vscode.TextDocument, position: vscode.Position): vscode.ProviderResult<vscode.Definition> {
const context = this._contextService.contexts[document.uri.toString()];
if (!context) {
return null;
}
const iri = context.getIriAtPosition(position);
if (!iri || !iri.startsWith('workspace:')) {
return null;
}
for (const ctx of Object.values(this._contextService.contexts)) {
if (ctx.graphIri.toString() === iri) {
return new vscode.Location(ctx.uri, new vscode.Range(0, 0, 0, 0));
}
}
return null;
}
}
|