2026-10-11 04:11:11 +00:00
|
|
|
import * as vscode from 'vscode';
|
|
|
|
|
import { CompletionStrategy } from './CompletionStrategy';
|
|
|
|
|
|
|
|
|
|
export class BuiltInCompletion implements CompletionStrategy {
|
|
|
|
|
|
|
|
|
|
public provideCompletions(document: vscode.TextDocument, position: vscode.Position, linePrefix: string): vscode.CompletionItem[] | undefined {
|
|
|
|
|
const items: vscode.CompletionItem[] = [];
|
|
|
|
|
|
|
|
|
|
// Prüft, ob wir im Namespace "log." oder "discovery." sind (auch wenn man danach weiter tippt!)
|
2026-10-18 01:03:33 +00:00
|
|
|
const match = linePrefix.match(/\b(discovery|log|model|text|regex|time|xpath|json|hash|inference)\.([a-zA-Z0-9_]*)$/);
|
2026-10-11 04:11:11 +00:00
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
|
const namespace = match[1];
|
|
|
|
|
|
|
|
|
|
if (namespace === 'log') {
|
|
|
|
|
const levels = ['debug', 'info', 'warn', 'error'];
|
|
|
|
|
for (const level of levels) {
|
|
|
|
|
const item = new vscode.CompletionItem(level, vscode.CompletionItemKind.Method);
|
|
|
|
|
item.insertText = new vscode.SnippetString(`${level}("\${1:message}");`);
|
|
|
|
|
item.documentation = new vscode.MarkdownString(`Schreibt eine Log-Meldung auf dem Level **${level}**.`);
|
|
|
|
|
items.push(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (namespace === 'discovery') {
|
|
|
|
|
const runCmd = new vscode.CompletionItem('runCommand', vscode.CompletionItemKind.Method);
|
|
|
|
|
runCmd.insertText = new vscode.SnippetString('runCommand(${1:host}, "${2:command}");');
|
|
|
|
|
runCmd.detail = "discovery.runCommand(host, command)";
|
|
|
|
|
items.push(runCmd);
|
|
|
|
|
}
|
|
|
|
|
return items; // Treffer gefunden, wir geben sie zurück!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|