Inhaltsverzeichnis
Core API
API-Referenz für die WvdS VSCode Core Extension.
Übersicht
Die Core Extension stellt zentrale Dienste bereit, die von allen anderen Extensions genutzt werden können.
uses WvdS.Core.Services, WvdS.Core.Toolchain, WvdS.Core.Logging;
Logging-Dienst
LogInfo
procedure LogInfo(const AMessage: string); procedure LogInfo(const AFormat: string; const AArgs: array of const);
Schreibt eine Info-Meldung in den Output Channel.
LogWarn
procedure LogWarn(const AMessage: string); procedure LogWarn(const AFormat: string; const AArgs: array of const);
Schreibt eine Warnung in den Output Channel.
LogError
procedure LogError(const AMessage: string); procedure LogError(const AFormat: string; const AArgs: array of const);
Schreibt einen Fehler in den Output Channel.
LogDebug
{$IFDEF DEBUG} procedure LogDebug(const AMessage: string); procedure LogDebug(const AFormat: string; const AArgs: array of const); {$ENDIF}
Schreibt eine Debug-Meldung. Nur verfügbar bei Kompilierung mit -dDEBUG.
Toolchain-Dienst
GetToolPath
function GetToolPath(ATool: TWvdSToolType): string;
Gibt den konfigurierten Pfad für ein Werkzeug zurück.
| TWvdSToolType | Beschreibung |
|---|---|
| ttFPC | Free Pascal Compiler |
| ttPas2js | pas2js Transpiler |
| ttLazbuild | Lazarus Build Tool |
| ttInnoSetup | Inno Setup Compiler |
| ttMake | GNU Make |
Beispiel:
var FpcPath: string; begin FpcPath := GetToolPath(ttFPC); if FpcPath = '' then raise EWvdSToolNotFound.Create(rsToolNotFound); end;
GetToolVersion
function GetToolVersion(ATool: TWvdSToolType): string;
Gibt die Version eines installierten Werkzeugs zurück.
IsToolAvailable
function IsToolAvailable(ATool: TWvdSToolType): Boolean;
Prüft, ob ein Werkzeug verfügbar ist.
AutoDetectTools
procedure AutoDetectTools;
Führt automatische Erkennung aller Werkzeuge durch.
Konfiguration
GetConfiguration
function GetConfiguration(const ASection: string): TJSObject;
Liest VS Code Konfiguration.
Beispiel:
var Config: TJSObject; LogLevel: string; begin Config := GetConfiguration('wvds.core'); LogLevel := String(Config['logLevel']); end;
UpdateConfiguration
procedure UpdateConfiguration( const ASection: string; const AKey: string; AValue: JSValue; ATarget: TConfigurationTarget );
Schreibt VS Code Konfiguration.
| TConfigurationTarget | Beschreibung |
|---|---|
| ctGlobal | Benutzer-Einstellungen |
| ctWorkspace | Workspace-Einstellungen |
| ctWorkspaceFolder | Ordner-Einstellungen |
Event-Bus
PublishEvent
procedure PublishEvent(const AEventName: string; AData: TJSObject);
Veröffentlicht ein Event für andere Extensions.
Beispiel:
var Data: TJSObject; begin Data := TJSObject.New; Data['projectPath'] := ProjectPath; Data['success'] := True; PublishEvent('wvds.build.completed', Data); end;
SubscribeEvent
procedure SubscribeEvent( const AEventName: string; AHandler: TWvdSEventHandler );
Abonniert Events.
Beispiel:
procedure HandleBuildCompleted(AData: TJSObject); begin if Boolean(AData['success']) then LogInfo('Build succeeded!') else LogError('Build failed!'); end; // Bei Aktivierung: SubscribeEvent('wvds.build.completed', @HandleBuildCompleted);
UI-Dienste
ShowInfoMessage
procedure ShowInfoMessage(const AMessage: string); function ShowInfoMessage( const AMessage: string; const AItems: array of string ): TJSPromise; // Resolves to selected item
ShowWarningMessage
procedure ShowWarningMessage(const AMessage: string);
ShowErrorMessage
procedure ShowErrorMessage(const AMessage: string);
ShowQuickPick
function ShowQuickPick( const AItems: array of string; const APlaceholder: string ): TJSPromise;
Workspace-Dienste
GetWorkspaceRoot
function GetWorkspaceRoot: string;
Gibt den Pfad zum Workspace-Ordner zurück.
GetOpenDocument
function GetOpenDocument: string;
Gibt den Pfad zum aktuell geöffneten Dokument zurück.