Class & Advanced Record Snippets

A class (or advanced record) snippet, defines a single Pascal class or advanced record (i.e. record with methods).

The source code must conform to the following rules:

Warning: It is an error to use this snippet kind for records or classes that have no methods – use simple type definition instead. It is also an error to define more than one class per snippet.

Here are examples valid class and advanced record snippets:

Example 1

type
  TMyClass = class(TObject)
  private
    fField: string;
  public
    constructor Create(AFoo: string);
    function Foo: string;
  end;

constructor TMyClass.Create(AFoo: string);
begin
  inherited Create;
  fField := AFoo;
end;

function TMyClass.Foo: string;
begin
  Result := fField;
end;

Example 2

type
  TPointEx = record
    X, Y: Integer;
    constructor Create(AX, AY: Integer);
  end;

constructor TPointEx.Create(AX, AY: Integer);
begin
  X := AX;
  Y := AY;
end;

Class and Advanced Record snippets may refer to other classes or advanced records, routines, simple type definitions or constants, providing they are defined in Delphi units or elsewhere in the database. The snippet's units and dependency references should indicate where to find referenced types, constants and routines. Freeform and unit snippets may not be referenced.

It is important that CodeSnip can understand the code because it must be able to separate the declaration and implementation parts when generating a unit containing the snippet.