====== Core API ====== API-referenca za WvdS VSCode Core Extension. ===== Pregled ===== Core Extension pruža centralne usluge koje mogu koristiti sve druge ekstenzije. uses WvdS.Core.Services, WvdS.Core.Toolchain, WvdS.Core.Logging; ===== Logging-servis ===== ==== LogInfo ==== procedure LogInfo(const AMessage: string); procedure LogInfo(const AFormat: string; const AArgs: array of const); Zapisuje info-poruku u Output Channel. ==== LogWarn ==== procedure LogWarn(const AMessage: string); procedure LogWarn(const AFormat: string; const AArgs: array of const); Zapisuje upozorenje u Output Channel. ==== LogError ==== procedure LogError(const AMessage: string); procedure LogError(const AFormat: string; const AArgs: array of const); Zapisuje grešku u Output Channel. ==== LogDebug ==== {$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''. ===== Toolchain-servis ===== ==== GetToolPath ==== 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; ==== GetToolVersion ==== function GetToolVersion(ATool: TWvdSToolType): string; Vraća verziju instaliranog alata. ==== IsToolAvailable ==== function IsToolAvailable(ATool: TWvdSToolType): Boolean; Provjerava je li alat dostupan. ==== AutoDetectTools ==== procedure AutoDetectTools; Izvršava automatsku detekciju svih alata. ===== Konfiguracija ===== ==== GetConfiguration ==== 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; ==== UpdateConfiguration ==== 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 | ===== Event-Bus ===== ==== PublishEvent ==== 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; ==== SubscribeEvent ==== 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); ===== UI-servisi ===== ==== 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-servisi ===== ==== GetWorkspaceRoot ==== function GetWorkspaceRoot: string; Vraća putanju do Workspace-foldera. ==== GetOpenDocument ==== function GetOpenDocument: string; Vraća putanju do trenutno otvorenog dokumenta. ===== Vidi također ===== * [[.:meta-api|Meta API]] * [[.:vscode-wrapper|VSCode Wrapper]] * [[.:extension-entwicklung|Razvoj ekstenzija]]