Class TPasUnit

Unit

Declaration

type TPasUnit = class(TPasItem)

Description

extends TPasItem to store anything about a unit, its constants, types etc.; also provides methods for parsing a complete unit.

Note: Remember to always set CacheDateTime after deserializing this unit.

Source: source/component/PasDoc_Items.pas (line 1023).

Hierarchy

Overview

Fields

Protected FTypes: TPasTypes;
Protected FVariables: TPasItems;
Protected FCIOs: TPasItems;
Protected FConstants: TPasItems;
Protected FFuncsProcs: TPasRoutines;
Protected FUsesUnits: TStringVector;
Protected FSourceFilename: string;
Protected FOutputFileName: string;
Protected FCacheDateTime: TDateTime;
Protected FSourceFileDateTime: TDateTime;
Protected FIsUnit: boolean;
Protected FIsProgram: boolean;

Methods

Protected procedure Serialize(const ADestination: TStream); override;
Protected procedure Deserialize(const ASource: TStream); override;
Public constructor Create; override;
Public destructor Destroy; override;
Public procedure AddCIO(const i: TPasCio);
Public procedure AddConstant(const i: TPasItem);
Public procedure AddType(const i: TPasItem);
Public procedure AddVariable(const i: TPasItem);
Public function FindInsideSomeClass(const AClassName, ItemInsideClass: string): TPasItem;
Public function FindInsideSomeEnum(const EnumName, EnumMember: string): TPasItem;
Public function FindItem(const ItemName: string): TBaseItem; override;
Public procedure Sort(const SortSettings: TSortSettings); override;
Public function FileNewerThanCache(const FileName: string): boolean;
Public function BasePath: string; override;

Properties

Public property CIOs: TPasItems read FCIOs;
Public property Constants: TPasItems read FConstants;
Public property FuncsProcs: TPasRoutines read FFuncsProcs;
Public property UsesUnits: TStringVector read FUsesUnits;
Public property Types: TPasTypes read FTypes;
Public property Variables: TPasItems read FVariables;
Public property OutputFileName: string read FOutputFileName write FOutputFileName;
Public property SourceFileName: string read FSourceFilename write FSourceFilename;
Public property SourceFileDateTime: TDateTime read FSourceFileDateTime write FSourceFileDateTime;
Public property CacheDateTime: TDateTime read FCacheDateTime write FCacheDateTime;
Public property IsUnit: boolean read FIsUnit write FIsUnit;
Public property IsProgram: boolean read FIsProgram write FIsProgram;

Description

Fields

Protected FTypes: TPasTypes;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1025).

Protected FVariables: TPasItems;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1026).

Protected FCIOs: TPasItems;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1027).

Protected FConstants: TPasItems;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1028).

Protected FFuncsProcs: TPasRoutines;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1029).

Protected FUsesUnits: TStringVector;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1030).

Protected FSourceFilename: string;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1031).

Protected FOutputFileName: string;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1032).

Protected FCacheDateTime: TDateTime;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1033).

Protected FSourceFileDateTime: TDateTime;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1034).

Protected FIsUnit: boolean;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1035).

Protected FIsProgram: boolean;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1036).

Methods

Protected procedure Serialize(const ADestination: TStream); override;

This item has no description. Showing description inherited from TBaseItem.Serialize.

Serialization of TPasItem need to store in stream only data that is generated by parser. That's because current approach treats "loading from cache" as equivalent to parsing a unit and stores to cache right after parsing a unit. So what is generated by parser must be written to cache.

That said,

  1. It will not break anything if you will accidentally store in cache something that is not generated by parser. That's because saving to cache will be done anyway right after doing parsing, so properties not initialized by parser will have their initial values anyway. You're just wasting memory for cache, and some cache saving/loading time.

  2. For now, in implementation of serialize/deserialize we try to add even things not generated by parser in a commented out code. This way if approach to cache will change some day, we will be able to use this code.

Source: source/component/PasDoc_Items.pas (line 1037).

Protected procedure Deserialize(const ASource: TStream); override;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1038).

Public constructor Create; override;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1040).

Public destructor Destroy; override;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1041).

Public procedure AddCIO(const i: TPasCio);

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1042).

Public procedure AddConstant(const i: TPasItem);

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1043).

Public procedure AddType(const i: TPasItem);

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1044).

Public procedure AddVariable(const i: TPasItem);

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1045).

Public function FindInsideSomeClass(const AClassName, ItemInsideClass: string): TPasItem;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1046).

Public function FindInsideSomeEnum(const EnumName, EnumMember: string): TPasItem;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1047).

Public function FindItem(const ItemName: string): TBaseItem; override;

This item has no description. Showing description inherited from TBaseItem.FindItem.

Search for an item called ItemName inside this Pascal item. For units, it searches for items declared inside this unit (like a procedure, or a class in this unit). For classes it searches for items declared within this class (like a method or a property). For an enumerated type, it searches for members of this enumerated type.

All normal rules of ObjectPascal scope apply, which means that e.g. if this item is a unit, FindItem searches for a class named ItemName but it doesn't search for a method named ItemName inside some class of this unit. Just like in ObjectPascal the scope of identifiers declared within the class always stays within the class. Of course, in ObjectPascal you can qualify a method name with a class name, and you can also do such qualified links in pasdoc, but this is not handled by this routine (see FindName instead).

Returns nil if not found.

Note that it never compares ItemName with Self.Name. You may want to check this yourself if you want.

Note that for TPasItem descendants, it always returns also some TPasItem descendant (so if you use this method with some TPasItem instance, you can safely cast result of this method to TPasItem).

Implementation in this class always returns nil. Override as necessary.

Source: source/component/PasDoc_Items.pas (line 1048).

Public procedure Sort(const SortSettings: TSortSettings); override;

This item has no description. Showing description inherited from TPasItem.Sort.

This recursively sorts all items inside this item, and all items inside these items, etc. E.g. in case of TPasUnit, this method sorts all variables, consts, CIOs etc. inside (honouring SortSettings), and also recursively calls Sort(SortSettings) for every CIO.

Note that this does not guarantee that absolutely everything inside will be really sorted. Some items may be deliberately left unsorted, e.g. Members of TPasEnum are never sorted (their declared order always matters, so we shouldn't sort them when displaying their documentation — reader of such documentation would be seriously misleaded). Sorting of other things depends on SortSettings — e.g. without ssMethods, CIOs methods will not be sorted.

So actually this method makes sure that all things that should be sorted are really sorted.

Source: source/component/PasDoc_Items.pas (line 1050).

Public function FileNewerThanCache(const FileName: string): boolean;

Returns if unit WasDeserialized, and file FileName exists, and file FileName is newer than CacheDateTime.

So if FileName contains some info generated from information of this unit, then we can somehow assume that FileName still contains valid information and we don't have to write it once again.

Sure, we're not really 100% sure that FileName still contains valid information, but that's how current approach to cache works.

Source: source/component/PasDoc_Items.pas (line 1110).

Public function BasePath: string; override;

This item has no description. Showing description inherited from TBaseItem.BasePath.

The full (absolute) path used to resolve filenames in this item's descriptions. Must always end with PathDelim. In this class, this simply returns GetCurrentDir (with PathDelim added if needed).

Source: source/component/PasDoc_Items.pas (line 1112).

Properties

Public property CIOs: TPasItems read FCIOs;

list of classes, interfaces, objects, and records defined in this unit

Source: source/component/PasDoc_Items.pas (line 1053).

Public property Constants: TPasItems read FConstants;

list of constants defined in this unit

Source: source/component/PasDoc_Items.pas (line 1055).

Public property FuncsProcs: TPasRoutines read FFuncsProcs;

list of functions and procedures defined in this unit

Source: source/component/PasDoc_Items.pas (line 1057).

Public property UsesUnits: TStringVector read FUsesUnits;

The names of all units mentioned in a uses clause in the interface section of this unit.

This is never nil.

After TDocGenerator.BuildLinks, for every i: UsesUnits.Objects[i] will point to TPasUnit object with Name = UsesUnits[i] (or nil, if pasdoc's didn't parse such unit). In other words, you will be able to use UsesUnits.Objects[i] to obtain given unit's instance, as parsed by pasdoc.

Source: source/component/PasDoc_Items.pas (line 1069).

Public property Types: TPasTypes read FTypes;

list of types defined in this unit

Source: source/component/PasDoc_Items.pas (line 1072).

Public property Variables: TPasItems read FVariables;

list of variables defined in this unit

Source: source/component/PasDoc_Items.pas (line 1074).

Public property OutputFileName: string read FOutputFileName write FOutputFileName;

name of documentation output file THIS SHOULD NOT BE HERE!

Source: source/component/PasDoc_Items.pas (line 1077).

Public property SourceFileName: string read FSourceFilename write FSourceFilename;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1079).

Public property SourceFileDateTime: TDateTime read FSourceFileDateTime write FSourceFileDateTime;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1080).

Public property CacheDateTime: TDateTime read FCacheDateTime write FCacheDateTime;

If WasDeserialized then this specifies the datetime of a cache data of this unit, i.e. when cache data was generated. If cache was obtained from a file then this is just the cache file modification date/time.

If not WasDeserialized then this property has undefined value – don't use it.

Source: source/component/PasDoc_Items.pas (line 1090).

Public property IsUnit: boolean read FIsUnit write FIsUnit;

If False, then this is a program or library file, not a regular unit (though it's treated by pasdoc almost like a unit, so we use TPasUnit class for this).

Source: source/component/PasDoc_Items.pas (line 1096).

Public property IsProgram: boolean read FIsProgram write FIsProgram;

This item has no description.

Source: source/component/PasDoc_Items.pas (line 1097).


Generated by PasDoc 0.17.0.snapshot.