API-referenca za WvdS VSCode Core Extension.
Core Extension pruža centralne usluge koje mogu koristiti sve druge ekstenzije.
uses WvdS.Core.Services, WvdS.Core.Toolchain, WvdS.Core.Logging;
procedure LogInfo(const AMessage: string); procedure LogInfo(const AFormat: string; const AArgs: array of const);
Zapisuje info-poruku u Output Channel.
procedure LogWarn(const AMessage: string); procedure LogWarn(const AFormat: string; const AArgs: array of const);
Zapisuje upozorenje u Output Channel.
procedure LogError(const AMessage: string); procedure LogError(const AFormat: string; const AArgs: array of const);
Zapisuje grešku u Output Channel.
{$IFDEF DEBUG} procedure LogDebug(const AMessage: string); procedure LogDebug(const AFormat: string; const AArgs: array of const); {$ENDIF}
Zapisuje debug-poruku. Dostupno samo kod kompilacije s -dDEBUG.
function GetToolPath(ATool: TWvdSToolType): string;
Vraća konfiguriranu putanju za alat.
| TWvdSToolType | Opis |
|---|---|
| ttFPC | Free Pascal Compiler |
| ttPas2js | pas2js Transpiler |
| ttLazbuild | Lazarus Build Tool |
| ttInnoSetup | Inno Setup Compiler |
| ttMake | GNU Make |
Primjer:
var FpcPath: string; begin FpcPath := GetToolPath(ttFPC); if FpcPath = '' then raise EWvdSToolNotFound.Create(rsToolNotFound); end;
function GetToolVersion(ATool: TWvdSToolType): string;
Vraća verziju instaliranog alata.
function IsToolAvailable(ATool: TWvdSToolType): Boolean;
Provjerava je li alat dostupan.
procedure AutoDetectTools;
Izvršava automatsku detekciju svih alata.
function GetConfiguration(const ASection: string): TJSObject;
Čita VS Code konfiguraciju.
Primjer:
var Config: TJSObject; LogLevel: string; begin Config := GetConfiguration('wvds.core'); LogLevel := String(Config['logLevel']); end;
procedure UpdateConfiguration( const ASection: string; const AKey: string; AValue: JSValue; ATarget: TConfigurationTarget );
Zapisuje VS Code konfiguraciju.
| TConfigurationTarget | Opis |
|---|---|
| ctGlobal | Korisničke postavke |
| ctWorkspace | Workspace-postavke |
| ctWorkspaceFolder | Folder-postavke |
procedure PublishEvent(const AEventName: string; AData: TJSObject);
Objavljuje event za druge ekstenzije.
Primjer:
var Data: TJSObject; begin Data := TJSObject.New; Data['projectPath'] := ProjectPath; Data['success'] := True; PublishEvent('wvds.build.completed', Data); end;
procedure SubscribeEvent( const AEventName: string; AHandler: TWvdSEventHandler );
Pretplaćuje se na evente.
Primjer:
procedure HandleBuildCompleted(AData: TJSObject); begin if Boolean(AData['success']) then LogInfo('Build succeeded!') else LogError('Build failed!'); end; // Kod aktivacije: SubscribeEvent('wvds.build.completed', @HandleBuildCompleted);
procedure ShowInfoMessage(const AMessage: string); function ShowInfoMessage( const AMessage: string; const AItems: array of string ): TJSPromise; // Resolves to selected item
procedure ShowWarningMessage(const AMessage: string);
procedure ShowErrorMessage(const AMessage: string);
function ShowQuickPick( const AItems: array of string; const APlaceholder: string ): TJSPromise;
function GetWorkspaceRoot: string;
Vraća putanju do Workspace-foldera.
function GetOpenDocument: string;
Vraća putanju do trenutno otvorenog dokumenta.