====== Meta API ====== Riferimento API per la WvdS VSCode UI Meta Extension. ===== Panoramica ===== La Meta Extension gestisce il registry dei componenti e fornisce servizi IntelliSense. uses WvdS.Meta.Registry, WvdS.Meta.IntelliSense; ===== Registry Componenti ===== ==== RegisterComponent ==== procedure RegisterComponent(const AInfo: TWvdSComponentInfo); Registra un nuovo componente nel registry. type TWvdSComponentInfo = record Name: string; // es. 'Button' Description: string; // Breve descrizione Category: string; // es. 'Input', 'Layout' Namespace: string; // es. 'WvdS.UI.Controls' Properties: TWvdSPropertyInfoArray; Events: TWvdSEventInfoArray; end; **Esempio:** var Info: TWvdSComponentInfo; begin Info.Name := 'MyButton'; Info.Description := 'Custom button with icon'; Info.Category := 'Input'; Info.Namespace := 'MyApp.Controls'; SetLength(Info.Properties, 2); Info.Properties[0].Name := 'Content'; Info.Properties[0].PropType := 'string'; Info.Properties[0].DefaultValue := ''; Info.Properties[1].Name := 'IconPath'; Info.Properties[1].PropType := 'string'; Info.Properties[1].DefaultValue := ''; RegisterComponent(Info); end; ==== GetComponent ==== function GetComponent(const AName: string): TWvdSComponentInfo; Restituisce informazioni su un componente. ==== GetAllComponents ==== function GetAllComponents: TWvdSComponentInfoArray; Restituisce tutti i componenti registrati. ==== GetComponentsByCategory ==== function GetComponentsByCategory(const ACategory: string): TWvdSComponentInfoArray; Restituisce tutti i componenti di una categoria. ===== Informazioni Property ===== ==== TWvdSPropertyInfo ==== type TWvdSPropertyInfo = record Name: string; // Nome property PropType: string; // 'string', 'number', 'boolean', ... Description: string; // Documentazione DefaultValue: string; // Valore predefinito Required: Boolean; // Campo obbligatorio? EnumValues: TStringArray; // Per tipo Enum end; ==== GetPropertyInfo ==== function GetPropertyInfo( const AComponentName: string; const APropertyName: string ): TWvdSPropertyInfo; ===== Informazioni Event ===== ==== TWvdSEventInfo ==== type TWvdSEventInfo = record Name: string; // Nome event (es. 'Click') Description: string; // Documentazione HandlerSignature: string; // es. 'procedure(Sender: TObject)' end; ===== Provider IntelliSense ===== ==== GetCompletions ==== function GetCompletions(AContext: TWvdSCompletionContext): TWvdSCompletionItemArray; Restituisce suggerimenti di completamento per una posizione. type TWvdSCompletionContext = record DocumentUri: string; Position: TPosition; TriggerCharacter: Char; CurrentElement: string; CurrentAttribute: string; end; TWvdSCompletionItem = record Label: string; Kind: TWvdSCompletionKind; Detail: string; Documentation: string; InsertText: string; end; ==== GetHoverInfo ==== function GetHoverInfo( const ADocumentUri: string; APosition: TPosition ): TWvdSHoverInfo; Restituisce documentazione hover per una posizione. type TWvdSHoverInfo = record Contents: string; // Contenuto Markdown Range: TRange; // Range nel documento end; ===== Gestione Cache ===== ==== RefreshRegistry ==== procedure RefreshRegistry; Ricarica il registry e aggiorna la cache. ==== ClearCache ==== procedure ClearCache; Cancella la cache dei componenti. ==== GetCachePath ==== function GetCachePath: string; Restituisce il percorso alla directory cache. ===== Annotations ===== I componenti possono essere registrati tramite Annotations: type ComponentInfoAttribute = class(TCustomAttribute) FName: string; FDescription: string; FCategory: string; public constructor Create(const AName, ADescription, ACategory: string); end; PropertyInfoAttribute = class(TCustomAttribute) FDescription: string; FDefaultValue: string; public constructor Create(const ADescription: string; const ADefault: string = ''); end; **Utilizzo:** type {$M+} [ComponentInfo('MyButton', 'Button with icon', 'Input')] TMyButton = class(TWvdSButton) published [PropertyInfo('Path to icon image', '')] property IconPath: string read FIconPath write SetIconPath; [PropertyInfo('Button text', 'Click')] property Content: string read FContent write SetContent; end; ===== Vedi anche ===== * [[.:core-api|Core API]] * [[.:vscode-wrapper|VSCode Wrapper]] * [[..:p:meta|UI Meta Extension]]