(
document: vscode.TextDocument,
token: vscode.CancellationToken
)
| 2 | |
| 3 | export class LoaderLens implements vscode.CodeLensProvider { |
| 4 | provideCodeLenses( |
| 5 | document: vscode.TextDocument, |
| 6 | token: vscode.CancellationToken |
| 7 | ): vscode.ProviderResult<vscode.CodeLens[]> { |
| 8 | const codeLenses: vscode.CodeLens[] = []; |
| 9 | const config = vscode.workspace.getConfiguration("remix-forge"); |
| 10 | // Define the regular expression pattern to match the function signature |
| 11 | const functionPattern = /export\s+const\s+loader\b/; |
| 12 | // Iterate over the document's text lines and look for matches |
| 13 | for (let lineIndex = 0; lineIndex < document.lineCount; lineIndex++) { |
| 14 | const line = document.lineAt(lineIndex); |
| 15 | const matches = functionPattern.exec(line.text); |
| 16 | if (matches) { |
| 17 | const range = new vscode.Range(lineIndex, line.firstNonWhitespaceCharacterIndex, lineIndex, line.text.length); |
| 18 | |
| 19 | const newCodeLens = new vscode.CodeLens(range); |
| 20 | // Set the command that will be executed when the code lens is clicked |
| 21 | newCodeLens.command = { |
| 22 | title: `Add authentication 🔒`, |
| 23 | command: "remix-forge.generateAuthSnippet", |
| 24 | arguments: [document.uri, "loader"], |
| 25 | tooltip: `Generate authentication code for this loader using the authentication from remix-auth`, |
| 26 | }; |
| 27 | |
| 28 | codeLenses.push(newCodeLens); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return codeLenses; |
| 33 | } |
| 34 | } |
nothing calls this directly
no outgoing calls
no test coverage detected