Inhaltsverzeichnis

Meta API

API-Referenz für die WvdS VSCode UI Meta Extension.

Übersicht

Die Meta Extension verwaltet die Komponenten-Registry und stellt IntelliSense-Dienste bereit.

uses
  WvdS.Meta.Registry,
  WvdS.Meta.IntelliSense;

Komponenten-Registry

RegisterComponent

procedure RegisterComponent(const AInfo: TWvdSComponentInfo);

Registriert eine neue Komponente in der Registry.

type
  TWvdSComponentInfo = record
    Name: string;           // z.B. 'Button'
    Description: string;    // Kurzbeschreibung
    Category: string;       // z.B. 'Input', 'Layout'
    Namespace: string;      // z.B. 'WvdS.UI.Controls'
    Properties: TWvdSPropertyInfoArray;
    Events: TWvdSEventInfoArray;
  end;

Beispiel:

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;

Gibt Informationen zu einer Komponente zurück.

GetAllComponents

function GetAllComponents: TWvdSComponentInfoArray;

Gibt alle registrierten Komponenten zurück.

GetComponentsByCategory

function GetComponentsByCategory(const ACategory: string): TWvdSComponentInfoArray;

Gibt alle Komponenten einer Kategorie zurück.

Property-Informationen

TWvdSPropertyInfo

type
  TWvdSPropertyInfo = record
    Name: string;           // Property-Name
    PropType: string;       // 'string', 'number', 'boolean', ...
    Description: string;    // Dokumentation
    DefaultValue: string;   // Standardwert
    Required: Boolean;      // Pflichtfeld?
    EnumValues: TStringArray; // Bei Enum-Typ
  end;

GetPropertyInfo

function GetPropertyInfo(
  const AComponentName: string;
  const APropertyName: string
): TWvdSPropertyInfo;

Event-Informationen

TWvdSEventInfo

type
  TWvdSEventInfo = record
    Name: string;           // Event-Name (z.B. 'Click')
    Description: string;    // Dokumentation
    HandlerSignature: string; // z.B. 'procedure(Sender: TObject)'
  end;

IntelliSense-Provider

GetCompletions

function GetCompletions(AContext: TWvdSCompletionContext): TWvdSCompletionItemArray;

Gibt Vervollständigungsvorschläge für eine Position zurück.

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;

Gibt Hover-Dokumentation für eine Position zurück.

type
  TWvdSHoverInfo = record
    Contents: string;       // Markdown-Inhalt
    Range: TRange;          // Bereich im Dokument
  end;

Cache-Verwaltung

RefreshRegistry

procedure RefreshRegistry;

Lädt die Registry neu und aktualisiert den Cache.

ClearCache

procedure ClearCache;

Löscht den Komponenten-Cache.

GetCachePath

function GetCachePath: string;

Gibt den Pfad zum Cache-Verzeichnis zurück.

Annotations

Komponenten können via Annotations registriert werden:

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;

Verwendung:

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;

Siehe auch