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 | 5x 5x 4x 4x 4x 4x 3x 3x 3x 3x 3x 3x 4x | import * as vscode from 'vscode';
import { container } from 'tsyringe';
import { ServiceToken } from '@src/services/tokens';
import { InferenceUri } from '@src/providers/inference-uri';
/**
* Provides document links for URIs with the 'inference:' scheme.
*/
export class InferenceUriLinkProvider implements vscode.DocumentLinkProvider {
constructor() {
// Self-register with the extension context for automatic disposal
const context = container.resolve<vscode.ExtensionContext>(ServiceToken.ExtensionContext);
context.subscriptions.push(
vscode.languages.registerDocumentLinkProvider({ scheme: 'file' }, this)
);
}
provideDocumentLinks(document: vscode.TextDocument): vscode.DocumentLink[] {
const links: vscode.DocumentLink[] = [];
const text = document.getText();
const regex = new RegExp(InferenceUri.uriRegex, 'g');
for (const match of text.matchAll(regex)) {
const start = document.positionAt(match.index);
const end = document.positionAt(match.index + match[0].length);
const range = new vscode.Range(start, end);
const uri = vscode.Uri.parse(match[0]);
Eif (uri) {
links.push(new vscode.DocumentLink(range, uri));
}
}
return links;
}
} |