(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken)
| 287 | } |
| 288 | |
| 289 | function getPipelineCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.CompletionItem[] { |
| 290 | const items: vscode.CompletionItem[] = []; |
| 291 | const range = extendSelection(position.line, (x) => document.lineAt(x).text, document.lineCount); |
| 292 | let symbol: string | undefined = undefined; |
| 293 | |
| 294 | for (let i = range.startLine; i <= range.endLine; i++) { |
| 295 | if (token.isCancellationRequested) { |
| 296 | break; |
| 297 | } |
| 298 | |
| 299 | const line = document.lineAt(i); |
| 300 | if (line.isEmptyOrWhitespace) { |
| 301 | continue; |
| 302 | } |
| 303 | |
| 304 | const cleanedLine = cleanLine(line.text); |
| 305 | if (cleanedLine.length === 0) { |
| 306 | continue; |
| 307 | } |
| 308 | |
| 309 | const pipeSymbolIndex = line.text.search(/([\w_.]+)\s*(%.+%|\|>)/); |
| 310 | if (pipeSymbolIndex < 0) { |
| 311 | break; |
| 312 | } |
| 313 | |
| 314 | const symbolPosition = new vscode.Position(i, pipeSymbolIndex); |
| 315 | const symbolRange = document.getWordRangeAtPosition(symbolPosition); |
| 316 | |
| 317 | if (symbolRange !== undefined) { |
| 318 | symbol = document.getText(symbolRange); |
| 319 | } |
| 320 | |
| 321 | break; |
| 322 | } |
| 323 | |
| 324 | if (!token.isCancellationRequested && symbol !== undefined) { |
| 325 | const obj = session.workspaceData.globalenv[symbol]; |
| 326 | if (obj !== undefined && obj.names !== undefined) { |
| 327 | const doc = new vscode.MarkdownString('Element of `' + symbol + '`'); |
| 328 | items.push(...getCompletionItems(obj.names, vscode.CompletionItemKind.Variable, '[session]', doc)); |
| 329 | } |
| 330 | } |
| 331 | return items; |
| 332 | } |
no test coverage detected