(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken)
| 245 | } |
| 246 | |
| 247 | function getBracketCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.CompletionItem[] { |
| 248 | const items: vscode.CompletionItem[] = []; |
| 249 | let range: vscode.Range | undefined = new vscode.Range(new vscode.Position(position.line, 0), position); |
| 250 | let expectOpenBrackets = 0; |
| 251 | let symbol: string | undefined = undefined; |
| 252 | |
| 253 | while (range) { |
| 254 | if (token.isCancellationRequested) { return []; } |
| 255 | const text = document.getText(range); |
| 256 | for (let i = text.length - 1; i >= 0; i -= 1) { |
| 257 | const chr = text.charAt(i); |
| 258 | if (chr === ']') { |
| 259 | expectOpenBrackets += 1; |
| 260 | } else if (chr === '[') { |
| 261 | if (expectOpenBrackets === 0) { |
| 262 | const symbolPosition = new vscode.Position(range.start.line, i - 1); |
| 263 | const symbolRange = document.getWordRangeAtPosition(symbolPosition); |
| 264 | symbol = document.getText(symbolRange); |
| 265 | range = undefined; |
| 266 | break; |
| 267 | } else { |
| 268 | expectOpenBrackets -= 1; |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | if (range?.start?.line !== undefined && range.start.line > 0) { |
| 273 | range = document.lineAt(range.start.line - 1).range; // check previous line |
| 274 | } else { |
| 275 | range = undefined; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if (!token.isCancellationRequested && symbol !== undefined) { |
| 280 | const obj = session.workspaceData.globalenv[symbol]; |
| 281 | if (obj !== undefined && obj.names !== undefined) { |
| 282 | const doc = new vscode.MarkdownString('Element of `' + symbol + '`'); |
| 283 | items.push(...getCompletionItems(obj.names, vscode.CompletionItemKind.Variable, '[session]', doc)); |
| 284 | } |
| 285 | } |
| 286 | return items; |
| 287 | } |
| 288 | |
| 289 | function getPipelineCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.CompletionItem[] { |
| 290 | const items: vscode.CompletionItem[] = []; |
no test coverage detected