====== Core API ====== API referenca za WvdS VSCode Core Extension. ===== Pregled ===== Core Extension zagotavlja centralne storitve, ki jih lahko uporabljajo vse druge razširitve. uses WvdS.Core.Services, WvdS.Core.Toolchain, WvdS.Core.Logging; ===== Storitev beleženja ===== ==== LogInfo ==== procedure LogInfo(const AMessage: string); procedure LogInfo(const AFormat: string; const AArgs: array of const); Zapiše informacijsko sporočilo v Output Channel. ==== LogWarn ==== procedure LogWarn(const AMessage: string); procedure LogWarn(const AFormat: string; const AArgs: array of const); Zapiše opozorilo v Output Channel. ==== LogError ==== procedure LogError(const AMessage: string); procedure LogError(const AFormat: string; const AArgs: array of const); Zapiše napako v Output Channel. ==== LogDebug ==== {$IFDEF DEBUG} procedure LogDebug(const AMessage: string); procedure LogDebug(const AFormat: string; const AArgs: array of const); {$ENDIF} Zapiše razhroščevalno sporočilo. Na voljo samo pri kompilaciji z ''-dDEBUG''. ===== Storitev orodne verige ===== ==== GetToolPath ==== function GetToolPath(ATool: TWvdSToolType): string; Vrne konfigurirano pot do orodja. ^ TWvdSToolType ^ Opis ^ | ttFPC | Free Pascal Compiler | | ttPas2js | pas2js Transpiler | | ttLazbuild | Lazarus Build Tool | | ttInnoSetup | Inno Setup Compiler | | ttMake | GNU Make | **Primer:** var FpcPath: string; begin FpcPath := GetToolPath(ttFPC); if FpcPath = '' then raise EWvdSToolNotFound.Create(rsToolNotFound); end; ==== GetToolVersion ==== function GetToolVersion(ATool: TWvdSToolType): string; Vrne verzijo nameščenega orodja. ==== IsToolAvailable ==== function IsToolAvailable(ATool: TWvdSToolType): Boolean; Preveri, ali je orodje na voljo. ==== AutoDetectTools ==== procedure AutoDetectTools; Izvede samodejno zaznavanje vseh orodij. ===== Konfiguracija ===== ==== GetConfiguration ==== function GetConfiguration(const ASection: string): TJSObject; Prebere VS Code konfiguracijo. **Primer:** 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 ); Zapiše VS Code konfiguracijo. ^ TConfigurationTarget ^ Opis ^ | ctGlobal | Uporabniške nastavitve | | ctWorkspace | Nastavitve delovnega prostora | | ctWorkspaceFolder | Nastavitve mape | ===== Event-Bus ===== ==== PublishEvent ==== procedure PublishEvent(const AEventName: string; AData: TJSObject); Objavi dogodek za druge razširitve. **Primer:** 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 ); Naroči se na dogodke. **Primer:** procedure HandleBuildCompleted(AData: TJSObject); begin if Boolean(AData['success']) then LogInfo('Build succeeded!') else LogError('Build failed!'); end; // Ob aktivaciji: SubscribeEvent('wvds.build.completed', @HandleBuildCompleted); ===== Storitve UI ===== ==== ShowInfoMessage ==== procedure ShowInfoMessage(const AMessage: string); function ShowInfoMessage( const AMessage: string; const AItems: array of string ): TJSPromise; // Razreši v izbrani element ==== ShowWarningMessage ==== procedure ShowWarningMessage(const AMessage: string); ==== ShowErrorMessage ==== procedure ShowErrorMessage(const AMessage: string); ==== ShowQuickPick ==== function ShowQuickPick( const AItems: array of string; const APlaceholder: string ): TJSPromise; ===== Storitve delovnega prostora ===== ==== GetWorkspaceRoot ==== function GetWorkspaceRoot: string; Vrne pot do mape delovnega prostora. ==== GetOpenDocument ==== function GetOpenDocument: string; Vrne pot do trenutno odprtega dokumenta. ===== Glejte tudi ===== * [[.:meta-api|Meta API]] * [[.:vscode-wrapper|VSCode Wrapper]] * [[.:extension-entwicklung|Razvoj razširitev]]